copyleftconf-website/pinaxcon/views.py

41 lines
1.2 KiB
Python
Raw Normal View History

2017-08-18 15:46:51 +00:00
from django.conf import settings
from django.contrib import messages
from django.http import HttpResponseServerError
from django.shortcuts import redirect, render
from django.template import RequestContext
from django.template import Template
from django.template.loader import get_template
from django.views import defaults
2017-08-18 15:46:51 +00:00
from account.forms import LoginEmailForm, LoginUsernameForm, SignupForm
2017-08-18 16:26:35 +00:00
from account.views import LoginView
2017-08-18 15:46:51 +00:00
def server_error(request, template_name=defaults.ERROR_500_TEMPLATE_NAME):
t = Template("{%% include '%s' %%}" % template_name)
return HttpResponseServerError(t.render(RequestContext(request)))
2017-08-18 15:46:51 +00:00
def account_login(request):
d = {
2017-08-18 16:26:35 +00:00
"login_form": LoginEmailForm(),
2017-08-18 15:46:51 +00:00
"signup_form": SignupForm(),
"signup_open": getattr(settings, "ACCOUNT_OPEN_SIGNUP", True),
}
print d["signup_open"], settings.ACCOUNT_OPEN_SIGNUP
return render(request, "account_login.html", d)
2017-08-18 16:26:35 +00:00
class EmailLoginView(LoginView):
form_class = LoginEmailForm
def buy_ticket(request):
print(dir(request.user))
if not request.user.is_authenticated():
messages.warning(request, 'To buy a ticket, either create an account, or log in.')
return redirect("/dashboard")