dynamicweb/railshosting/views.py
Nico Schottelius 6aaa04eaa2 get railshosting running
Signed-off-by: Nico Schottelius <nico@wurzel.schottelius.org>
2015-05-27 15:41:43 +02:00

33 lines
981 B
Python

import datetime
from django.shortcuts import get_object_or_404, render
from django.forms import ModelForm
from django.http import HttpResponseRedirect
from django.core.urlresolvers import reverse
from .models import RailsBetaUser
class RailsBetaUserForm(ModelForm):
required_css_class = 'form-control'
class Meta:
model = RailsBetaUser
fields = [ 'email' ]
def index(request):
email = RailsBetaUser(received_date=datetime.datetime.now())
context = {}
context['form'] = RailsBetaUserForm()
if request.method == 'POST':
form = RailsBetaUserForm(request.POST, instance=email)
context['form'] = form
if form.is_valid():
form.save()
return HttpResponseRedirect(reverse("railshosting:beta"))
else:
context['error_message'] = "a problem"
return render(request, 'railshosting/index.html', context)
def beta(request):
return render(request, 'railshosting/beta.html')