def site_episode(req, podcast_slug, episode_id): pod = get_object_or_404(Podcast, slug=podcast_slug) site = get_object_or_404(models.Site, podcast=pod) episode = get_object_or_404(PodcastEpisode, podcast=site.podcast, id=episode_id) return _srender(req, site, 'episode.html', {'episode': episode})
def site_home(req, podcast_slug): pod = get_object_or_404(Podcast, slug=podcast_slug) site = get_object_or_404(models.Site, podcast=pod) episodes = pod.get_episodes() paginator = Paginator(episodes, SITE_EPISODES_PER_PAGE) try: pager = paginator.page(req.GET.get('page')) except PageNotAnInteger: pager = paginator.page(1) except EmptyPage: return redirect('site_home', podcast_slug=pod.slug) return _srender(req, site, 'home.html', {'pager': pager})
def favicon(req, podcast_slug): pod = get_object_or_404(Podcast, slug=podcast_slug) us = UserSettings.get_from_user(pod.owner) if not minimum(us.plan, FEATURE_MIN_SITE_FAVICON): return redirect('https://pinecast.com/static/img/favicon.png') site = get_object_or_404(models.Site, podcast=pod) if not site.favicon_url: return redirect('https://pinecast.com/static/img/favicon.png') return redirect(site.favicon_url)
def site_blog(req, podcast_slug): pod = get_object_or_404(Podcast, slug=podcast_slug) site = get_object_or_404(models.Site, podcast=pod) posts = site.siteblogpost_set.filter( publish__lt=datetime.datetime.now()).order_by('-publish') paginator = Paginator(posts, 5) try: pager = paginator.page(req.GET.get('page')) except PageNotAnInteger: pager = paginator.page(1) except EmptyPage: return redirect('site_home', podcast_slug=pod.slug) return _srender(req, site, 'blog.html', {'pager': pager})
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 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 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 send_tip(req, podcast_slug): pod = get_object_or_404(Podcast, slug=podcast_slug) try: amount = int(float(req.POST.get('amount')) / 100.0) * 100 if amount < 100: return {'error': ugettext('Tips less than $1 are not allowed.')} except Exception: return HttpResponse(status=400) tip_type = req.POST.get('type') owner_us = UserSettings.get_from_user(pod.owner) if owner_us.plan == PLAN_DEMO and tip_type == 'subscribe': return {'error': ugettext('You cannot have recurring tips for free podcasts.')} if amount > PLAN_TIP_LIMITS[owner_us.plan]: return {'error': ugettext('That tip is too large for %s') % pod.name} if tip_type == 'charge': return _send_one_time_tip(req, pod, owner_us, amount) elif tip_type == 'subscribe': return _auth_subscription(req, pod, amount) else: return HttpResponse(status=400)
def test_notification(req): podcast = _get_podcast(req, id=req.POST.get('podcast')) notification = get_object_or_404(NotificationHook, podcast=podcast, id=req.POST.get('id')) notification.send_test() return redirect(reverse('podcast_dashboard', podcast_slug=podcast.slug) + '?notification_sent=true#settings,notifications')
def edit_blog_post(req, podcast_slug, post_slug): site = get_site(req, podcast_slug) post = get_object_or_404(SiteBlogPost, site=site, slug=post_slug) if not req.POST: return _pmrender(req, 'dashboard/sites/blog/page_edit.html', { 'site': site, 'post': post }) try: naive_publish = datetime.datetime.strptime( req.POST.get('publish', '').split('.')[0], '%Y-%m-%dT%H:%M:%S') # 2015-07-09T12:00 adjusted_publish = naive_publish - UserSettings.get_from_user( req.user).get_tz_delta() post.title = req.POST.get('title') post.slug = req.POST.get('slug') post.body = req.POST.get('body') post.publish = adjusted_publish post.disable_comments = req.POST.get('disable_comments') == 'true' post.save() except Exception as e: data.update(error=True, default=req.POST) return _pmrender(req, 'dashboard/sites/blog/page_edit.html', data) else: return redirect( reverse('podcast_dashboard', podcast_slug=podcast_slug) + '#site,blog')
def delete_page(req, podcast_slug, page_slug): site = get_site(req, podcast_slug) page = get_object_or_404(SitePage, site=site, slug=page_slug) page.delete() return redirect( reverse('podcast_dashboard', podcast_slug=podcast_slug) + '#site')
def network_dashboard(req, network_id): net = get_object_or_404(Network, deactivated=False, id=network_id, members__in=[req.user]) net_podcasts = net.podcast_set.all() pod_map = {str(p.id): p for p in net_podcasts} top_episodes_data = analytics_query.get_top_episodes([str(p.id) for p in net_podcasts]) top_episodes = [] for ep_id, count in sorted(top_episodes_data.items(), key=lambda x: -1 * x[1])[:75]: try: episode = PodcastEpisode.objects.get(id=ep_id) except PodcastEpisode.DoesNotExist: continue top_episodes.append({ 'count': count, 'episode': episode, 'podcast': pod_map[str(episode.podcast_id)], }) upcoming_episodes = PodcastEpisode.objects.filter( podcast__in=net_podcasts, publish__gt=round_now()) return _pmrender(req, 'dashboard/network/page_dash.html', {'error': req.GET.get('error'), 'network': net, 'net_podcasts': net_podcasts, 'net_podcasts_map': pod_map, 'top_episodes': top_episodes, 'upcoming_episodes': list(upcoming_episodes)})
def get_site(req, podcast_slug): pod = get_object_or_404(Podcast, slug=podcast_slug) if (pod.owner != req.user and not Network.objects.filter( deactivated=False, members__in=[req.user], podcast__in=[pod]).count()): raise Http404() return pod.site
def network_add_member(req, network_id): net = get_object_or_404(Network, deactivated=False, id=network_id, members__in=[req.user]) try: user = User.objects.get(email=req.POST.get('email')) except User.DoesNotExist: return redirect( reverse('network_dashboard', network_id=network_id) + '?error=udne#members,add-member') net.members.add(user) net.save() pinecast.email.send_notification_email( user, ugettext('[Pinecast] You have been added to "%s"') % net.name, ugettext(''' We are emailing you to let you know that you were added to the network "%s". No action is required on your part. If you log in to Pinecast, you will now have read and write access to all of the podcasts in the network, and will be able to add your own podcasts to the network. ''') % net.name) return redirect( reverse('network_dashboard', network_id=net.id) + '#members')
def podcast_episode_publish_now(req, podcast_slug, episode_id): pod = get_podcast(req, podcast_slug) ep = get_object_or_404(PodcastEpisode, id=episode_id, podcast=pod) ep.publish = datetime.datetime.now() ep.save() return redirect('podcast_episode', podcast_slug=pod.slug, episode_id=str(ep.id))
def get_site(req, podcast_slug): pod = get_object_or_404(Podcast, slug=podcast_slug) if (pod.owner != req.user and not Network.objects.filter(deactivated=False, members__in=[req.user], podcast__in=[pod]).count()): raise Http404() return pod.site
def player(req, episode_id): ep = get_object_or_404(PodcastEpisode, id=episode_id) resp = render(req, 'player.html', {'episode': ep}) # If the user is not a demo user, allow the player to be used outside the app. if UserSettings.user_meets_plan(ep.podcast.owner, plans.FEATURE_MIN_PLAYER): resp.xframe_options_exempt = True return resp
def listen(req, episode_id): ep = get_object_or_404(PodcastEpisode, id=episode_id) if req.method == 'GET': analytics_log.write_listen( ep=ep, source='embed' if req.GET.get('embed') else 'direct', req=req) return redirect(_asset(ep.audio_url))
def delete_podcast(req, podcast_slug): # This doesn't use `get_podcast` because only the owner may delete the podcast pod = get_object_or_404(Podcast, slug=podcast_slug, owner=req.user) for tip in pod.recurring_tips.all(): tip.cancel() pod.delete() return redirect('dashboard')
def remove_blog_post(req, podcast_slug): site = get_site(req, podcast_slug) post = get_object_or_404(SiteBlogPost, site=site, slug=req.POST.get('slug')) post.delete() return redirect( reverse('podcast_dashboard', podcast_slug=podcast_slug) + '#site,blog')
def network_remove_podcast(req, network_id, podcast_slug): net = get_object_or_404(Network, deactivated=False, id=network_id, members__in=[req.user]) pod = get_object_or_404(Podcast, slug=podcast_slug, networks__in=[net]) # We don't need to confirm if the user is the owner. if pod.owner == req.user: pod.networks.remove(net) pod.save() return redirect('network_dashboard', network_id=net.id) if req.user != net.owner: raise Http404() pod.networks.remove(net) pod.save() return redirect('network_dashboard', network_id=net.id)
def import_progress(req, podcast_slug): p = get_object_or_404(Podcast, slug=podcast_slug, owner=req.user) ids = req.GET.get('ids') reqs = AssetImportRequest.objects.filter(id__in=ids.split(',')) total = reqs.count() return { 'elems': {x.id: x.get_json_payload() for x in reqs}, 'status': sum(1.0 for r in reqs if r.resolved) / total * 100.0, }
def network_deactivate(req, network_id): net = get_object_or_404(Network, deactivated=False, id=network_id, owner=req.user) if req.POST.get('confirm') != 'doit': return redirect('dashboard') net.deactivated = True net.save() return redirect('dashboard')
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 network_remove_member(req, network_id, member_id): net = get_object_or_404(Network, deactivated=False, id=network_id, members__in=[req.user]) user = get_object_or_404(User, id=member_id) if not net.members.filter(username=user.username).count(): raise Http404() # We don't need to confirm if the user is the owner. if net.owner == user: return redirect('network_dashboard', network_id=net.id) pods = Podcast.objects.filter(owner=user, networks__in=[net]) for pod in pods: pod.networks.remove(net) pod.save() net.members.remove(user) net.save() return redirect(reverse('network_dashboard', network_id=net.id) + '#members')
def network_edit(req, network_id): net = get_object_or_404(Network, deactivated=False, id=network_id, members__in=[req.user]) try: net.name = req.POST.get('name') net.image_url = signer.unsign(req.POST.get('image-url')) if req.POST.get('image-url') else None net.save() except Exception as e: # TODO: maybe handle this better? pass return redirect('network_dashboard', network_id=net.id)
def network_add_show(req, network_id): net = get_object_or_404(Network, deactivated=False, id=network_id, members__in=[req.user]) slug = req.POST.get('slug') try: pod = Podcast.objects.get(slug=slug) except Podcast.DoesNotExist: return redirect(reverse('network_dashboard', network_id=net.id) + '?error=aslg#shows,add-show') else: if pod.owner != req.user: return redirect(reverse('network_dashboard', network_id=net.id) + '?error=nown#shows,add-show') pod.networks.add(net) pod.save() return redirect('network_dashboard', network_id=net.id)
def sitemap(req, podcast_slug): pod = get_object_or_404(Podcast, slug=podcast_slug) site = get_object_or_404(models.Site, podcast=pod) output = '''<?xml version="1.0" encoding="UTF-8"?> <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> ''' pages = pod.podcastepisode_set.all().count() for i in range(pages): output += ''' <url> <loc>{url}</loc> <changefreq>weekly</changefreq> </url> '''.format( url='%s?page=%d' % (_subdomain_reverse('site_home', podcast_slug=pod.slug), i + 1)) output += ''' <url><loc>{url}</loc></url> '''.format(url=_subdomain_reverse('site_blog', podcast_slug=pod.slug)) for episode in pod.podcastepisode_set.all(): output += ''' <url><loc>{url}</loc></url> '''.format(url=_subdomain_reverse( 'site_episode', podcast_slug=pod.slug, episode_id=str(episode.id))) for post in site.siteblogpost_set.all(): output += ''' <url><loc>{url}</loc></url> '''.format(url=_subdomain_reverse( 'site_post', podcast_slug=pod.slug, post_slug=post.slug)) output += '</urlset>' return HttpResponse(output, content_type='application/xml')
def podcast_episode(req, podcast_slug, episode_id): pod = get_podcast(req, podcast_slug) ep = get_object_or_404(PodcastEpisode, id=episode_id, podcast=pod) total_listens = analytics_query.total_listens(pod, episode=ep) data = { 'error': 'error' in req.GET, 'podcast': pod, 'episode': ep, 'analytics': {'total_listens': total_listens}, 'feedback': Feedback.objects.filter(podcast=pod, episode=ep).order_by('-created'), } return _pmrender(req, 'dashboard/episode/page_episode.html', data)
def delete_comment(req, podcast_slug, comment_id): pod = get_podcast(req, podcast_slug) comment = get_object_or_404(Feedback, podcast=pod, id=comment_id) ep = comment.episode comment.delete() if ep: return redirect( reverse('podcast_episode', podcast_slug=podcast_slug, episode_id=str(ep.id)) + '#tab-feedback' ) else: return redirect( reverse('podcast_dashboard', podcast_slug=podcast_slug) + '#tab-feedback' )
def podcast_episode(req, podcast_slug, episode_id): pod = get_podcast(req, podcast_slug) ep = get_object_or_404(PodcastEpisode, id=episode_id, podcast=pod) total_listens = analytics_query.total_listens(pod, episode_id=str(ep.id)) data = { 'error': 'error' in req.GET, 'podcast': pod, 'episode': ep, 'analytics': {'total_listens': total_listens}, 'feedback': Feedback.objects.filter(podcast=pod, episode=ep).order_by('-created'), } return _pmrender(req, 'dashboard/episode/page_episode.html', data)
def sitemap(req, podcast_slug): pod = get_object_or_404(Podcast, slug=podcast_slug) site = get_object_or_404(models.Site, podcast=pod) output = '''<?xml version="1.0" encoding="UTF-8"?> <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> ''' pages = pod.podcastepisode_set.all().count() for i in range(pages): output += ''' <url> <loc>{url}</loc> <changefreq>weekly</changefreq> </url> '''.format(url='%s?page=%d' % ( _subdomain_reverse('site_home', podcast_slug=pod.slug), i + 1)) output += ''' <url><loc>{url}</loc></url> '''.format(url=_subdomain_reverse('site_blog', podcast_slug=pod.slug)) for episode in pod.podcastepisode_set.all(): output += ''' <url><loc>{url}</loc></url> '''.format(url=_subdomain_reverse('site_episode', podcast_slug=pod.slug, episode_id=str(episode.id))) for post in site.siteblogpost_set.all(): output += ''' <url><loc>{url}</loc></url> '''.format(url=_subdomain_reverse('site_post', podcast_slug=pod.slug, post_slug=post.slug)) output += '</urlset>' return HttpResponse(output, content_type='application/xml')
def network_remove_member(req, network_id, member_id): net = get_object_or_404(Network, deactivated=False, id=network_id, members__in=[req.user]) user = get_object_or_404(User, id=member_id) if not net.members.filter(username=user.username).count(): raise Http404() # We don't need to confirm if the user is the owner. if net.owner == user: return redirect('network_dashboard', network_id=net.id) pods = Podcast.objects.filter(owner=user, networks__in=[net]) for pod in pods: pod.networks.remove(net) pod.save() net.members.remove(user) net.save() return redirect( reverse('network_dashboard', network_id=net.id) + '#members')
def network_edit(req, network_id): net = get_object_or_404(Network, deactivated=False, id=network_id, members__in=[req.user]) try: net.name = req.POST.get('name') net.image_url = signer.unsign( req.POST.get('image-url')) if req.POST.get('image-url') else None net.save() except Exception as e: # TODO: maybe handle this better? pass return redirect('network_dashboard', network_id=net.id)
def import_result(req): p = get_object_or_404(AssetImportRequest, access_token=req.POST.get('token'), id=req.POST.get('id')) if req.POST.get('failed'): p.failure_message = req.POST.get('error') p.save() return {'success': True} try: p.resolve(req.POST.get('url')) except Exception as e: return HttpResponseBadRequest(str(e)) return {'success': True}
def network_listen_history(req): net = get_object_or_404(Network, id=req.GET.get("network_id"), members__in=[req.user]) pods = net.podcast_set.all() f = ( Format(req, "listen") .select(episode_f="count") .last_thirty() .interval() .group("podcast") .where(podcast=[str(p.id) for p in pods]) ) return f.format_intervals( labels_map={str(p.id): p.name for p in pods}, extra_data={str(p.id): {"slug": p.slug} for p in pods} )
def _get_podcast(req, **kwargs): podcast = get_object_or_404(Podcast, **kwargs) us = UserSettings.get_from_user(podcast.owner) if not minimum(us.plan, FEATURE_MIN_NOTIFICATIONS): raise HttpResponseForbidden() if req.user.is_staff: return podcast if req.user == podcast.owner: return podcast pods = Network.objects.filter(deactivated=False, members__in=[req.user], podcast__in=[podcast]) if not pods.count(): raise Http404() return podcast
def import_result(req): p = get_object_or_404(AssetImportRequest, access_token=req.POST.get('token'), id=req.POST.get('id')) if req.POST.get('failed'): p.failure_message = req.POST.get('error') p.failed = True p.save() return {'success': True} try: p.resolve(req.POST.get('url')) except Exception as e: return HttpResponseBadRequest(str(e)) return {'success': True}
def edit_page(req, podcast_slug, page_slug): site = get_site(req, podcast_slug) page = get_object_or_404(SitePage, site=site, slug=page_slug) if not req.POST: return _pmrender(req, 'dashboard/sites/pages/page_edit.html', { 'site': site, 'page': page }) try: page.title = req.POST.get('title') page.body = SitePage.get_body_from_req(req, page.page_type) page.save() except Exception as e: data.update(error=True, default=req.POST) return _pmrender(req, 'dashboard/sites/pages/page_edit.html', data) else: return redirect( reverse('podcast_dashboard', podcast_slug=podcast_slug) + '#site')
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 edit_blog_post(req, podcast_slug, post_slug): site = get_site(req, podcast_slug) post = get_object_or_404(SiteBlogPost, site=site, slug=post_slug) if not req.POST: return _pmrender(req, 'dashboard/sites/blog/page_edit.html', {'site': site, 'post': post}) try: naive_publish = datetime.datetime.strptime(req.POST.get('publish'), '%Y-%m-%dT%H:%M') # 2015-07-09T12:00 adjusted_publish = naive_publish - UserSettings.get_from_user(req.user).get_tz_delta() post.title = req.POST.get('title') post.slug = req.POST.get('slug') post.body = req.POST.get('body') post.publish = adjusted_publish post.disable_comments = req.POST.get('disable_comments') == 'true' post.save() except Exception as e: data.update(error=True, default=req.POST) return _pmrender(req, 'dashboard/sites/blog/page_edit.html', data) else: return redirect('site_manage_blog', podcast_slug=podcast_slug)
def get_episodes(req): pod_slug = req.GET.get('podcast') network = req.GET.get('network_id') start_date = req.GET.get('start_date') if not pod_slug and not network: return [] pods = set() if pod_slug: pods.add(get_podcast(req, pod_slug)) if network: net = get_object_or_404(Network, id=network, members__in=[req.user]) pods = pods | set(net.podcast_set.all()) if not pods: return [] query = PodcastEpisode.objects.filter( podcast__in=list(pods), publish__lt=datetime.datetime.now(), awaiting_import=False ) if start_date: try: parsed_date = datetime.datetime.strptime(start_date, '%Y-%m-%dT%H:%M:%S') except ValueError: raise Http404() query = query.filter(publish__gte=parsed_date) uset = UserSettings.get_from_user(req.user) tz_delta = uset.get_tz_delta() return [ {'id': ep.id, 'title': ep.title, 'podcastSlug': ep.podcast.slug, 'publish': (ep.publish + tz_delta).strftime('%Y-%m-%dT%H:%M:%S')} for ep in sorted(query, key=lambda x: x.publish) ]
def edit_podcast_episode(req, podcast_slug, episode_id): pod = get_podcast(req, podcast_slug) ep = get_object_or_404(PodcastEpisode, id=episode_id, podcast=pod) try: publish_parsed = datetime.datetime.strptime(req.POST.get('publish').split('.')[0], ISO_FORMAT) ep.title = req.POST.get('title') ep.subtitle = req.POST.get('subtitle') ep.publish = publish_parsed ep.description = req.POST.get('description') ep.duration = int(req.POST.get('duration-hours')) * 3600 + int(req.POST.get('duration-minutes')) * 60 + int(req.POST.get('duration-seconds')) ep.audio_url = signer.unsign(req.POST.get('audio-url')) ep.audio_size = int(req.POST.get('audio-url-size')) ep.audio_type = req.POST.get('audio-url-type') image_url = req.POST.get('image-url') if image_url: ep.image_url = signer.unsign(req.POST.get('image-url')) else: ep.image_url = pod.cover_image ep.copyright = req.POST.get('copyright') ep.license = req.POST.get('license') ep.explicit_override = req.POST.get('explicit_override') ep.set_flair(req.POST, no_save=True) ep.save() ep.delete_feedback_prompt() if req.POST.get('feedback_prompt'): prompt = EpisodeFeedbackPrompt(episode=ep, prompt=req.POST.get('feedback_prompt')) prompt.save() except Exception as e: return redirect(reverse('podcast_episode', podcast_slug=pod.slug, episode_id=str(ep.id)) + '?error=true#edit') return redirect('podcast_episode', podcast_slug=pod.slug, episode_id=str(ep.id))