remotes/1693045480750635534/spooky-22
Aevann1 2021-09-12 01:40:58 +02:00
parent 6eed6d5f60
commit 4caff1ab4b
9 changed files with 89 additions and 71 deletions

View File

@ -262,48 +262,6 @@ ACTIONTYPES={
"color": "bg-muted",
"title": 'un-pinned post {self.target_post.title}'
},
"invite_mod":{
"str":'invited admin {self.target_link}',
"icon":"fa-user-crown",
"color": "bg-info",
"title": 'invited admin @{self.target_user.username}'
},
"uninvite_mod":{
"str":'rescinded admin invitation to {self.target_link}',
"icon":"fa-user-crown",
"color": "bg-muted",
"title": 'rescinded admin invitation to @{self.target_user.username}'
},
"accept_mod_invite":{
"str":'accepted admin invitation',
"icon":"fa-user-crown",
"color": "bg-warning",
"title": 'accepted admin invitation'
},
"remove_mod":{
"str":'removed admin {self.target_link}',
"icon":"fa-user-crown",
"color": "bg-danger",
"title": 'removed admin @{self.target_user.username}'
},
"add_mod":{
"str":'added admin {self.target_link}',
"icon":"fa-user-crown",
"color": "bg-success",
"title": 'added admin @{self.target_user.username}'
},
"update_settings":{
"str":'updated setting',
"icon":"fa-cog",
"color": "bg-info",
"title": 'updated settings'
},
"update_appearance":{
"str":'updated appearance',
"icon":"fa-palette",
"color": "bg-info",
"title": 'updated appearance'
},
"set_nsfw":{
"str":'set nsfw on post {self.target_link}',
"icon":"fa-eye-evil",
@ -340,6 +298,18 @@ ACTIONTYPES={
"color": "bg-muted",
"title": "reinstated post {self.target_post.title}"
},
"club":{
"str": 'marked post {self.target_link} as viewable to users with +150 coins only',
"icon":"fa-eye-slash",
"color": "bg-danger",
"title": 'marked post {self.target_post} as viewable to users with +150 coins only'
},
"unclub":{
"str": 'unmarked post {self.target_link} as viewable to users with +150 coins only',
"icon":"fa-eye",
"color": "bg-muted",
"title": 'unmarked post {self.target_post} as viewable to users with +150 coins only'
},
"ban_comment":{
"str": 'removed {self.target_link}',
"icon":"fa-comment",

View File

@ -54,6 +54,7 @@ class Submission(Base, Stndrd, Age_times, Scores, Fuzzing):
stickied = Column(Boolean, default=False)
is_pinned = Column(Boolean, default=False)
private = Column(Boolean, default=False)
club = Column(Boolean, default=False)
comment_count = Column(Integer, default=0)
comments = relationship(
"Comment",
@ -359,10 +360,11 @@ class Submission(Base, Stndrd, Age_times, Scores, Fuzzing):
g.db.add(self.submission_aux)
def realtitle(self, v):
if self.title_html: title = self.title_html
if self.club and not (v and v.coins > 150): return 'COUNTRY CLUB MEMBERS ONLY'
elif self.title_html: title = self.title_html
else: title = self.title
if not v or v.slurreplacer:
if not v or v.slurreplacer:
for s,r in SLURS.items(): title = title.replace(s, r)
return title

View File

@ -541,20 +541,6 @@ class User(Base, Stndrd, Age_times):
def is_blocked(self):
return self.__dict__.get('_is_blocked', 0)
def refresh_referral_badges(self):
# check self-setting badges
badge_types = g.db.query(BadgeDef).filter(BadgeDef.qualification_expr.isnot(None)).all()
for badge in badge_types:
if eval(badge.qualification_expr, {}, {'v': self}):
if not self.has_badge(badge.id):
new_badge = Badge(user_id=self.id, badge_id=badge.id)
g.db.add(new_badge)
else:
bad_badge = self.has_badge(badge.id)
if bad_badge: g.db.delete(bad_badge)
g.db.add(self)
@property
def applications(self):

View File

@ -334,7 +334,17 @@ def sign_up_post(v):
ref_user = g.db.query(User).options(
lazyload('*')).filter_by(id=ref_id).first()
if ref_user:
ref_user.refresh_referral_badges()
# check self-setting badges
badge_types = g.db.query(BadgeDef).filter(BadgeDef.qualification_expr.isnot(None)).all()
for badge in badge_types:
if eval(badge.qualification_expr, {}, {'v': self}):
if not ref_user.has_badge(badge.id):
new_badge = Badge(user_id=ref_user.id, badge_id=badge.id)
g.db.add(new_badge)
else:
bad_badge = ref_user.has_badge(badge.id)
if bad_badge: g.db.delete(bad_badge)
g.db.add(ref_user)
id_1 = g.db.query(User).filter_by(id=6).count()

View File

@ -21,10 +21,35 @@ from files.__main__ import app, limiter, cache
from PIL import Image as PILimage
from .front import frontlist, changeloglist
site = environ.get("DOMAIN").strip()
with open("snappy.txt", "r") as f: snappyquotes = f.read().split("{[para]}")
@app.post("/toggle_club/<pid>")
@auth_required
def toggle_club(pid, v):
post = get_post(pid)
if not post.author_id == v.id and not v.admin_level >= 3: abort(403)
post.club = not post.club
g.db.add(post)
if post.author_id!=v.id:
ma=ModAction(
kind="club" if post.club else "unclub",
user_id=v.id,
target_submission_id=post.id,
)
g.db.add(ma)
if post.club: return {"message": "Post has been marked as +150-coins only!"}
else: return {"message": "Post has been unmarked as +150-coins only!"}
@app.post("/publish/<pid>")
@auth_required
@validate_formkey
@ -83,6 +108,8 @@ def post_id(pid, anything=None, v=None):
post = get_post(pid, v=v)
if post.club and not (v and v.coins > 150): abort(403)
if v:
votes = g.db.query(CommentVote).filter_by(user_id=v.id).subquery()
@ -830,6 +857,7 @@ def submit_post(v):
new_post = Submission(
private=bool(request.form.get("private","")),
club=bool(request.form.get("club","")),
author_id=v.id,
over_18=bool(request.form.get("over_18","")),
app_id=v.client.application.id if v.client else None,

View File

@ -99,7 +99,7 @@ def log(v):
page=int(request.args.get("page",1))
if v and v.admin_level == 6: actions = g.db.query(ModAction).order_by(ModAction.id.desc()).offset(25 * (page - 1)).limit(26).all()
else: actions=g.db.query(ModAction).filter(ModAction.kind!="shadowban", ModAction.kind!="unshadowban").order_by(ModAction.id.desc()).offset(25*(page-1)).limit(26).all()
else: actions=g.db.query(ModAction).filter(ModAction.kind!="shadowban", ModAction.kind!="unshadowban", ModAction.kind!="club", ModAction.kind!="unclub").order_by(ModAction.id.desc()).offset(25*(page-1)).limit(26).all()
next_exists=len(actions)==26
actions=actions[:25]

View File

@ -131,6 +131,12 @@
{% if v %}
<button id="save2-{{p.id}}" class="{% if p.id in v.saved_idlist() %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-left text-muted"><a href="javascript:void(0)" onclick="post_toast2('/save_post/{{p.id}}','save2-{{p.id}}','unsave2-{{p.id}}')" data-dismiss="modal"><i class="fas fa-save text-center text-muted mr-3"></i>Save</a></button>
<button id="unsave2-{{p.id}}" class="{% if not p.id in v.saved_idlist() %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-left text-muted"><a href="javascript:void(0)" onclick="post_toast2('/unsave_post/{{p.id}}','save2-{{p.id}}','unsave2-{{p.id}}')" data-dismiss="modal"><i class="fas fa-save text-center text-muted mr-3"></i>Unsave</a></button>
{% if v.admin_level >=3 or v.id == p.author.id and v.coins > 150 %}
<button id="club2-{{p.id}}" class="{% if p.club %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-danger text-left" href="javascript:void(0)" onclick="post_toast2('/toggle_club/{{p.id}}','club2-{{p.id}}','unclub2-{{p.id}}')" data-dismiss="modal"><i class="fas fa-eye-slash mr-3"></i>Mark as +150 coins</button>
<button id="unclub2-{{p.id}}" class="{% if p.club %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-danger text-left" href="javascript:void(0)" onclick="post_toast2('/toggle_club/{{p.id}}','club2-{{p.id}}','unclub2-{{p.id}}')" data-dismiss="modal"><i class="fas fa-eye mr-3"></i>Unmark as +150 coins</button>
{% endif %}
{% if v.admin_level >=3 %}
<button id="pin2-{{p.id}}" class="{% if p.stickied %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-left" href="javascript:void(0)" onclick="post_toast2('/sticky/{{p.id}}','pin2-{{p.id}}','unpin2-{{p.id}}')" data-dismiss="modal"><i class="fas fa-thumbtack text-center mr-3"></i>Pin</button>
<button id="unpin2-{{p.id}}" class="{% if not p.stickied %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-left" href="javascript:void(0)" onclick="post_toast2('/sticky/{{p.id}}','pin2-{{p.id}}','unpin2-{{p.id}}')" data-dismiss="modal"><i class="fas fa-thumbtack text-center mr-3"></i>Unpin</button>
@ -247,6 +253,7 @@
<div id="post-content" class="{% if p.deleted_utc > 0 %}deleted {% endif %}card-block w-100 my-md-auto">
<div class="post-meta text-left mb-2">
{% if p.club %}<span class="patron font-weight-bold" style="background-color:red;">COUNTRY CLUB</span>{% endif %}
{% if p.bannedfor and p.author.banned_by %}
<a href="javascript:void(0)"><i class="fad fa-gavel text-danger" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="User was banned for this post by @{{p.author.banned_by.username}}"></i></a>
{% endif %}
@ -436,6 +443,11 @@
{% endif %}
{% if v %}
{% if v.admin_level >=3 or v.id == p.author.id and v.coins > 150 %}
<li id="club-{{p.id}}" class="{% if p.club %}d-none{% endif %} list-inline-item"><a class="text-danger" href="javascript:void(0)" onclick="post_toast2('/toggle_club/{{p.id}}','club-{{p.id}}','unclub-{{p.id}}')"><i class="fas fa-eye-slash"></i>Mark as +150 coins</a></li>
<li id="unclub-{{p.id}}" class="{% if not p.club %}d-none{% endif %} list-inline-item"><a class="text-danger" href="javascript:void(0)" onclick="post_toast2('/toggle_club/{{p.id}}','club-{{p.id}}','unclub-{{p.id}}')"><i class="fas fa-eye"></i>Unmark as +150 coins</a></li>
{% endif %}
{% if v.admin_level >=3 %}
<li id="remove-{{p.id}}" class="{% if p.is_banned %}d-none{% endif %} list-inline-item"><a class="text-danger" href="javascript:void(0)" onclick="post_toast2('/ban_post/{{p.id}}','remove-{{p.id}}','approve-{{p.id}}')"><i class="fas fa-ban"></i>Remove</a></li>
<li id="approve-{{p.id}}" class="{% if not p.is_banned %}d-none{% endif %} list-inline-item"><a class="text-success" href="javascript:void(0)" onclick="post_toast2('/unban_post/{{p.id}}','remove-{{p.id}}','approve-{{p.id}}')"><i class="fas fa-check"></i>Approve</a></li>

View File

@ -64,7 +64,9 @@
<div style="z-index: 3;">
{% if not p.url %}
{% if p.club and not (v and v.coins > 150) %}
<img loading="lazy" src="/assets/images/emojis/marseyglow.gif" class="post-img">
{% elif not p.url %}
<a {% if v and v.newtab %}target="_blank"{% endif %} {% if v %}href="{{p.permalink}}"{% else %}href="/logged_out{{p.permalink}}"{% endif %}>
<img loading="lazy" src="{{p.thumb_url}}" class="post-img">
</a>
@ -90,6 +92,8 @@
<div class="card-block text-left x-scroll-parent my-md-auto w-100">
<div class="post-meta text-left x-scroll mb-md-2">
{% if p.club %}<span class="patron font-weight-bold" style="background-color:red;">COUNTRY CLUB</span>{% endif %}
{% if p.bannedfor and p.author.banned_by %}
<a href="javascript:void(0)"><i class="fad fa-gavel text-danger" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="User was banned for this post by @{{p.author.banned_by.username}}"></i></a>
{% endif %}
@ -125,14 +129,6 @@
{{p.realtitle(v) | safe}}
</a></h5>
{% if p.thumb_url %}
<div class="row post-img-lg mb-3">
<div class="col px-0">
<a {% if v and v.newtab %}target="_blank"{% endif %} {% if v %}href="{{p.permalink}}"{% else %}href="/logged_out{{p.permalink}}"{% endif %}><img loading="lazy" src="{{p.thumb_url}}" class="img-fluid" alt="post image"></a>
</div>
</div>
{% endif %}
<div class="post-actions mt-2 d-none d-md-block">
<ul class="list-inline text-right d-flex">
{% if p.realbody(v) %}
@ -179,6 +175,10 @@
{% endif %}
{% if v %}
{% if v.admin_level >=3 or v.id == p.author.id and v.coins > 150 %}
<li id="club-{{p.id}}" class="{% if p.club %}d-none{% endif %} list-inline-item"><a class="text-danger" href="javascript:void(0)" onclick="post_toast2('/toggle_club/{{p.id}}','club-{{p.id}}','unclub-{{p.id}}')"><i class="fas fa-eye-slash"></i>Mark as +150 coins</a></li>
<li id="unclub-{{p.id}}" class="{% if not p.club %}d-none{% endif %} list-inline-item"><a class="text-danger" href="javascript:void(0)" onclick="post_toast2('/toggle_club/{{p.id}}','club-{{p.id}}','unclub-{{p.id}}')"><i class="fas fa-eye"></i>Unmark as +150 coins</a></li>
{% endif %}
{% if v.admin_level >=3 %}
{% if "/flagged/" in request.path %}
@ -320,9 +320,12 @@
{% if v %}
<button id="save2-{{p.id}}" class="{% if p.id in v.saved_idlist() %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-left text-muted"><a href="javascript:void(0)" onclick="post_toast2('/save_post/{{p.id}}','save2-{{p.id}}','unsave2-{{p.id}}')" data-dismiss="modal"><i class="fas fa-save text-center text-muted mr-3"></i>Save</a></button>
<button id="unsave2-{{p.id}}" class="{% if not p.id in v.saved_idlist() %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-left text-muted"><a href="javascript:void(0)" onclick="post_toast2('/unsave_post/{{p.id}}','save2-{{p.id}}','unsave2-{{p.id}}')" data-dismiss="modal"><i class="fas fa-save text-center text-muted mr-3"></i>Unsave</a></button>
{% endif %}
{% if v %}
{% if v.admin_level >=3 or v.id == p.author.id and v.coins > 150 %}
<button id="club2-{{p.id}}" class="{% if p.club %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-danger text-left" href="javascript:void(0)" onclick="post_toast2('/toggle_club/{{p.id}}','club2-{{p.id}}','unclub2-{{p.id}}')" data-dismiss="modal"><i class="fas fa-eye-slash mr-3"></i>Mark as +150 coins</button>
<button id="unclub2-{{p.id}}" class="{% if p.club %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-danger text-left" href="javascript:void(0)" onclick="post_toast2('/toggle_club/{{p.id}}','club2-{{p.id}}','unclub2-{{p.id}}')" data-dismiss="modal"><i class="fas fa-eye mr-3"></i>Unmark as +150 coins</button>
{% endif %}
{% if v.admin_level >=3 %}
<button id="pin2-{{p.id}}" class="{% if p.stickied %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-left" href="javascript:void(0)" onclick="post_toast2('/sticky/{{p.id}}','pin2-{{p.id}}','unpin2-{{p.id}}')" data-dismiss="modal"><i class="fas fa-thumbtack text-center mr-3"></i>Pin</button>
<button id="unpin2-{{p.id}}" class="{% if not p.stickied %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-left" href="javascript:void(0)" onclick="post_toast2('/sticky/{{p.id}}','pin2-{{p.id}}','unpin2-{{p.id}}')" data-dismiss="modal"><i class="fas fa-thumbtack text-center mr-3"></i>Unpin</button>

View File

@ -395,6 +395,13 @@
<input type="checkbox" class="custom-control-input" id="privateCheck" name="private">
<label class="custom-control-label" for="privateCheck">Draft</label>
</div>
{% if v.coins > 150 %}
<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="clubCheck" name="club">
<label class="custom-control-label" for="clubCheck">+150 dramacoins to view</label>
</div>
{% endif %}
<pre>