Beispiel #1
0
    def upload(self) -> str:
        """
		Upload file and return info data for uploaded file.
		"""
        file = request.files.get('file')
        if file is not None:
            fileinfo = temporary_file(file)
        if fileinfo is not None:
            return {'status': 'ok', 'fileinfo': fileinfo}, 200
        return blueprints.__('Upload error'), 500
Beispiel #2
0
def create():
    """
	Return poll create page.
	"""
    form = poll_form.PollForm()
    if form.form_valid:
        if form.submit.data:
            poll = form.create()
            poll_history.PollHistoryList.create(current_user.user.id, poll.id,
                                                'create')
            return redirect(url_for('poll.get_catalog'))
    return render_template('poll_form.html',
                           form=form,
                           action=blueprints.__('Create'))
Beispiel #3
0
def update_option(poll_uid: str, uid: str):
    """
	Return poll's option update page.
	"""
    form = option_form.OptionForm(uid)
    if form.form_valid:
        if form.submit.data:
            option = form.update(uid)
            option_history.OptionHistoryList.create(current_user.user.id,
                                                    option.id, 'update')
            return redirect(
                url_for('poll.get_option_catalog', poll_uid=poll_uid))
    return render_template('option_form.html',
                           form=form,
                           action=blueprints.__('Update'),
                           poll_uid=poll_uid)
Beispiel #4
0
def update(uid: str):
    """
	Return poll update page.
	"""
    form = poll_form.PollForm(uid)
    if form.form_valid:
        if form.submit.data:
            poll = form.update(uid)
            poll_history.PollHistoryList.create(current_user.user.id, poll.id,
                                                'update')
            return redirect(url_for('poll.get_catalog'))
    return render_template('poll_form.html',
                           form=form,
                           action=blueprints.__('Update'),
                           poll_uid=uid,
                           poll_active=False)