email invites 0.8

This commit is contained in:
Johnson Chetty 2012-12-14 13:30:13 +01:00
parent 6bfa53f1dc
commit 9b7ccda4dd
5 changed files with 19 additions and 5 deletions

View File

@ -58,6 +58,7 @@ def signup(request, **kwargs):
template_name = kwargs.pop("template_name", "account/signup.html")
redirect_field_name = kwargs.pop("redirect_field_name", "next")
success_url = kwargs.pop("success_url", None)
invite_code = kwargs.pop("invite_code", None)
if success_url is None:
success_url = get_default_redirect(request, redirect_field_name)
@ -66,6 +67,11 @@ def signup(request, **kwargs):
form = form_class(request.POST)
if form.is_valid():
user = form.save(request=request)
if invite_code:
from itfprofiles.models import PersonInvitation, Person
person = PersonInvite.objects.get(invite_code=invite_code).invitee
person.user = user
#success_url = '/edit_profile'
return complete_signup(request, user, success_url)
else:

View File

@ -253,7 +253,7 @@ class ItfAllAuthRegForm(forms.Form):
def save(self, user, request=None):
first_name = self.cleaned_data['firstname']
last_name = self.cleaned_data['lastname']
if request.session['invite_code']:
if request.session.has_key('invite_code'):
invite_code = request.session['invite_code']
pi = PersonInvitation.objects.get(invite_code=invite_code)
inviter = pi.inviter

View File

@ -27,8 +27,8 @@ class Person(ItfModel):
#ItfModel stuff:
form_names = ['PersonForm', 'PopupPersonForm']
fts_fields = ['first_name', 'last_name', 'email', 'about']
#Basic Info
user = models.ForeignKey(User, blank=True, null=True, db_index=True, editable=False)
#Basic Info
user = models.OneToOneField(User, blank=True, null=True, db_index=True, editable=False)
first_name = models.CharField(max_length=255)
last_name = models.CharField(max_length=255)
email = models.EmailField(blank=True, null=True, unique=True, db_index=True)

View File

@ -84,8 +84,11 @@ def friend_invite(request):
def invitation_accept(request,invite_code):
#invitation = get_object_or_404(PersonInvitation, invite_code__exact=invite_code)
invitee = get_object_or_404(PersonInvitation, invite_code__exact=invite_code).invitee
request.session['invite_code'] = invite_code
request.session['invitee_first_name'] = invitee.first_name
request.session['invtee_last_name'] = invitee.last_name
request.session['invitee_email'] = invitee.email
return HttpResponseRedirect('/accounts/signup')

View File

@ -14,7 +14,12 @@
<form class="signup" id="signup_form" method="post" action="{% url account_signup %}">
{% csrf_token %}
{{ form.as_p }}
{{ form.as_p }}
{% if request.session.invite_code %}
<input type="hidden" name="icode" value="{{ request.session.invite_code }}" />
{% endif %}
{% if redirect_field_value %}
<input type="hidden" name="{{ redirect_field_name }}" value="{{ redirect_field_value }}" />
{% endif %}