diff --git a/files/assets/css/main.css b/files/assets/css/main.css index bde466c8e..2558b0464 100644 --- a/files/assets/css/main.css +++ b/files/assets/css/main.css @@ -4625,13 +4625,6 @@ span.green { .patron[style="background-color:#FFFFFF;"] { color: black !important; } -.post--category-tag { - padding: 2px 5px 3px 5px; - border-radius: 5px; - font-size: 12px; - font-weight: 700; - margin-right: 0.25rem; -} .container, .container-fluid { background-color: var(--background) !important; } @@ -5684,19 +5677,6 @@ g { border-radius:.35rem; } -.category--tag-button { - display: inline-block; - cursor: pointer; -} - -#submit-categories input { - display: none; -} - -#submit-categories input:checked + label { - border: 5px var(--black) double; -} - /* ------- Font Awesome ------- */ @font-face{ font-family:"Font Awesome 6 Pro"; @@ -6070,7 +6050,7 @@ g { } @media (max-width: 767.98px) { - .pronouns, .patron, .post--category-tag, .mod { + .pronouns, .patron, .mod { padding: 2px 5px !important; } } diff --git a/files/assets/js/category_modal.js b/files/assets/js/category_modal.js deleted file mode 100644 index b5d82acb5..000000000 --- a/files/assets/js/category_modal.js +++ /dev/null @@ -1,41 +0,0 @@ -function category_modal(id, title, sub) { - document.getElementById("category-modal-title").innerHTML = `Category: ${title}`; - - xhrCategories = new XMLHttpRequest(); - xhrCategories.open("GET", "/categories.json"); - xhrCategories.onload = function () { - let data; - try { - data = JSON.parse(xhrCategories.response); - } catch(e) { console.log(e) } - - categories = [{id: '', name: 'None', sub: sub, color_text: '#000', color_bg: '#FFF'}]; - categories = [].concat(categories, data[sub]); - - document.getElementById("category-modal-body").innerHTML = ''; - categories.forEach(function (c) { - document.getElementById("category-modal-body").innerHTML += - `
` + - `${c.name}` + - `
`; - }); - - document.querySelectorAll('.category--tag-button').forEach(tag => - tag.addEventListener('click', function (e) { - reqBody = new FormData(); - reqBody.append('formkey', formkey()); - reqBody.append('post_id', id); - reqBody.append('category_id', tag.dataset.category); - - xhrSubmit = new XMLHttpRequest(); - xhrSubmit.open('POST', `/post_recategorize`); - xhrSubmit.onload = function () { - window.location.reload(); - } - xhrSubmit.send(reqBody); - }) - ); - } - xhrCategories.send(); -} diff --git a/files/assets/js/submit.js b/files/assets/js/submit.js index e8845a091..ef0bc80b3 100644 --- a/files/assets/js/submit.js +++ b/files/assets/js/submit.js @@ -180,32 +180,6 @@ function checkRepost() { } } -function updateCategories() { - if (document.getElementById("submit-categories") == null) { - return; - } - sub = document.getElementById("sub").value; - - xhrCategories = new XMLHttpRequest(); - xhrCategories.open("GET", "/categories.json"); - xhrCategories.onload = function () { - let data; - try { - data = JSON.parse(xhrCategories.response); - } catch(e) { console.log(e) } - - document.getElementById("submit-categories").innerHTML = ''; - data[sub].forEach(function (c) { - document.getElementById("submit-categories").innerHTML += - `` + - ``; - }); - } - xhrCategories.send(); -} - document.addEventListener('keydown', (e) => { if(!((e.ctrlKey || e.metaKey) && e.key === "Enter")) return; @@ -215,5 +189,4 @@ document.addEventListener('keydown', (e) => { submitButton.click(); }); -checkRepost(); -updateCategories(); +checkRepost(); \ No newline at end of file diff --git a/files/classes/__init__.py b/files/classes/__init__.py index 887b1b8e1..7e8f93c05 100644 --- a/files/classes/__init__.py +++ b/files/classes/__init__.py @@ -8,7 +8,6 @@ from .badges import * from .userblock import * from .submission import * from .votes import * -from .category import * from .domains import * from .subscriptions import * from files.__main__ import app diff --git a/files/classes/category.py b/files/classes/category.py deleted file mode 100644 index c601bb125..000000000 --- a/files/classes/category.py +++ /dev/null @@ -1,31 +0,0 @@ -from sqlalchemy import * -from sqlalchemy.orm import relationship -from files.__main__ import Base -import time - -class Category(Base): - __tablename__ = "category" - - id = Column(Integer, primary_key=True, nullable=False) - name = Column(String(128), nullable=False) - sub = Column(String(20), ForeignKey("subs.name")) - color_text = Column(String(6)) - color_bg = Column(String(6)) - created_utc = Column(Integer) - - def __init__(self, *args, **kwargs): - if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time()) - super().__init__(*args, **kwargs) - - def __repr__(self): - return f"" - - def as_json(self): - data = { - 'id': self.id, - 'name': self.name, - 'sub': self.sub if self.sub else '', - 'color_text': '#' + self.color_text, - 'color_bg': '#' + self.color_bg, - } - return data diff --git a/files/classes/mod_logs.py b/files/classes/mod_logs.py index 5a7d93385..def124b88 100644 --- a/files/classes/mod_logs.py +++ b/files/classes/mod_logs.py @@ -314,11 +314,6 @@ ACTIONTYPES = { "icon": 'fa-thumbtack fa-rotate--45', "color": 'bg-success' }, - 'post_recategorize': { - "str": 'changed category of {self.target_link}', - "icon": 'fa-grid', - "color": 'bg-primary' - }, 'purge_cache': { "str": 'purged cache', "icon": 'fa-memory', diff --git a/files/classes/submission.py b/files/classes/submission.py index 656840254..b6d7dcc9e 100644 --- a/files/classes/submission.py +++ b/files/classes/submission.py @@ -53,7 +53,6 @@ class Submission(Base): body = Column(String) body_html = Column(String) flair = Column(String) - category_id = Column(Integer, ForeignKey("category.id")) ban_reason = Column(String) embed_url = Column(String) new = Column(Boolean) @@ -67,7 +66,6 @@ class Submission(Base): comments = relationship("Comment", primaryjoin="Comment.parent_submission==Submission.id", back_populates="post") subr = relationship("Sub", primaryjoin="foreign(Submission.sub)==remote(Sub.name)") options = relationship("SubmissionOption", order_by="SubmissionOption.id") - category = relationship("Category", primaryjoin="Submission.category_id==Category.id") bump_utc = deferred(Column(Integer, server_default=FetchedValue())) diff --git a/files/helpers/const.py b/files/helpers/const.py index 9a8427c35..4dafc7b7f 100644 --- a/files/helpers/const.py +++ b/files/helpers/const.py @@ -124,8 +124,6 @@ AGENDAPOSTER_MSG_HTML = """

Hi ") -@admin_level_required(PERMS['ADMIN_CATEGORIES_MANAGE']) -def admin_categories_update(v, cid): - if not FEATURES['CATEGORIES']: - abort(404) - - cat_name = request.values.get("name").strip() - cat_color_text = request.values.get("color_text").strip().strip('#').lower() - cat_color_bg = request.values.get("color_bg").strip().strip('#').lower() - - try: - cat_id = int(cid) - except: - abort(400) - - cat = g.db.query(Category).filter(Category.id == cat_id).one_or_none() - if not cat: - abort(400) - - cat.name = cat_name - cat.color_text = cat_color_text - cat.color_bg = cat_color_bg - - g.db.add(cat) - g.db.commit() - - return redirect("/admin/categories") - -@app.post("/admin/categories/delete/") -@admin_level_required(PERMS['ADMIN_CATEGORIES_MANAGE']) -def admin_categories_delete(v, cid): - if not FEATURES['CATEGORIES']: - abort(404) - - try: - cat_id = int(cid) - except: - abort(400) - - cat = g.db.query(Category).filter(Category.id == cat_id).one_or_none() - g.db.delete(cat) - g.db.commit() - - return redirect("/admin/categories") - @app.post("/admin/nuke_user") @limiter.limit("1/second;30/minute;200/hour;1000/day") @admin_level_required(2) diff --git a/files/routes/posts.py b/files/routes/posts.py index 5e75687cd..1ffa53943 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -709,14 +709,6 @@ def submit_post(v, sub=None): if not sub and HOLE_REQUIRED: return error(f"You must choose a {HOLE_NAME} for your post!") - category = None - if FEATURES['CATEGORIES']: - category_id = request.values.get('category', '') - try: - category = int(category_id) - except: - category = None - if v.is_suspended: return error("You can't perform this action while banned.") torture = (v.agendaposter and not v.marseyawarded and sub != 'chudrama') @@ -933,7 +925,6 @@ def submit_post(v, sub=None): title=title[:500], title_html=title_html, sub=sub, - category_id=category, ghost=ghost ) @@ -1168,42 +1159,6 @@ def toggle_post_nsfw(pid, v): if post.over_18: return {"message": "Post has been marked as +18!"} else: return {"message": "Post has been unmarked as +18!"} -@app.post("/post_recategorize") -@auth_required -def post_recategorize(v): - if not FEATURES['CATEGORIES']: - abort(404) - if v.admin_level < PERMS['ADMIN_CATEGORIES_CHANGE']: - abort(403) - - post_id = request.values.get("post_id") - category_id = request.values.get("category_id") - try: - pid = int(post_id) - cid = None - if category_id != '': - cid = int(category_id) - except: - abort(400) - - post = g.db.get(Submission, pid) - post.category_id = cid - g.db.add(post) - - category_new_name = '<none>' - if category_id != '': - category_new_name = g.db.get(Category, cid).name - ma = ModAction( - kind='post_recategorize', - user_id=v.id, - target_submission_id=post.id, - _note=category_new_name - ) - g.db.add(ma) - - g.db.commit() - return {"message": "Success!"} - @app.post("/save_post/") @limiter.limit("1/second;30/minute;200/hour;1000/day") @limiter.limit("1/second;30/minute;200/hour;1000/day", key_func=lambda:f'{SITE}-{session.get("lo_user")}') diff --git a/files/routes/static.py b/files/routes/static.py index adbe0e6fb..c050d098b 100644 --- a/files/routes/static.py +++ b/files/routes/static.py @@ -435,16 +435,4 @@ def knowledgebase(v, page): if not os.path.exists('files/templates/' + template_path): abort(404) - return render_template(template_path, v=v) - -@app.get("/categories.json") -def categories_json(): - categories = g.db.query(Category).all() - - data = {} - for c in categories: - sub = c.sub if c.sub else '' - sub_cats = (data[sub] if sub in data else []) + [c.as_json()] - data.update({sub: sub_cats}) - - return jsonify(data) + return render_template(template_path, v=v) \ No newline at end of file diff --git a/files/templates/admin/admin_home.html b/files/templates/admin/admin_home.html index c0466fd1c..5b22dc091 100644 --- a/files/templates/admin/admin_home.html +++ b/files/templates/admin/admin_home.html @@ -94,9 +94,6 @@

{% if v.admin_level > 2 %} diff --git a/files/templates/admin/categories.html b/files/templates/admin/categories.html deleted file mode 100644 index e279f581c..000000000 --- a/files/templates/admin/categories.html +++ /dev/null @@ -1,51 +0,0 @@ -{% extends "default.html" %} - -{% block title %} - Admin — Categories -{% endblock %} - -{% block content %} -
- - - - - - - - - - - - - {% for category in categories %} - - - - - - - - - - - - - - - - {% endfor %} - - - - - - - - - - - - -
Category{{ HOLE_NAME | capitalize }}NameText ColorBackground ColorActions 
{{help.submission_category_tag(category.name, category.color_text, category.color_bg)}}{{category.sub if category.sub else '—'|safe}}
-{% endblock %} diff --git a/files/templates/category_modal.html b/files/templates/category_modal.html deleted file mode 100644 index 85a91878b..000000000 --- a/files/templates/category_modal.html +++ /dev/null @@ -1,16 +0,0 @@ - - - diff --git a/files/templates/comments.html b/files/templates/comments.html index 1bb01ba3a..6ca262425 100644 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -756,9 +756,6 @@ {% include "emoji_modal.html" %} {% if v.admin_level > 1 %} {% include "ban_modal.html" %} - {% if FEATURES['CATEGORIES'] -%} - {% include "category_modal.html" %} - {%- endif %} {% endif %}