def add_blog_post(req, podcast_slug): site = get_site(req, podcast_slug) if not payment_plans.minimum( UserSettings.get_from_user(site.podcast.owner).plan, payment_plans.FEATURE_MIN_BLOG): raise Http404() data = {'site': site} if not req.POST: return _pmrender(req, 'dashboard/sites/blog/page_new.html', data) 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 = SiteBlogPost( site=site, title=req.POST.get('title'), slug=req.POST.get('slug'), body=req.POST.get('body'), publish=adjusted_publish ) post.save() except Exception as e: print e data.update(error=True, default=req.POST) return _pmrender(req, 'dashboard/sites/blog/page_new.html', data) else: return redirect('site_manage_blog', podcast_slug=podcast_slug)
def add_blog_post(req, podcast_slug): site = get_site(req, podcast_slug) if not payment_plans.minimum( UserSettings.get_from_user(site.podcast.owner).plan, payment_plans.FEATURE_MIN_BLOG): raise Http404() try: publis_parsed = datetime.datetime.strptime( req.POST.get('publish', '').split('.')[0], '%Y-%m-%dT%H:%M:%S') post = SiteBlogPost( site=site, title=req.POST.get('title'), slug=req.POST.get('slug'), body=req.POST.get('body'), publish=publis_parsed, disable_comments=req.POST.get('disable_comments') == 'true') post.save() except Exception as e: print(e) return redirect( reverse('podcast_dashboard', podcast_slug=podcast_slug) + '?error=sblog#site,blog') else: return redirect( reverse('podcast_dashboard', podcast_slug=podcast_slug) + '#site,blog')
def add_blog_post(req, podcast_slug): site = get_site(req, podcast_slug) if not payment_plans.minimum( UserSettings.get_from_user(site.podcast.owner).plan, payment_plans.FEATURE_MIN_BLOG): raise Http404() try: publis_parsed = datetime.datetime.strptime(req.POST.get('publish'), '%Y-%m-%dT%H:%M:00.000Z') post = SiteBlogPost( site=site, title=req.POST.get('title'), slug=req.POST.get('slug'), body=req.POST.get('body'), publish=publis_parsed, disable_comments=req.POST.get('disable_comments') == 'true') post.save() except Exception as e: return redirect(reverse('podcast_dashboard', podcast_slug=podcast_slug) + '?error=sblog#site,blog') else: return redirect(reverse('podcast_dashboard', podcast_slug=podcast_slug) + '#site,blog')