root / invitations / views.py @ 4f8b91cd
History | View | Annotate | Download (1.1 kB)
1 |
from django import forms |
---|---|
2 |
from django.http import HttpResponse, HttpResponseRedirect |
3 |
from django.shortcuts import render_to_response |
4 |
from django.template import Template |
5 |
from synnefo.api.common import method_not_allowed |
6 |
|
7 |
from synnefo.db.models import SynnefoUser |
8 |
|
9 |
class InvitationForm(forms.Form): |
10 |
emails = forms.Textarea |
11 |
|
12 |
def send_emails(self, request): |
13 |
if request.method == 'POST': # If the form has been submitted... |
14 |
form = InvitationForm(request.POST) # A form bound to the POST data
|
15 |
if form.is_valid(): # All validation rules pass |
16 |
# Process the data in form.cleaned_data
|
17 |
# ...
|
18 |
return HttpResponseRedirect('/thanks/') # Redirect after POST |
19 |
else:
|
20 |
form = InvitationForm() # An unbound form
|
21 |
|
22 |
return render_to_response('invitation.html', {'form': form,}) |
23 |
|
24 |
def inv_demux(request): |
25 |
if request.method == 'GET': |
26 |
t = Template() |
27 |
data = t.render('invitation.html', {'invitations': None}) |
28 |
return HttpResponse(data)
|
29 |
elif request.method == 'POST': |
30 |
f = InvitationForm(request) |
31 |
else:
|
32 |
method_not_allowed(request) |