add "child warning" to WPD

pull/222/head
Aevann 2024-02-12 20:56:36 +02:00
parent 1577ad5fbf
commit b4e290f820
7 changed files with 35 additions and 3 deletions

View File

@ -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) {

View File

@ -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")

View File

@ -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

View File

@ -92,7 +92,14 @@
{{macros.reports(p, 'post')}}
<h1 id="post-title" class="{{p.award_classes(v, True)}} card-title post-title text-left mb-md-3">
{% if p.effortpost %}<a href="/?effortposts_only=True" class="post-flair effortpost-flair font-weight-bolder mr-1">EFFORTPOST</a>{% endif %}
{% if p.cw %}
<span class="post-flair bg-danger font-weight-bolder mr-1">CHILD WARNING</span>
{% endif %}
{% if p.effortpost %}
<a href="/?effortposts_only=True" class="post-flair effortpost-flair font-weight-bolder mr-1">EFFORTPOST</a>
{% endif %}
{% if p.realurl(v) and not v_forbid_deleted %}
<a class="novisited" {% if not v or v.newtabexternal %}target="_blank"{% endif %} rel="noopener" href="{{p.realurl(v)}}">
{% if p.flair %}<span class="post-flair font-weight-bolder mr-1">{{p.flair | safe}}</span>{% endif %}

View File

@ -91,7 +91,14 @@
{{macros.post_meta(p)}}
</div>
<h5 class="card-title post-title text-left w-lg-95 pb-0 pb-md-1">
{% if p.effortpost %}<a href="/?effortposts_only=True" class="post-flair effortpost-flair font-weight-bolder mr-1">EFFORTPOST</a>{% endif %}
{% if p.cw %}
<span class="post-flair bg-danger font-weight-bolder mr-1">CHILD WARNING</span>
{% endif %}
{% if p.effortpost %}
<a href="/?effortposts_only=True" class="post-flair effortpost-flair font-weight-bolder mr-1">EFFORTPOST</a>
{% endif %}
<a id="{{p.id}}-title" {% if v and v.newtab %}data-target="t" target="_blank"{% endif %} href="{{p.permalink}}" class="{% if p.hole %}sub{% endif %} stretched-link {% if p.chudded %}text-uppercase{% endif %}">
{% if p.flair %}<span class="post-flair font-weight-bolder mr-1">{{p.flair | safe}}</span>{% endif %}
{{p.realtitle(v) | safe}}

View File

@ -81,6 +81,14 @@
<label class="custom-control-label" for="post-nsfw">NSFW</label>
</div>
{% endif %}
{% if SITE_NAME == 'WPD' %}
<div class="custom-control custom-checkbox">
<input autocomplete="off" type="checkbox" class="custom-control-input" id="post-cw" name="cw" data-nonce="{{g.nonce}}" data-onchange="savetext()">
<label class="custom-control-label" for="post-cw">Child Warning</label>
</div>
{% endif %}
<div class="custom-control custom-checkbox">
<input autocomplete="off" type="checkbox" class="custom-control-input" id="post-private" name="private" data-nonce="{{g.nonce}}" data-onchange="savetext()">
<label class="custom-control-label" for="post-private">Draft</label>

View File

@ -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;