summaryrefslogtreecommitdiff
path: root/devel/views.py
diff options
context:
space:
mode:
authorParabola <dev@list.parabolagnulinux.org>2011-03-06 14:13:36 +0000
committerParabola <dev@list.parabolagnulinux.org>2011-03-06 14:13:36 +0000
commit3ee286527f1ec23ead2c11201b9fa504a5bf6208 (patch)
tree8a9f605f751126c884139a6b3baa2835684ed22b /devel/views.py
parent2c2614c48957c32334aa9ba317db935a979cd67f (diff)
parentfee4c20e9607ccc479c33b2476fa1ba709efe607 (diff)
Merge branch 'master' of /srv/git/projects/parabolaweb
Conflicts: .gitignore
Diffstat (limited to 'devel/views.py')
-rw-r--r--devel/views.py39
1 files changed, 20 insertions, 19 deletions
diff --git a/devel/views.py b/devel/views.py
index b26c7af0..311922ca 100644
--- a/devel/views.py
+++ b/devel/views.py
@@ -4,6 +4,7 @@ from django.contrib.auth.decorators import login_required, permission_required
from django.contrib.auth.models import User
from django.contrib.sites.models import Site
from django.core.mail import send_mail
+from django.template import loader, Context
from django.views.decorators.cache import never_cache
from django.views.generic.simple import direct_to_template
@@ -23,8 +24,8 @@ from string import ascii_letters, digits
def index(request):
'''the Developer dashboard'''
inner_q = PackageRelation.objects.filter(user=request.user).values('pkgbase')
- flagged = Package.objects.select_related('arch', 'repo').filter(flag_date__isnull=False)
- flagged = flagged.filter(pkgbase__in=inner_q).order_by('pkgname')
+ flagged = Package.objects.select_related('arch', 'repo').filter(
+ flag_date__isnull=False, pkgbase__in=inner_q).order_by('pkgname')
todopkgs = TodolistPkg.objects.select_related(
'pkg', 'pkg__arch', 'pkg__repo').filter(complete=False)
@@ -65,15 +66,6 @@ def clock(request):
return direct_to_template(request, 'devel/clock.html', page_dict)
-@login_required
-def change_notify(request):
- maint = User.objects.get(username=request.user.username)
- notify = request.POST.get('notify', 'no')
- prof = maint.get_profile()
- prof.notify = (notify == 'yes')
- prof.save()
- return HttpResponseRedirect('/devel/')
-
class ProfileForm(forms.Form):
email = forms.EmailField(label='Private email (not shown publicly):',
help_text="Used for out-of-date notifications, etc.")
@@ -120,25 +112,34 @@ class NewUserForm(forms.ModelForm):
first_name = forms.CharField(required=False)
last_name = forms.CharField(required=False)
+ def clean_username(self):
+ username = self.cleaned_data['username']
+ if User.objects.filter(username=username).exists():
+ raise forms.ValidationError(
+ "A user with that username already exists.")
+ return username
+
def save(self):
profile = forms.ModelForm.save(self, False)
pwletters = ascii_letters + digits
- pw = ''.join([random.choice(pwletters) for i in xrange(8)])
+ password = ''.join([random.choice(pwletters) for i in xrange(8)])
user = User.objects.create_user(username=self.cleaned_data['username'],
- email=self.cleaned_data['email'], password=pw)
+ email=self.cleaned_data['email'], password=password)
user.first_name = self.cleaned_data['first_name']
user.last_name = self.cleaned_data['last_name']
user.save()
profile.user = user
profile.save()
- domain = Site.objects.get_current().domain
+
+ t = loader.get_template('devel/new_account.txt')
+ c = Context({
+ 'site': Site.objects.get_current(),
+ 'user': user,
+ 'password': password,
+ })
send_mail("Your new archweb account",
- """You can now log into:
-https://%s/login/
-with these login details:
-Username: %s
-Password: %s""" % (domain, user.username, pw),
+ t.render(c),
'Arch Website Notification <nobody@archlinux.org>',
[user.email],
fail_silently=False)