rDrama/files/routes/static.py

490 lines
17 KiB
Python
Raw Normal View History

2022-05-18 19:29:07 +00:00
import os
[DO NOT MERGE] import detanglation (#442) * move Base definition to files.classes.__init__.py * fix ImportError * move userpage listing to users.py * don't import the app from classes * consts: set default values to avoid crashes consts: warn if the secret key is the default config value * card view: sneed (user db schema) * cloudflare: use DEFAULT_CONFIG_VALUE * const: set default values * decouple media.py from __main__ * pass database to avoid imports * import cleanup and import request not in const, but in the requests mega import * move asset_submissions site check to __init__ * asset submissions feature flag * flag * g.is_tor * don't import request where it's not needed * i think this is fine * mail: move to own routes and helper * wrappers * required wrappers move * unfuck wrappers a bit * move snappy quotes and marseys to stateful consts * marsify * :pepodrool: * fix missing import * import cache * ...and settings.py * and static.py * static needs cache * route * lmao all of the jinja shit was in feeds.py amazing * classes should only import what they need from flask * import Response * hdjbjdhbhjf * ... * dfdfdfdf * make get a non-required import * isort imports (mostly) * but actually * configs * reload config on import * fgfgfgfg * config * config * initialize snappy and test * cookie of doom debug * edfjnkf * xikscdfd * debug config * set session cookie domain, i think this fixes the can't login bug * sdfbgnhvfdsghbnjfbdvvfghnn * hrsfxgf * dump the entire config on a request * kyskyskyskyskyskyskyskyskys * duifhdskfjdfd * dfdfdfdfdfdfdfdfdfdfdfdf * dfdfdfdf * imoprt all of the consts beacuse fuck it * 😭 * dfdfdfdfdfdfsdasdf * print the entire session * rffdfdfjkfksj * fgbhffh * not the secret keys * minor bug fixes * be helpful in the warning * gfgfgfg * move warning lower * isort main imports (i hope this doesn't fuck something up) * test * session cookie domain redux * dfdfdfd * try only importing Flask * formkeys fix * y * :pepodrool: * route helper * remove before flight * dfdfdfdfdf * isort classes * isort helpers * move check_for_alts to routehelpers and also sort imports and get rid of unused ones * that previous commit but actkally * readd the cache in a dozen places they were implicitly imported * use g.is_tor instead of request.headers. bla bla bla * upgrade streamers to their own route file * get rid of unused imports in __main__ * fgfgf * don't pull in the entire ORM where we don't need it * features * explicit imports for the get helper * explicit imports for the get helper redux * testing allroutes * remove unused import * decouple flask from classes * syntax fix also remember these have side fx for some reason (why?) * move side effects out of the class * posts * testing on devrama * settings * reloading * settingssdsdsds * streamer features * site settings * testing settings on devrama * import * fix modlog * remove debug stuff * revert commit 67275b21ab6e2f2520819e84d10bfc1c746a15b6 * archiveorg to _archiveorg * skhudkfkjfd * fix cron for PCM * fix bugs that snekky wants me to * Fix call to realbody passing db, standardize kwarg * test * import check_for_alts from the right place * cloudflare * testing on devrama * fix cron i think * shadow properly * tasks * Remove print which will surely be annoying in prod. * v and create new session * use files.classes * make errors import little and fix rare 500 in /allow_nsfw * Revert "use files.classes" This reverts commit 98c10b876cf86ce058b7fb955cf1ec0bfb9996c6. * pass v to media functions rather than using g * fix * dfdfdfdfd * cleanup, py type checking is dumb so don't use it where it causes issues * Fix some merge bugs, add DEFAULT_RATELIMIT to main. * Fix imports on sqlalchemy expressions. * `from random import random` is an error. * Fix replies db param. * errors: fix missing import * fix rare 500: only send to GIFT_NOTIF_ID if it exists, and send them the right text * Fix signup formkey. * fix 2 500s * propagate db to submissions * fix replies * dfdfdfdf * Fix verifiedcolor. * is_manual * can't use getters outside of an app context * don't attempt to do gumroad on sites where it's not enabled * don't attempt to do gumraod on sites's where it's unnecessary * Revert "don't attempt to do gumroad on sites where it's not enabled" This reverts commit 6f8a6331878655492dfaf1907b27f8be513c14d3. * fix 500 * validate media type Co-authored-by: TLSM <duolsm@outlook.com>
2022-11-15 09:19:08 +00:00
from shutil import copyfile
from sqlalchemy import func, text
2023-03-06 19:32:08 +00:00
from files.helpers.media import *
[DO NOT MERGE] import detanglation (#442) * move Base definition to files.classes.__init__.py * fix ImportError * move userpage listing to users.py * don't import the app from classes * consts: set default values to avoid crashes consts: warn if the secret key is the default config value * card view: sneed (user db schema) * cloudflare: use DEFAULT_CONFIG_VALUE * const: set default values * decouple media.py from __main__ * pass database to avoid imports * import cleanup and import request not in const, but in the requests mega import * move asset_submissions site check to __init__ * asset submissions feature flag * flag * g.is_tor * don't import request where it's not needed * i think this is fine * mail: move to own routes and helper * wrappers * required wrappers move * unfuck wrappers a bit * move snappy quotes and marseys to stateful consts * marsify * :pepodrool: * fix missing import * import cache * ...and settings.py * and static.py * static needs cache * route * lmao all of the jinja shit was in feeds.py amazing * classes should only import what they need from flask * import Response * hdjbjdhbhjf * ... * dfdfdfdf * make get a non-required import * isort imports (mostly) * but actually * configs * reload config on import * fgfgfgfg * config * config * initialize snappy and test * cookie of doom debug * edfjnkf * xikscdfd * debug config * set session cookie domain, i think this fixes the can't login bug * sdfbgnhvfdsghbnjfbdvvfghnn * hrsfxgf * dump the entire config on a request * kyskyskyskyskyskyskyskyskys * duifhdskfjdfd * dfdfdfdfdfdfdfdfdfdfdfdf * dfdfdfdf * imoprt all of the consts beacuse fuck it * 😭 * dfdfdfdfdfdfsdasdf * print the entire session * rffdfdfjkfksj * fgbhffh * not the secret keys * minor bug fixes * be helpful in the warning * gfgfgfg * move warning lower * isort main imports (i hope this doesn't fuck something up) * test * session cookie domain redux * dfdfdfd * try only importing Flask * formkeys fix * y * :pepodrool: * route helper * remove before flight * dfdfdfdfdf * isort classes * isort helpers * move check_for_alts to routehelpers and also sort imports and get rid of unused ones * that previous commit but actkally * readd the cache in a dozen places they were implicitly imported * use g.is_tor instead of request.headers. bla bla bla * upgrade streamers to their own route file * get rid of unused imports in __main__ * fgfgf * don't pull in the entire ORM where we don't need it * features * explicit imports for the get helper * explicit imports for the get helper redux * testing allroutes * remove unused import * decouple flask from classes * syntax fix also remember these have side fx for some reason (why?) * move side effects out of the class * posts * testing on devrama * settings * reloading * settingssdsdsds * streamer features * site settings * testing settings on devrama * import * fix modlog * remove debug stuff * revert commit 67275b21ab6e2f2520819e84d10bfc1c746a15b6 * archiveorg to _archiveorg * skhudkfkjfd * fix cron for PCM * fix bugs that snekky wants me to * Fix call to realbody passing db, standardize kwarg * test * import check_for_alts from the right place * cloudflare * testing on devrama * fix cron i think * shadow properly * tasks * Remove print which will surely be annoying in prod. * v and create new session * use files.classes * make errors import little and fix rare 500 in /allow_nsfw * Revert "use files.classes" This reverts commit 98c10b876cf86ce058b7fb955cf1ec0bfb9996c6. * pass v to media functions rather than using g * fix * dfdfdfdfd * cleanup, py type checking is dumb so don't use it where it causes issues * Fix some merge bugs, add DEFAULT_RATELIMIT to main. * Fix imports on sqlalchemy expressions. * `from random import random` is an error. * Fix replies db param. * errors: fix missing import * fix rare 500: only send to GIFT_NOTIF_ID if it exists, and send them the right text * Fix signup formkey. * fix 2 500s * propagate db to submissions * fix replies * dfdfdfdf * Fix verifiedcolor. * is_manual * can't use getters outside of an app context * don't attempt to do gumroad on sites where it's not enabled * don't attempt to do gumraod on sites's where it's unnecessary * Revert "don't attempt to do gumroad on sites where it's not enabled" This reverts commit 6f8a6331878655492dfaf1907b27f8be513c14d3. * fix 500 * validate media type Co-authored-by: TLSM <duolsm@outlook.com>
2022-11-15 09:19:08 +00:00
import files.helpers.stats as statshelper
[DO NOT MERGE] import detanglation (#442) * move Base definition to files.classes.__init__.py * fix ImportError * move userpage listing to users.py * don't import the app from classes * consts: set default values to avoid crashes consts: warn if the secret key is the default config value * card view: sneed (user db schema) * cloudflare: use DEFAULT_CONFIG_VALUE * const: set default values * decouple media.py from __main__ * pass database to avoid imports * import cleanup and import request not in const, but in the requests mega import * move asset_submissions site check to __init__ * asset submissions feature flag * flag * g.is_tor * don't import request where it's not needed * i think this is fine * mail: move to own routes and helper * wrappers * required wrappers move * unfuck wrappers a bit * move snappy quotes and marseys to stateful consts * marsify * :pepodrool: * fix missing import * import cache * ...and settings.py * and static.py * static needs cache * route * lmao all of the jinja shit was in feeds.py amazing * classes should only import what they need from flask * import Response * hdjbjdhbhjf * ... * dfdfdfdf * make get a non-required import * isort imports (mostly) * but actually * configs * reload config on import * fgfgfgfg * config * config * initialize snappy and test * cookie of doom debug * edfjnkf * xikscdfd * debug config * set session cookie domain, i think this fixes the can't login bug * sdfbgnhvfdsghbnjfbdvvfghnn * hrsfxgf * dump the entire config on a request * kyskyskyskyskyskyskyskyskys * duifhdskfjdfd * dfdfdfdfdfdfdfdfdfdfdfdf * dfdfdfdf * imoprt all of the consts beacuse fuck it * 😭 * dfdfdfdfdfdfsdasdf * print the entire session * rffdfdfjkfksj * fgbhffh * not the secret keys * minor bug fixes * be helpful in the warning * gfgfgfg * move warning lower * isort main imports (i hope this doesn't fuck something up) * test * session cookie domain redux * dfdfdfd * try only importing Flask * formkeys fix * y * :pepodrool: * route helper * remove before flight * dfdfdfdfdf * isort classes * isort helpers * move check_for_alts to routehelpers and also sort imports and get rid of unused ones * that previous commit but actkally * readd the cache in a dozen places they were implicitly imported * use g.is_tor instead of request.headers. bla bla bla * upgrade streamers to their own route file * get rid of unused imports in __main__ * fgfgf * don't pull in the entire ORM where we don't need it * features * explicit imports for the get helper * explicit imports for the get helper redux * testing allroutes * remove unused import * decouple flask from classes * syntax fix also remember these have side fx for some reason (why?) * move side effects out of the class * posts * testing on devrama * settings * reloading * settingssdsdsds * streamer features * site settings * testing settings on devrama * import * fix modlog * remove debug stuff * revert commit 67275b21ab6e2f2520819e84d10bfc1c746a15b6 * archiveorg to _archiveorg * skhudkfkjfd * fix cron for PCM * fix bugs that snekky wants me to * Fix call to realbody passing db, standardize kwarg * test * import check_for_alts from the right place * cloudflare * testing on devrama * fix cron i think * shadow properly * tasks * Remove print which will surely be annoying in prod. * v and create new session * use files.classes * make errors import little and fix rare 500 in /allow_nsfw * Revert "use files.classes" This reverts commit 98c10b876cf86ce058b7fb955cf1ec0bfb9996c6. * pass v to media functions rather than using g * fix * dfdfdfdfd * cleanup, py type checking is dumb so don't use it where it causes issues * Fix some merge bugs, add DEFAULT_RATELIMIT to main. * Fix imports on sqlalchemy expressions. * `from random import random` is an error. * Fix replies db param. * errors: fix missing import * fix rare 500: only send to GIFT_NOTIF_ID if it exists, and send them the right text * Fix signup formkey. * fix 2 500s * propagate db to submissions * fix replies * dfdfdfdf * Fix verifiedcolor. * is_manual * can't use getters outside of an app context * don't attempt to do gumroad on sites where it's not enabled * don't attempt to do gumraod on sites's where it's unnecessary * Revert "don't attempt to do gumroad on sites where it's not enabled" This reverts commit 6f8a6331878655492dfaf1907b27f8be513c14d3. * fix 500 * validate media type Co-authored-by: TLSM <duolsm@outlook.com>
2022-11-15 09:19:08 +00:00
from files.classes.award import AWARDS
from files.classes.badges import Badge, BadgeDef
from files.classes.mod_logs import ModAction
[DO NOT MERGE] import detanglation (#442) * move Base definition to files.classes.__init__.py * fix ImportError * move userpage listing to users.py * don't import the app from classes * consts: set default values to avoid crashes consts: warn if the secret key is the default config value * card view: sneed (user db schema) * cloudflare: use DEFAULT_CONFIG_VALUE * const: set default values * decouple media.py from __main__ * pass database to avoid imports * import cleanup and import request not in const, but in the requests mega import * move asset_submissions site check to __init__ * asset submissions feature flag * flag * g.is_tor * don't import request where it's not needed * i think this is fine * mail: move to own routes and helper * wrappers * required wrappers move * unfuck wrappers a bit * move snappy quotes and marseys to stateful consts * marsify * :pepodrool: * fix missing import * import cache * ...and settings.py * and static.py * static needs cache * route * lmao all of the jinja shit was in feeds.py amazing * classes should only import what they need from flask * import Response * hdjbjdhbhjf * ... * dfdfdfdf * make get a non-required import * isort imports (mostly) * but actually * configs * reload config on import * fgfgfgfg * config * config * initialize snappy and test * cookie of doom debug * edfjnkf * xikscdfd * debug config * set session cookie domain, i think this fixes the can't login bug * sdfbgnhvfdsghbnjfbdvvfghnn * hrsfxgf * dump the entire config on a request * kyskyskyskyskyskyskyskyskys * duifhdskfjdfd * dfdfdfdfdfdfdfdfdfdfdfdf * dfdfdfdf * imoprt all of the consts beacuse fuck it * 😭 * dfdfdfdfdfdfsdasdf * print the entire session * rffdfdfjkfksj * fgbhffh * not the secret keys * minor bug fixes * be helpful in the warning * gfgfgfg * move warning lower * isort main imports (i hope this doesn't fuck something up) * test * session cookie domain redux * dfdfdfd * try only importing Flask * formkeys fix * y * :pepodrool: * route helper * remove before flight * dfdfdfdfdf * isort classes * isort helpers * move check_for_alts to routehelpers and also sort imports and get rid of unused ones * that previous commit but actkally * readd the cache in a dozen places they were implicitly imported * use g.is_tor instead of request.headers. bla bla bla * upgrade streamers to their own route file * get rid of unused imports in __main__ * fgfgf * don't pull in the entire ORM where we don't need it * features * explicit imports for the get helper * explicit imports for the get helper redux * testing allroutes * remove unused import * decouple flask from classes * syntax fix also remember these have side fx for some reason (why?) * move side effects out of the class * posts * testing on devrama * settings * reloading * settingssdsdsds * streamer features * site settings * testing settings on devrama * import * fix modlog * remove debug stuff * revert commit 67275b21ab6e2f2520819e84d10bfc1c746a15b6 * archiveorg to _archiveorg * skhudkfkjfd * fix cron for PCM * fix bugs that snekky wants me to * Fix call to realbody passing db, standardize kwarg * test * import check_for_alts from the right place * cloudflare * testing on devrama * fix cron i think * shadow properly * tasks * Remove print which will surely be annoying in prod. * v and create new session * use files.classes * make errors import little and fix rare 500 in /allow_nsfw * Revert "use files.classes" This reverts commit 98c10b876cf86ce058b7fb955cf1ec0bfb9996c6. * pass v to media functions rather than using g * fix * dfdfdfdfd * cleanup, py type checking is dumb so don't use it where it causes issues * Fix some merge bugs, add DEFAULT_RATELIMIT to main. * Fix imports on sqlalchemy expressions. * `from random import random` is an error. * Fix replies db param. * errors: fix missing import * fix rare 500: only send to GIFT_NOTIF_ID if it exists, and send them the right text * Fix signup formkey. * fix 2 500s * propagate db to submissions * fix replies * dfdfdfdf * Fix verifiedcolor. * is_manual * can't use getters outside of an app context * don't attempt to do gumroad on sites where it's not enabled * don't attempt to do gumraod on sites's where it's unnecessary * Revert "don't attempt to do gumroad on sites where it's not enabled" This reverts commit 6f8a6331878655492dfaf1907b27f8be513c14d3. * fix 500 * validate media type Co-authored-by: TLSM <duolsm@outlook.com>
2022-11-15 09:19:08 +00:00
from files.classes.userblock import UserBlock
2023-09-07 09:15:22 +00:00
from files.classes.usermute import UserMute
[DO NOT MERGE] import detanglation (#442) * move Base definition to files.classes.__init__.py * fix ImportError * move userpage listing to users.py * don't import the app from classes * consts: set default values to avoid crashes consts: warn if the secret key is the default config value * card view: sneed (user db schema) * cloudflare: use DEFAULT_CONFIG_VALUE * const: set default values * decouple media.py from __main__ * pass database to avoid imports * import cleanup and import request not in const, but in the requests mega import * move asset_submissions site check to __init__ * asset submissions feature flag * flag * g.is_tor * don't import request where it's not needed * i think this is fine * mail: move to own routes and helper * wrappers * required wrappers move * unfuck wrappers a bit * move snappy quotes and marseys to stateful consts * marsify * :pepodrool: * fix missing import * import cache * ...and settings.py * and static.py * static needs cache * route * lmao all of the jinja shit was in feeds.py amazing * classes should only import what they need from flask * import Response * hdjbjdhbhjf * ... * dfdfdfdf * make get a non-required import * isort imports (mostly) * but actually * configs * reload config on import * fgfgfgfg * config * config * initialize snappy and test * cookie of doom debug * edfjnkf * xikscdfd * debug config * set session cookie domain, i think this fixes the can't login bug * sdfbgnhvfdsghbnjfbdvvfghnn * hrsfxgf * dump the entire config on a request * kyskyskyskyskyskyskyskyskys * duifhdskfjdfd * dfdfdfdfdfdfdfdfdfdfdfdf * dfdfdfdf * imoprt all of the consts beacuse fuck it * 😭 * dfdfdfdfdfdfsdasdf * print the entire session * rffdfdfjkfksj * fgbhffh * not the secret keys * minor bug fixes * be helpful in the warning * gfgfgfg * move warning lower * isort main imports (i hope this doesn't fuck something up) * test * session cookie domain redux * dfdfdfd * try only importing Flask * formkeys fix * y * :pepodrool: * route helper * remove before flight * dfdfdfdfdf * isort classes * isort helpers * move check_for_alts to routehelpers and also sort imports and get rid of unused ones * that previous commit but actkally * readd the cache in a dozen places they were implicitly imported * use g.is_tor instead of request.headers. bla bla bla * upgrade streamers to their own route file * get rid of unused imports in __main__ * fgfgf * don't pull in the entire ORM where we don't need it * features * explicit imports for the get helper * explicit imports for the get helper redux * testing allroutes * remove unused import * decouple flask from classes * syntax fix also remember these have side fx for some reason (why?) * move side effects out of the class * posts * testing on devrama * settings * reloading * settingssdsdsds * streamer features * site settings * testing settings on devrama * import * fix modlog * remove debug stuff * revert commit 67275b21ab6e2f2520819e84d10bfc1c746a15b6 * archiveorg to _archiveorg * skhudkfkjfd * fix cron for PCM * fix bugs that snekky wants me to * Fix call to realbody passing db, standardize kwarg * test * import check_for_alts from the right place * cloudflare * testing on devrama * fix cron i think * shadow properly * tasks * Remove print which will surely be annoying in prod. * v and create new session * use files.classes * make errors import little and fix rare 500 in /allow_nsfw * Revert "use files.classes" This reverts commit 98c10b876cf86ce058b7fb955cf1ec0bfb9996c6. * pass v to media functions rather than using g * fix * dfdfdfdfd * cleanup, py type checking is dumb so don't use it where it causes issues * Fix some merge bugs, add DEFAULT_RATELIMIT to main. * Fix imports on sqlalchemy expressions. * `from random import random` is an error. * Fix replies db param. * errors: fix missing import * fix rare 500: only send to GIFT_NOTIF_ID if it exists, and send them the right text * Fix signup formkey. * fix 2 500s * propagate db to submissions * fix replies * dfdfdfdf * Fix verifiedcolor. * is_manual * can't use getters outside of an app context * don't attempt to do gumroad on sites where it's not enabled * don't attempt to do gumraod on sites's where it's unnecessary * Revert "don't attempt to do gumroad on sites where it's not enabled" This reverts commit 6f8a6331878655492dfaf1907b27f8be513c14d3. * fix 500 * validate media type Co-authored-by: TLSM <duolsm@outlook.com>
2022-11-15 09:19:08 +00:00
from files.helpers.actions import *
from files.helpers.alerts import *
from files.helpers.config.const import *
2023-01-25 16:06:27 +00:00
from files.helpers.config.modaction_types import *
[DO NOT MERGE] import detanglation (#442) * move Base definition to files.classes.__init__.py * fix ImportError * move userpage listing to users.py * don't import the app from classes * consts: set default values to avoid crashes consts: warn if the secret key is the default config value * card view: sneed (user db schema) * cloudflare: use DEFAULT_CONFIG_VALUE * const: set default values * decouple media.py from __main__ * pass database to avoid imports * import cleanup and import request not in const, but in the requests mega import * move asset_submissions site check to __init__ * asset submissions feature flag * flag * g.is_tor * don't import request where it's not needed * i think this is fine * mail: move to own routes and helper * wrappers * required wrappers move * unfuck wrappers a bit * move snappy quotes and marseys to stateful consts * marsify * :pepodrool: * fix missing import * import cache * ...and settings.py * and static.py * static needs cache * route * lmao all of the jinja shit was in feeds.py amazing * classes should only import what they need from flask * import Response * hdjbjdhbhjf * ... * dfdfdfdf * make get a non-required import * isort imports (mostly) * but actually * configs * reload config on import * fgfgfgfg * config * config * initialize snappy and test * cookie of doom debug * edfjnkf * xikscdfd * debug config * set session cookie domain, i think this fixes the can't login bug * sdfbgnhvfdsghbnjfbdvvfghnn * hrsfxgf * dump the entire config on a request * kyskyskyskyskyskyskyskyskys * duifhdskfjdfd * dfdfdfdfdfdfdfdfdfdfdfdf * dfdfdfdf * imoprt all of the consts beacuse fuck it * 😭 * dfdfdfdfdfdfsdasdf * print the entire session * rffdfdfjkfksj * fgbhffh * not the secret keys * minor bug fixes * be helpful in the warning * gfgfgfg * move warning lower * isort main imports (i hope this doesn't fuck something up) * test * session cookie domain redux * dfdfdfd * try only importing Flask * formkeys fix * y * :pepodrool: * route helper * remove before flight * dfdfdfdfdf * isort classes * isort helpers * move check_for_alts to routehelpers and also sort imports and get rid of unused ones * that previous commit but actkally * readd the cache in a dozen places they were implicitly imported * use g.is_tor instead of request.headers. bla bla bla * upgrade streamers to their own route file * get rid of unused imports in __main__ * fgfgf * don't pull in the entire ORM where we don't need it * features * explicit imports for the get helper * explicit imports for the get helper redux * testing allroutes * remove unused import * decouple flask from classes * syntax fix also remember these have side fx for some reason (why?) * move side effects out of the class * posts * testing on devrama * settings * reloading * settingssdsdsds * streamer features * site settings * testing settings on devrama * import * fix modlog * remove debug stuff * revert commit 67275b21ab6e2f2520819e84d10bfc1c746a15b6 * archiveorg to _archiveorg * skhudkfkjfd * fix cron for PCM * fix bugs that snekky wants me to * Fix call to realbody passing db, standardize kwarg * test * import check_for_alts from the right place * cloudflare * testing on devrama * fix cron i think * shadow properly * tasks * Remove print which will surely be annoying in prod. * v and create new session * use files.classes * make errors import little and fix rare 500 in /allow_nsfw * Revert "use files.classes" This reverts commit 98c10b876cf86ce058b7fb955cf1ec0bfb9996c6. * pass v to media functions rather than using g * fix * dfdfdfdfd * cleanup, py type checking is dumb so don't use it where it causes issues * Fix some merge bugs, add DEFAULT_RATELIMIT to main. * Fix imports on sqlalchemy expressions. * `from random import random` is an error. * Fix replies db param. * errors: fix missing import * fix rare 500: only send to GIFT_NOTIF_ID if it exists, and send them the right text * Fix signup formkey. * fix 2 500s * propagate db to submissions * fix replies * dfdfdfdf * Fix verifiedcolor. * is_manual * can't use getters outside of an app context * don't attempt to do gumroad on sites where it's not enabled * don't attempt to do gumraod on sites's where it's unnecessary * Revert "don't attempt to do gumroad on sites where it's not enabled" This reverts commit 6f8a6331878655492dfaf1907b27f8be513c14d3. * fix 500 * validate media type Co-authored-by: TLSM <duolsm@outlook.com>
2022-11-15 09:19:08 +00:00
from files.routes.wrappers import *
from files.__main__ import app, cache, limiter
2022-05-04 23:09:46 +00:00
@app.get("/r/drama/comments/<int:id>/<title>")
@app.get("/r/Drama/comments/<int:id>/<title>")
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400)
2022-05-04 23:09:46 +00:00
def rdrama(id, title):
id = ''.join(f'{x}/' for x in id)
return redirect(f'/archives/drama/comments/{id}{title}.html')
2022-11-28 22:12:39 +00:00
@app.get("/r/<subreddit>")
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400)
2022-11-28 22:12:39 +00:00
@auth_desired
def subreddit(subreddit, v):
reddit = v.reddit if v else "old.reddit.com"
return redirect(f'https://{reddit}/r/{subreddit}')
2022-05-04 23:09:46 +00:00
@app.get("/reddit/<subreddit>/comments/<path:path>")
@app.get("/r/<subreddit>/comments/<path:path>")
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400)
@auth_desired
def reddit_post(subreddit, v, path):
post_id = path.rsplit("/", 1)[0].replace('/', '')
reddit = v.reddit if v else "old.reddit.com"
return redirect(f'https://{reddit}/{post_id}')
2023-10-26 15:38:22 +00:00
@app.get("/marseys")
@app.get("/emojis")
def marseys_redirect():
2024-02-03 03:29:53 +00:00
return redirect("/emojis/marsey")
2023-10-26 15:38:22 +00:00
@cache.cached(make_cache_key=lambda kind, nsfw:f"emoji_list_{kind}_{nsfw}", timeout=86400)
2023-10-05 10:19:50 +00:00
def get_emoji_list(kind, nsfw):
2023-10-26 15:44:34 +00:00
emojis = g.db.query(Emoji).filter(Emoji.submitter_id == None, Emoji.kind == kind)
2023-10-05 10:19:50 +00:00
if not nsfw:
2023-10-26 15:44:34 +00:00
emojis = emojis.filter(Emoji.nsfw == False)
2023-10-26 20:50:35 +00:00
emojis = emojis.order_by(Emoji.count.desc()).all()
2023-07-04 21:40:00 +00:00
return emojis
2023-08-05 11:13:59 +00:00
@app.get("/emojis/<kind>")
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400)
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400, key_func=get_ID)
2023-07-04 21:40:00 +00:00
@auth_required
2023-08-05 11:13:59 +00:00
def emoji_list(v, kind):
2024-02-02 23:02:53 +00:00
kind = kind.title()
2023-10-05 10:19:50 +00:00
emojis = get_emoji_list(kind, g.show_nsfw)
2023-07-04 21:40:00 +00:00
authors = get_accounts_dict([e.author_id for e in emojis], v=v, graceful=True)
2023-07-05 16:22:40 +00:00
2023-10-24 19:04:40 +00:00
if FEATURES['EMOJI_SUBMISSIONS']:
2023-07-05 16:22:40 +00:00
original = os.listdir("/asset_submissions/emojis/original")
for emoji in emojis:
emoji.user = authors.get(emoji.author_id)
for x in IMAGE_FORMATS:
if f'{emoji.name}.{x}' in original:
emoji.og = f'{emoji.name}.{x}'
break
else:
for emoji in emojis:
emoji.user = authors.get(emoji.author_id)
2023-08-05 13:52:53 +00:00
emojis_hash = cache.get('emojis_hash') or ''
2024-02-03 02:11:13 +00:00
return render_template("emojis.html", v=v, emojis=emojis, kind=kind.lower(), emojis_hash=emojis_hash)
2022-05-04 23:09:46 +00:00
@cache.cached(make_cache_key=lambda nsfw:f"emojis_{nsfw}", timeout=86400)
2023-10-05 10:19:50 +00:00
def get_emojis(nsfw):
emojis = g.db.query(Emoji, User).join(User, Emoji.author_id == User.id).options(load_only(
User.id,
User.username,
User.original_username,
2023-11-25 21:57:15 +00:00
User.extra_username,
User.prelock_username,
)).filter(Emoji.submitter_id == None)
2023-10-05 10:19:50 +00:00
if not nsfw:
emojis = emojis.filter(Emoji.nsfw == False)
emojis1 = emojis.filter(Emoji.kind != 'Marsey Alphabet').order_by(Emoji.count.desc()).all()
emojis2 = emojis.filter(Emoji.kind == 'Marsey Alphabet').order_by(func.length(Emoji.name), Emoji.name).all()
emojis = emojis1 + emojis2
collected = []
for emoji, author in emojis:
if author.id == 2:
if SITE == 'rdrama.net':
emoji.author_username = 'a WPD user'
else:
emoji.author_username = 'an rDrama user'
else:
emoji.author_username = author.username
emoji.author_original_username = author.original_username
2023-11-25 21:57:15 +00:00
emoji.author_extra_username = author.extra_username
emoji.author_prelock_username = author.prelock_username
collected.append(emoji.json())
return collected
2022-05-04 23:09:46 +00:00
2023-10-27 09:22:44 +00:00
@app.get("/emojis.csv")
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400)
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400, key_func=get_ID)
@auth_required
2024-03-07 16:24:38 +00:00
def emojis_csv(v):
2023-10-27 12:01:50 +00:00
show_nsfw = request.values.get('show_nsfw') == 'True'
return get_emojis(show_nsfw)
2024-03-06 00:11:35 +00:00
@app.get("/groups.csv")
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400)
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400, key_func=get_ID)
@auth_required
2024-03-07 16:24:38 +00:00
def groups_csv(v):
2024-03-06 00:11:35 +00:00
return [x[0] for x in g.db.query(Group.name).order_by(Group.name).all()]
2024-03-07 16:24:38 +00:00
@app.get("/users.csv")
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400)
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400, key_func=get_ID)
@auth_required
def users_csv(v):
2024-03-07 17:05:07 +00:00
users = g.db.query(User.username)
if SITE == 'watchpeopledie.tv':
2024-03-07 17:40:45 +00:00
users = users.filter(User.truescore > 100)
2024-03-07 17:05:07 +00:00
if SITE == 'rdrama.net':
t = time.time() - 604800
users = users.filter(or_(User.truescore > 10, User.last_active > t))
2024-03-07 17:05:07 +00:00
return [x[0] for x in users.order_by(User.truescore.desc()).all()]
2024-03-07 16:24:38 +00:00
2022-05-04 23:09:46 +00:00
@app.get('/sidebar')
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400)
@auth_desired
2023-07-30 00:42:06 +00:00
def sidebar(v):
2022-05-04 23:09:46 +00:00
return render_template('sidebar.html', v=v)
2022-12-20 00:42:39 +00:00
@app.get("/stats")
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400)
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400, key_func=get_ID)
2022-12-20 00:42:39 +00:00
@auth_required
2023-07-30 00:42:06 +00:00
def participation_stats(v):
2024-01-23 13:59:17 +00:00
stats = cache.get('stats')
if not stats:
2024-01-23 14:04:30 +00:00
stats = statshelper.stats()
cache.set('stats', stats, timeout=172800)
2022-12-20 02:26:23 +00:00
if v.client: return stats
2024-01-23 14:06:29 +00:00
return render_template("stats.html", v=v, title="Statistics", stats=stats)
2022-05-04 23:09:46 +00:00
@app.get("/chart")
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400)
2022-05-04 23:09:46 +00:00
def chart():
return redirect('/weekly_chart')
2024-01-23 12:20:51 +00:00
@app.get("/weekly_chart.webp")
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400)
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400, key_func=get_ID)
2022-05-04 23:09:46 +00:00
@auth_required
2023-07-30 00:42:06 +00:00
def weekly_chart(v):
return send_file(statshelper.chart_path(kind="weekly", site=SITE))
2022-05-04 23:09:46 +00:00
2024-01-23 12:20:51 +00:00
@app.get("/daily_chart.webp")
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400)
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400, key_func=get_ID)
2022-05-04 23:09:46 +00:00
@auth_required
2023-07-30 00:42:06 +00:00
def daily_chart(v):
return send_file(statshelper.chart_path(kind="daily", site=SITE))
2022-05-04 23:09:46 +00:00
2023-05-03 14:45:14 +00:00
@app.get("/admin/patrons")
@app.get("/admin/paypigs")
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400)
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400, key_func=get_ID)
2022-10-06 05:48:55 +00:00
@admin_level_required(PERMS['VIEW_PATRONS'])
2022-05-04 23:09:46 +00:00
def patrons(v):
2024-03-21 22:24:54 +00:00
if AEVANN_ID and v.id != AEVANN_ID:
abort(404)
2023-05-11 14:22:00 +00:00
ids = [x[0] for x in g.db.query(User.id).filter(User.lifetimedonated > 0).order_by(User.email, User.truescore.desc()).distinct(User.email)]
users = g.db.query(User).filter(User.id.in_(ids)).order_by(User.patron.desc(), User.truescore.desc()).all()
2022-05-04 23:09:46 +00:00
2023-01-22 08:04:49 +00:00
return render_template("admin/patrons.html", v=v, users=users, benefactor_def=AWARDS['benefactor'])
2022-05-04 23:09:46 +00:00
@app.get("/admins")
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400)
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400, key_func=get_ID)
2022-05-04 23:09:46 +00:00
@auth_required
2023-07-30 00:42:06 +00:00
def admins(v):
2023-04-15 02:42:39 +00:00
admins = g.db.query(User).filter(User.admin_level >= PERMS['ADMIN_MOP_VISIBLE']).order_by(User.admin_level.desc(), User.truescore.desc()).all()
2022-05-04 23:09:46 +00:00
return render_template("admins.html", v=v, admins=admins)
@app.get("/log")
@app.get("/modlog")
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400)
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400, key_func=get_ID)
2022-05-04 23:09:46 +00:00
@auth_required
2023-07-30 00:42:06 +00:00
def log(v):
2022-05-04 23:09:46 +00:00
2023-05-05 05:23:59 +00:00
page = get_page()
2022-05-04 23:09:46 +00:00
admin = request.values.get("admin")
2023-09-15 23:48:33 +00:00
if admin: admin_id = get_user(admin, attributes=[User.id]).id
2022-05-04 23:09:46 +00:00
else: admin_id = 0
kind = request.values.get("kind")
2024-01-12 07:20:32 +00:00
if v.admin_level >= PERMS['USER_SHADOWBAN']:
2023-03-25 23:29:55 +00:00
if v.admin_level >= PERMS['PROGSTACK']:
2023-01-26 05:45:38 +00:00
types = MODACTION_TYPES
else:
types = MODACTION_TYPES__FILTERED
else: types = MODACTION_TYPES_FILTERED
2022-05-04 23:09:46 +00:00
if kind and kind not in types:
kind = None
actions = []
total = 0
else:
2023-03-16 06:27:58 +00:00
actions = g.db.query(ModAction)
2024-01-12 07:20:32 +00:00
if v.admin_level < PERMS['USER_SHADOWBAN']:
actions = actions.filter(ModAction.kind.notin_(MODACTION_PRIVILEGED_TYPES))
2023-03-25 23:29:55 +00:00
if v.admin_level < PERMS['PROGSTACK']:
2023-01-25 16:52:16 +00:00
actions = actions.filter(ModAction.kind.notin_(MODACTION_PRIVILEGED__TYPES))
if admin_id:
actions = actions.filter_by(user_id=admin_id)
kinds = set(x.kind for x in actions)
kinds.add(kind)
types2 = {}
for k,val in types.items():
if k in kinds: types2[k] = val
types = types2
if kind: actions = actions.filter_by(kind=kind)
total = actions.count()
2023-05-05 00:54:55 +00:00
actions = actions.order_by(ModAction.id.desc()).offset(PAGE_SIZE*(page-1)).limit(PAGE_SIZE).all()
2023-08-11 13:15:34 +00:00
admins = [x[0] for x in g.db.query(User.username).filter(User.admin_level >= PERMS['ADMIN_MOP_VISIBLE']).order_by(User.username)]
2022-05-04 23:09:46 +00:00
return render_template("log.html", v=v, admins=admins, types=types, admin=admin, type=kind, actions=actions, total=total, page=page, single_user_url='admin')
2022-05-04 23:09:46 +00:00
@app.get("/log/<int:id>")
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400)
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400, key_func=get_ID)
2022-05-04 23:09:46 +00:00
@auth_required
def log_item(id, v):
2023-08-23 21:57:39 +00:00
action = g.db.get(ModAction, id)
2022-05-04 23:09:46 +00:00
if not action: abort(404)
2024-01-12 07:20:32 +00:00
if action.kind in MODACTION_PRIVILEGED_TYPES and v.admin_level < PERMS['USER_SHADOWBAN']:
2023-03-25 23:30:21 +00:00
abort(404)
2023-08-11 13:15:34 +00:00
admins = [x[0] for x in g.db.query(User.username).filter(User.admin_level >= PERMS['ADMIN_MOP_VISIBLE'])]
2022-05-04 23:09:46 +00:00
2024-01-12 07:20:32 +00:00
if v.admin_level >= PERMS['USER_SHADOWBAN']:
2023-03-25 23:29:55 +00:00
if v.admin_level >= PERMS['PROGSTACK']:
2023-01-26 05:45:38 +00:00
types = MODACTION_TYPES
else:
types = MODACTION_TYPES__FILTERED
else: types = MODACTION_TYPES_FILTERED
2022-05-04 23:09:46 +00:00
return render_template("log.html", v=v, actions=[action], total=1, page=1, action=action, admins=admins, types=types, single_user_url='admin')
2022-05-04 23:09:46 +00:00
@app.get("/directory")
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400)
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400, key_func=get_ID)
@auth_required
2023-08-05 13:46:47 +00:00
def directory(v):
2023-08-05 13:52:53 +00:00
return render_template("directory.html", v=v)
2022-05-04 23:09:46 +00:00
2022-11-26 21:04:39 +00:00
@app.get("/api")
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400)
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400, key_func=get_ID)
2022-11-26 21:04:39 +00:00
@auth_required
def api(v):
return render_template("api.html", v=v)
2022-05-04 23:09:46 +00:00
@app.get("/contact")
2022-09-09 09:13:50 +00:00
@app.get("/contactus")
@app.get("/contact_us")
2022-05-04 23:09:46 +00:00
@app.get("/press")
@app.get("/media")
@app.get("/admin/chat")
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400)
@auth_desired
2023-07-30 00:42:06 +00:00
def contact(v):
2023-08-11 21:50:23 +00:00
return render_template("contact.html", v=v)
2022-05-04 23:09:46 +00:00
2023-01-29 09:23:15 +00:00
@app.post("/contact")
2023-02-27 05:33:45 +00:00
@limiter.limit('1/second', scope=rpath)
@limiter.limit('1/second', scope=rpath, key_func=get_ID)
@limiter.limit("1/minute;10/day", deduct_when=lambda response: response.status_code < 400)
@limiter.limit("1/minute;10/day", deduct_when=lambda response: response.status_code < 400, key_func=get_ID)
2022-05-04 23:09:46 +00:00
@auth_required
def submit_contact(v):
body = request.values.get("message")
if not body: abort(400)
if v.is_muted:
abort(403, "You are muted!")
2023-02-26 12:08:37 +00:00
body = process_files(request.files, v, body)
body = body.strip()
body_html = sanitize(body)
2022-05-04 23:09:46 +00:00
2022-11-14 03:48:52 +00:00
execute_antispam_duplicate_comment_check(v, body_html)
2022-11-13 02:48:33 +00:00
2022-05-04 23:09:46 +00:00
new_comment = Comment(author_id=v.id,
parent_post=None,
2022-09-04 23:15:37 +00:00
level=1,
2023-02-24 06:53:40 +00:00
body=body,
2022-09-04 23:15:37 +00:00
body_html=body_html,
sentto=MODMAIL_ID
2022-09-04 23:15:37 +00:00
)
2023-03-16 06:27:58 +00:00
g.db.add(new_comment)
g.db.flush()
2022-11-14 02:43:26 +00:00
execute_blackjack(v, new_comment, new_comment.body_html, 'modmail')
2022-11-30 17:37:35 +00:00
execute_under_siege(v, new_comment, new_comment.body_html, 'modmail')
2022-05-04 23:09:46 +00:00
new_comment.top_comment_id = new_comment.id
2023-01-01 11:36:20 +00:00
2023-08-11 21:50:23 +00:00
return {"message": "Your message has been sent to the admins!"}
2022-05-04 23:09:46 +00:00
2024-02-21 21:14:35 +00:00
@app.get("/badges")
@feature_required('BADGES')
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400)
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400, key_func=get_ID)
@auth_required
def badges(v):
badges = g.db.query(BadgeDef)
2024-02-21 21:14:35 +00:00
if v.admin_level < PERMS['VIEW_PATRONS']:
badges = badges.filter(BadgeDef.id.notin_(PATRON_BADGES))
2023-07-03 00:26:20 +00:00
badges = badges.order_by(BadgeDef.id).all()
2023-03-16 06:27:58 +00:00
counts_raw = g.db.query(Badge.badge_id, func.count()).group_by(Badge.badge_id).all()
users = g.db.query(User).count()
2022-05-04 23:09:46 +00:00
counts = {}
for c in counts_raw:
counts[c[0]] = (c[1], float(c[1]) * 100 / max(users, 1))
2023-01-01 11:36:20 +00:00
2022-05-04 23:09:46 +00:00
return render_template("badges.html", v=v, badges=badges, counts=counts)
@app.get("/blocks")
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400)
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400, key_func=get_ID)
@auth_required
def blocks(v):
2024-02-02 21:49:01 +00:00
sort = request.values.get("sort")
page = get_page()
blocks = g.db.query(UserBlock).options(
joinedload(UserBlock.user),
joinedload(UserBlock.target),
2024-02-02 21:49:01 +00:00
)
total = blocks.count()
if sort == "user":
key = text('users_1_username')
2024-02-02 21:49:01 +00:00
elif sort == "target":
key = text('users_2_username')
2024-02-02 21:49:01 +00:00
else:
sort = "time"
key = UserBlock.created_utc.desc()
blocks = blocks.order_by(key).offset(PAGE_SIZE * (page - 1)).limit(PAGE_SIZE)
2024-02-02 21:49:01 +00:00
return render_template("blocks.html", v=v, blocks=blocks, sort=sort, total=total, page=page)
2023-09-07 09:15:22 +00:00
@app.get("/notification_mutes")
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400)
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400, key_func=get_ID)
2023-09-05 12:30:16 +00:00
@auth_required
2023-09-07 09:15:22 +00:00
def mutes(v):
mutes = g.db.query(UserMute).options(
joinedload(UserMute.user),
joinedload(UserMute.target),
).order_by(UserMute.created_utc.desc())
2023-09-07 09:15:22 +00:00
return render_template("notification_mutes.html", v=v, mutes=mutes)
2022-05-04 23:09:46 +00:00
@app.get("/formatting")
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400)
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400, key_func=get_ID)
2022-05-04 23:09:46 +00:00
@auth_required
2023-07-30 00:42:06 +00:00
def formatting(v):
2024-02-12 16:19:05 +00:00
return render_template("formatting.html", v=v, allowed_tags=allowed_tags, allowed_css_properties=allowed_css_properties)
2022-05-04 23:09:46 +00:00
@app.get("/app")
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400)
@auth_desired
2023-07-30 00:42:06 +00:00
def mobile_app(v):
return render_template("app.html", v=v)
2022-05-04 23:09:46 +00:00
@app.post("/dismiss_mobile_tip")
2023-02-27 05:33:45 +00:00
@limiter.limit('1/second', scope=rpath)
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400)
2022-05-04 23:09:46 +00:00
def dismiss_mobile_tip():
session["tooltip_dismissed"] = int(time.time())
2023-10-10 19:34:38 +00:00
return ""
@app.get("/transfers/<int:id>")
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400)
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400, key_func=get_ID)
@auth_required
def transfers_id(id, v):
2023-03-16 06:27:58 +00:00
transfer = g.db.get(Comment, id)
if not transfer: abort(404)
return render_template("transfers.html", v=v, page=1, comments=[transfer], standalone=True, total=1)
@app.get("/transfers")
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400)
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400, key_func=get_ID)
@auth_required
2023-07-30 00:42:06 +00:00
def transfers(v):
2024-02-11 11:24:43 +00:00
comments = g.db.query(Comment).filter(
Comment.author_id == AUTOJANNY_ID,
Comment.parent_post == None,
Comment.body_html.like("%</a> has transferred %"),
)
2023-05-05 05:23:59 +00:00
page = get_page()
total = comments.count()
comments = comments.order_by(Comment.id.desc()).offset(PAGE_SIZE * (page - 1)).limit(PAGE_SIZE).all()
if v.client:
return {"data": [x.json for x in comments]}
else:
return render_template("transfers.html", v=v, page=page, comments=comments, standalone=True, total=total)
2022-09-19 23:59:24 +00:00
@app.get('/donate')
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400)
@auth_desired
2022-09-19 23:59:24 +00:00
def donate(v):
2023-03-05 10:17:05 +00:00
return render_template(f'donate.html', v=v)
2023-09-24 22:12:42 +00:00
@app.get("/orgy")
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400)
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400, key_func=get_ID)
@auth_required
def orgy(v):
return redirect("/chat")
@app.get("/sidebar_images")
@app.get("/banners")
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400)
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400, key_func=get_ID)
@auth_required
def view_art(v):
if request.path == '/sidebar_images':
location_kind = 'sidebar'
title = "Sidebar Images"
else:
location_kind = 'banners'
title = "Banners"
urls = os.listdir(f'files/assets/images/{SITE_NAME}/{location_kind}')
2024-03-05 22:13:28 +00:00
urls = sorted(urls, key=lambda x: int(x.split('.webp')[0]), reverse=True)
urls = [f"{SITE_FULL_IMAGES}/i/{SITE_NAME}/{location_kind}/{x}" for x in urls]
return render_template(f'view_art.html', v=v, urls=urls, title=title)