diff --git a/files/assets/js/submit.js b/files/assets/js/submit.js index 30b52351b..b31153907 100644 --- a/files/assets/js/submit.js +++ b/files/assets/js/submit.js @@ -8,7 +8,7 @@ for (const id of save_value) { autoExpand(document.getElementById('post-text')) markdown(document.getElementById("post-text")); -const save_checked = ['post-notify', 'post-new', 'post-nsfw', 'post-private', 'post-effortpost', 'post-ghost'] +const save_checked = ['post-notify', 'post-new', 'post-nsfw', 'post-private', 'post-effortpost', 'post-ghost', 'post-cw'] for (const key of save_checked) { const value = localStorage.getItem(key) if (value) { diff --git a/files/classes/post.py b/files/classes/post.py index 98c8afc01..2af97907b 100644 --- a/files/classes/post.py +++ b/files/classes/post.py @@ -74,6 +74,9 @@ class Post(Base): else: nsfw = False + if SITE_NAME == 'WPD': + cw = Column(Boolean, default=False) + author = relationship("User", primaryjoin="Post.author_id==User.id") oauth_app = relationship("OauthApp") approved_by = relationship("User", uselist=False, primaryjoin="Post.is_approved==User.id") diff --git a/files/routes/posts.py b/files/routes/posts.py index 8272b73c5..6fdfe3c76 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -572,6 +572,8 @@ def submit_post(v, hole=None): ghost=flag_ghost, ) + if SITE_NAME == 'WPD': + p.cw = request.values.get("cw", False, bool) p.chudded = v.chud and hole != 'chudrama' and not (p.is_longpost and not v.chudded_by) p.queened = v.queen and not p.is_longpost diff --git a/files/templates/post.html b/files/templates/post.html index 43bc071ad..491de5d6d 100644 --- a/files/templates/post.html +++ b/files/templates/post.html @@ -92,7 +92,14 @@ {{macros.reports(p, 'post')}}

- {% if p.effortpost %}EFFORTPOST{% endif %} + {% if p.cw %} + CHILD WARNING + {% endif %} + + {% if p.effortpost %} + EFFORTPOST + {% endif %} + {% if p.realurl(v) and not v_forbid_deleted %} {% if p.flair %}{{p.flair | safe}}{% endif %} diff --git a/files/templates/post_listing.html b/files/templates/post_listing.html index 9b2ebdcf9..10fc61abc 100644 --- a/files/templates/post_listing.html +++ b/files/templates/post_listing.html @@ -91,7 +91,14 @@ {{macros.post_meta(p)}}
- {% if p.effortpost %}EFFORTPOST{% endif %} + {% if p.cw %} + CHILD WARNING + {% endif %} + + {% if p.effortpost %} + EFFORTPOST + {% endif %} + {% if p.flair %}{{p.flair | safe}}{% endif %} {{p.realtitle(v) | safe}} diff --git a/files/templates/submit.html b/files/templates/submit.html index b2adc6328..e028e0a30 100644 --- a/files/templates/submit.html +++ b/files/templates/submit.html @@ -81,6 +81,14 @@ {% endif %} + + {% if SITE_NAME == 'WPD' %} +
+ + +
+ {% endif %} +
diff --git a/migrations/20240212-add-cw.sql b/migrations/20240212-add-cw.sql new file mode 100644 index 000000000..b56c787c3 --- /dev/null +++ b/migrations/20240212-add-cw.sql @@ -0,0 +1,5 @@ +alter table posts add column cw bool default false not null; + +update posts set cw=true where title ilike '%[cw]%' or title ilike '%(cw)%' or title ilike '%child warning%'; + +alter table posts alter column cw drop default;