2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2025-12-16 15:47:03 +00:00

[svn] Enable profile setup forms.

Profiles are Person model instances, and are linked to django's built in User model by a one to one foreign key.

We are using the django-registration and django-profiles pluggables.
Copied from http://cucc@cucc.survex.com/svn/trunk/expoweb/troggle/, rev. 8247 by aaron @ 2/18/2009 9:35 PM
This commit is contained in:
substantialnoninfringinguser
2009-05-13 05:54:17 +01:00
parent 24dc7c5a0c
commit b57452f68d
8 changed files with 86 additions and 24 deletions

View File

@@ -2,7 +2,6 @@
Views for creating, editing and viewing site-specific user profiles.
"""
from django.contrib.auth.decorators import login_required
from django.contrib.auth.models import User
from django.core.exceptions import ObjectDoesNotExist
@@ -13,11 +12,35 @@ from django.shortcuts import get_object_or_404
from django.shortcuts import render_to_response
from django.template import RequestContext
from django.views.generic.list_detail import object_list
from django import forms
from expo.models import Person
from troggle.alwaysUseRequestContext import render_response
from profiles import utils
import troggle.settings as settings
from django.conf import settings
class SelectPersonForm(forms.Form): #This and the select_profile view
person = forms.ModelChoiceField(queryset=Person.objects.all())
def select_profile(request):
if request.method == 'POST':
form = SelectPersonForm(request.POST)
if form.is_valid():
profile_obj=form.cleaned_data['person']
profile_obj.user=request.user
profile_obj.save()
return HttpResponseRedirect(profile_obj.get_absolute_url())
else:
form = SelectPersonForm()
context = RequestContext(request)
return render_to_response('profiles/select_profile.html', {
'form':form,},
context_instance=context
)
def create_profile(request, form_class=None, success_url=None,
@@ -81,7 +104,7 @@ def create_profile(request, form_class=None, success_url=None,
"""
try:
profile_obj = request.user.get_profile()
return HttpResponseRedirect(reverse('profiles_edit_profile'))
return HttpResponseRedirect(profile_obj.get_absolute_url())
except ObjectDoesNotExist:
pass