diff --git a/.gitignore b/.gitignore index 567f4900..abe4802a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ db.sqlite3 *.pyc +*.DS_Store build/ dist/ *.egg_info diff --git a/digitalglarus/forms.py b/digitalglarus/forms.py new file mode 100644 index 00000000..da789c9c --- /dev/null +++ b/digitalglarus/forms.py @@ -0,0 +1,26 @@ +from django import forms +from .models import Message +from django.template.loader import render_to_string +from django.core.mail import EmailMultiAlternatives + + +class ContactUsForm(forms.ModelForm): + error_css_class = 'autofocus' + + class Meta: + model = Message + fields = ['name', 'email', 'phone_number', 'message'] + widgets = { + 'name': forms.TextInput(attrs={'class': u'form-control'}), + 'email': forms.TextInput(attrs={'class': u'form-control'}), + 'phone_number': forms.TextInput(attrs={'class': u'form-control'}), + 'message': forms.Textarea(attrs={'class': u'form-control'}), + } + + def send_email(self): + text_content = render_to_string('emails/contact.txt', {'data': self.cleaned_data}) + html_content = render_to_string('emails/contact.html', {'data': self.cleaned_data}) + email = EmailMultiAlternatives('Subject', text_content) + email.attach_alternative(html_content, "text/html") + email.to = ['info@digitalglarus.ch'] + email.send() diff --git a/digitalglarus/locale/de/LC_MESSAGES/django.mo b/digitalglarus/locale/de/LC_MESSAGES/django.mo new file mode 100644 index 00000000..f3f8d216 Binary files /dev/null and b/digitalglarus/locale/de/LC_MESSAGES/django.mo differ diff --git a/digitalglarus/locale/de/LC_MESSAGES/django.po b/digitalglarus/locale/de/LC_MESSAGES/django.po new file mode 100644 index 00000000..37f877ac --- /dev/null +++ b/digitalglarus/locale/de/LC_MESSAGES/django.po @@ -0,0 +1,43 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-04-09 02:43-0500\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: cms_plugins.py:9 +msgid "Digital Glarus Gallery" +msgstr "" + +#: cms_plugins.py:21 +msgid "Digital Glarus Supporters" +msgstr "" + +#: urls.py:8 +msgid "contact/?$" +msgstr "kontakt/?$" + +#: urls.py:9 +msgid "supporters/?$" +msgstr "befurworter/?$" + +#: urls.py:10 +msgid "support-us/?$" +msgstr "" + +#: views.py:23 +msgid "Message Successfully Sent" +msgstr "" diff --git a/digitalglarus/migrations/0005_auto_20160407_0519.py b/digitalglarus/migrations/0005_auto_20160407_0519.py new file mode 100644 index 00000000..17e64289 --- /dev/null +++ b/digitalglarus/migrations/0005_auto_20160407_0519.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.4 on 2016-04-07 05:19 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('digitalglarus', '0004_dggallery_dggalleryplugin_dgpicture_dgsupportersplugin_supporter'), + ] + + operations = [ + migrations.AlterField( + model_name='message', + name='received_date', + field=models.DateTimeField(auto_now_add=True), + ), + ] diff --git a/digitalglarus/models.py b/digitalglarus/models.py index 08e5636a..6c24ae0d 100644 --- a/digitalglarus/models.py +++ b/digitalglarus/models.py @@ -8,8 +8,7 @@ class Message(models.Model): email = models.EmailField() phone_number = models.CharField(max_length=200) message = models.TextField() - - received_date = models.DateTimeField('date received') + received_date = models.DateTimeField(auto_now_add=True) def __str__(self): return "%s - %s - %s" % (self.name, self.email, self.received_date) @@ -18,7 +17,7 @@ class Message(models.Model): class Supporter(models.Model): name = models.CharField(max_length=200) description = models.TextField(null=True, blank=True) - + def __str__(self): return "%s" % (self.name) @@ -26,6 +25,7 @@ class Supporter(models.Model): return reverse('dgSupporters_view', args=[self.pk]) + class DGGallery(models.Model): parent = models.ForeignKey('self', blank=True, null=True) name = models.CharField(max_length=30) diff --git a/digitalglarus/static/digitalglarus/img/thank-you.png b/digitalglarus/static/digitalglarus/img/thank-you.png new file mode 100644 index 00000000..3f332b0a Binary files /dev/null and b/digitalglarus/static/digitalglarus/img/thank-you.png differ diff --git a/digitalglarus/templates/base_glarus.html b/digitalglarus/templates/base_glarus.html index 54eefe42..36a86190 100644 --- a/digitalglarus/templates/base_glarus.html +++ b/digitalglarus/templates/base_glarus.html @@ -109,7 +109,7 @@

Copyright © ungleich GmbH - 2015

+ {% now "Y" %}

diff --git a/digitalglarus/templates/contact.html b/digitalglarus/templates/contact.html index 11767a8a..bb7447c0 100755 --- a/digitalglarus/templates/contact.html +++ b/digitalglarus/templates/contact.html @@ -6,17 +6,26 @@
-
+ {% for message in messages %} + + {% endfor %} +

- {% placeholder 'digital_glarus_contact' %} + {% static_placeholder "digital_glarus_contact_title" %}


- {% placeholder 'digital_glarus_contact_content' %} +

+ {% static_placeholder "digital_glarus_contact_location" %} +

- {% placeholder 'digital_glarus_contact_information' %} + {% static_placeholder "digital_glarus_contact_information" %} +
 
@@ -25,41 +34,46 @@
-
-

Contact - form -

-
-

If you want further information on Digital Glarus, please send us a message using the form below.

-
- {% csrf_token %} -
-
- - -
-
- - -
-
- - -
-
-
- - -
-
- - -
-
-
+
+

+ {% static_placeholder "digital_glarus_contact_form_title" %} +

+
+

{% static_placeholder "digital_glarus_contact_form_text" %}

+
+ {% csrf_token %} +
+
+ {{ form.name.label_tag }} + {{ form.name }} + {{ form.name.errors|striptags}} +
+
+ {{ form.email.label_tag }} + {{ form.email }} + {{ form.email.errors|striptags}} +
+
+ {{ form.phone_number.label_tag }} + {{ form.phone_number }} + {{ form.phone_number.errors|striptags}} +
+
+
+ {{ form.message.label_tag }} + {{ form.message }} + {{ form.message.errors|striptags}} +
+ {{ form.non_field_errors }} +
+ + +
+
+
+
-
{% endblock %} \ No newline at end of file diff --git a/digitalglarus/templates/emails/contact.html b/digitalglarus/templates/emails/contact.html new file mode 100644 index 00000000..a87121a3 --- /dev/null +++ b/digitalglarus/templates/emails/contact.html @@ -0,0 +1,15 @@ + +< + + + + + + +Name:{{data.name}}
+Email:{{data.email}}
+Phone number:{{data.phone_number}}
+Message:{{data.message}}
+ + + diff --git a/digitalglarus/templates/emails/contact.txt b/digitalglarus/templates/emails/contact.txt new file mode 100644 index 00000000..a87121a3 --- /dev/null +++ b/digitalglarus/templates/emails/contact.txt @@ -0,0 +1,15 @@ + +< + + + + + + +Name:{{data.name}}
+Email:{{data.email}}
+Phone number:{{data.phone_number}}
+Message:{{data.message}}
+ + + diff --git a/digitalglarus/templates/support.html b/digitalglarus/templates/support.html new file mode 100644 index 00000000..5ba63ee5 --- /dev/null +++ b/digitalglarus/templates/support.html @@ -0,0 +1,24 @@ +{% extends "base_glarus.html" %} +{% load staticfiles %} +{% load cms_tags %} +{% block title %}About{% endblock %} + +{% block content %} +
+
+
+
+

+ {% static_placeholder "digital_glarus_supporters_become_supporter" %} +

+
+
+
+ {% static_placeholder "digital_glarus_support_info" %} +
+
+
+
+ + +{% endblock %} \ No newline at end of file diff --git a/digitalglarus/templates/supporters.html b/digitalglarus/templates/supporters.html index 9b1c4dbf..7d6d6dd7 100644 --- a/digitalglarus/templates/supporters.html +++ b/digitalglarus/templates/supporters.html @@ -1,28 +1,35 @@ {% extends "base_glarus.html" %} {% load staticfiles %} +{% load cms_tags %} {% block title %}About{% endblock %} {% block content %}
+

-

- Supporters +

+ {% static_placeholder "digital_glarus_supporters_title" %}


- {% for supporter in supporters %} -
-
-
-

{{supporter.name}}

-

{{supporter.description}}

-
-
+
+ {% static_placeholder "digital_glarus_supporters_info" %}
- {% endfor %} +
+
+
+ {% for supporter in supporters %} +
+

{{supporter.name}}

+
+ {% endfor %} +
+ {% static_placeholder "digital_glarus_supporters_become_supporter" %} +
+
diff --git a/digitalglarus/urls.py b/digitalglarus/urls.py index 346b465f..dc06b6b4 100644 --- a/digitalglarus/urls.py +++ b/digitalglarus/urls.py @@ -1,11 +1,13 @@ from django.conf.urls import url +from django.utils.translation import ugettext_lazy as _ from . import views +from .views import ContactView urlpatterns = [ - url(r'old_contact$', views.contact, name='contact'), - url(r'supporters/$', views.supporters, name='supporters'), - # url(r'', views.index, name='index'), + url(_(r'contact/?$'), ContactView.as_view(), name='contact'), + url(_(r'supporters/?$'), views.supporters, name='supporters'), + url(_(r'support-us/?$'), views.support, name='support'), url(r'^blog/(?P\w[-\w]*)/$', views.blog_detail, name='blog-detail'), - url(r'blog/$',views.blog,name='blog'), + url(r'blog/$', views.blog, name='blog'), ] diff --git a/digitalglarus/views.py b/digitalglarus/views.py index a06bc1ef..64c6f791 100644 --- a/digitalglarus/views.py +++ b/digitalglarus/views.py @@ -7,14 +7,26 @@ from django.core.urlresolvers import reverse 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 django.views.generic.edit import FormView -class MessageForm(ModelForm): - required_css_class = 'form-control' - class Meta: - model = Message - fields = ['name', 'email', 'phone_number', 'message' ] + +class ContactView(FormView): + template_name = 'contact.html' + form_class = ContactUsForm + success_url = '/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 detail(request, message_id): @@ -41,24 +53,6 @@ def home(request): def letscowork(request): return render(request, 'digitalglarus/letscowork.html') -def contact(request): - message = Message(received_date=datetime.datetime.now()) - form = MessageForm(request.POST, instance=message) - - if request.method == 'POST': - - if form.is_valid(): - form.save() - return HttpResponseRedirect(reverse("digitalglarus:contact")) - - # form = MessageForm() - - context = { - 'form': form, - } - - return render(request, 'digitalglarus/contact.html', context) - def blog(request): tags = ["digitalglarus"] @@ -80,6 +74,10 @@ def blog_detail(request, slug): return render(request, 'glarus_blog/post_detail.html', context) +def support(request): + return render(request, 'support.html') + + def supporters(request): context = { 'supporters': Supporter.objects.order_by('name') diff --git a/dynamicweb/settings/base.py b/dynamicweb/settings/base.py index 89062f70..e0987911 100644 --- a/dynamicweb/settings/base.py +++ b/dynamicweb/settings/base.py @@ -82,18 +82,18 @@ INSTALLED_APPS = ( 'djangocms_file', 'djangocms_picture', 'djangocms_video', - 'djangocms_flash', - 'djangocms_googlemap', - 'djangocms_inherit', - 'djangocms_link', - 'djangocms_teaser', + # 'djangocms_flash', + # 'djangocms_googlemap', + # 'djangocms_inherit', + # 'djangocms_link', + # 'djangocms_teaser', 'djangocms_page_meta', 'djangocms_text_ckeditor', 'djangocms_admin_style', 'cmsplugin_filer_file', 'cmsplugin_filer_folder', 'cmsplugin_filer_link', - 'cmsplugin_filer_teaser', + # 'cmsplugin_filer_teaser', 'cmsplugin_filer_video', # #blog @@ -178,6 +178,9 @@ DATABASES = { } } + + + # Internationalization # https://docs.djangoproject.com/en/1.7/topics/i18n/ @@ -196,6 +199,11 @@ LANGUAGES = ( LANGUAGE_CODE = 'en-us' +LOCALE_PATHS = [ + + os.path.join(PROJECT_DIR,'digitalglarus/locale'), +] + CMS_PLACEHOLDER_CONF = { 'logo_image': { 'name': 'Logo Image', diff --git a/dynamicweb/settings/prod.py b/dynamicweb/settings/prod.py index 3b385370..80a8d120 100644 --- a/dynamicweb/settings/prod.py +++ b/dynamicweb/settings/prod.py @@ -1,9 +1,10 @@ from .base import * -DEBUG = False +DEBUG = True ADMINS = ( ('Nico Schottelius', 'nico.schottelius@ungleich.ch'), + ('Raul Ascencio', 'raul.ascencio@yandex.com'), ) # ('Sanghee Kim', 'sanghee.kim@ungleich.ch'),