Exemplo n.º 1
0
def edit(id: int, site_url_setting_repository: ISiteUrlSettingRepository,
         bot_repository: IBotRepository):
    site_url_setting_service = SiteUrlSettingService(
        site_url_setting_repository)
    site_url_setting = site_url_setting_service.find_by_id(id)
    site = site_url_setting.site

    bot_service = BotService(bot_repository)
    bots = bot_service.get_bots()

    form = SiteUrlSettingForm()

    if request.method == 'POST':
        site_url_setting.url_pattern = request.form['url_pattern']
        site_url_setting.bot_id = request.form['bot_id']
        site_url_setting.enable_flag = 'enable_flag' in request.form and request.form[
            'enable_flag'] == 'true'

        if form.validate_on_submit():
            site_url_setting_service.edit(site_url_setting)
            return redirect('/admin/site')

    return render_template('admin/site_url_setting/input.html',
                           site=site,
                           site_url_setting=site_url_setting,
                           bots=bots,
                           form=form,
                           operation='編集')
Exemplo n.º 2
0
def index(bot_repository: IBotRepository):
    bot_service = BotService(bot_repository=bot_repository)
    bots = bot_service.get_bots()

    return render_template('admin/bot/index.html', bots=bots)