diff --git a/digitalglarus/test_views.py b/digitalglarus/test_views.py
new file mode 100644
index 00000000..1c5824f5
--- /dev/null
+++ b/digitalglarus/test_views.py
@@ -0,0 +1,23 @@
+from django.test import TestCase
+from django.core.urlresolvers import reverse
+from django.core.urlresolvers import resolve
+
+
+class ContactViewTest(TestCase):
+
+ def setUp(self):
+ self.url = reverse('digitalglarus:contact')
+ self.data = {
+ 'name': 'test',
+ 'email': 'test@gmail.com',
+ 'phone_number': '32123123123123',
+ 'message': 'This is a message',
+ }
+
+ def url_resolve_to_view_correctly(self):
+ found = resolve(self.url)
+ self.assertEqual(found.func.__name__, self.view.__name__)
+
+ def test_any_user_should_contact_us(self):
+ response = self.client.post(self.url, self.data, follow=True)
+ self.assertEqual(response.status_code, 200)
diff --git a/digitalglarus/views.py b/digitalglarus/views.py
index 64c6f791..86838336 100644
--- a/digitalglarus/views.py
+++ b/digitalglarus/views.py
@@ -3,23 +3,22 @@ import datetime
from django.shortcuts import get_object_or_404, render
from django.forms import ModelForm
from django.http import HttpResponseRedirect
-from django.core.urlresolvers import reverse
+from django.core.urlresolvers import reverse_lazy
from django.utils.translation import get_language
from djangocms_blog.models import Post
-from django.core.urlresolvers import resolve
from django.contrib import messages
from django.utils.translation import ugettext as _
-from .models import Message, Supporter
-from .forms import ContactUsForm
+from .models import Supporter
+from utils.forms import ContactUsForm
from django.views.generic.edit import FormView
class ContactView(FormView):
template_name = 'contact.html'
form_class = ContactUsForm
- success_url = '/digitalglarus/contact/'
+ success_url = reverse_lazy('digitalglarus:contact')
success_message = _('Message Successfully Sent')
def form_valid(self, form):
diff --git a/dynamicweb/settings/base.py b/dynamicweb/settings/base.py
index c2461e99..1783ad12 100644
--- a/dynamicweb/settings/base.py
+++ b/dynamicweb/settings/base.py
@@ -52,6 +52,8 @@ INSTALLED_APPS = (
'django.contrib.staticfiles',
'django.contrib.sites',
'easy_thumbnails',
+ 'utils',
+ 'ungleich_page',
'mptt',
'parler',
'taggit',
@@ -125,6 +127,7 @@ MIDDLEWARE_CLASSES = (
ROOT_URLCONF = 'dynamicweb.urls'
+
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
diff --git a/dynamicweb/urls.py b/dynamicweb/urls.py
index fe2054ce..0b1bad0b 100644
--- a/dynamicweb/urls.py
+++ b/dynamicweb/urls.py
@@ -20,6 +20,7 @@ urlpatterns = [
urlpatterns += i18n_patterns('',
# url(r'^$',include('ungleich.urls')),
url(r'^blog/',include('ungleich.urls',namespace='ungleich')),
+ url(r'^',include('ungleich_page.urls',namespace='ungleich_page')),
url(r'^login/',include(membership_urls)),
url(r'^admin/', include(admin.site.urls)),
url(r'^digitalglarus/', include('digitalglarus.urls',
diff --git a/ungleich/models.py b/ungleich/models.py
index a3c531e7..fb76704b 100644
--- a/ungleich/models.py
+++ b/ungleich/models.py
@@ -7,6 +7,7 @@ from filer.fields.image import FilerImageField
# Create your models here.
+
class UngleichPage(PageExtension):
#image_header = models.ImageField(upload_to='image_header')
image = FilerImageField(null=True, blank=True,
diff --git a/ungleich/urls.py b/ungleich/urls.py
index 8004657e..afdef4de 100644
--- a/ungleich/urls.py
+++ b/ungleich/urls.py
@@ -2,8 +2,8 @@ from django.conf.urls import url
from . import views
urlpatterns = [
- url(r'^$',views.PostListViewUngleich.as_view()),
+ url(r'^$', views.PostListViewUngleich.as_view()),
# url(r'^$',views.PostListView.as_view()),
- url(r'^(?P
\d{4})/(?P\d{1,2})/(?P\d{1,2})/(?P\w[-\w]*)/$',views.details)
-
-]
\ No newline at end of file
+ url(r'^(?P\d{4})/(?P\d{1,2})/(?P\d{1,2})/(?P\w[-\w]*)/$',
+ views.details)
+]
diff --git a/ungleich/views.py b/ungleich/views.py
index 1970e54b..9c06d4fa 100644
--- a/ungleich/views.py
+++ b/ungleich/views.py
@@ -1,14 +1,11 @@
from django.shortcuts import render
from django.utils.translation import get_language
from djangocms_blog.models import Post
-from django.views.generic import ListView
-from djangocms_blog.views import PostListView,BaseBlogView
-from django.core.paginator import Paginator
-from django.core.paginator import PageNotAnInteger
-from django.core.paginator import EmptyPage
+from djangocms_blog.views import PostListView
from djangocms_blog.settings import get_setting
+
def blog(request):
posts = Post.objects.all()
print(posts)
diff --git a/ungleich_page/__init__.py b/ungleich_page/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/ungleich_page/admin.py b/ungleich_page/admin.py
new file mode 100644
index 00000000..8c38f3f3
--- /dev/null
+++ b/ungleich_page/admin.py
@@ -0,0 +1,3 @@
+from django.contrib import admin
+
+# Register your models here.
diff --git a/ungleich_page/apps.py b/ungleich_page/apps.py
new file mode 100644
index 00000000..4385d1cd
--- /dev/null
+++ b/ungleich_page/apps.py
@@ -0,0 +1,5 @@
+from django.apps import AppConfig
+
+
+class UngleichPageConfig(AppConfig):
+ name = 'ungleich_page'
diff --git a/ungleich_page/migrations/__init__.py b/ungleich_page/migrations/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/ungleich_page/models.py b/ungleich_page/models.py
new file mode 100644
index 00000000..71a83623
--- /dev/null
+++ b/ungleich_page/models.py
@@ -0,0 +1,3 @@
+from django.db import models
+
+# Create your models here.
diff --git a/ungleich_page/templates/ungleich_page/_footer.html b/ungleich_page/templates/ungleich_page/_footer.html
new file mode 100644
index 00000000..f03fc2b7
--- /dev/null
+++ b/ungleich_page/templates/ungleich_page/_footer.html
@@ -0,0 +1,40 @@
+{% load cms_tags %}
+
+
+
diff --git a/ungleich_page/templates/ungleich_page/_header_base.html b/ungleich_page/templates/ungleich_page/_header_base.html
new file mode 100644
index 00000000..4facf0f1
--- /dev/null
+++ b/ungleich_page/templates/ungleich_page/_header_base.html
@@ -0,0 +1,17 @@
+{% load cms_tags staticfiles %}
+
+
+
diff --git a/ungleich_page/templates/ungleich_page/_menu.html b/ungleich_page/templates/ungleich_page/_menu.html
new file mode 100644
index 00000000..05acc787
--- /dev/null
+++ b/ungleich_page/templates/ungleich_page/_menu.html
@@ -0,0 +1,36 @@
+{% load menu_tags staticfiles cms_tags %}
+
+
diff --git a/ungleich_page/templates/ungleich_page/base_ungleich.html b/ungleich_page/templates/ungleich_page/base_ungleich.html
new file mode 100644
index 00000000..49ceefe9
--- /dev/null
+++ b/ungleich_page/templates/ungleich_page/base_ungleich.html
@@ -0,0 +1,78 @@
+{% load cms_tags menu_tags sekizai_tags staticfiles bootstrap3 %}
+
+
+
+
+ {% block title %}
+ {% page_attribute "page_title" %}
+ {% endblock %}
+
+ {% addtoblock "external-css" %}
+ {% bootstrap_css %}
+
+
+
+
+
+
+
+
+ {% endaddtoblock %}
+
+ {% addtoblock "css" %}
+
+ {% endaddtoblock %}
+ {% block meta %}
+
+
+ {% include 'meta.html' %}
+ {% endblock %}
+ {% render_block "external-css" %}
+ {% render_block "css" postprocessor "compressor.contrib.sekizai.compress" %}
+
+
+ {% cms_toolbar %}
+ {% show_menu 0 0 0 1 "cms/ungleichch/_menu.html" %}
+
+
+ {% block base_header %}
+ {% include "ungleich_page/_header_base.html" %}
+ {% endblock %}
+
+
+
+ {% block base_content %}
+ {% placeholder "default" %}
+ {% endblock %}
+
+
+
+
+ {% include "cms/ungleichch/_footer.html" %}
+ {% addtoblock "external-js" %}
+ {% bootstrap_javascript %}
+ {% endaddtoblock %}
+ {% addtoblock "js" %}
+
+
+
+
+ {% endaddtoblock %}
+ {% render_block "js" postprocessor "compressor.contrib.sekizai.compress" %}
+ {% render_block "external-js" %}
+
+
diff --git a/ungleich_page/templates/ungleich_page/contact.html b/ungleich_page/templates/ungleich_page/contact.html
new file mode 100644
index 00000000..8deb38dc
--- /dev/null
+++ b/ungleich_page/templates/ungleich_page/contact.html
@@ -0,0 +1,38 @@
+{% extends "ungleich_page/base_ungleich.html" %}
+
+{% block base_content %}
+
+
+{% block content %}
+{% endblock %}
+{% endblock %}
\ No newline at end of file
diff --git a/ungleich_page/templates/ungleich_page/index.html b/ungleich_page/templates/ungleich_page/index.html
new file mode 100644
index 00000000..f8b86001
--- /dev/null
+++ b/ungleich_page/templates/ungleich_page/index.html
@@ -0,0 +1,3 @@
+{% extends "base_glarus.html" %}
+{% block base_content %}
+{% endblock %}
diff --git a/ungleich_page/templates/ungleich_page/page.html b/ungleich_page/templates/ungleich_page/page.html
new file mode 100644
index 00000000..fde34d47
--- /dev/null
+++ b/ungleich_page/templates/ungleich_page/page.html
@@ -0,0 +1,5 @@
+{% extends "base_ungleich.html" %}
+{% load cms_tags %}
+{% block base_content %}
+{% placeholder "page_content" %}
+{% endblock %}
diff --git a/ungleich_page/test_views.py b/ungleich_page/test_views.py
new file mode 100644
index 00000000..d67708bd
--- /dev/null
+++ b/ungleich_page/test_views.py
@@ -0,0 +1,23 @@
+from django.test import TestCase
+from django.core.urlresolvers import reverse
+from django.core.urlresolvers import resolve
+
+
+class ContactViewTest(TestCase):
+
+ def setUp(self):
+ self.url = reverse('ungleich_page:contact')
+ self.data = {
+ 'name': 'test',
+ 'email': 'test@gmail.com',
+ 'phone_number': '32123123123123',
+ 'message': 'This is a message',
+ }
+
+ def url_resolve_to_view_correctly(self):
+ found = resolve(self.url)
+ self.assertEqual(found.func.__name__, self.view.__name__)
+
+ def test_any_user_should_contact_us(self):
+ response = self.client.post(self.url, self.data, follow=True)
+ self.assertEqual(response.status_code, 200)
diff --git a/digitalglarus/tests.py b/ungleich_page/tests.py
similarity index 100%
rename from digitalglarus/tests.py
rename to ungleich_page/tests.py
diff --git a/ungleich_page/urls.py b/ungleich_page/urls.py
new file mode 100644
index 00000000..1b03b20c
--- /dev/null
+++ b/ungleich_page/urls.py
@@ -0,0 +1,6 @@
+from django.conf.urls import url
+from .views import ContactView
+
+urlpatterns = [
+ url(r'contact/?$', ContactView.as_view(), name='contact'),
+]
diff --git a/ungleich_page/views.py b/ungleich_page/views.py
new file mode 100644
index 00000000..997c713b
--- /dev/null
+++ b/ungleich_page/views.py
@@ -0,0 +1,25 @@
+from django.contrib import messages
+
+from django.views.generic.edit import FormView
+from django.utils.translation import ugettext as _
+from django.core.urlresolvers import reverse_lazy
+from utils.forms import ContactUsForm
+
+
+class ContactView(FormView):
+ template_name = 'ungleich_page/contact.html'
+ form_class = ContactUsForm
+ success_url = reverse_lazy('digitalglarus:contact')
+ success_message = _('Message Successfully Sent')
+
+ def form_valid(self, form):
+ form.save()
+ form.send_email()
+ messages.add_message(self.request, messages.SUCCESS, self.success_message)
+ return super(ContactView, self).form_valid(form)
+
+ def get_context_data(self, **kwargs):
+ context = super(ContactView, self).get_context_data(**kwargs)
+ context['page_title'] = _('Contact Us')
+ context['page_subtitle'] = _('If you have any question, just send us an email.')
+ return context
diff --git a/utils/__init__.py b/utils/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/utils/admin.py b/utils/admin.py
new file mode 100644
index 00000000..8c38f3f3
--- /dev/null
+++ b/utils/admin.py
@@ -0,0 +1,3 @@
+from django.contrib import admin
+
+# Register your models here.
diff --git a/utils/apps.py b/utils/apps.py
new file mode 100644
index 00000000..7527884c
--- /dev/null
+++ b/utils/apps.py
@@ -0,0 +1,5 @@
+from django.apps import AppConfig
+
+
+class UtilsConfig(AppConfig):
+ name = 'utils'
diff --git a/digitalglarus/forms.py b/utils/forms.py
similarity index 94%
rename from digitalglarus/forms.py
rename to utils/forms.py
index b482779e..f7d5ef01 100644
--- a/digitalglarus/forms.py
+++ b/utils/forms.py
@@ -1,5 +1,5 @@
from django import forms
-from .models import Message
+from .models import ContactMessage
from django.template.loader import render_to_string
from django.core.mail import EmailMultiAlternatives
from django.utils.translation import ugettext_lazy as _
@@ -9,7 +9,7 @@ class ContactUsForm(forms.ModelForm):
error_css_class = 'autofocus'
class Meta:
- model = Message
+ model = ContactMessage
fields = ['name', 'email', 'phone_number', 'message']
widgets = {
'name': forms.TextInput(attrs={'class': u'form-control'}),
diff --git a/utils/migrations/0001_initial.py b/utils/migrations/0001_initial.py
new file mode 100644
index 00000000..c75c8623
--- /dev/null
+++ b/utils/migrations/0001_initial.py
@@ -0,0 +1,27 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.9.4 on 2016-04-10 17:04
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ initial = True
+
+ dependencies = [
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name='ContactMessage',
+ fields=[
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('name', models.CharField(max_length=200)),
+ ('email', models.EmailField(max_length=254)),
+ ('phone_number', models.CharField(max_length=200)),
+ ('message', models.TextField()),
+ ('received_date', models.DateTimeField(auto_now_add=True)),
+ ],
+ ),
+ ]
diff --git a/utils/migrations/__init__.py b/utils/migrations/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/utils/models.py b/utils/models.py
new file mode 100644
index 00000000..5b3ed5c0
--- /dev/null
+++ b/utils/models.py
@@ -0,0 +1,14 @@
+from django.db import models
+
+# Create your models here.
+
+
+class ContactMessage(models.Model):
+ name = models.CharField(max_length=200)
+ email = models.EmailField()
+ phone_number = models.CharField(max_length=200)
+ message = models.TextField()
+ received_date = models.DateTimeField(auto_now_add=True)
+
+ def __str__(self):
+ return "%s - %s - %s" % (self.name, self.email, self.received_date)
\ No newline at end of file
diff --git a/utils/test_forms.py b/utils/test_forms.py
new file mode 100644
index 00000000..3e5701a7
--- /dev/null
+++ b/utils/test_forms.py
@@ -0,0 +1,25 @@
+from django.test import TestCase
+from .forms import ContactUsForm
+
+
+class ContactUsFormTest(TestCase):
+
+ def setUp(self):
+ self.completed_data = {
+ 'name': 'test',
+ 'email': 'test@gmail.com',
+ 'phone_number': '32123123123123',
+ 'message': 'This is a message',
+ }
+
+ self.incompleted_data = {
+ 'name': 'test',
+ }
+
+ def test_valid_form(self):
+ form = ContactUsForm(data=self.completed_data)
+ self.assertTrue(form.is_valid())
+
+ def test_invalid_form(self):
+ form = ContactUsForm(data=self.incompleted_data)
+ self.assertFalse(form.is_valid())
diff --git a/utils/tests.py b/utils/tests.py
new file mode 100644
index 00000000..7ce503c2
--- /dev/null
+++ b/utils/tests.py
@@ -0,0 +1,3 @@
+from django.test import TestCase
+
+# Create your tests here.
diff --git a/utils/views.py b/utils/views.py
new file mode 100644
index 00000000..91ea44a2
--- /dev/null
+++ b/utils/views.py
@@ -0,0 +1,3 @@
+from django.shortcuts import render
+
+# Create your views here.