def confirm_article_deletion(request): article_id = request.matchdict['id'] article = articles.get(article_id) return { 'id': article.get('id'), 'title': article.get('title'), 'margin_left': str(random.randint(0, 85)), 'margin_top': str(random.randint(5, 25)) }
def save_article(request): us_article_id = request.matchdict['id'] article = articles.get(us_article_id) save_data = {} for us_key, us_value in request.POST.items(): """Only auto-save fields with the article-prefix to keep junk from entering the article-hash """ if us_key[:8] == 'article-': save_data[us_key[8:]] = us_value article.set(**save_data)
def schedule_article(request): us_article_id = request.matchdict['id'] us_date = request.POST.get('date') match = re.match('(\d\d)/(\d\d)/(\d\d\d\d)\s(\d\d):(\d\d)', us_date, flags=re.IGNORECASE) month, day, year, hour, minute = match.groups() dt = datetime.datetime(int(year), int(month), int(day), int(hour), int(minute)) timestamp = time.mktime(dt.timetuple()) article = articles.get(us_article_id) article.schedule(timestamp)
def edit_article(request): article = articles.get(request.matchdict['id']) if article.has('publish_at'): publish_at = article.get('publish_at') else: publish_at = None return { 'editing': True, 'id': article.get('id'), 'text': article.get('text'), 'text_compiled': article.get('text_compiled'), 'title': article.get('title'), 'tldr': article.get('tldr'), 'updated_at': article.get('updated_at'), 'publish_at': publish_at, 'is_published': article.is_published(), 'is_scheduled': article.is_scheduled(), 'date_format': date_format }
def unpublish_article(request): us_article_id = request.matchdict['id'] article = articles.get(us_article_id) article.unpublish()
def delete_article(request): us_article_id = request.matchdict['id'] article = articles.get(us_article_id) article.delete() return HTTPFound(location='/admin')