make chud effects not retroactive

pull/157/head
Aevann 2023-06-23 16:14:23 +03:00
parent 31748db667
commit e607c39d67
9 changed files with 21 additions and 7 deletions

View File

@ -137,6 +137,7 @@ class Comment(Base):
slots_result = Column(String) slots_result = Column(String)
blackjack_result = Column(String) blackjack_result = Column(String)
casino_game_id = Column(Integer, ForeignKey("casino_games.id")) casino_game_id = Column(Integer, ForeignKey("casino_games.id"))
chudded = Column(Boolean, default=False)
oauth_app = relationship("OauthApp") oauth_app = relationship("OauthApp")
post = relationship("Post", back_populates="comments") post = relationship("Post", back_populates="comments")

View File

@ -59,6 +59,7 @@ class Post(Base):
embed = Column(String) embed = Column(String)
new = Column(Boolean) new = Column(Boolean)
notify = Column(Boolean) notify = Column(Boolean)
chudded = Column(Boolean, default=False)
author = relationship("User", primaryjoin="Post.author_id==User.id") author = relationship("User", primaryjoin="Post.author_id==User.id")
oauth_app = relationship("OauthApp") oauth_app = relationship("OauthApp")

View File

@ -729,6 +729,7 @@ def torture_object(obj, torture_method):
def complies_with_chud(obj): def complies_with_chud(obj):
#check for cases where u should leave #check for cases where u should leave
if not obj.chudded: return True
if not (obj.author.chud or obj.author.queen): return True if not (obj.author.chud or obj.author.queen): return True
if obj.author.marseyawarded: return True if obj.author.marseyawarded: return True
if isinstance(obj, Post): if isinstance(obj, Post):

View File

@ -264,6 +264,8 @@ def comment(v:User):
is_bot = v.client is not None and v.id not in PRIVILEGED_USER_BOTS is_bot = v.client is not None and v.id not in PRIVILEGED_USER_BOTS
chudded = v.chud and not (posting_to_submission and post_target.sub == 'chudrama')
c = Comment(author_id=v.id, c = Comment(author_id=v.id,
parent_submission=post_target.id if posting_to_submission else None, parent_submission=post_target.id if posting_to_submission else None,
wall_user_id=post_target.id if not posting_to_submission else None, wall_user_id=post_target.id if not posting_to_submission else None,
@ -275,6 +277,7 @@ def comment(v:User):
body_html=body_html, body_html=body_html,
body=body, body=body,
ghost=ghost, ghost=ghost,
chudded=chudded,
) )
c.upvotes = 1 c.upvotes = 1

View File

@ -596,6 +596,8 @@ def submit_post(v:User, sub=None):
if url == '': url = None if url == '': url = None
flag_chudded = v.chud and sub != 'chudrama'
p = Post( p = Post(
private=flag_private, private=flag_private,
notify=flag_notify, notify=flag_notify,
@ -611,7 +613,8 @@ def submit_post(v:User, sub=None):
title=title, title=title,
title_html=title_html, title_html=title_html,
sub=sub, sub=sub,
ghost=flag_ghost ghost=flag_ghost,
chudded=flag_chudded,
) )
g.db.add(p) g.db.add(p)

View File

@ -242,7 +242,7 @@
{% endif %} {% endif %}
{% set realbody = c.realbody(v) %} {% set realbody = c.realbody(v) %}
<div id="comment-text-{{c.id}}" class="comment-text mb-0 {% if c.author.chud and not (c.parent_submission and c.post.sub == 'chudrama') %}text-uppercase chud-img chud-{{c.id_last_num}}{% endif %} {% if c.author.rainbow %}rainbow-text{% endif %} {%if c.author.queen%}queen{%endif%}"> <div id="comment-text-{{c.id}}" class="comment-text mb-0 {% if c.chudded %}text-uppercase chud-img chud-{{c.id_last_num}}{% endif %} {% if c.author.rainbow %}rainbow-text{% endif %} {%if c.author.queen%}queen{%endif%}">
{{realbody | safe}} {{realbody | safe}}
</div> </div>
{% if c.parent_submission or c.wall_user_id %} {% if c.parent_submission or c.wall_user_id %}

View File

@ -80,14 +80,14 @@
{{macros.flags(p, 'post')}} {{macros.flags(p, 'post')}}
{% if p.realurl(v) and not v_forbid_deleted %} {% if p.realurl(v) and not v_forbid_deleted %}
<h1 id="post-title" class="card-title post-title text-left mb-md-3 {% if p.author.chud and p.sub != 'chudrama' %}text-uppercase{% endif %}"> <h1 id="post-title" class="card-title post-title text-left mb-md-3 {% if p.chudded %}text-uppercase{% endif %}">
<a {% if p.author.rainbow %}class="rainbow-text"{% endif %} {%if p.author.queen%}queen{%endif%} {% if not v or v.newtabexternal %}target="_blank"{% endif %} rel="nofollow noopener" href="{{p.realurl(v)}}"> <a {% if p.author.rainbow %}class="rainbow-text"{% endif %} {%if p.author.queen%}queen{%endif%} {% if not v or v.newtabexternal %}target="_blank"{% endif %} rel="nofollow noopener" href="{{p.realurl(v)}}">
{% if p.flair %}<span class="patron font-weight-bolder mr-1" style="background-color:var(--primary); font-size:12px; line-height:2;">{{p.flair | safe}}</span>{% endif %} {% if p.flair %}<span class="patron font-weight-bolder mr-1" style="background-color:var(--primary); font-size:12px; line-height:2;">{{p.flair | safe}}</span>{% endif %}
{{p.realtitle(v) | safe}} {{p.realtitle(v) | safe}}
</a> </a>
</h1> </h1>
{% else %} {% else %}
<h1 id="post-title" class="card-title post-title text-left mb-md-3 {% if p.author.chud and p.sub != 'chudrama' %}text-uppercase{% endif %} {% if p.author.rainbow %}rainbow-text{% endif %} {%if p.author.queen%}queen{%endif%}"> <h1 id="post-title" class="card-title post-title text-left mb-md-3 {% if p.chudded %}text-uppercase{% endif %} {% if p.author.rainbow %}rainbow-text{% endif %} {%if p.author.queen%}queen{%endif%}">
{% if p.flair %}<span class="patron font-weight-bolder mr-1" style="background-color:var(--primary); font-size:12px; line-height:2;">{{p.flair | safe}}</span>{% endif %} {% if p.flair %}<span class="patron font-weight-bolder mr-1" style="background-color:var(--primary); font-size:12px; line-height:2;">{{p.flair | safe}}</span>{% endif %}
{{p.realtitle(v) | safe}} {{p.realtitle(v) | safe}}
</h1> </h1>
@ -117,7 +117,7 @@
{% endif %} {% endif %}
<div id="post-text" class="{% if p.author.chud and p.sub != 'chudrama' %}text-uppercase chud-img chud-{{p.id_last_num}}{% endif %} {% if p.author.rainbow %}rainbow-text{% endif %} {%if p.author.queen%}queen{%endif%}"> <div id="post-text" class="{% if p.chudded %}text-uppercase chud-img chud-{{p.id_last_num}}{% endif %} {% if p.author.rainbow %}rainbow-text{% endif %} {%if p.author.queen%}queen{%endif%}">
{% if p.is_image %} {% if p.is_image %}
<div class="row no-gutters mb-4"> <div class="row no-gutters mb-4">
<div class="col"> <div class="col">

View File

@ -96,7 +96,7 @@
{{ macros.post_meta(p) }} {{ macros.post_meta(p) }}
</div> </div>
<h5 class="card-title post-title text-left w-lg-95 pb-0 pb-md-1"> <h5 class="card-title post-title text-left w-lg-95 pb-0 pb-md-1">
<a id="{{p.id}}-title" {% if v and v.newtab %}data-target="t" target="_blank"{% endif %} href="{{p.permalink}}" class="{% if p.sub %}sub{% endif %} stretched-link {% if p.author.chud and p.sub != 'chudrama' %}text-uppercase{% endif %}"> <a id="{{p.id}}-title" {% if v and v.newtab %}data-target="t" target="_blank"{% endif %} href="{{p.permalink}}" class="{% if p.sub %}sub{% endif %} stretched-link {% if p.chudded %}text-uppercase{% endif %}">
{% if p.flair %}<span class="patron font-weight-bolder mr-1" style="background-color:var(--primary); font-size:12px; line-height:2;">{{p.flair | safe}}</span>{% endif %} {% if p.flair %}<span class="patron font-weight-bolder mr-1" style="background-color:var(--primary); font-size:12px; line-height:2;">{{p.flair | safe}}</span>{% endif %}
{{p.realtitle(v) | safe}} {{p.realtitle(v) | safe}}
</a></h5> </a></h5>
@ -208,7 +208,7 @@
{% if not v_forbid_deleted %} {% if not v_forbid_deleted %}
{% if p.realbody(v, listing=True) %} {% if p.realbody(v, listing=True) %}
<div class="d-none card rounded border {% if p.author.chud and p.sub != 'chudrama' %}text-uppercase chud-img chud-{{p.id_last_num}}{% endif %} {% if p.author.rainbow %}rainbow-text{% endif %} {%if p.author.queen%}queen{%endif%} post-preview" id="post-text-{{p.id}}"> <div class="d-none card rounded border {% if p.chudded %}text-uppercase chud-img chud-{{p.id_last_num}}{% endif %} {% if p.author.rainbow %}rainbow-text{% endif %} {%if p.author.queen%}queen{%endif%} post-preview" id="post-text-{{p.id}}">
{{p.realbody(v, listing=True) | safe}} {{p.realbody(v, listing=True) | safe}}
</div> </div>
{% endif %} {% endif %}

View File

@ -0,0 +1,5 @@
alter table posts add column chudded bool default false;
alter table comments add column chudded bool default false;
alter table posts alter column chudded drop default;
alter table comments alter column chudded drop default;