def confirm(request, key): try: su = signup_model.get_signup_by_invite_code(key) unsubscribe_model.unsubscribe_user(su['email']) messages.success(request, 'You have been successfully unsubscribed.') except: log.error(u'Could not find signup for confirmation code {0}'.format(key)) messages.error(request, 'We could not find the signup that corresponds to the unsubscribe link you used.') return http.HttpResponseRedirect(reverse('home'))
def call_view(*args, **kwargs): request = args[0] key = request.GET.get('key', None) if not key: return method(*args, **kwargs) try: su = signup_api.get_signup_by_invite_code(key) except: return method(*args, **kwargs) request.session['user_email'] = su['email'] if request.session.get('user_bio'): del request.session['user_bio'] # get the user bio if possible try: request.session['user_bio'] = classphoto_api.get_bio(su['email']) except: pass return http.HttpResponseRedirect(request.path)