Example #1
0
def open_external_datepicker(session, context, poll):
    """All options are entered the poll is created."""
    keyboard = get_external_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.new_user_option.name:
        message.edit_text(
            i18n.t("creation.option.finished", locale=context.user.locale))
        return

    message.edit_text(get_datepicker_text(poll),
                      parse_mode="markdown",
                      reply_markup=keyboard)
Example #2
0
def update_datepicker(context, poll, datepicker_context, current_date):
    """Update the creation datepicker."""
    message = get_datepicker_text(context.poll)
    if datepicker_context == DatepickerContext.creation:
        keyboard = get_creation_datepicker_keyboard(poll, current_date)
    elif datepicker_context == DatepickerContext.additional_option:
        keyboard = get_add_option_datepicker_keyboard(poll, current_date)
    elif datepicker_context == DatepickerContext.external_add_option:
        keyboard = get_external_datepicker_keyboard(poll, current_date)
    elif datepicker_context == DatepickerContext.due_date:
        message = get_settings_text(poll)
        keyboard = get_due_date_datepicker_keyboard(poll, current_date)
    else:
        raise Exception('Unknown DatepickerContext')

    context.query.message.edit_text(message,
                                    parse_mode='markdown',
                                    reply_markup=keyboard,
                                    disable_web_page_preview=True)