mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2024-11-22 07:11:52 +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:
parent
24dc7c5a0c
commit
b57452f68d
@ -66,13 +66,13 @@ class Person(models.Model):
|
||||
mug_shot = models.CharField(max_length=100, blank=True,null=True)
|
||||
blurb = models.TextField(blank=True,null=True)
|
||||
|
||||
href = models.CharField(max_length=200)
|
||||
#href = models.CharField(max_length=200)
|
||||
orderref = models.CharField(max_length=200) # for alphabetic
|
||||
|
||||
#the below have been removed and made methods. I'm not sure what the b in bisnotable stands for. - AC 16 Feb
|
||||
#notability = models.FloatField() # for listing the top 20 people
|
||||
#bisnotable = models.BooleanField()
|
||||
user = models.ForeignKey(User, unique=True, null=True, blank=True)
|
||||
user = models.OneToOneField(User, null=True, blank=True)
|
||||
def get_absolute_url(self):
|
||||
return settings.URL_ROOT + "/person/%s_%s/" % (self.first_name, self.last_name)
|
||||
|
||||
@ -93,24 +93,24 @@ class Person(models.Model):
|
||||
# def Lastexpedition(self):
|
||||
# return self.personexpedition_set.order_by('-expedition')[0]
|
||||
|
||||
def notability(self):
|
||||
notability = 0.0
|
||||
for personexpedition in person.personexpedition_set.all():
|
||||
if not personexpedition.is_guest:
|
||||
notability += 1.0 / (2012 - int(self.personexpedition.expedition.year))
|
||||
return notability
|
||||
#def notability(self):
|
||||
#notability = 0.0
|
||||
#for personexpedition in person.personexpedition_set.all():
|
||||
#if not personexpedition.is_guest:
|
||||
#notability += 1.0 / (2012 - int(self.personexpedition.expedition.year))
|
||||
#return notability
|
||||
|
||||
def bisnotable(self):
|
||||
return self.notability > 0.3
|
||||
#def bisnotable(self):
|
||||
#return self.notability > 0.3
|
||||
|
||||
def Sethref(self):
|
||||
if self.last_name:
|
||||
self.href = self.first_name.lower() + "_" + self.last_name.lower()
|
||||
self.orderref = self.last_name + " " + self.first_name
|
||||
else:
|
||||
self.href = self.first_name.lower()
|
||||
self.orderref = self.first_name
|
||||
self.notability = 0.0 # set temporarily
|
||||
#def Sethref(self):
|
||||
#if self.last_name:
|
||||
#self.href = self.first_name.lower() + "_" + self.last_name.lower()
|
||||
#self.orderref = self.last_name + " " + self.first_name
|
||||
#else:
|
||||
# self.href = self.first_name.lower()
|
||||
#self.orderref = self.first_name
|
||||
#self.notability = 0.0 # set temporarily
|
||||
|
||||
|
||||
class PersonExpedition(models.Model):
|
||||
@ -291,7 +291,7 @@ class Cave(models.Model):
|
||||
extent = models.CharField(max_length=100,blank=True,null=True)
|
||||
survex_file = models.CharField(max_length=100,blank=True,null=True) #should be filefield, need to fix parser first
|
||||
|
||||
href = models.CharField(max_length=100)
|
||||
#href = models.CharField(max_length=100)
|
||||
|
||||
def get_absolute_url(self):
|
||||
if self.kataster_number:
|
||||
|
@ -28,6 +28,9 @@ from profiles import views
|
||||
|
||||
|
||||
urlpatterns = patterns('',
|
||||
url(r'^select/$',
|
||||
views.select_profile,
|
||||
name='profiles_select_profile'),
|
||||
url(r'^create/$',
|
||||
views.create_profile,
|
||||
name='profiles_create_profile'),
|
||||
|
@ -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
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
{% block content %}
|
||||
|
||||
<form method="post">
|
||||
{{ form }}
|
||||
{{ form.as_p }}
|
||||
<input type="submit" />
|
||||
</form>
|
||||
|
||||
|
13
templates/profiles/edit_profile.html
Normal file
13
templates/profiles/edit_profile.html
Normal file
@ -0,0 +1,13 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<form method="post">
|
||||
{{ form.as_p }}
|
||||
<input type="submit" />
|
||||
</form>
|
||||
|
||||
{% if form.errors %}
|
||||
<p class="errornote">Please correct the errors below</p>
|
||||
{% endif %}
|
||||
{% endblock %}
|
10
templates/profiles/profile_detail.html
Normal file
10
templates/profiles/profile_detail.html
Normal file
@ -0,0 +1,10 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
{{ profile }}
|
||||
|
||||
{% if form.errors %}
|
||||
<p class="errornote">Please correct the errors below</p>
|
||||
{% endif %}
|
||||
{% endblock %}
|
13
templates/profiles/select_profile.html
Normal file
13
templates/profiles/select_profile.html
Normal file
@ -0,0 +1,13 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<form method="post">
|
||||
{{ form.as_p }}
|
||||
<input type="submit" />
|
||||
</form>
|
||||
|
||||
{% if form.errors %}
|
||||
<p class="errornote">Please correct the errors below</p>
|
||||
{% endif %}
|
||||
{% endblock %}
|
@ -9,5 +9,5 @@ registration_complete.html | {{ block.super }}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
Thank you for signing up. An email with the activation code has been sent to your inbox.
|
||||
Thank you for signing up, {{ user.username }}. An email with the activation code has been sent to your inbox. Please <a href={% url profiles_create_profile %}> create your profile</a>. If you have been on the expedition in the past, this step allows existing expedition data to be linked to your new account.
|
||||
{% endblock %}
|
Loading…
Reference in New Issue
Block a user