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.db.models import TextField, BooleanField, CharField
SSH_TYPE_CHOICES = (
('ssh-rsa', 'ssh-rsa',),
('ssh-dss', 'ssh-dss',),
)
class Townie(User):
"""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")
reviewed = BooleanField(default=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
def home_path(self):

View File

@ -2,6 +2,18 @@
<html>
<head>
<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>
<body>
<h1>sign up for a tilde.town account</h1>
@ -11,23 +23,85 @@
<form action="{% url 'users:signup' %}" method="post">
{% csrf_token %}
<!-- TODO captcha of some kind -->
<!-- TODO help text. how best to do? could throw this all in a table :3 -->
<label>
desired username:
<input type="text" required="true" name="username">
</label>
<label>
email address:
<input name="email" type="email" required="true">
</label>
<label>
display name:
<input name="displayname" type="text">
</label>
<label>
public key:
<textarea name="pubkey" required="true"></textarea>
</label>
<table id="signup">
<tr>
<td class="label">
<p>
username
</p>
<p>
Must be lowercase and start with letters.
</p>
</td>
<td>
<input type="text" required="true" name="username">
</td>
</tr>
<tr>
<td class="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" />
</form>
</body>

View File

@ -1,7 +1,7 @@
from django.http import HttpResponse
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
# 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):
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):
print(request.POST)
# TODO validate