def post_news(): print(request.form) if request.form.get('action') == 'delete': ns.delete(request.form.get('id')) else: date = dtutil.parse(request.form.get('date'), dtutil.FORM_FORMAT, dtutil.WOTC_TZ) ns.add_or_update_news(request.form.get('id'), date, request.form.get('title'), request.form.get('body')) return edit_news()
def post_news(news_id: int, title: str = None, url: str = None, date: str = None) -> wrappers.Response: if request.form.get('action') == 'delete': ns.delete(news_id) else: if date is not None and title is not None and url is not None: date_dt = dtutil.parse(date, dtutil.FORM_FORMAT, dtutil.WOTC_TZ) ns.add_or_update_news(news_id, date_dt, title, url) return redirect(url_for('edit_news'))