21 lines
480 B
Python
21 lines
480 B
Python
from app import app, db
|
|
from flask import request
|
|
from flask_login import current_user
|
|
|
|
from app.models.poll import Poll
|
|
|
|
@app.route("/poll/<int:poll_id>", methods=['POST'])
|
|
def poll_submit(poll_id):
|
|
p = Poll.query.first_or_404()
|
|
|
|
if not current_user.is_authenticated:
|
|
return 401
|
|
if p.has_voted(current_user):
|
|
return 403
|
|
|
|
try:
|
|
resp = request.get_json()['text']
|
|
except BadRequestKeyError:
|
|
abort(400)
|
|
return str(md(markdown))
|