def add_item(components, user): url = get_from_array(components, 1) title = get_from_array(components, 2) if url is None: return get_response("Error: No URL Found") else: if check_url(url): try: result = rss.add_artcle(url, title, "", user) if result == rss.STATUS_OK: return get_response('Successfully added Article ' + url + " to feed " + settings.main_url) elif result == rss.STATUS_EXISTS: return get_response("Error: Article was added less than 7 days ago") else: return get_response("Error: Could not save URL.") except: return get_response('Error: Could not save URL.') else: return get_response("Error: Invalid URL")
def add(): error = None if 'login' not in session: return redirect(url_for('login')) user = dbservice.get_user(username=session['login']) if user is None: return redirect(url_for('login')) if request.method == 'POST': url = request.form['url'] description = request.form['description'] title = request.form['title'] try: result = rss.add_artcle(url, description, title, user) if result == rss.STATUS_OK: error = "Success" elif result == rss.STATUS_EXISTS: error = "Feed was added less than 7 days ago" except: error = 'Could not save' return render_template("add_item.html", error=error, title=settings.title)