Merge pull request #3 from nathanielksmith/master

small improvements
pull/16/head
Nathaniel Smith 2017-01-16 23:31:25 -08:00 committed by GitHub
commit 9996fbeb6a
3 changed files with 5 additions and 2 deletions

View File

@ -13,4 +13,5 @@ class PubkeyInline(admin.TabularInline):
@admin.register(Townie) @admin.register(Townie)
class TownieAdmin(admin.ModelAdmin): class TownieAdmin(admin.ModelAdmin):
inlines = [PubkeyInline] inlines = [PubkeyInline]
pass list_display = ('reviewed', 'username', 'email')
ordering = ('reviewed',)

View File

@ -22,7 +22,7 @@ def validate_username(username):
if len(username) < USERNAME_MIN_LENGTH: if len(username) < USERNAME_MIN_LENGTH:
raise ValidationError('Username too short.') raise ValidationError('Username too short.')
if not USERNAME_RE.match(username): if not USERNAME_RE.match(username):
raise ValidationError('Username must be all lowercase, start with a letter, and only use the _ special charcter') raise ValidationError('Username must be all lowercase, start with a letter, and only use the _ special character')
duplicate = Townie.objects.filter(username=username).count() duplicate = Townie.objects.filter(username=username).count()
if duplicate > 0: if duplicate > 0:
raise ValidationError('Username already in use :(') raise ValidationError('Username already in use :(')

View File

@ -23,6 +23,8 @@ class SignupView(FormView):
key_type=form.cleaned_data.pop('pubkey_type')) key_type=form.cleaned_data.pop('pubkey_type'))
t = Townie(**form.cleaned_data) t = Townie(**form.cleaned_data)
if not getattr(t, 'displayname'):
t.displayname = t.username
t.set_unusable_password() t.set_unusable_password()
t.save() t.save()
pubkey.townie = t pubkey.townie = t