def contributor_signup(request): """Request for new contributor to signup""" context = RequestContext(request) registered = False if request.method == 'POST': print "we have a request to register" contributor_form = ContributorForm(request.POST, request.FILES) if contributor_form.is_valid(): print "Forms are valid" if 'picture' in request.FILES: user = Contributor(picture=request.FILES['picture']) user = Contributor( validation_docs=request.FILES['validation_docs']) user = contributor_form.save(commit=False) user.set_password(user.password) user.save() email_subject = "New Contributor has registered" email_message = """ New Contributor has registered. Details: Name:""" + user.first_name + """ """ + user.last_name + """" Email:""" + user.email + """ # + newContributor.validation_docs + Waiting for your your approval""" # send_mail(email_subject, email_message, '*****@*****.**', ['*****@*****.**'],fail_silently=False) messages.success( request, "form successfully submitted. Waiting for activation from admin." ) return HttpResponseRedirect(reverse('webapp.views.home')) else: if contributor_form.errors: print contributor_form.errors else: contributor_form = ContributorForm() context_dict = { 'contributor_form': contributor_form, 'registered': registered } return render_to_response('webapp/signup.html', context_dict, context)
def contributor_signup(request): """Request for new contributor to signup""" context = RequestContext(request) registered = False if request.method == 'POST': print "we have a request to register" contributor_form = ContributorForm(request.POST,request.FILES) if contributor_form.is_valid(): print "Forms are valid" if 'picture' in request.FILES: user = Contributor(picture=request.FILES['picture']) user = Contributor(validation_docs=request.FILES['validation_docs']) user = contributor_form.save(commit=False) user.set_password(user.password) user.save() email_subject="New Contributor has registered" email_message=""" New Contributor has registered. Details: Name:""" + user.first_name + """ """ + user.last_name + """" Email:""" + user.email + """ # + newContributor.validation_docs + Waiting for your your approval""" # send_mail(email_subject, email_message, '*****@*****.**', ['*****@*****.**'],fail_silently=False) messages.success(request,"form successfully submitted. Waiting for activation from admin.") return HttpResponseRedirect(reverse('webapp.views.home')) else: if contributor_form.errors: print contributor_form.errors else: contributor_form = ContributorForm() context_dict = {'contributor_form': contributor_form, 'registered': registered} return render_to_response('webapp/signup.html', context_dict, context)
def add_contributor(user, contact, picture, validation_docs): up = Contributor(user=user, contact=contact, picture=picture, validation_docs=validation_docs) up.save()