Commit e89ce6fb authored by Alexander Færøy's avatar Alexander Færøy 🍍
Browse files

Merge branch 'update/username' into 'main'

Updated username properties

See merge request !5
parents 317d6e02 7d875f40
......@@ -19,7 +19,7 @@ delete.short_description = "Delete account requests"
class GitlabAccountRequestAdmin(admin.ModelAdmin):
fields = ('username', 'email', 'approved', 'reason')
list_display = ('username', 'email', 'approved', 'reason', 'created_date')
list_display = ('username', 'email', 'approved', 'reason')
actions = [approve, delete]
def has_delete_permission(self, request, obj=None):
from django.db import models
from django import forms
from django.utils.translation import gettext_lazy as _
def is_valid_username(name):
if not all(x.isalpha() or x=='_' or x.isnumeric() for x in name):
raise forms.ValidationError(
_('%(name)s is not a valid username. Should be A-Z, a-z, 0-9 and _.'),
params={'name': name},
def is_username_exists(name):
if GitlabAccountRequest.objects.filter(username=name).count() > 0:
raise forms.ValidationError(
_('%(name)s already exists.'),
params={'name': name},
class GitlabAccountRequest(models.Model):
username = models.CharField(max_length=64)
username = models.CharField(max_length=64, validators=[is_valid_username,is_username_exists])
email = models.EmailField()
reason = models.CharField(max_length=256)
approved = models.BooleanField(default=False)
created_date = models.DateTimeField(auto_now_add=True)
class GitlabAccountRequestForm(forms.ModelForm):
class Meta:
......@@ -12,6 +12,10 @@
<label for="input-username" class="sr-only">Username</label>
<input type="text" id="input-username" name="username" class="form-control" placeholder="Username" required>
<div style="color: red; margin-bottom:10px">
{{ form.username.errors | striptags }}
<p>Please explain why you want to collaborate with the Tor community</p>
<textarea class="form-control" name="reason" maxlength="256" placeholder="For Example: I wish to report an issue in Tor Browser." rows="3"></textarea>
......@@ -23,6 +23,8 @@ def index(request):
return HttpResponseRedirect('/success/')
return render(request, 'core/signup.html', {'form': form})
return HttpResponseRedirect('/failure/')
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment