Merge branch 'develop'

This commit is contained in:
rascencio 2016-04-09 19:56:45 +02:00
commit b2334037c1
17 changed files with 260 additions and 86 deletions

1
.gitignore vendored
View file

@ -1,5 +1,6 @@
db.sqlite3
*.pyc
*.DS_Store
build/
dist/
*.egg_info

26
digitalglarus/forms.py Normal file
View file

@ -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()

Binary file not shown.

View file

@ -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 <EMAIL@ADDRESS>, 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 <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\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 ""

View file

@ -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),
),
]

View file

@ -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)
@ -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)

Binary file not shown.

After

Width:  |  Height:  |  Size: 557 KiB

View file

@ -109,7 +109,7 @@
<div class="row">
<div class="col-lg-12 text-center">
<p class="text-center">Copyright &copy; <a href="http://www.ungleich.ch">ungleich GmbH
2015</a></p>
{% now "Y" %}</a></p>
</div>
</div>
</div>

View file

@ -6,17 +6,26 @@
<div class="row">
<div class="box">
<div class="col-lg-12">
{% for message in messages %}
<div class="alert alert-success alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<strong>{{ message }}</strong>
</div>
{% endfor %}
<hr>
<h2 class="intro-text text-center">
{% placeholder 'digital_glarus_contact' %}
{% static_placeholder "digital_glarus_contact_title" %}
</h2>
<hr>
</div>
<div class="col-md-8">
{% placeholder 'digital_glarus_contact_content' %}
<p>
{% static_placeholder "digital_glarus_contact_location" %}
</p>
</div>
<div class="col-md-4">
{% placeholder 'digital_glarus_contact_information' %}
{% static_placeholder "digital_glarus_contact_information" %}
<div class="clearfix">&nbsp;</div>
</div>
<div class="clearfix"></div>
</div>
@ -26,38 +35,43 @@
<div class="box">
<div class="col-lg-12">
<hr>
<h2 class="intro-text text-center">Contact
<strong>form</strong>
<h2 class="intro-text text-center">
{% static_placeholder "digital_glarus_contact_form_title" %}
</h2>
<hr>
<p>If you want further information on Digital Glarus, please send us a message using the form below.</p>
<form action="{% url 'digitalglarus:contact' %}" method="post" role="form">
<p>{% static_placeholder "digital_glarus_contact_form_text" %}</p>
<form action="" method="post" >
{% csrf_token %}
<div class="row">
<div class="form-group col-lg-4">
<label>Name</label>
<input type="text" class="form-control" name="name">
<div autofocus class="form-group col-lg-4 {% if form.name.errors %}has-error text-danger{% endif %}">
{{ form.name.label_tag }}
{{ form.name }}
{{ form.name.errors|striptags}}
</div>
<div class="form-group col-lg-4">
<label>Email Address</label>
<input type="email" class="form-control" name="email">
<div class="form-group col-lg-4 {% if form.email.errors %}has-error text-danger {% endif %}">
{{ form.email.label_tag }}
{{ form.email }}
{{ form.email.errors|striptags}}
</div>
<div class="form-group col-lg-4">
<label>Phone Number</label>
<input type="tel" class="form-control" name="phone_number">
<div class="form-group col-lg-4 {% if form.phone_number.errors %}has-error text-danger {% endif %}">
{{ form.phone_number.label_tag }}
{{ form.phone_number }}
{{ form.phone_number.errors|striptags}}
</div>
<div class="clearfix"></div>
<div class="form-group col-lg-12">
<label>Message</label>
<textarea class="form-control" rows="6" name="message"></textarea>
<div class="form-group col-lg-12 {% if form.message.errors %}has-error text-danger {% endif %}">
{{ form.message.label_tag }}
{{ form.message }}
{{ form.message.errors|striptags}}
</div>
{{ form.non_field_errors }}
<div class="form-group col-lg-12">
<input type="hidden" name="save" value="contact">
<button type="submit" class="btn btn-default">Submit</button>
<button type="submit" class="btn btn-default" {% if form.name.errors %} autofocus {% endif %}>Submit</button>
</div>
</div>
</form>
</div>
<!-- -->
</div>
</div>
</div>

View file

@ -0,0 +1,15 @@
<<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
Name:{{data.name}}<br/>
Email:{{data.email}}<br/>
Phone number:{{data.phone_number}}<br/>
Message:{{data.message}}<br/>
</body>
</html>

View file

@ -0,0 +1,15 @@
<<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
Name:{{data.name}}<br/>
Email:{{data.email}}<br/>
Phone number:{{data.phone_number}}<br/>
Message:{{data.message}}<br/>
</body>
</html>

View file

@ -0,0 +1,24 @@
{% extends "base_glarus.html" %}
{% load staticfiles %}
{% load cms_tags %}
{% block title %}About{% endblock %}
{% block content %}
<div class="row">
<div class="box">
<div class="col-lg-12">
<hr>
<h2 class="text-center">
{% static_placeholder "digital_glarus_supporters_become_supporter" %}
</h2>
<hr>
</div>
<div class="col-md-7 col-md-offset-3">
{% static_placeholder "digital_glarus_support_info" %}
</div>
<div class="clearfix"></div>
</div>
</div>
<!-- /.container -->
{% endblock %}

View file

@ -1,28 +1,35 @@
{% extends "base_glarus.html" %}
{% load staticfiles %}
{% load cms_tags %}
{% block title %}About{% endblock %}
{% block content %}
<div class="row">
<div class="box">
<img class="img-responsive img-full" src="{% static 'digitalglarus/img/thank-you.png' %}" alt="">
<div class="col-lg-12">
<hr>
<h2 class="intro-text text-center">
Supporters
<h2 class="text-center">
{% static_placeholder "digital_glarus_supporters_title" %}
</h2>
<hr>
</div>
<div class="col-md-12">
<div class="text-center">
{% static_placeholder "digital_glarus_supporters_info" %}
</div>
</div>
<div class="col-md-12">
<div class="text-center">
{% for supporter in supporters %}
<div class="col-md-6">
<div class="thumbnail">
<div class="caption">
<h3>{{supporter.name}}</h3>
<p>{{supporter.description}}</p>
</div>
</div>
</div>
{% endfor %}
<hr>
<a class="btn btn-default" href="{% url 'digitalglarus:support' %}" role="button">{% static_placeholder "digital_glarus_supporters_become_supporter" %}</a>
</div>
</div>
<div class="clearfix"></div>
</div>

View file

@ -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<slug>\w[-\w]*)/$', views.blog_detail, name='blog-detail'),
url(r'blog/$', views.blog, name='blog'),
]

View file

@ -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')

View file

@ -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',

View file

@ -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'),