def edit_story(story_id):
    if request.method == 'GET':
        story = Story.get(Story.id == story_id)
        return render_template('form.html',
                               us_story=story,
                               header="Edit Story",
                               button="Update")
    else:
        edit_story = Story.update(
            story_title=request.form['story_title'],
            user_story=request.form['user_story'],
            acceptance_criteria=request.form['acceptance_criteria'],
            business_value=request.form['business_value'],
            estimation=request.form['estimation'],
            status=request.form['status']).where(Story.id == story_id)
        edit_story.execute()
        return redirect(url_for('show_stories'))
Exemplo n.º 2
0
async def callback_handler(callback: CallbackQuery):
    logger.debug(callback)

    data = json.loads(callback.data)
    story = Story.get(data['story_id'])

    chat_id = callback['message']['chat']['id']
    message_id = callback['message']['message_id']

    if data['action'] == 'reject':
        await bot.delete_message(chat_id, message_id)
        await callback.answer('Story has been deleted')

    elif data['action'] == 'schedule':
        story.schedule()
        keyboard = get_story_keyboard(story)
        await callback.answer(f'Story scheduled at {story.scheduled_datetime}')
        await bot.edit_message_reply_markup(chat_id,
                                            message_id=message_id,
                                            reply_markup=keyboard)
    elif data['action'] == 'switch_description':
        if callback.message.caption:
            caption = None
        else:
            caption = story.title

        keyboard = get_story_keyboard(story)
        await bot.edit_message_caption(chat_id,
                                       message_id=message_id,
                                       caption=caption,
                                       reply_markup=keyboard)
        if caption:
            await callback.answer('Description returned')
        else:
            await callback.answer('Description removed')

        story.caption = caption
        story.save()
Exemplo n.º 3
0
def edit(story_id):
    story = Story.get(Story.id == story_id)
    return render_template('form.html',
                           story=story,
                           header="Edit",
                           button="Update")
Exemplo n.º 4
0
def delete(id):
    row = Story.get(Story.id == id)
    row.delete_instance()
    return redirect(url_for('list'))
Exemplo n.º 5
0
def story(id):
    if Story.select().where(Story.id == id).exists():
        user_story = Story.get(Story.id == id)
    else:
        user_story = None
    return render_template("form.html", user_story=user_story)