Exemple #1
0
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(),
    )
Exemple #2
0
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(),
    )
Exemple #3
0
 def run(self, *args, **kwargs):
     repo = get_repo()
     form = ConfirmForm(request.form, prefix='action-', csrf_enabled=False)
     if form.validate():
         output = operation_repo(repo, 'commit', self.files, self.commit_message)
         app.logger.info('commit_action - %s [%s]' % (self.name, ', '.join(self.files)))
         flash_message = gettext('"%(label)s" was executed.', label=self.label)
         flash(flash_message)
         return
     message = gettext('Execute "%(label)s"', label=self.label)
     form = ConfirmForm(None, confirm=1, prefix='action-', csrf_enabled=False)
     return render_template('actions/commit.html',
         message=message,
         repository=repo,
         form=form,
         action_name=self.name,
     )
Exemple #4
0
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(),
    )
Exemple #5
0
 def run(self, *args, **kwargs):
     repo = get_repo()
     form = ConfirmForm(request.form, prefix='action-', csrf_enabled=False)
     if form.validate():
         output = exec_command(self.command)
         app.logger.info('exec_command - %s [%s]' % (self.name, ' '.join(self.command)))
         if self.encoding:
             output = output.decode(self.encoding)
         if output:
             flash_message = output
         else:
             flash_message = gettext('"%(label)s" was executed.', label=self.label)
         flash(flash_message)
         return
     message = gettext('Execute "%(label)s"', label=self.label)
     form = ConfirmForm(None, confirm=1, prefix='action-', csrf_enabled=False)
     return render_template('actions/command.html',
         message=message,
         repository=repo,
         form=form,
         action_name=self.name,
     )