more form stuff; it's working

pull/1/head
nathaniel smith 2016-11-21 21:14:47 -08:00
parent dbd4b740b5
commit 80e4a85883
3 changed files with 105 additions and 18 deletions

View File

@ -3,6 +3,10 @@ from django.dispatch import receiver
from django.contrib.auth.models import User from django.contrib.auth.models import User
from django.db.models import TextField, BooleanField, CharField from django.db.models import TextField, BooleanField, CharField
SSH_TYPE_CHOICES = (
('ssh-rsa', 'ssh-rsa',),
('ssh-dss', 'ssh-dss',),
)
class Townie(User): class Townie(User):
"""Both an almost normal Django User as well as an abstraction over a """Both an almost normal Django User as well as an abstraction over a
@ -11,6 +15,10 @@ class Townie(User):
shell = CharField(max_length=50, default="/bin/bash") shell = CharField(max_length=50, default="/bin/bash")
reviewed = BooleanField(default=False) reviewed = BooleanField(default=False)
displayname = CharField(max_length=100, blank=False, null=False) displayname = CharField(max_length=100, blank=False, null=False)
pubkey_type = CharField(max_length=15,
blank=False,
null=False,
choices=SSH_TYPE_CHOICES)
@property @property
def home_path(self): def home_path(self):

View File

@ -2,6 +2,18 @@
<html> <html>
<head> <head>
<title>tilde.town signup page</title> <title>tilde.town signup page</title>
<style type="text/css">
td.label {
width:40%;
}
td.label p:first-child {
font-weight:bold;
}
td.label p:last-child {
font-style: oblique;
font-size:80%;
}
</style>
</head> </head>
<body> <body>
<h1>sign up for a tilde.town account</h1> <h1>sign up for a tilde.town account</h1>
@ -11,23 +23,85 @@
<form action="{% url 'users:signup' %}" method="post"> <form action="{% url 'users:signup' %}" method="post">
{% csrf_token %} {% csrf_token %}
<!-- TODO captcha of some kind --> <!-- TODO captcha of some kind -->
<!-- TODO help text. how best to do? could throw this all in a table :3 --> <table id="signup">
<label> <tr>
desired username: <td class="label">
<input type="text" required="true" name="username"> <p>
</label> username
<label> </p>
email address: <p>
<input name="email" type="email" required="true"> Must be lowercase and start with letters.
</label> </p>
<label> </td>
display name: <td>
<input name="displayname" type="text"> <input type="text" required="true" name="username">
</label> </td>
<label> </tr>
public key: <tr>
<textarea name="pubkey" required="true"></textarea> <td class="label">
</label> <p>
email
</p>
<p>
used to notify you about your account. not used for
any other reason and never shared.
</p>
</td>
<td>
<input name="email" type="email" required="true">
</td>
</tr>
<tr>
<td class="label">
<p>
display name
</p>
<p>
an optional long-form name to go by. absolutely no
obligation to provide your "real" name. will appear
in various places.
</p>
</td>
<td>
<input name="displayname" type="text">
</td>
</tr>
<tr>
<td class="label">
<p>
ssh public key
</p>
<p>
your ssh <strong>public</strong> key. if ssh is new
to you, <a
href="http://tilde.town/~wiki/ssh.html">check out
our guide for help</a>. Provide just the guts
of the key; it will most likely start with
<strong><code>AAAAB3NzaC1iyc</code></strong>
</p>
</td>
<td>
<textarea name="pubkey" required="true"></textarea>
</td>
</tr>
<tr>
<td class="label">
<p>
ssh public key type
</p>
<p>
You can leave this alone unless you know that you need to change it.
</p>
</td>
<td>
<select name="pubkey_type">
{% for choice in ssh_type_choices %}
<option value="{{choice.0}}">{{choice.1}}</option>
{% endfor %}
</select>
</td>
</tr>
</table>
<input type="submit" value="sign up <3" /> <input type="submit" value="sign up <3" />
</form> </form>
</body> </body>

View File

@ -1,7 +1,7 @@
from django.http import HttpResponse from django.http import HttpResponse
from django.views.generic import TemplateView from django.views.generic import TemplateView
from .models import Townie from .models import Townie, SSH_TYPE_CHOICES
# TODO validation functions for final request validation and live js validation # 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 # I refuse to duplicate the logic for validation on the front-end and am going
@ -10,6 +10,11 @@ from .models import Townie
class UserSignupView(TemplateView): class UserSignupView(TemplateView):
template_name = 'ttadmin/signup.html' template_name = 'ttadmin/signup.html'
def get_context_data(self):
ctx = super().get_context_data()
ctx['ssh_type_choices'] = SSH_TYPE_CHOICES
return ctx
def post(self, request): def post(self, request):
print(request.POST) print(request.POST)
# TODO validate # TODO validate