summaryrefslogtreecommitdiff
path: root/devel/views.py
diff options
context:
space:
mode:
authoreliott <eliott@cactuswax.net>2007-12-29 15:34:02 -0800
committereliott <eliott@cactuswax.net>2007-12-29 15:34:02 -0800
commit15ceff77fef19819cba43e866938311aeffd0732 (patch)
tree16903554adbb32300aad9a5b3d647679710e9302 /devel/views.py
parentd1cc0f54a490e5eacf07107e461672979266f461 (diff)
Modified render_template and renamed it to render_response (consistent with
archweb_pub conventions). Moved pkgmaint_guide to a template.
Diffstat (limited to 'devel/views.py')
-rw-r--r--devel/views.py87
1 files changed, 44 insertions, 43 deletions
diff --git a/devel/views.py b/devel/views.py
index d31dd10c..206d1fab 100644
--- a/devel/views.py
+++ b/devel/views.py
@@ -2,7 +2,7 @@ from django.http import HttpResponse, HttpResponseRedirect
from django.contrib.auth.decorators import login_required
from django.contrib.auth.models import User
from django.core import validators
-from archweb_dev.utils import render_template
+from archweb_dev.utils import render_response
from archweb_dev.packages.models import Package
from archweb_dev.todolists.models import Todolist, TodolistPkg
from archweb_dev.settings import DATA_DIR
@@ -11,57 +11,58 @@ from archweb_dev.public.models import UserProfile
@login_required
def index(request):
- try:
- thismaint = User.objects.get(username=request.user.username)
- except User.DoesNotExist:
- # weird, we don't have a maintainer record for this logged-in user
- thismaint = None
+ try:
+ thismaint = User.objects.get(username=request.user.username)
+ except User.DoesNotExist:
+ # weird, we don't have a maintainer record for this logged-in user
+ thismaint = None
- # get a list of incomplete package todo lists
- todos = Todolist.objects.get_incomplete()
- # get flagged-package stats for all maintainers
- stats = Package.objects.get_flag_stats()
- if thismaint:
- # get list of flagged packages for this maintainer
- pkgs = Package.objects.filter(maintainer=thismaint.id).filter(needupdate=True).order_by('repo', 'pkgname')
- else:
- pkgs = None
+ # get a list of incomplete package todo lists
+ todos = Todolist.objects.get_incomplete()
+ # get flagged-package stats for all maintainers
+ stats = Package.objects.get_flag_stats()
+ if thismaint:
+ # get list of flagged packages for this maintainer
+ pkgs = Package.objects.filter(maintainer=thismaint.id).filter(needupdate=True).order_by('repo', 'pkgname')
+ else:
+ pkgs = None
- return render_template('devel/index.html', request,
- {'stats':stats, 'pkgs':pkgs, 'todos':todos, 'maint':thismaint})
+ return render_response(request, 'devel/index.html',
+ {'stats':stats, 'pkgs':pkgs, 'todos':todos, 'maint':thismaint})
@login_required
#@is_maintainer
def change_notify(request):
- maint = User.objects.get(username=request.user.username)
- notify = request.POST.get('notify', 'no')
- try:
- maint.get_profile().notify = notify == 'yes'
- except UserProfile.DoesNotExist:
- UserProfile(user_id=maint.id ,notify=notify == 'yes').save()
- maint.get_profile().save()
- return HttpResponseRedirect('/devel/')
+ maint = User.objects.get(username=request.user.username)
+ notify = request.POST.get('notify', 'no')
+ try:
+ maint.get_profile().notify = notify == 'yes'
+ except UserProfile.DoesNotExist:
+ UserProfile(user_id=maint.id ,notify=notify == 'yes').save()
+ maint.get_profile().save()
+ return HttpResponseRedirect('/devel/')
@login_required
def change_profile(request):
- errors = {}
- if request.POST:
- passwd1, passwd2 = request.POST['passwd'], request.POST['passwd2']
- email = request.POST['email']
- # validate
- if passwd1 != passwd2:
- errors['password'] = [' Passwords do not match. ']
- validate(errors, 'Email', email, validators.isValidEmail, False, request)
- # apply changes
- if not errors:
- request.user.email = email
- if passwd1:
- request.user.set_password(passwd1)
- request.user.save()
- return HttpResponseRedirect('/devel/')
- return render_template('devel/profile.html', request, {'errors':errors,'email':request.user.email})
+ errors = {}
+ if request.POST:
+ passwd1, passwd2 = request.POST['passwd'], request.POST['passwd2']
+ email = request.POST['email']
+ # validate
+ if passwd1 != passwd2:
+ errors['password'] = [' Passwords do not match. ']
+ validate(errors, 'Email', email, validators.isValidEmail, False, request)
+ # apply changes
+ if not errors:
+ request.user.email = email
+ if passwd1:
+ request.user.set_password(passwd1)
+ request.user.save()
+ return HttpResponseRedirect('/devel/')
+ return render_response(request, 'devel/profile.html', {'errors':errors,'email':request.user.email})
@login_required
def guide(request):
- return HttpResponse(file(DATA_DIR + '/pkgmaint_guide.txt').read(),
- mimetype='text/plain')
+ return render_response(request, 'devel/pkgmaint_guide.txt', {'errors':errors,'email':request.user.email})
+ return HttpResponse(file(DATA_DIR + '/pkgmaint_guide.txt').read(),
+ mimetype='text/plain')