From 2e5ef31e697fbd01f7438c389edb40aac60839fc Mon Sep 17 00:00:00 2001 From: "B. Stack" Date: Sun, 13 Feb 2022 19:19:03 -0500 Subject: add redirects after delete, and simplify css calls --- pastebin.py | 12 ++++++++++-- static/small.css | 6 ------ static/style.css | 9 +++++++++ templates/layout.html | 2 +- 4 files changed, 20 insertions(+), 9 deletions(-) delete mode 100644 static/small.css diff --git a/pastebin.py b/pastebin.py index 4c529f9..3851d01 100644 --- a/pastebin.py +++ b/pastebin.py @@ -48,6 +48,13 @@ def url_for_other_page(page): app.jinja_env.globals['url_for_other_page'] = url_for_other_page app.jinja_env.globals['appname'] = app.config['APPNAME'] +def refresh_string(delay,url): + """ + Returns a string for html content for redirecting the user back after the + requested delay, to the requested url. + """ + return f'' + @app.before_request def check_user_status(): g.user = None @@ -148,9 +155,10 @@ def delete_paste(paste_id): try: Paste.query.filter(Paste.id == paste.id).delete() db.session.commit() - return "OK",200 # WORKHERE: make this and the 500 redirect to admin/ + message = refresh_string(1, url_for("admin")) + "OK" + return message,200 except: - return "failure to delete object.",500 + return f"failure to delete object. Select here to return to the admin panel.",500 def get_all_pastes(): """ diff --git a/static/small.css b/static/small.css deleted file mode 100644 index 7bba2a3..0000000 --- a/static/small.css +++ /dev/null @@ -1,6 +0,0 @@ -pre { - font-size: 14px; - line-height: 1.6em; -} - -.page { margin: 20px auto; width: 100%; } diff --git a/static/style.css b/static/style.css index 1fc54ce..4507323 100644 --- a/static/style.css +++ b/static/style.css @@ -22,3 +22,12 @@ textarea { border: none; width: 780px; } .pagination strong, .pagination span.ellipsis, .pagination a { border: 1px solid #d00; padding: 2px 6px; text-decoration: none; } + +/* trying to simplify the requests for style.css and small.css */ +@media only screen and (max-width: 800px) { + pre { + font-size: 14px; + line-height: 1.6em; + } + .page { margin: 20px auto; width: 100%; } +} diff --git a/templates/layout.html b/templates/layout.html index fc2d8e5..3c6d8ab 100644 --- a/templates/layout.html +++ b/templates/layout.html @@ -5,7 +5,7 @@ - +{##}