def subscriptions_login(req): email = req.GET.get('email', req.POST.get('email')) if req.GET.get(CONFIRMATION_PARAM): validated = validate_confirmation(req) if validated: try: tip_user = TipUser.objects.get(email_address=email) except TipUser.DoesNotExist: # Verified because they just confirmed their email tip_user = TipUser(email=email, verified=True) tip_user.save() req.session['pay_session'] = tip_user.id return redirect('tip_jar_subs') # fallthrough if not req.POST: return _pmrender(req, 'payments/tip_jar/login.html') send_email( req.POST.get('email'), ugettext('Podcast Tip Jar - Email Verification'), ugettext( 'Thanks for verifying your email! Click the link below ' 'to see your podcast subscriptions.'), reverse('tip_jar_login') + '?email=%s' % quote(email)) return _pmrender(req, 'payments/tip_jar/check_email.html')
def signup(req): if not req.user.is_anonymous(): return redirect('dashboard') if not req.POST: return _pmrender( req, 'signup/main.html', {'email': req.GET.get('email', '')} ) error = None if not _validate_recaptcha(req): error = ugettext('Your humanity was not verified') elif not req.POST.get('email'): error = ugettext('Missing email address') elif not req.POST.get('password'): error = ugettext('Come on, you need a password') elif len(req.POST.get('password')) < 8: error = ugettext('Your password needs to be at least 8 characters long') elif User.objects.filter(email=req.POST.get('email')).count(): error = ugettext('That email address is already associated with an account') if error: return _pmrender(req, 'signup/main.html', { 'error': error, 'email': req.POST.get('email'), }) try: u = User.objects.create_user( str(uuid.uuid4())[:30], req.POST.get('email'), req.POST.get('password') ) u.save() except Exception as e: return _pmrender(req, 'signup/main.html', { 'error': str(e), 'email': req.POST.get('email'), }) try: us = UserSettings.get_from_user(u) us.tz_offset = req.POST.get('timezone') us.save() except Exception: pass # whatever. return redirect(reverse('login') + '?signup_success=true')
def ep_comment_box(req, podcast_slug, episode_id): pod = get_object_or_404(Podcast, slug=podcast_slug) if not UserSettings.user_meets_plan(pod.owner, plans.FEATURE_MIN_COMMENT_BOX): raise Http404() ep = get_object_or_404(PodcastEpisode, podcast=pod, id=episode_id) if not req.POST: return _pmrender(req, 'feedback/comment_episode.html', { 'podcast': pod, 'episode': ep }) try: if not _validate_recaptcha(req): raise Exception('Invalid ReCAPTCHA') ip = analyze.get_request_ip(req) f = Feedback(podcast=pod, episode=ep, sender=req.POST.get('email'), message=req.POST.get('message'), sender_ip=ip) f.save() send_notification_email( pod.owner, ugettext('[Pinecast] You got some feedback!'), 'Go check the Feedback page of %s--an episode on %s--to see what was written.\n\n' 'https://pinecast.com%s' % (ep.title, pod.name, reverse('podcast_episode', podcast_slug=podcast_slug, episode_id=str(ep.id)) + '#tab-feedback')) NotificationHook.trigger_notification(podcast=pod, trigger_type='feedback', data={ 'episode': ep, 'content': req.POST.get('message'), 'sender': req.POST.get('email') }) except Exception: return _pmrender(req, 'feedback/comment_episode.html', { 'podcast': pod, 'episode': ep, 'error': True, 'default': req.POST }) return _pmrender(req, 'feedback/thanks.html', {'podcast': pod})
def signup(req): if not req.user.is_anonymous(): return redirect('dashboard') if not req.POST: return _pmrender(req, 'signup/main.html', {'email': req.GET.get('email', '')}) error = None if not _validate_recaptcha(req): error = ugettext('Your humanity was not verified') elif not req.POST.get('email'): error = ugettext('Missing email address') elif not req.POST.get('password'): error = ugettext('Come on, you need a password') elif len(req.POST.get('password')) < 8: error = ugettext( 'Your password needs to be at least 8 characters long') elif User.objects.filter(email=req.POST.get('email')).count(): error = ugettext( 'That email address is already associated with an account') if error: return _pmrender(req, 'signup/main.html', { 'error': error, 'email': req.POST.get('email'), }) try: u = User.objects.create_user( str(uuid.uuid4())[:30], req.POST.get('email'), req.POST.get('password')) u.save() except Exception as e: return _pmrender(req, 'signup/main.html', { 'error': str(e), 'email': req.POST.get('email'), }) try: us = UserSettings.get_from_user(u) us.tz_offset = req.POST.get('timezone') us.save() except Exception: pass # whatever. return redirect(reverse('login') + '?signup_success=true')
def ep_comment_box(req, podcast_slug, episode_id): pod = get_object_or_404(Podcast, slug=podcast_slug) if not UserSettings.user_meets_plan(pod.owner, plans.FEATURE_MIN_COMMENT_BOX): raise Http404() ep = get_object_or_404(PodcastEpisode, podcast=pod, id=episode_id) if not req.POST: return _pmrender(req, 'feedback/comment_episode.html', {'podcast': pod, 'episode': ep}) try: if not _validate_recaptcha(req): raise Exception('Invalid ReCAPTCHA') ip = analyze.get_request_ip(req) f = Feedback( podcast=pod, episode=ep, sender=req.POST.get('email'), message=req.POST.get('message'), sender_ip=ip ) f.save() analytics_log.write('feedback', { 'podcast': unicode(pod.id), 'episode': unicode(ep.id), 'profile': { 'email': req.POST.get('email'), 'email_host': req.POST.get('email').split('@')[1], 'ip': ip, 'ua': req.META.get('HTTP_USER_AGENT'), }, }, req=req) send_notification_email( pod.owner, ugettext('[Pinecast] You got some feedback!'), 'Go check the Feedback page of %s--an episode on %s--to see what was written.\n\n' 'https://pinecast.com%s' % (ep.title, pod.name, reverse('podcast_episode', podcast_slug=podcast_slug, episode_id=str(ep.id)) + '#tab-feedback') ) except Exception: return _pmrender(req, 'feedback/comment_episode.html', {'podcast': pod, 'episode': ep, 'error': True, 'default': req.POST}) return _pmrender(req, 'feedback/thanks.html', {'podcast': pod})
def tip_flow(req, podcast_slug): pod = get_object_or_404(Podcast, slug=podcast_slug) us = UserSettings.get_from_user(pod.owner) if not us.stripe_payout_managed_account: if pod.homepage: return redirect(pod.homepage) else: raise Http404() recurring_tip = None pay_session = req.session.get('pay_session') tipper = None if pay_session: tipper = TipUser.objects.get(id=pay_session, verified=True) try: recurring_tip = RecurringTip.objects.get( podcast=pod, tipper=tipper, deactivated=False) except Exception as e: pass ctx = {'error': req.GET.get('error'), 'recurring_tip': recurring_tip, 'podcast': pod, 'tipper': tipper} return _pmrender(req, 'payments/tip_jar/main.html', ctx)
def subscriptions(req): if not req.session.get('pay_session'): return redirect('tip_jar_login') tip_user = get_object_or_404(TipUser, id=req.session['pay_session']) ctx = {'tip_user': tip_user} return _pmrender(req, 'payments/tip_jar/subscriptions.html', ctx)
def upgrade(req): us = UserSettings.get_from_user(req.user) customer = us.get_stripe_customer() ctx = { 'stripe_customer': customer, } return _pmrender(req, 'payments/main.html', ctx)
def upgrade(req): us = UserSettings.get_from_user(req.user) customer = us.get_stripe_customer() ctx = { 'active_coupon': req.session.get('coupon'), 'coupon_applied': 'coupon_applied' in req.GET, 'coupon_invalid': 'coupon_invalid' in req.GET, 'coupon_unavailable': 'coupon_unavailable' in req.GET, 'error': req.GET.get('error'), 'stripe_customer': customer, 'success': 'success' in req.GET, } return _pmrender(req, 'payments/main.html', ctx)
def podcast_comment_box(req, podcast_slug): pod = get_object_or_404(Podcast, slug=podcast_slug) if not UserSettings.user_meets_plan(pod.owner, plans.FEATURE_MIN_COMMENT_BOX): raise Http404() if not req.POST: return _pmrender(req, 'feedback/comment_podcast.html', {'podcast': pod}) try: if not _validate_recaptcha(req): raise Exception('Invalid ReCAPTCHA') ip = analyze.get_request_ip(req) f = Feedback( podcast=pod, sender=req.POST.get('email'), message=req.POST.get('message'), sender_ip=ip ) f.save() send_notification_email( pod.owner, ugettext('[Pinecast] You got some feedback!'), 'Go check the Feedback page of your podcast, %s, to see what was written.\n\n' 'https://pinecast.com%s' % (pod.name, reverse('podcast_dashboard', podcast_slug=podcast_slug) + '#tab-feedback') ) NotificationHook.trigger_notification( podcast=pod, trigger_type='feedback', data={'content': req.POST.get('message'), 'sender': req.POST.get('email')}) except Exception: return _pmrender(req, 'feedback/comment_podcast.html', {'podcast': pod, 'error': True, 'default': req.POST}) return _pmrender(req, 'feedback/thanks.html', {'podcast': pod})
def confirm_sub(req, podcast_slug): if not validate_confirmation(req): return _pmrender(req, 'payments/tip_jar/bad_link.html', ctx) pod = get_object_or_404(Podcast, slug=podcast_slug) try: amount = int(req.GET.get('amount')) except ValueError: return HttpResponse(status=400) email = req.GET.get('email') token = req.GET.get('token') try: result = _finish_sub(req, pod, amount, email, token) if result: return redirect('tip_jar_subs') except Exception: return HttpResponse(status=400)
def user_settings_page(req): return _pmrender(req, 'account/settings.html', {'success': req.GET.get('success'), 'error': req.GET.get('error')})