2016-11-20 05:34:38 +00:00
|
|
|
from django.http import HttpResponse
|
|
|
|
from django.views.generic import TemplateView
|
|
|
|
|
2016-11-21 07:56:55 +00:00
|
|
|
from .models import Townie
|
|
|
|
|
|
|
|
# TODO validation functions for final request validation and live js validation
|
|
|
|
# I refuse to duplicate the logic for validation on the front-end and am going
|
|
|
|
# to accept round-trip validation costs with long-term caching.
|
|
|
|
|
2016-11-20 05:34:38 +00:00
|
|
|
class UserSignupView(TemplateView):
|
|
|
|
template_name = 'ttadmin/signup.html'
|
|
|
|
|
|
|
|
def post(self, request):
|
2016-11-21 07:56:55 +00:00
|
|
|
print(request.POST)
|
|
|
|
# TODO validate
|
|
|
|
username = request.POST.get('username')
|
|
|
|
|
|
|
|
displayname = request.POST.get('displayname')
|
|
|
|
|
|
|
|
if displayname is None:
|
|
|
|
displayname = username
|
|
|
|
else:
|
|
|
|
# TODO validate
|
|
|
|
pass
|
|
|
|
|
|
|
|
# TODO validate
|
|
|
|
pubkey = request.POST.get('pubkey')
|
|
|
|
|
|
|
|
# TODO validate
|
|
|
|
email = request.POST.get('email')
|
|
|
|
|
|
|
|
t = Townie(
|
|
|
|
username=username,
|
|
|
|
displayname=displayname,
|
|
|
|
pubkey=pubkey,
|
|
|
|
email=email,
|
|
|
|
)
|
|
|
|
|
|
|
|
t.set_unusable_password()
|
|
|
|
t.save()
|
|
|
|
|
|
|
|
|
2016-11-20 05:34:38 +00:00
|
|
|
return HttpResponse('LOLOLOLOL')
|