diff --git a/ttadmin/users/models.py b/ttadmin/users/models.py
index 2826e63..b3dc292 100644
--- a/ttadmin/users/models.py
+++ b/ttadmin/users/models.py
@@ -1,15 +1,16 @@
from django.db.models.signals import post_save
from django.dispatch import receiver
from django.contrib.auth.models import User
-from django.db.models import TextField, BooleanField
+from django.db.models import TextField, BooleanField, CharField
class Townie(User):
"""Both an almost normal Django User as well as an abstraction over a
system user."""
pubkey = TextField(blank=False, null=False)
- shell = TextField(max_length=50, default="/bin/bash")
- pending = BooleanField(default=True)
+ shell = CharField(max_length=50, default="/bin/bash")
+ reviewed = BooleanField(default=False)
+ displayname = CharField(max_length=100, blank=False, null=False)
@property
def home_path(self):
@@ -25,10 +26,6 @@ class Townie(User):
is."""
raise NotImplementedError()
- def __init__(self):
- self.set_unusable_password()
- super().__init__(self)
-
@receiver(post_save, sender=Townie)
def sync_system_state(sender, instance, created, **kwargs):
if created:
diff --git a/ttadmin/users/templates/ttadmin/signup.html b/ttadmin/users/templates/ttadmin/signup.html
index ebeda0e..41f2e6b 100644
--- a/ttadmin/users/templates/ttadmin/signup.html
+++ b/ttadmin/users/templates/ttadmin/signup.html
@@ -26,7 +26,7 @@
diff --git a/ttadmin/users/views.py b/ttadmin/users/views.py
index f3dc413..081eabf 100644
--- a/ttadmin/users/views.py
+++ b/ttadmin/users/views.py
@@ -1,8 +1,43 @@
from django.http import HttpResponse
from django.views.generic import TemplateView
+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.
+
class UserSignupView(TemplateView):
template_name = 'ttadmin/signup.html'
def post(self, request):
+ 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()
+
+
return HttpResponse('LOLOLOLOL')