def open_creation_datepicker(session, context, poll): """Open the datepicker during the creation of a poll.""" keyboard = get_creation_datepicker_keyboard(poll, date.today()) # Switch from new option by text to new option via datepicker message = context.query.message if context.user.expected_input != ExpectedInput.options.name: message.edit_text( i18n.t("creation.option.finished", locale=context.user.locale)) return context.user.expected_input = ExpectedInput.date.name message.edit_text(get_datepicker_text(poll), parse_mode="markdown", reply_markup=keyboard)
def open_creation_datepicker(session, context, poll): """All options are entered the poll is created.""" keyboard = get_creation_datepicker_keyboard(poll) # Switch from new option by text to new option via datepicker message = context.query.message if context.user.expected_input != ExpectedInput.options.name: message.edit_text( i18n.t('creation.option.finished', locale=context.user.locale)) return context.user.expected_input = ExpectedInput.date.name message.edit_text(get_datepicker_text(poll), parse_mode='markdown', reply_markup=keyboard)
def update_datepicker(context, poll): """Update the creation datepicker.""" user = context.user if poll.created and poll.user != user: keyboard = get_external_datepicker_keyboard(context.poll) elif poll.created and poll.user == user: if poll.user.expected_input == ExpectedInput.due_date.name: context.query.message.edit_reply_markup( reply_markup=get_due_date_datepicker_keyboard(context.poll)) return else: keyboard = get_add_option_datepicker_keyboard(context.poll) elif not poll.created: keyboard = get_creation_datepicker_keyboard(context.poll) else: raise Exception('Unknown update constellation in datepicker') context.query.message.edit_text(get_datepicker_text(context.poll), parse_mode='markdown', reply_markup=keyboard)
def open_creation_datepicker(session, context, poll): """Open the datepicker during the creation of a poll.""" keyboard = get_creation_datepicker_keyboard(poll, date.today()) # Switch from new option by text to new option via datepicker message = context.query.message if context.user.expected_input != ExpectedInput.options.name: message.edit_text( i18n.t("creation.option.finished", locale=context.user.locale) ) return context.user.expected_input = ExpectedInput.date.name text = get_datepicker_text(poll) if len(text) > 4000: error_message = i18n.t("misc.too_many_options", locale=context.user.locale) raise RollbackException(error_message) message.edit_text(text, parse_mode="markdown", reply_markup=keyboard)