def add_unknown_confirm(): """ Show confirm on adding untracked files """ if not get_allow_commit(): abort(401) repo = get_repo() form = SelectFileConfirmForm(request.form) form.files.choices = get_choices_unknown(repo) if not form.validate(): flash(_('Invalid request. Please input again.')) return redirect(url_for('index')) if form.data.get('confirm'): # add to repos repo.add(form.data['files']) flash(_('added.')) return redirect(url_for('index')) formdata = MultiDict(request.form) del formdata['csrf'] form = SelectFileConfirmForm(None, confirm=1, **formdata) form.files.choices = get_choices_unknown(repo) form.validate() return render_template('add_unknown_confirm.html', repository=repo, form=form, hostname=gethostname(), )
def submit_confirm(): """ Show confirm submitting """ if not get_allow_commit(): abort(401) repo = get_repo() form = SelectFileSubmitConfirmForm(request.form, prefix='ctrl-') form.files.choices = get_choices_ctrl(repo) if not form.validate(): flash(_('Invalid request. Please input again.')) return redirect(url_for('index')) if form.data.get('confirm'): # operation message = operation_repo(repo, form.data['operation'], form.data['files'], form.data['commit_message']) flash(message) return redirect(url_for('index')) formdata = MultiDict(request.form) del formdata['ctrl-csrf'] form = SelectFileSubmitConfirmForm(None, prefix='ctrl-', confirm=1, **formdata) form.files.choices = get_choices_ctrl(repo) form.validate() return render_template('submit.html', repository=repo, form=form, message=OPERATION_MESSAGE.get(form.data['operation']), enable_commit_message=form.data['operation'] == 'commit', hostname=gethostname(), )
def index(): """ top page """ repo = get_repo() form_ctrl = SelectFileForm(request.form, prefix='ctrl-') form_unknown = SelectFileForm(request.form) form_ctrl.files.choices = get_choices_ctrl(repo) form_unknown.files.choices = get_choices_unknown(repo) form_actions = SelectActionForm(request.form, prefix='action-') form_actions.action.choices = action_manager.list() return render_template('index.html', repository=repo, form_unknown=form_unknown, form_ctrl=form_ctrl, form_actions=form_actions, hostname=gethostname(), allow_commit=get_allow_commit(), )