Ejemplo n.º 1
0
def add_vote(**kwargs):
    form = AddVoteForm(csrf_enabled=False);
    if form.validate_on_submit():
        userid = current_user.id
        groupid = form.groupid.data
        title = form.title.data
        info = form.info.data
        limit = form.limit.data
        options = form.options.data
        duration = form.duration.data
        if form.groupid.data is not None:
            vote = Vote(groupid,title,info,limit,duration)
            db.session.add(vote)
            db.session.commit()
            vote.set_option(options.split(","))
            message.vote_add_message(vote)
            return dict(success=1)
        else:
            return dict(fail=1)
    else:
        return dict(fail=1)