summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--expo/models.py40
-rw-r--r--profiles/urls.py3
-rw-r--r--profiles/views.py29
-rw-r--r--templates/profiles/create_profile.html2
-rw-r--r--templates/profiles/edit_profile.html13
-rw-r--r--templates/profiles/profile_detail.html10
-rw-r--r--templates/profiles/select_profile.html13
-rw-r--r--templates/registration/registration_complete.html2
8 files changed, 87 insertions, 25 deletions
diff --git a/expo/models.py b/expo/models.py
index faa4ce3..c55bfe8 100644
--- a/expo/models.py
+++ b/expo/models.py
@@ -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 bisnotable(self):
- return self.notability > 0.3
+ #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 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:
diff --git a/profiles/urls.py b/profiles/urls.py
index 05ff9e4..a703e9b 100644
--- a/profiles/urls.py
+++ b/profiles/urls.py
@@ -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'),
diff --git a/profiles/views.py b/profiles/views.py
index c119165..b3e3672 100644
--- a/profiles/views.py
+++ b/profiles/views.py
@@ -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
diff --git a/templates/profiles/create_profile.html b/templates/profiles/create_profile.html
index 2eed3e4..7e32597 100644
--- a/templates/profiles/create_profile.html
+++ b/templates/profiles/create_profile.html
@@ -3,7 +3,7 @@
{% block content %}
<form method="post">
-{{ form }}
+{{ form.as_p }}
<input type="submit" />
</form>
diff --git a/templates/profiles/edit_profile.html b/templates/profiles/edit_profile.html
new file mode 100644
index 0000000..7e32597
--- /dev/null
+++ b/templates/profiles/edit_profile.html
@@ -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 %} \ No newline at end of file
diff --git a/templates/profiles/profile_detail.html b/templates/profiles/profile_detail.html
new file mode 100644
index 0000000..543785f
--- /dev/null
+++ b/templates/profiles/profile_detail.html
@@ -0,0 +1,10 @@
+{% extends "base.html" %}
+
+{% block content %}
+
+{{ profile }}
+
+{% if form.errors %}
+ <p class="errornote">Please correct the errors below</p>
+{% endif %}
+{% endblock %} \ No newline at end of file
diff --git a/templates/profiles/select_profile.html b/templates/profiles/select_profile.html
new file mode 100644
index 0000000..7e32597
--- /dev/null
+++ b/templates/profiles/select_profile.html
@@ -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 %} \ No newline at end of file
diff --git a/templates/registration/registration_complete.html b/templates/registration/registration_complete.html
index 552fa04..7cc8ab2 100644
--- a/templates/registration/registration_complete.html
+++ b/templates/registration/registration_complete.html
@@ -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 %} \ No newline at end of file