Compare commits
2 commits
76ca5a8319
...
f2b75bf731
| Author | SHA1 | Date | |
|---|---|---|---|
| f2b75bf731 | |||
| 005114efe2 |
4 changed files with 45 additions and 41 deletions
|
|
@ -26,7 +26,7 @@ from suou import twocolon_list, WantsContentType
|
||||||
|
|
||||||
from .colors import color_themes, theme_classes
|
from .colors import color_themes, theme_classes
|
||||||
|
|
||||||
__version__ = '0.5.0-dev49'
|
__version__ = '0.5.0-dev50'
|
||||||
|
|
||||||
APP_BASE_DIR = os.path.dirname(os.path.dirname(__file__))
|
APP_BASE_DIR = os.path.dirname(os.path.dirname(__file__))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -446,7 +446,11 @@ async def patch_settings_appearance(data: SettingsIn):
|
||||||
@bp.get('/about/about')
|
@bp.get('/about/about')
|
||||||
async def about_about():
|
async def about_about():
|
||||||
return dict(
|
return dict(
|
||||||
content=await render_template("about.md")
|
content=await render_template("about.md",
|
||||||
|
quart_version=quart_version,
|
||||||
|
sa_version=sa_version,
|
||||||
|
python_version=sys.version.split()[0]
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@bp.get('/about/terms')
|
@bp.get('/about/terms')
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,6 @@
|
||||||
<button type="submit" name="do" value="1" class="primary">Remove</button>
|
<button type="submit" name="do" value="1" class="primary">Remove</button>
|
||||||
<button type="submit" name="do" value="2">Strike</button>
|
<button type="submit" name="do" value="2">Strike</button>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<button type="submit" name="do" value="2">Put on hold</button>
|
<button type="submit" name="do" value="3">Put on hold</button>
|
||||||
</form>
|
</form>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ from quart import Blueprint, abort, redirect, render_template, request, send_fro
|
||||||
from quart_auth import current_user
|
from quart_auth import current_user
|
||||||
from markupsafe import Markup
|
from markupsafe import Markup
|
||||||
from sqlalchemy import insert, select, update
|
from sqlalchemy import insert, select, update
|
||||||
|
from sqlalchemy.ext.asyncio import AsyncSession
|
||||||
from suou import additem, not_implemented
|
from suou import additem, not_implemented
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
|
@ -97,8 +98,7 @@ def get_content(target) -> str | None:
|
||||||
REPORT_ACTIONS = {}
|
REPORT_ACTIONS = {}
|
||||||
|
|
||||||
@additem(REPORT_ACTIONS, '1')
|
@additem(REPORT_ACTIONS, '1')
|
||||||
async def accept_report(target, source: PostReport):
|
async def accept_report(target, source: PostReport, session: AsyncSession):
|
||||||
async with db as session:
|
|
||||||
if source.is_critical():
|
if source.is_critical():
|
||||||
warnings.warn('attempted remove on a critical report case, striking instead', UserWarning)
|
warnings.warn('attempted remove on a critical report case, striking instead', UserWarning)
|
||||||
return await strike_report(target, source)
|
return await strike_report(target, source)
|
||||||
|
|
@ -106,18 +106,17 @@ async def accept_report(target, source: PostReport):
|
||||||
await remove_content(target, source.reason_code)
|
await remove_content(target, source.reason_code)
|
||||||
|
|
||||||
source.update_status = REPORT_UPDATE_COMPLETE
|
source.update_status = REPORT_UPDATE_COMPLETE
|
||||||
# XXX disabled because of a session conflict
|
session.add(source)
|
||||||
#session.add(source)
|
await session.commit()
|
||||||
|
|
||||||
|
|
||||||
@additem(REPORT_ACTIONS, '2')
|
@additem(REPORT_ACTIONS, '2')
|
||||||
async def strike_report(target, source: PostReport):
|
async def strike_report(target, source: PostReport, session: AsyncSession):
|
||||||
async with db as session:
|
|
||||||
await remove_content(target, source.reason_code)
|
await remove_content(target, source.reason_code)
|
||||||
|
|
||||||
author = get_author(target)
|
author = get_author(target)
|
||||||
if author:
|
if author:
|
||||||
session.execute(insert(UserStrike).values(
|
await session.execute(insert(UserStrike).values(
|
||||||
user_id = author.id,
|
user_id = author.id,
|
||||||
target_type = TARGET_TYPES[type(target)],
|
target_type = TARGET_TYPES[type(target)],
|
||||||
target_id = target.id,
|
target_id = target.id,
|
||||||
|
|
@ -131,21 +130,22 @@ async def strike_report(target, source: PostReport):
|
||||||
author.banned_reason = source.reason_code
|
author.banned_reason = source.reason_code
|
||||||
|
|
||||||
source.update_status = REPORT_UPDATE_COMPLETE
|
source.update_status = REPORT_UPDATE_COMPLETE
|
||||||
#session.add(source)
|
session.add(source)
|
||||||
|
await session.commit()
|
||||||
|
|
||||||
|
|
||||||
@additem(REPORT_ACTIONS, '0')
|
@additem(REPORT_ACTIONS, '0')
|
||||||
async def reject_report(target, source: PostReport):
|
async def reject_report(target, source: PostReport, session: AsyncSession):
|
||||||
async with db as session:
|
|
||||||
source.update_status = REPORT_UPDATE_REJECTED
|
source.update_status = REPORT_UPDATE_REJECTED
|
||||||
#session.add(source)
|
session.add(source)
|
||||||
|
await session.commit()
|
||||||
|
|
||||||
|
|
||||||
@additem(REPORT_ACTIONS, '3')
|
@additem(REPORT_ACTIONS, '3')
|
||||||
async def withhold_report(target, source: PostReport):
|
async def withhold_report(target, source: PostReport, session: AsyncSession):
|
||||||
async with db as session:
|
|
||||||
source.update_status = REPORT_UPDATE_ON_HOLD
|
source.update_status = REPORT_UPDATE_ON_HOLD
|
||||||
#session.add(source)
|
session.add(source)
|
||||||
|
await session.commit()
|
||||||
|
|
||||||
|
|
||||||
@additem(REPORT_ACTIONS, '4')
|
@additem(REPORT_ACTIONS, '4')
|
||||||
|
|
@ -184,7 +184,7 @@ async def report_detail(id: int):
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
form = await get_request_form()
|
form = await get_request_form()
|
||||||
action = REPORT_ACTIONS[form['do']]
|
action = REPORT_ACTIONS[form['do']]
|
||||||
await action(target, report)
|
await action(target, report, session)
|
||||||
return redirect(url_for('admin.reports'))
|
return redirect(url_for('admin.reports'))
|
||||||
return await render_template('admin/admin_report_detail.html', report=report,
|
return await render_template('admin/admin_report_detail.html', report=report,
|
||||||
report_reasons=REPORT_REASON_STRINGS)
|
report_reasons=REPORT_REASON_STRINGS)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue