def create_team_user(request,team_id): if request.method == 'POST': # If the form has been submitted... form = CreateUserForm(request.POST) # A form bound to the POST data if form.is_valid(): newuser = User() newuser.username = form.cleaned_data['username'] newuser.first_name = form.cleaned_data['firstName'] newuser.last_name = form.cleaned_data['lastName'] newuser.email = form.cleaned_data['email'] newuser.set_password(form.cleaned_data['password']) newuser.save() newuser.groups.add(form.cleaned_data['group']) newuser.save() newprofile = UserProfile() newprofile.email = form.cleaned_data['email'] newprofile.club = form.cleaned_data['club'] # newprofile.team = request.team_id newprofile.phone = form.cleaned_data['phone'] newprofile.user = newuser newprofile.save() return HttpResponseRedirect('/accounts/detail/%d' % newuser.id) else: form = CreateUserForm() # An unbound form return render_to_response('core/user_form.html', { 'form': form, 'user': request.user })
user.username = form.cleaned_data['username'] name = invitation.name.split(' ') user.first_name = name[0] user.last_name = name[1] user.email = invitation.email user.set_password(form.cleaned_data['password']) user.is_active = False user.save() user.groups.add(invitation.group) user.save() userProfile = UserProfile() userProfile.user = user userProfile.team = invitation.team userProfile.club = invitation.club userProfile.email = invitation.email userProfile.save() # mark invitation as used invitation.used = True invitation.save() # generate confirmation email hash = hashlib.sha256() # TODO: un-hardcode salt hash.update("confirmation_%s_%s" % (userProfile.id, "hockeypuck")) userProfile.confirmation = hash.hexdigest() userProfile.confirmed = False userProfile.save() send_confirmation(userProfile.id)