def add_trello_quest_source(trello_id): trello = Trello.get_by_id(trello_id) if trello.user.id != current_user.id: abort(403) form = AddTrelloQuestSourceForm() if form.validate_on_submit(): session = trello.get_session() board_id = form.board.data list_id = form.list.data board_display_name = session.get_board(board_id)["name"] list_display_name = session.get_list(list_id)["name"] QuestSource.register( backend=trello, board_id=board_id, list_id=list_id, board_display_name=board_display_name, list_display_name=list_display_name, ) return redirect(url_for("board.settings")) return render_template("board/add_trello_quest_source.html", form=form, trello=trello)
def add_google_quest_source(google_id): google = Google.get_by_id(google_id) if google.user.id != current_user.id: abort(403) session: GoogleAPISession = google.get_session() form = AddGoogleQuestSourceForm() if form.validate_on_submit(): calendar_id = form.calendar.data calendar_data = session.get_calendar(calendar_id) calendar_display_name = calendar_data["summary"] QuestSource.register( backend=google, calendar_id=calendar_id, calendar_display_name=calendar_display_name, ) return redirect(url_for("board.settings")) form.calendar.choices = [(c["id"], c["summary"]) for c in session.iter_calendars()] return render_template("board/add_google_quest_source.html", form=form, google=google)
def remove_quest_source(source_id): source = QuestSource.get_by_id(source_id) if source.user.id != current_user.id: abort(403) QuestSource.remove(source) return redirect(url_for("board.settings"))
def edit_quest_source(source_id): source: QuestSource = QuestSource.get_by_id(source_id) if source.user.id != current_user.id: abort(403) form = EditQuestSourceForm() if form.validate_on_submit(): source.set_label_name(form.label_name.data) source.set_label_fg_color(form.label_fg_color.data) source.set_label_bg_color(form.label_bg_color.data) source.set_blacklist(form.blacklist.data) return redirect(url_for("board.settings")) form.label_name.data = source.label_name form.label_fg_color.data = source.label_fg_color form.label_bg_color.data = source.label_bg_color form.blacklist.data = source.blacklist return render_template("board/edit_quest_source.html", form=form)