def homepage(request): if request.method == "POST" and request.user.is_authenticated: if request.POST["action"] == "add": add_email_form = AddEmailForm(request.POST, request.user) if add_email_form.is_valid(): add_email_form.save() elif request.POST["action"] == "send": email = request.POST["email"] try: email_address = EmailAddress.objects.get(user=request.user, email=email) request.user.message_set.create( message="Confirmation email sent to %s" % email) EmailConfirmation.objects.send_confirmation(email_address) except EmailAddress.DoesNotExist: pass add_email_form = AddEmailForm() else: add_email_form = AddEmailForm() return render_to_response( "homepage.html", { "user": request.user, "messages": request.user.get_and_delete_messages(), "add_email_form": add_email_form, })
def get(self, request): edit_user_form = EditUserForm(instance=request.user) add_email_form = AddEmailForm(instance=EmailAddress(user=request.user)) page_title = 'Profile' return render_to_response('profile.html', locals(), context_instance=RequestContext(request))
def post(self, request): if request.POST['form-name'] == 'edit-user-form': add_email_form = AddEmailForm() edit_user_form = EditUserForm(request.POST, instance=request.user) if edit_user_form.is_valid(): edit_user_form.save() return redirect('/profile/') if request.POST['form-name'] == 'add-email-form': edit_user_form = EditUserForm(instance=request.user) add_email_form = AddEmailForm(request.POST) if add_email_form.is_valid(): add_email_form.save() return redirect('/profile/') page_title = 'Profile' return render_to_response('profile.html', locals(), context_instance=RequestContext(request))
def new_email(contact_id): data = contact_id.split('"')[-2:] id = data[0] my_email = Email.query.filter(Email.contact_id == contact_id).first() form = AddEmailForm(obj=my_email) if form.validate_on_submit(): # create Email Object my_email = Email() form.populate_obj(my_email) database.session.add(my_email) try: database.session.commit() flash('Save Successfully', 'success') return redirect(url_for('emails', contact_id=id)) except: database.session.rollback() flash('Error! ', 'danger') return render_template('web/new_email.html', form=form)
def homepage(request): if request.method == "POST" and request.user.is_authenticated(): if request.POST["action"] == "add": add_email_form = AddEmailForm(request.POST, request.user) if add_email_form.is_valid(): add_email_form.save() messages.info( request, "Confirmation e-mail sent to %s" % add_email_form.cleaned_data["email"] ) elif request.POST["action"] == "send": email = request.POST["email"] try: email_address = EmailAddress.objects.get( user=request.user, email=email ) messages.info( request, "Confirmation e-mail sent to %s" % email ) EmailConfirmation.objects.send_confirmation(email_address) except EmailAddress.DoesNotExist: pass add_email_form = AddEmailForm() else: add_email_form = AddEmailForm() return render_to_response("homepage.html", { "user": request.user, "add_email_form": add_email_form, }, context_instance=RequestContext(request), )
def Options(request): try: if CheckAccess(request,'25') != 'OK': return render_to_response("client/notaccess/options.html") except: return HttpResponseRedirect('/') form = AddEmailForm(request.POST) if form.is_valid(): status = form.cleaned_data['status'] user = form.cleaned_data['user'] AddEmailUser( request, user, status ) if request.method == 'GET': try: delemail = request.GET['delemail'] DelEmailUser(delemail) except: pass data = GetEmailUser() form = AddEmailForm(None) c = RequestContext(request,{'form':form,'data':data}) c.update(csrf(request)) return render_to_response("client/options.html",c)
def homepage(request): if request.method == "POST" and request.user.is_authenticated(): if request.POST["action"] == "add": add_email_form = AddEmailForm(request.POST, request.user) if add_email_form.is_valid(): add_email_form.save() elif request.POST["action"] == "send": email = request.POST["email"] try: email_address = EmailAddress.objects.get(user=request.user, email=email) request.user.message_set.create(message="Confirmation email sent to %s" % email) EmailConfirmation.objects.send_confirmation(email_address) except EmailAddress.DoesNotExist: pass add_email_form = AddEmailForm() else: add_email_form = AddEmailForm() return render_to_response("homepage.html", { "user": request.user, "messages": request.user.get_and_delete_messages(), "add_email_form": add_email_form, })
def email(request): if request.method == "POST" and request.user.is_authenticated(): if request.POST["action"] == "add": add_email_form = AddEmailForm(request.user, request.POST) if add_email_form.is_valid(): add_email_form.save() add_email_form = AddEmailForm() # @@@ else: add_email_form = AddEmailForm() if request.POST["action"] == "send": email = request.POST["email"] try: email_address = EmailAddress.objects.get(user=request.user, email=email) request.user.message_set.create(message="Confirmation email sent to %s" % email) EmailConfirmation.objects.send_confirmation(email_address) except EmailAddress.DoesNotExist: pass elif request.POST["action"] == "remove": email = request.POST["email"] try: email_address = EmailAddress.objects.get(user=request.user, email=email) email_address.delete() request.user.message_set.create(message="Removed email address %s" % email) except EmailAddress.DoesNotExist: pass elif request.POST["action"] == "primary": email = request.POST["email"] email_address = EmailAddress.objects.get(user=request.user, email=email) email_address.set_as_primary() else: add_email_form = AddEmailForm() return direct_to_template(request, "account/email.html", { "add_email_form": add_email_form, })