def request_link(request): signup = None try: signups = signup_api.get_all_user_signups(request.POST.get('email')) if len(signups) == 0: raise Exception() signup = signups[0] messages.success(request, 'Check your inbox -- a tasty new link will be there shortly.') send_user_link(signup['email'], signup['key']) # TODO user will receive an error if they request a link and they only signed up for a previous sequence :( except: messages.error(request, 'Not so fast, partner -- you need to sign up for the Mechanical MOOC first!') url = reverse('classphoto_sequence_redirect') if settings.DEBUG and signup: url += '?key={0}'.format(signup['key']) return http.HttpResponseRedirect(url)
def unsubscribe(request): context = {} if request.method == 'POST': email = request.POST.get('email') try: # TODO signups = signup_model.get_all_user_signups(email) if len(signups) == 0: raise Exception() send_unsubscribe_confirmation(signups[0]) messages.info(request, u'You will shortly receive an email to confirm that you wish to unsubscribe') return http.HttpResponseRedirect(reverse('home')) except: context['error'] = 'Could not find signup.' return render_to_response('unsubscribe/unsubscribe.html', context, context_instance=RequestContext(request))
def unsubscribe_user(address): """ Unsubscribe user completely from the Mechanical Mooc - all sequences """ # remove from sequence group signups = signup_model.get_all_user_signups(address) for user_signup in signups: sequence_list = sequence_model.sequence_list_name(user_signup["sequence"]) mailgun_api.remove_list_member(sequence_list, address) # remove from small groups groups = groups_model.get_member_groups(address) for group in groups: groups_model.remove_group_member(group["uri"], address) groups_model.sync_group_with_mailgun(group["uri"]) # mark as unsubscribed in the signups for user_signup in signups: signup_model.delete_signup(address, user_signup["sequence"]) mailgun_api.delete_all_unsubscribes(address)
def request_link(request): signup = None try: signups = signup_api.get_all_user_signups(request.POST.get('email')) if len(signups) == 0: raise Exception() signup = signups[0] messages.success( request, 'Check your inbox -- a tasty new link will be there shortly.') send_user_link(signup['email'], signup['key']) # TODO user will receive an error if they request a link and they only signed up for a previous sequence :( except: messages.error( request, 'Not so fast, partner -- you need to sign up for the Mechanical MOOC first!' ) url = reverse('classphoto_sequence_redirect') if settings.DEBUG and signup: url += '?key={0}'.format(signup['key']) return http.HttpResponseRedirect(url)
def unsubscribe_user(address): """ Unsubscribe user completely from the Mechanical Mooc - all sequences """ # remove from sequence group signups = signup_model.get_all_user_signups(address) for user_signup in signups: sequence_list = sequence_model.sequence_list_name( user_signup['sequence']) mailgun_api.remove_list_member(sequence_list, address) # remove from small groups groups = groups_model.get_member_groups(address) for group in groups: groups_model.remove_group_member(group['uri'], address) groups_model.sync_group_with_mailgun(group['uri']) # mark as unsubscribed in the signups for user_signup in signups: signup_model.delete_signup(address, user_signup['sequence']) mailgun_api.delete_all_unsubscribes(address)