Adapt copyright copy to use current year, Add bank account info, Set the correct text on supporters page, HTML Form adapted to Django template, Create forms.py to have all forms, Create Contact Django Form View, Create a HTML template to contact email, Send contact email to info@digitalglarus.ch
This commit is contained in:
parent
d7cb1fbbc6
commit
bb8c5314bc
12 changed files with 184 additions and 66 deletions
26
digitalglarus/forms.py
Normal file
26
digitalglarus/forms.py
Normal 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 = ['to@example.com']
|
||||||
|
email.send()
|
20
digitalglarus/migrations/0005_auto_20160407_0519.py
Normal file
20
digitalglarus/migrations/0005_auto_20160407_0519.py
Normal 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),
|
||||||
|
),
|
||||||
|
]
|
|
@ -8,8 +8,7 @@ class Message(models.Model):
|
||||||
email = models.EmailField()
|
email = models.EmailField()
|
||||||
phone_number = models.CharField(max_length=200)
|
phone_number = models.CharField(max_length=200)
|
||||||
message = models.TextField()
|
message = models.TextField()
|
||||||
|
received_date = models.DateTimeField(auto_now_add=True)
|
||||||
received_date = models.DateTimeField('date received')
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "%s - %s - %s" % (self.name, self.email, self.received_date)
|
return "%s - %s - %s" % (self.name, self.email, self.received_date)
|
||||||
|
|
|
@ -101,7 +101,7 @@
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-12 text-center">
|
<div class="col-lg-12 text-center">
|
||||||
<p class="text-center">Copyright © <a href="http://www.ungleich.ch">ungleich GmbH
|
<p class="text-center">Copyright © <a href="http://www.ungleich.ch">ungleich GmbH
|
||||||
2016</a></p>
|
{% now "Y" %}</a></p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -6,17 +6,33 @@
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="box">
|
<div class="box">
|
||||||
<div class="col-lg-12">
|
<div class="col-lg-12">
|
||||||
<hr>
|
{% 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">×</span></button>
|
||||||
|
<strong>{{ message }}</strong>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
<hr>
|
||||||
<h2 class="intro-text text-center">
|
<h2 class="intro-text text-center">
|
||||||
{% placeholder 'digital_glarus_contact' %}
|
<p class="text-center">
|
||||||
|
Contact <strong>DIGITAL GLARUS</strong>
|
||||||
|
</p>
|
||||||
</h2>
|
</h2>
|
||||||
<hr>
|
<hr>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-8">
|
<div class="col-md-8">
|
||||||
{% placeholder 'digital_glarus_contact_content' %}
|
<p>
|
||||||
|
<iframe frameborder="0" height="400" scrolling="no" src="//maps.google.com/maps?hl=en&ie=UTF8&ll=46.969959,9.039001&spn=56.506174,79.013672&t=m&z=12&output=embed" width="100%"></iframe>
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-4">
|
<div class="col-md-4">
|
||||||
{% placeholder 'digital_glarus_contact_information' %}
|
<p>Phone: <strong>+41 (0) 44 534 66 22</strong></p>
|
||||||
|
|
||||||
|
<p>Email: <strong><a href="mailto:info@digitalglarus.ch">info@digitalglarus.ch</a></strong></p>
|
||||||
|
|
||||||
|
<p>Address: <strong><span style="">In Der Au 7, 8762 Schwanden Switzerland</span></strong></p>
|
||||||
|
|
||||||
|
<div class="clearfix"> </div>
|
||||||
</div>
|
</div>
|
||||||
<div class="clearfix"></div>
|
<div class="clearfix"></div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -25,41 +41,46 @@
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="box">
|
<div class="box">
|
||||||
<div class="col-lg-12">
|
<div class="col-lg-12">
|
||||||
<hr>
|
<hr>
|
||||||
<h2 class="intro-text text-center">Contact
|
<h2 class="intro-text text-center">
|
||||||
<strong>form</strong>
|
Contact <strong>form</strong>
|
||||||
</h2>
|
</h2>
|
||||||
<hr>
|
<hr>
|
||||||
<p>If you want further information on Digital Glarus, please send us a message using the form below.</p>
|
<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">
|
<form action="" method="post" >
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="form-group col-lg-4">
|
<div autofocus class="form-group col-lg-4 {% if form.name.errors %}has-error text-danger{% endif %}">
|
||||||
<label>Name</label>
|
{{ form.name.label_tag }}
|
||||||
<input type="text" class="form-control" name="name">
|
{{ form.name }}
|
||||||
</div>
|
{{ form.name.errors|striptags}}
|
||||||
<div class="form-group col-lg-4">
|
</div>
|
||||||
<label>Email Address</label>
|
<div class="form-group col-lg-4 {% if form.email.errors %}has-error text-danger {% endif %}">
|
||||||
<input type="email" class="form-control" name="email">
|
{{ form.email.label_tag }}
|
||||||
</div>
|
{{ form.email }}
|
||||||
<div class="form-group col-lg-4">
|
{{ form.email.errors|striptags}}
|
||||||
<label>Phone Number</label>
|
</div>
|
||||||
<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 %}">
|
||||||
</div>
|
{{ form.phone_number.label_tag }}
|
||||||
<div class="clearfix"></div>
|
{{ form.phone_number }}
|
||||||
<div class="form-group col-lg-12">
|
{{ form.phone_number.errors|striptags}}
|
||||||
<label>Message</label>
|
</div>
|
||||||
<textarea class="form-control" rows="6" name="message"></textarea>
|
<div class="clearfix"></div>
|
||||||
</div>
|
<div class="form-group col-lg-12 {% if form.message.errors %}has-error text-danger {% endif %}">
|
||||||
<div class="form-group col-lg-12">
|
{{ form.message.label_tag }}
|
||||||
<input type="hidden" name="save" value="contact">
|
{{ form.message }}
|
||||||
<button type="submit" class="btn btn-default">Submit</button>
|
{{ form.message.errors|striptags}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
{{ form.non_field_errors }}
|
||||||
</form>
|
<div class="form-group col-lg-12">
|
||||||
|
<input type="hidden" name="save" value="contact">
|
||||||
|
<button type="submit" class="btn btn-default" {% if form.name.errors %} autofocus {% endif %}>Submit</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
<!-- -->
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
<!-- /.container -->
|
<!-- /.container -->
|
||||||
{% endblock %}
|
{% endblock %}
|
15
digitalglarus/templates/emails/contact.html
Normal file
15
digitalglarus/templates/emails/contact.html
Normal 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>
|
15
digitalglarus/templates/emails/contact.txt
Normal file
15
digitalglarus/templates/emails/contact.txt
Normal 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>
|
|
@ -18,11 +18,14 @@
|
||||||
you can send your donation to:
|
you can send your donation to:
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<strong>Bank info</strong>
|
<strong>Bank info</strong><br/>
|
||||||
<br>
|
Postfinance<br/>
|
||||||
Account: 123123123123123123
|
89-849216-5<br/>
|
||||||
<br>
|
<br/>
|
||||||
Name: Fake name
|
CH36 0900 0000 8984 9216 5<br/>
|
||||||
|
Nico Schottelius<br/>
|
||||||
|
Hauptstrasse 14<br/>
|
||||||
|
8775 Luchsingen<br/>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
If you want to donate us in other means (your time, skill, etc..)
|
If you want to donate us in other means (your time, skill, etc..)
|
||||||
|
|
|
@ -14,9 +14,10 @@
|
||||||
<hr>
|
<hr>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
<p>
|
<div class="text-center">
|
||||||
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.
|
<h3>HERE ARE OUR PROUD SUPPORTERS OF PROJECT DIGITALGLARUS!</h3>
|
||||||
</p>
|
<p class="text-center">Thanks to our supporters, the first cowerking space in Glarus will have a new look!</p>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
from django.conf.urls import url
|
from django.conf.urls import url
|
||||||
|
|
||||||
from . import views
|
from . import views
|
||||||
|
from .views import ContactView
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
url(r'old_contact$', views.contact, name='contact'),
|
url(r'contact/?$', ContactView.as_view(), name='contact'),
|
||||||
url(r'supporters/?$', views.supporters, name='supporters'),
|
url(r'supporters/?$', views.supporters, name='supporters'),
|
||||||
url(r'support-us/?$', views.support, name='support'), # url(r'', views.index, name='index'),
|
url(r'support-us/?$', views.support, name='support'), # url(r'', views.index, name='index'),
|
||||||
url(r'blog/',views.blog,name='blog'),
|
url(r'blog/',views.blog,name='blog'),
|
||||||
|
|
|
@ -7,14 +7,26 @@ from django.core.urlresolvers import reverse
|
||||||
from django.utils.translation import get_language
|
from django.utils.translation import get_language
|
||||||
from djangocms_blog.models import Post
|
from djangocms_blog.models import Post
|
||||||
from django.core.urlresolvers import resolve
|
from django.core.urlresolvers import resolve
|
||||||
|
from django.contrib import messages
|
||||||
|
from django.utils.translation import ugettext as _
|
||||||
|
|
||||||
|
|
||||||
from .models import Message, Supporter
|
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 ContactView(FormView):
|
||||||
class Meta:
|
template_name = 'contact.html'
|
||||||
model = Message
|
form_class = ContactUsForm
|
||||||
fields = ['name', 'email', 'phone_number', 'message' ]
|
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):
|
def detail(request, message_id):
|
||||||
|
@ -41,23 +53,23 @@ def home(request):
|
||||||
def letscowork(request):
|
def letscowork(request):
|
||||||
return render(request, 'digitalglarus/letscowork.html')
|
return render(request, 'digitalglarus/letscowork.html')
|
||||||
|
|
||||||
def contact(request):
|
# def contact(request):
|
||||||
message = Message(received_date=datetime.datetime.now())
|
# message = Message(received_date=datetime.datetime.now())
|
||||||
form = MessageForm(request.POST, instance=message)
|
# form = MessageForm(request.POST, instance=message)
|
||||||
|
|
||||||
if request.method == 'POST':
|
# if request.method == 'POST':
|
||||||
|
|
||||||
if form.is_valid():
|
# if form.is_valid():
|
||||||
form.save()
|
# form.save()
|
||||||
return HttpResponseRedirect(reverse("digitalglarus:contact"))
|
# return HttpResponseRedirect(reverse("digitalglarus:contact"))
|
||||||
|
|
||||||
# form = MessageForm()
|
# # form = MessageForm()
|
||||||
|
|
||||||
context = {
|
# context = {
|
||||||
'form': form,
|
# 'form': form,
|
||||||
}
|
# }
|
||||||
|
|
||||||
return render(request, 'digitalglarus/contact.html', context)
|
# return render(request, 'digitalglarus/contact.html', context)
|
||||||
|
|
||||||
|
|
||||||
def blog(request):
|
def blog(request):
|
||||||
|
@ -76,9 +88,11 @@ def blog_detail(request, slug):
|
||||||
}
|
}
|
||||||
return render(request, 'post_detail.html', context)
|
return render(request, 'post_detail.html', context)
|
||||||
|
|
||||||
|
|
||||||
def support(request):
|
def support(request):
|
||||||
return render(request, 'support.html')
|
return render(request, 'support.html')
|
||||||
|
|
||||||
|
|
||||||
def supporters(request):
|
def supporters(request):
|
||||||
context = {
|
context = {
|
||||||
'supporters': Supporter.objects.order_by('name')
|
'supporters': Supporter.objects.order_by('name')
|
||||||
|
|
|
@ -181,6 +181,9 @@ DATABASES = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Internationalization
|
# Internationalization
|
||||||
# https://docs.djangoproject.com/en/1.7/topics/i18n/
|
# https://docs.djangoproject.com/en/1.7/topics/i18n/
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue