Browse Source

add cmd to delete posts that are too shit

graphs-n-shit
lza_menace 10 months ago
parent
commit
2d4b503f36
  1. 2
      bin/cmd
  2. 13
      suchwow/app.py

2
bin/cmd

@ -4,4 +4,4 @@ source .venv/bin/activate
export FLASK_APP=suchwow/app.py
export FLASK_SECRETS=config.py
export FLASK_DEBUG=1
flask $1
flask $@

13
suchwow/app.py

@ -1,7 +1,8 @@
import json
import click
from datetime import datetime, timedelta
from random import choice
from os import makedirs
from os import makedirs, path, remove
from flask import Flask, request, session, redirect
from flask import render_template, flash, url_for
from flask_session import Session
@ -103,5 +104,15 @@ def payout_users():
sweep = wallet.sweep_all(account=post.account_index, dest_address=submitter.address)
print(sweep)
@app.cli.command("delete_post")
@click.argument("post_id")
def delete_post(post_id):
post = Post.get(id=post_id)
save_path_base = path.join(app.config["DATA_FOLDER"], "uploads")
save_path = path.join(save_path_base, post.image_name)
post.delete_instance()
remove(save_path)
print(f"Deleted post {post_id} and image {save_path}")
if __name__ == "__main__":
app.run()

Loading…
Cancel
Save