diff --git a/freak/__init__.py b/freak/__init__.py index fcac5d5..fbd6dc0 100644 --- a/freak/__init__.py +++ b/freak/__init__.py @@ -26,7 +26,7 @@ from suou import twocolon_list, WantsContentType from .colors import color_themes, theme_classes -__version__ = '0.5.0-dev50' +__version__ = '0.5.0-dev49' APP_BASE_DIR = os.path.dirname(os.path.dirname(__file__)) diff --git a/freak/rest/__init__.py b/freak/rest/__init__.py index fc1ded8..8354f6c 100644 --- a/freak/rest/__init__.py +++ b/freak/rest/__init__.py @@ -446,11 +446,7 @@ async def patch_settings_appearance(data: SettingsIn): @bp.get('/about/about') async def about_about(): return dict( - content=await render_template("about.md", - quart_version=quart_version, - sa_version=sa_version, - python_version=sys.version.split()[0] - ) + content=await render_template("about.md") ) @bp.get('/about/terms') diff --git a/freak/templates/admin/admin_report_detail.html b/freak/templates/admin/admin_report_detail.html index 6d14ea2..370134e 100644 --- a/freak/templates/admin/admin_report_detail.html +++ b/freak/templates/admin/admin_report_detail.html @@ -29,6 +29,6 @@ {% endif %} - + {% endblock %} diff --git a/freak/website/admin.py b/freak/website/admin.py index 5c4b155..61210e3 100644 --- a/freak/website/admin.py +++ b/freak/website/admin.py @@ -9,7 +9,6 @@ from quart import Blueprint, abort, redirect, render_template, request, send_fro from quart_auth import current_user from markupsafe import Markup from sqlalchemy import insert, select, update -from sqlalchemy.ext.asyncio import AsyncSession from suou import additem, not_implemented import logging @@ -98,54 +97,55 @@ def get_content(target) -> str | None: REPORT_ACTIONS = {} @additem(REPORT_ACTIONS, '1') -async def accept_report(target, source: PostReport, session: AsyncSession): - if source.is_critical(): - warnings.warn('attempted remove on a critical report case, striking instead', UserWarning) - return await strike_report(target, source) +async def accept_report(target, source: PostReport): + async with db as session: + if source.is_critical(): + warnings.warn('attempted remove on a critical report case, striking instead', UserWarning) + return await strike_report(target, source) - await remove_content(target, source.reason_code) + await remove_content(target, source.reason_code) - source.update_status = REPORT_UPDATE_COMPLETE - session.add(source) - await session.commit() + source.update_status = REPORT_UPDATE_COMPLETE + # XXX disabled because of a session conflict + #session.add(source) @additem(REPORT_ACTIONS, '2') -async def strike_report(target, source: PostReport, session: AsyncSession): - await remove_content(target, source.reason_code) +async def strike_report(target, source: PostReport): + async with db as session: + await remove_content(target, source.reason_code) - author = get_author(target) - if author: - await session.execute(insert(UserStrike).values( - user_id = author.id, - target_type = TARGET_TYPES[type(target)], - target_id = target.id, - target_content = get_content(target), - reason_code = source.reason_code, - issued_by_id = current_user.id - )) + author = get_author(target) + if author: + session.execute(insert(UserStrike).values( + user_id = author.id, + target_type = TARGET_TYPES[type(target)], + target_id = target.id, + target_content = get_content(target), + reason_code = source.reason_code, + issued_by_id = current_user.id + )) - if source.is_critical(): - author.banned_at = datetime.datetime.now() - author.banned_reason = source.reason_code + if source.is_critical(): + author.banned_at = datetime.datetime.now() + author.banned_reason = source.reason_code - source.update_status = REPORT_UPDATE_COMPLETE - session.add(source) - await session.commit() + source.update_status = REPORT_UPDATE_COMPLETE + #session.add(source) @additem(REPORT_ACTIONS, '0') -async def reject_report(target, source: PostReport, session: AsyncSession): - source.update_status = REPORT_UPDATE_REJECTED - session.add(source) - await session.commit() +async def reject_report(target, source: PostReport): + async with db as session: + source.update_status = REPORT_UPDATE_REJECTED + #session.add(source) @additem(REPORT_ACTIONS, '3') -async def withhold_report(target, source: PostReport, session: AsyncSession): - source.update_status = REPORT_UPDATE_ON_HOLD - session.add(source) - await session.commit() +async def withhold_report(target, source: PostReport): + async with db as session: + source.update_status = REPORT_UPDATE_ON_HOLD + #session.add(source) @additem(REPORT_ACTIONS, '4') @@ -184,10 +184,10 @@ async def report_detail(id: int): if request.method == 'POST': form = await get_request_form() action = REPORT_ACTIONS[form['do']] - await action(target, report, session) + await action(target, report) return redirect(url_for('admin.reports')) - return await render_template('admin/admin_report_detail.html', report=report, - report_reasons=REPORT_REASON_STRINGS) + return await render_template('admin/admin_report_detail.html', report=report, + report_reasons=REPORT_REASON_STRINGS) @bp.route('/admin/strikes/') @admin_required