def addStep(event_id): event = Event.query.get(event_id) form = StepForm() suggestions = Suggestion.query.filter(Suggestion.category == event.category) event_steps = Step.query.order_by(Step.step_num).filter(Step.event_id == event.id) step_num = event_steps.count() + 1 def add_step(event_id, step_num, step): new_step = Step(event_id = event_id, step_num = step_num, step=step) sqldb.session.add(new_step) sqldb.session.commit() if form.validate_on_submit(): add_step(event_id, step_num, form.step.data) return redirect("addStep/"+str(event_id)) return render_template("addStep.html", form = form, event=event, suggestions = suggestions, event_steps=event_steps)
def edit_step(id): check_admin() add_step = False step = Step.query.get_or_404(id) form = StepForm(obj=step) if form.validate_on_submit(): step.name = form.name.data step.description = form.description.data step.step_action = form.step_action.data step.action_string = form.action_string.data step.secondary_regex = form.secondary_regex.data step.filename_mask = form.filename_mask.data db.session.commit() flash('You have successfully edited a step.') return redirect(url_for('admin.list_steps', task_id=step.task_id)) return add_edit_form_template("Edit", "Step", form)
def add_step(task_id): check_admin() add_step = True form = StepForm() if form.validate_on_submit(): step = Step(name=form.name.data, description=form.description.data, step_action=form.step_action.data, action_string=form.action_string.data, secondary_regex=form.secondary_regex.data, filename_mask=form.filename_mask.data, task_id=task_id) try: db.session.add(step) db.session.commit() flash('You have successfully added a new step.') except: flash('Error: name already exists.') return redirect(url_for('admin.list_steps', task_id=task_id)) return add_edit_form_template("Add", "Step", form)