Website: Test contact form.
This commit is contained in:
parent
dddc327b90
commit
33489522eb
@ -125,3 +125,26 @@ footer a:hover {
|
||||
color: #FFFFFF;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
ul.errorlist {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
list-style: none outside none;
|
||||
}
|
||||
.errorlist li {
|
||||
color: #DA3939;
|
||||
font-size: 9px;
|
||||
font-style: italic;
|
||||
height: 13px;
|
||||
padding: 0;
|
||||
}
|
||||
form .error {
|
||||
color: #DA3939;
|
||||
font-weight: bold;
|
||||
}
|
||||
form p.error {
|
||||
margin-top: 0;
|
||||
}
|
||||
form .error input, form .error textarea {
|
||||
border: 1px solid #DA3939;
|
||||
}
|
||||
|
@ -13,6 +13,12 @@ Kontaktmöglichkeiten zur OpenSlides Community
|
||||
|
||||
{% block content %}
|
||||
|
||||
<form action="" method="post">{% csrf_token %}
|
||||
{{ form.name_of_field.errors }}
|
||||
{{ form.as_p }}
|
||||
<input type="submit" value="Submit" />
|
||||
</form>
|
||||
|
||||
<h3>Mailinglisten</h3>
|
||||
|
||||
<p>OpenSlides bietet öffentliche Mailinglisten zur Koordination der Entwicklung
|
||||
|
@ -1,6 +1,7 @@
|
||||
from django.conf.urls import patterns, include, url
|
||||
from django.conf.urls.i18n import i18n_patterns
|
||||
from django.views.generic import TemplateView
|
||||
from website import views
|
||||
|
||||
#from views import TemplateView
|
||||
# Uncomment the next two lines to enable the admin:
|
||||
@ -18,7 +19,8 @@ urlpatterns = i18n_patterns('',
|
||||
url(r'^download/$', TemplateView.as_view(template_name="download.html"), name='download',),
|
||||
url(r'^support/$', TemplateView.as_view(template_name="support.html"), name='support',),
|
||||
url(r'^development/$', TemplateView.as_view(template_name="development.html"), name='development',),
|
||||
url(r'^contact/$', TemplateView.as_view(template_name="contact.html"), name='contact',),
|
||||
url(r'^contact/$', 'website.views.contact', name='contact',),
|
||||
#url(r'^contact/$', TemplateView.as_view(template_name="contact.html"), name='contact',),
|
||||
url(r'^demo/$', TemplateView.as_view(template_name="demo.html"), name='demo',),
|
||||
url(r'^impressum/$', TemplateView.as_view(template_name="impressum.html"), name='impressum',),
|
||||
)
|
||||
|
@ -1,7 +0,0 @@
|
||||
|
||||
# Oskar
|
||||
class TemplateView(_TemplateView):
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(TemplateView, self).get_context_data(**kwargs)
|
||||
context[request] = self.request
|
||||
return context
|
@ -1,9 +1,34 @@
|
||||
from django.views.generic import TemplateView
|
||||
#from django.views.generic import TemplateView
|
||||
from django.shortcuts import render_to_response, render
|
||||
from django.http import HttpResponseRedirect
|
||||
|
||||
class TemplateView():
|
||||
from website.forms import ContactForm
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(TemplateView, self).get_context_data(**kwargs)
|
||||
print self.request
|
||||
# template_manipulation.send(sender=self.__class__, request=self.request, context=context)
|
||||
return context
|
||||
#class TemplateView(TemplateView):
|
||||
# def get_context_data(self, **kwargs):
|
||||
# context = super(TemplateView, self).get_context_data(**kwargs)
|
||||
# context[request] = self.request
|
||||
# return context
|
||||
|
||||
|
||||
def contact(request):
|
||||
if request.method == 'POST': # If the form has been submitted...
|
||||
form = ContactForm(request.POST) # A form bound to the POST data
|
||||
if form.is_valid(): # All validation rules pass
|
||||
subject = form.cleaned_data['subject']
|
||||
message = form.cleaned_data['message']
|
||||
sender = form.cleaned_data['sender']
|
||||
cc_myself = form.cleaned_data['cc_myself']
|
||||
recipients = ['emanuel@intevation.de']
|
||||
if cc_myself:
|
||||
recipients.append(sender)
|
||||
|
||||
from django.core.mail import send_mail
|
||||
send_mail(subject, message, sender, recipients)
|
||||
return HttpResponseRedirect('/demo/') # Redirect after POST
|
||||
else:
|
||||
form = ContactForm() # An unbound form
|
||||
|
||||
return render(request, 'contact.html', {
|
||||
'form': form,
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user