def remove_due_date(session, context, poll): """Remove the due date from a poll.""" poll.due_date = None poll.next_notification = None poll.user.expected_input = ExpectedInput.due_date.name context.query.message.edit_text( text=get_settings_text(context.poll), parse_mode='markdown', reply_markup=get_due_date_datepicker_keyboard(poll))
def pick_due_date(session, context, poll): """Add a date from the datepicker to the poll.""" if poll.current_date <= date.today(): return i18n.t('callback.due_date_in_past', locale=poll.user.locale) due_date = datetime.combine(poll.current_date, time(hour=12, minute=00)) if (due_date == poll.due_date): return poll.set_due_date(due_date) context.query.message.edit_text( text=get_settings_text(context.poll), parse_mode='markdown', reply_markup=get_due_date_datepicker_keyboard(poll))
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_due_date_datepicker(session, context, poll): """Open the datepicker for setting a due date.""" poll.user.expected_input = ExpectedInput.due_date.name keyboard = get_due_date_datepicker_keyboard(poll, date.today()) context.query.message.edit_reply_markup(reply_markup=keyboard)