def get(self, request, email): try: email_profile = EmailProfile.objects.get(email=email) except EmailProfile.DoesNotExist: email_profile = EmailProfile.objects.create(email=email) res = send_confirmation_emails.delay([email_profile.email]) return render(request, "after_subscribe.html", {"email_profile": email_profile})
def get(self, request, email): try: email_profile = EmailProfile.objects.get(email=email) except EmailProfile.DoesNotExist: email_profile = EmailProfile.objects.create(email=email) res = send_confirmation_emails.delay([email_profile.email]) return render(request, 'after_subscribe.html', {'email_profile':email_profile})
def post(self, request, email): EmailFormSet = formset_factory(EmailSubscribeForm) formset = EmailFormSet(request.POST) if formset.is_valid(): print "formset is valid" inviter_profile = EmailProfile.objects.get(email=email) emails = [] for form in formset: new_email = form["email"].data try: email_profile = EmailProfile.objects.create(email=new_email, invited_by=inviter_profile) emails.append(new_email) except IntegrityError: pass send_confirmation_emails.delay(emails) return render(request, "after_invite.html", {"emails": emails}) else: print "formset isn't valid" email_profile = get_object_or_404(EmailProfile, pk=email) return render(request, "invite.html", {"email_profile": email_profile, "errors": formset})
def post(self, request, email): EmailFormSet = formset_factory(EmailSubscribeForm) formset = EmailFormSet(request.POST) if formset.is_valid(): print "formset is valid" inviter_profile = EmailProfile.objects.get(email=email) emails = [] for form in formset: new_email = form['email'].data try: email_profile = EmailProfile.objects.create(email=new_email, invited_by=inviter_profile) emails.append(new_email) except IntegrityError: pass send_confirmation_emails.delay(emails) return render(request, 'after_invite.html', {'emails':emails}) else: print "formset isn't valid" email_profile = get_object_or_404(EmailProfile, pk=email) return render(request, 'invite.html', {'email_profile': email_profile, 'errors':formset})
def post(self, request): form = EmailSubscribeForm(request.POST) if form.is_valid(): # Time to create the object then send them the 'did subscribe' template try: email = self.request.POST["email"] except KeyError: # handle an error saying you didn't put in an email error = "not_email" return render(request, "after_subscribe.html", {"error": error}) try: email_profile = EmailProfile.objects.create(email=email) except IntegrityError: error = "already_sub" return render(request, "after_subscribe.html", {"error": error}) """ Left to do: +1. create send_confirmation_emails in tasks.py +1a) reuse the hero_preprocessed.html template to create a confirmation view +2. Generate the token in send_confirmation_emails +3. Import the token generator in ConfirmSubscription view, call default_token_generator(check_token) +4. If True, then in ConfirmSubscription.get, set email_profile.is_confirmed to true, show confirmed_subscribe.html +5. If False, then return an error to confirmed_subscribe.html just like I'm doing right below this +Then check that gmail actually is in good shape. +Then fill in the remaining links (for subscribe) +Then make the homepage view Then handle the invitefriends view Before sending: change subject in send_newsletter... or is it a model object? +make twitter, facebook remove sendgrid clicktracking add your own clicktracking profit??? """ # Now start the celery task: res = send_confirmation_emails.delay([email_profile.email]) return render(request, "after_subscribe.html", {"email_profile": email_profile}) else: # This'll show the errors in a list: return render(request, "after_subscribe.html", {"error": form})
def post(self, request): form = EmailSubscribeForm(request.POST) if form.is_valid(): # Time to create the object then send them the 'did subscribe' template try: email = self.request.POST['email'] except KeyError: # handle an error saying you didn't put in an email error = "not_email" return render(request, 'after_subscribe.html', {'error':error}) try: email_profile = EmailProfile.objects.create(email=email) except IntegrityError: error = "already_sub" return render(request, 'after_subscribe.html', {'error':error}) """ Left to do: +1. create send_confirmation_emails in tasks.py +1a) reuse the hero_preprocessed.html template to create a confirmation view +2. Generate the token in send_confirmation_emails +3. Import the token generator in ConfirmSubscription view, call default_token_generator(check_token) +4. If True, then in ConfirmSubscription.get, set email_profile.is_confirmed to true, show confirmed_subscribe.html +5. If False, then return an error to confirmed_subscribe.html just like I'm doing right below this +Then check that gmail actually is in good shape. +Then fill in the remaining links (for subscribe) +Then make the homepage view Then handle the invitefriends view Before sending: change subject in send_newsletter... or is it a model object? +make twitter, facebook remove sendgrid clicktracking add your own clicktracking profit??? """ # Now start the celery task: res = send_confirmation_emails.delay([email_profile.email]) return render(request, 'after_subscribe.html', {'email_profile':email_profile}) else: # This'll show the errors in a list: return render(request, 'after_subscribe.html', {'error':form})