dffd
This commit is contained in:
parent
f534c510ad
commit
e995caafcb
19 changed files with 69 additions and 349 deletions
|
@ -101,14 +101,11 @@ class Comment(Base, Age_times, Scores, Stndrd, Fuzzing):
|
|||
@lazy
|
||||
def parent(self):
|
||||
|
||||
if not self.parent_submission:
|
||||
return None
|
||||
if not self.parent_submission: return None
|
||||
|
||||
if self.level == 1:
|
||||
return self.post
|
||||
if self.level == 1: return self.post
|
||||
|
||||
else:
|
||||
return g.db.query(Comment).get(self.parent_comment_id)
|
||||
else: return g.db.query(Comment).get(self.parent_comment_id)
|
||||
|
||||
@property
|
||||
def replies(self):
|
||||
|
@ -136,47 +133,6 @@ class Comment(Base, Age_times, Scores, Stndrd, Fuzzing):
|
|||
if self.post: return f"{self.post.permalink}/{self.id}/"
|
||||
else: return f"/comment/{self.id}/"
|
||||
|
||||
def rendered_comment(self, v=None, render_replies=True,
|
||||
standalone=False, level=1, **kwargs):
|
||||
|
||||
kwargs["post_base36id"] = kwargs.get(
|
||||
"post_base36id", self.post.base36id if self.post else None)
|
||||
|
||||
if self.is_banned or self.deleted_utc > 0:
|
||||
if v and v.admin_level > 1:
|
||||
return render_template("single_comment.html",
|
||||
v=v,
|
||||
c=self,
|
||||
render_replies=render_replies,
|
||||
standalone=standalone,
|
||||
level=level,
|
||||
**kwargs)
|
||||
|
||||
elif self.any_descendants_live:
|
||||
return render_template("single_comment_removed.html",
|
||||
c=self,
|
||||
render_replies=render_replies,
|
||||
standalone=standalone,
|
||||
level=level,
|
||||
**kwargs)
|
||||
else:
|
||||
return ""
|
||||
|
||||
return render_template("single_comment.html",
|
||||
v=v,
|
||||
c=self,
|
||||
render_replies=render_replies,
|
||||
standalone=standalone,
|
||||
level=level,
|
||||
**kwargs)
|
||||
|
||||
@property
|
||||
def active_flags(self):
|
||||
if self.is_approved:
|
||||
return 0
|
||||
else:
|
||||
return self.flag_count
|
||||
|
||||
@property
|
||||
def json_raw(self):
|
||||
data= {
|
||||
|
@ -186,7 +142,6 @@ class Comment(Base, Age_times, Scores, Stndrd, Fuzzing):
|
|||
'author_name': self.author.username,
|
||||
'body': self.body,
|
||||
'body_html': self.body_html,
|
||||
'is_archived': self.is_archived,
|
||||
'is_bot': self.is_bot,
|
||||
'created_utc': self.created_utc,
|
||||
'edited_utc': self.edited_utc or 0,
|
||||
|
@ -318,10 +273,6 @@ class Comment(Base, Age_times, Scores, Stndrd, Fuzzing):
|
|||
self.comment_aux.ban_reason = x
|
||||
g.db.add(self.comment_aux)
|
||||
|
||||
@property
|
||||
def flag_count(self):
|
||||
return len(self.flags)
|
||||
|
||||
#@property
|
||||
#def award_count(self):
|
||||
#return len(self.awards)
|
||||
|
@ -341,41 +292,6 @@ class Comment(Base, Age_times, Scores, Stndrd, Fuzzing):
|
|||
|
||||
return False
|
||||
|
||||
@property
|
||||
def flagged_by(self):
|
||||
return [x.user for x in self.flags]
|
||||
|
||||
@property
|
||||
def self_download_json(self):
|
||||
|
||||
#This property should never be served to anyone but author and admin
|
||||
if not self.is_banned and not self.is_banned:
|
||||
return self.json_core
|
||||
|
||||
data= {
|
||||
"author": self.author.name,
|
||||
"body": self.body,
|
||||
"body_html": self.body_html,
|
||||
"is_banned": bool(self.is_banned),
|
||||
"deleted_utc": self.deleted_utc,
|
||||
'created_utc': self.created_utc,
|
||||
'id': self.base36id,
|
||||
'fullname': self.fullname,
|
||||
'permalink': self.permalink,
|
||||
'post_id': self.post.base36id,
|
||||
'level': self.level
|
||||
}
|
||||
if self.level>=2:
|
||||
data['parent_comment_id']= base36encode(self.parent_comment_id)
|
||||
|
||||
return data
|
||||
|
||||
@property
|
||||
def json_admin(self):
|
||||
data= self.json_raw
|
||||
|
||||
return data
|
||||
|
||||
@property
|
||||
@lazy
|
||||
def is_op(self):
|
||||
|
|
|
@ -151,8 +151,7 @@ class Fuzzing:
|
|||
@property
|
||||
def upvotes_fuzzed(self):
|
||||
|
||||
if self.upvotes <= 10 or self.is_archived:
|
||||
return self.upvotes
|
||||
if self.upvotes <= 10: return self.upvotes
|
||||
|
||||
lower = int(self.upvotes * 0.99)
|
||||
upper = int(self.upvotes * 1.01) + 1
|
||||
|
@ -161,8 +160,7 @@ class Fuzzing:
|
|||
|
||||
@property
|
||||
def downvotes_fuzzed(self):
|
||||
if self.downvotes <= 10 or self.is_archived:
|
||||
return self.downvotes
|
||||
if self.downvotes <= 10: return self.downvotes
|
||||
|
||||
lower = int(self.downvotes * 0.99)
|
||||
upper = int(self.downvotes * 1.01) + 1
|
||||
|
|
|
@ -68,7 +68,7 @@ class ModAction(Base, Stndrd, Age_times):
|
|||
@property
|
||||
def target_link(self):
|
||||
if self.target_user:
|
||||
return f'<a href="{self.target_user.permalink}">{self.target_user.username}</a>'
|
||||
return f'<a href="{self.target_user.url}">{self.target_user.username}</a>'
|
||||
elif self.target_post:
|
||||
return f'<a href="{self.target_post.permalink}">{self.target_post.title}</a>'
|
||||
elif self.target_comment:
|
||||
|
|
|
@ -116,13 +116,6 @@ class Submission(Base, Stndrd, Age_times, Scores, Fuzzing):
|
|||
def score_disputed(self):
|
||||
return (self.upvotes+1) * (self.downvotes+1)
|
||||
|
||||
@property
|
||||
def is_repost(self):
|
||||
return bool(self.repost_id)
|
||||
|
||||
@property
|
||||
def is_archived(self):
|
||||
return false
|
||||
|
||||
@property
|
||||
@lazy
|
||||
|
@ -147,15 +140,6 @@ class Submission(Base, Stndrd, Age_times, Scores, Fuzzing):
|
|||
|
||||
return f"/post/{self.id}/{output}"
|
||||
|
||||
@property
|
||||
def is_archived(self):
|
||||
|
||||
now = int(time.time())
|
||||
|
||||
cutoff = now - (60 * 60 * 24 * 180)
|
||||
|
||||
return self.created_utc < cutoff
|
||||
|
||||
def rendered_page(self, sort=None, comment=None, comment_info=None, v=None):
|
||||
|
||||
# check for banned
|
||||
|
@ -220,13 +204,6 @@ class Submission(Base, Stndrd, Age_times, Scores, Fuzzing):
|
|||
else:
|
||||
self.__dict__["replies"] = pinned_comment + index.get(self.fullname, [])
|
||||
|
||||
@property
|
||||
def active_flags(self):
|
||||
if self.is_approved:
|
||||
return 0
|
||||
else:
|
||||
return len(self.flags)
|
||||
|
||||
@property
|
||||
#@lazy
|
||||
def thumb_url(self):
|
||||
|
@ -250,7 +227,6 @@ class Submission(Base, Stndrd, Age_times, Scores, Fuzzing):
|
|||
'is_bot': self.is_bot,
|
||||
'thumb_url': self.thumb_url,
|
||||
'domain': self.domain,
|
||||
'is_archived': self.is_archived,
|
||||
'url': self.url,
|
||||
'body': self.body,
|
||||
'body_html': self.body_html,
|
||||
|
@ -315,10 +291,6 @@ class Submission(Base, Stndrd, Age_times, Scores, Fuzzing):
|
|||
def voted(self):
|
||||
return self._voted if "_voted" in self.__dict__ else 0
|
||||
|
||||
@property
|
||||
def user_title(self):
|
||||
return self._title if "_title" in self.__dict__ else self.author.title
|
||||
|
||||
@property
|
||||
def title(self):
|
||||
return self.submission_aux.title
|
||||
|
@ -428,14 +400,6 @@ class Submission(Base, Stndrd, Age_times, Scores, Fuzzing):
|
|||
def is_blocking(self):
|
||||
return self.__dict__.get('_is_blocking', False)
|
||||
|
||||
@property
|
||||
def flag_count(self):
|
||||
return len(self.flags)
|
||||
|
||||
@property
|
||||
def report_count(self):
|
||||
return len(self.reports)
|
||||
|
||||
#@property
|
||||
#def award_count(self):
|
||||
#return len(self.awards)
|
||||
|
@ -444,52 +408,12 @@ class Submission(Base, Stndrd, Age_times, Scores, Fuzzing):
|
|||
def embed_template(self):
|
||||
return f"site_embeds/{self.domain_obj.embed_template}.html"
|
||||
|
||||
@property
|
||||
def flagged_by(self):
|
||||
return [x.user for x in self.flags]
|
||||
|
||||
@property
|
||||
def is_image(self):
|
||||
if self.url: return self.url.endswith('jpg') or self.url.endswith('png') or self.url.endswith('.gif') or self.url.endswith('jpeg') or self.url.endswith('?maxwidth=9999') or self.url.endswith('?maxwidth=8888')
|
||||
else: return False
|
||||
|
||||
@property
|
||||
def self_download_json(self):
|
||||
|
||||
#This property should never be served to anyone but author and admin
|
||||
if not self.is_banned and self.deleted_utc == 0:
|
||||
return self.json_core
|
||||
|
||||
data= {
|
||||
"title":self.title,
|
||||
"author": self.author.username,
|
||||
"url": self.url,
|
||||
"body": self.body,
|
||||
"body_html": self.body_html,
|
||||
"is_banned": bool(self.is_banned),
|
||||
"deleted_utc": self.deleted_utc,
|
||||
'created_utc': self.created_utc,
|
||||
'id': self.base36id,
|
||||
'fullname': self.fullname,
|
||||
'comment_count': self.comment_count,
|
||||
'permalink': self.permalink
|
||||
}
|
||||
|
||||
return data
|
||||
|
||||
@property
|
||||
def json_admin(self):
|
||||
|
||||
data=self.json_raw
|
||||
|
||||
return data
|
||||
|
||||
@property
|
||||
def is_exiled_for(self):
|
||||
return self.__dict__.get('_is_exiled_for', None)
|
||||
|
||||
|
||||
|
||||
|
||||
class SaveRelationship(Base, Stndrd):
|
||||
|
||||
__tablename__="save_relationship"
|
||||
|
|
|
@ -67,10 +67,6 @@ class User(Base, Stndrd, Age_times):
|
|||
"Notification",
|
||||
lazy="dynamic")
|
||||
|
||||
# unread_notifications_relationship=relationship(
|
||||
# "Notification",
|
||||
# primaryjoin="and_(Notification.user_id==User.id, Notification.read==False)")
|
||||
|
||||
referred_by = Column(Integer)
|
||||
is_banned = Column(Integer, default=None)
|
||||
unban_utc = Column(Integer, default=None)
|
||||
|
@ -126,11 +122,6 @@ class User(Base, Stndrd, Age_times):
|
|||
return g.db.query(UserBlock).filter_by(
|
||||
user_id=self.id, target_id=target.id).first()
|
||||
|
||||
def is_blocked_by(self, user):
|
||||
|
||||
return g.db.query(UserBlock).filter_by(
|
||||
user_id=user.id, target_id=self.id).first()
|
||||
|
||||
def any_block_exists(self, other):
|
||||
|
||||
return g.db.query(UserBlock).filter(
|
||||
|
@ -243,22 +234,12 @@ class User(Base, Stndrd, Age_times):
|
|||
@property
|
||||
def banned_by(self):
|
||||
|
||||
if not self.is_banned:
|
||||
return None
|
||||
|
||||
if not self.is_banned: return None
|
||||
return g.db.query(User).filter_by(id=self.is_banned).first()
|
||||
|
||||
def has_badge(self, badgedef_id):
|
||||
return self.badges.filter_by(badge_id=badgedef_id).first()
|
||||
|
||||
def vote_status_on_post(self, post):
|
||||
|
||||
return post.voted
|
||||
|
||||
def vote_status_on_comment(self, comment):
|
||||
|
||||
return comment.voted
|
||||
|
||||
def hash_password(self, password):
|
||||
return generate_password_hash(
|
||||
password, method='pbkdf2:sha512', salt_length=8)
|
||||
|
@ -284,18 +265,6 @@ class User(Base, Stndrd, Age_times):
|
|||
def url(self):
|
||||
return f"/@{self.username}"
|
||||
|
||||
@property
|
||||
def permalink(self):
|
||||
return self.url
|
||||
|
||||
@property
|
||||
def uid_permalink(self):
|
||||
return f"/uid/{self.base36id}"
|
||||
|
||||
@property
|
||||
def original_link(self):
|
||||
return f"/@{self.original_username}"
|
||||
|
||||
def __repr__(self):
|
||||
return f"<User(username={self.username})>"
|
||||
|
||||
|
@ -399,22 +368,6 @@ class User(Base, Stndrd, Age_times):
|
|||
|
||||
return output
|
||||
|
||||
def alts_subquery(self):
|
||||
return g.db.query(User.id).filter(
|
||||
or_(
|
||||
User.id.in_(
|
||||
g.db.query(Alt.user1).filter(
|
||||
Alt.user2 == self.id
|
||||
).subquery()
|
||||
),
|
||||
User.id.in_(
|
||||
g.db.query(Alt.user2).filter(
|
||||
Alt.user1 == self.id
|
||||
).subquery()
|
||||
).subquery()
|
||||
)
|
||||
).subquery()
|
||||
|
||||
def alts_threaded(self, db):
|
||||
|
||||
subq = db.query(Alt).filter(
|
||||
|
@ -451,44 +404,11 @@ class User(Base, Stndrd, Age_times):
|
|||
return g.db.query(Follow).filter_by(
|
||||
target_id=self.id, user_id=user.id).first()
|
||||
|
||||
def set_profile(self, file):
|
||||
|
||||
self.del_profile()
|
||||
imageurl = upload_file(name=f"profile.gif", file=file, resize=(100, 100))
|
||||
if imageurl:
|
||||
self.profileurl = imageurl
|
||||
self.profile_upload_ip = request.remote_addr
|
||||
self.profile_set_utc = int(time.time())
|
||||
self.profile_upload_region = request.headers.get("cf-ipcountry")
|
||||
g.db.add(self)
|
||||
|
||||
def set_banner(self, file):
|
||||
|
||||
self.del_banner()
|
||||
imageurl = upload_file(name=f"banner.gif", file=file)
|
||||
if imageurl:
|
||||
self.bannerurl = imageurl
|
||||
self.banner_upload_ip = request.remote_addr
|
||||
self.banner_set_utc = int(time.time())
|
||||
self.banner_upload_region = request.headers.get("cf-ipcountry")
|
||||
g.db.add(self)
|
||||
|
||||
def del_profile(self):
|
||||
|
||||
self.profileurl = None
|
||||
g.db.add(self)
|
||||
|
||||
def del_banner(self):
|
||||
|
||||
self.bannerurl = None
|
||||
g.db.add(self)
|
||||
|
||||
@property
|
||||
def banner_url(self):
|
||||
if self.bannerurl:
|
||||
return self.bannerurl
|
||||
else:
|
||||
return "/assets/images/default_bg.png"
|
||||
if self.bannerurl: return self.bannerurl
|
||||
else: return "/assets/images/default_bg.png"
|
||||
|
||||
@cache.memoize(0)
|
||||
def defaultpicture(self):
|
||||
|
@ -497,27 +417,13 @@ class User(Base, Stndrd, Age_times):
|
|||
|
||||
@property
|
||||
def profile_url(self):
|
||||
if self.profileurl:
|
||||
return self.profileurl
|
||||
else:
|
||||
return self.defaultpicture()
|
||||
|
||||
@property
|
||||
def can_submit_image(self):
|
||||
return self.dramacoins >= 0
|
||||
|
||||
@property
|
||||
def can_upload_avatar(self):
|
||||
return self.dramacoins >= 0
|
||||
|
||||
@property
|
||||
def can_upload_banner(self):
|
||||
return self.dramacoins >= 0
|
||||
if self.profileurl: return self.profileurl
|
||||
else: return self.defaultpicture()
|
||||
|
||||
@property
|
||||
def json_raw(self):
|
||||
data = {'username': self.username,
|
||||
'permalink': self.permalink,
|
||||
'url': self.url,
|
||||
'is_banned': bool(self.is_banned),
|
||||
'is_premium': self.has_premium_no_renew,
|
||||
'created_utc': self.created_utc,
|
||||
|
@ -538,7 +444,7 @@ class User(Base, Stndrd, Age_times):
|
|||
now = int(time.time())
|
||||
if self.is_banned and (not self.unban_utc or now < self.unban_utc):
|
||||
return {'username': self.username,
|
||||
'permalink': self.permalink,
|
||||
'url': self.url,
|
||||
'is_banned': True,
|
||||
'is_permanent_ban': not bool(self.unban_utc),
|
||||
'ban_reason': self.ban_reason,
|
||||
|
@ -557,10 +463,6 @@ class User(Base, Stndrd, Age_times):
|
|||
|
||||
return data
|
||||
|
||||
@property
|
||||
def can_use_darkmode(self):
|
||||
return True
|
||||
|
||||
def ban(self, admin=None, reason=None, days=0):
|
||||
|
||||
if days > 0:
|
||||
|
@ -568,26 +470,17 @@ class User(Base, Stndrd, Age_times):
|
|||
self.unban_utc = ban_time
|
||||
|
||||
else:
|
||||
if self.bannerurl:
|
||||
self.del_banner()
|
||||
if self.profileurl:
|
||||
self.del_profile()
|
||||
|
||||
self.bannerurl = None
|
||||
self.profileurl = None
|
||||
delete_role(self, "linked")
|
||||
|
||||
self.is_banned = admin.id if admin else 2317
|
||||
if reason:
|
||||
self.ban_reason = reason
|
||||
if reason: self.ban_reason = reason
|
||||
|
||||
try:
|
||||
g.db.add(self)
|
||||
except:
|
||||
pass
|
||||
g.db.add(self)
|
||||
|
||||
def unban(self):
|
||||
|
||||
# Takes care of all functions needed for account reinstatement.
|
||||
|
||||
self.is_banned = 0
|
||||
self.unban_utc = 0
|
||||
|
||||
|
@ -694,24 +587,6 @@ class User(Base, Stndrd, Age_times):
|
|||
l = [i for i in l if i]
|
||||
return l
|
||||
|
||||
@property
|
||||
def json_admin(self):
|
||||
data = self.json_raw
|
||||
|
||||
data['email'] = self.email
|
||||
data['email_verified'] = self.is_activated
|
||||
|
||||
return data
|
||||
|
||||
@property
|
||||
def can_upload_comment_image(self):
|
||||
return self.dramacoins >= 0 and request.headers.get("cf-ipcountry") != "T1"
|
||||
|
||||
@property
|
||||
def can_change_name(self):
|
||||
return True
|
||||
# return self.name_changed_utc < int(time.time())-60*60*24*90
|
||||
|
||||
|
||||
class ViewerRelationship(Base):
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ class CustomRenderer(HTMLRenderer):
|
|||
|
||||
if not user: return f"{space}@{target}"
|
||||
|
||||
return f'{space}<a href="{user.permalink}" class="d-inline-block mention-user" data-original-name="{user.original_username}"><img src="/uid/{user.base36id}/pic/profile" class="profile-pic-20 mr-1">@{user.username}</a>'
|
||||
return f'{space}<a href="{user.url}" class="d-inline-block mention-user" data-original-name="{user.original_username}"><img src="/uid/{user.base36id}/pic/profile" class="profile-pic-20 mr-1">@{user.username}</a>'
|
||||
|
||||
def render_sub_mention(self, token):
|
||||
space = token.target[0]
|
||||
|
|
|
@ -172,7 +172,7 @@ def badge_grant_post(v):
|
|||
if user.has_badge(badge_id):
|
||||
g.db.query(Badge).filter_by(badge_id=badge_id, user_id=user.id,).delete()
|
||||
g.db.commit()
|
||||
return redirect(user.permalink)
|
||||
return redirect(user.url)
|
||||
|
||||
new_badge = Badge(badge_id=badge_id,
|
||||
user_id=user.id,
|
||||
|
@ -204,7 +204,7 @@ def badge_grant_post(v):
|
|||
elif badge_id in [24,28]: user.banawards = 3
|
||||
g.db.add(user)
|
||||
|
||||
return redirect(user.permalink)
|
||||
return redirect(user.url)
|
||||
|
||||
|
||||
@app.route("/admin/users", methods=["GET"])
|
||||
|
@ -969,7 +969,7 @@ def admin_nuke_user(v):
|
|||
)
|
||||
g.db.add(ma)
|
||||
|
||||
return redirect(user.permalink)
|
||||
return redirect(user.url)
|
||||
|
||||
@app.route("/admin/unnuke_user", methods=["POST"])
|
||||
@admin_level_required(4)
|
||||
|
@ -999,7 +999,7 @@ def admin_nunuke_user(v):
|
|||
)
|
||||
g.db.add(ma)
|
||||
|
||||
return redirect(user.permalink)
|
||||
return redirect(user.url)
|
||||
|
||||
@app.route("/api/user_stat_data", methods=['GET'])
|
||||
@admin_level_required(2)
|
||||
|
|
|
@ -867,7 +867,7 @@ def submit_post(v):
|
|||
# check for embeddable video
|
||||
domain = parsed_url.netloc
|
||||
|
||||
if request.files.get('file') and not v.can_submit_image:
|
||||
if request.files.get('file') and not v.dramacoins >= 0:
|
||||
abort(403)
|
||||
|
||||
|
||||
|
|
|
@ -324,36 +324,45 @@ def settings_log_out_others(v):
|
|||
@auth_required
|
||||
@validate_formkey
|
||||
def settings_images_profile(v):
|
||||
if v.can_upload_avatar:
|
||||
if v.dramacoins >= 0:
|
||||
|
||||
if request.content_length > 16 * 1024 * 1024:
|
||||
g.db.rollback()
|
||||
abort(413)
|
||||
|
||||
v.set_profile(request.files["profile"])
|
||||
v.profileurl = None
|
||||
imageurl = upload_file(name=f"profile.gif", file=request.files["profile"], resize=(100, 100))
|
||||
if imageurl:
|
||||
v.profileurl = imageurl
|
||||
g.db.add(v)
|
||||
|
||||
return render_template("settings_profile.html",
|
||||
v=v, msg="Profile picture successfully updated.")
|
||||
|
||||
return render_template("settings_profile.html", v=v,
|
||||
msg="Avatars require 300 reputation.")
|
||||
msg="Avatars require +0 dramacoins.")
|
||||
|
||||
|
||||
@app.route("/settings/images/banner", methods=["POST"])
|
||||
@auth_required
|
||||
@validate_formkey
|
||||
def settings_images_banner(v):
|
||||
if v.can_upload_banner:
|
||||
if v.dramacoins >= 0:
|
||||
if request.content_length > 16 * 1024 * 1024:
|
||||
g.db.rollback()
|
||||
abort(413)
|
||||
|
||||
v.set_banner(request.files["banner"])
|
||||
v.bannerurl = None
|
||||
imageurl = upload_file(name=f"banner.gif", file=request.files["banner"])
|
||||
if imageurl:
|
||||
v.bannerurl = imageurl
|
||||
g.db.add(v)
|
||||
|
||||
return render_template("settings_profile.html",
|
||||
v=v, msg="Banner successfully updated.")
|
||||
|
||||
return render_template("settings_profile.html", v=v,
|
||||
msg="Banners require 500 reputation.")
|
||||
msg="Banners require +0 dramacoins.")
|
||||
|
||||
|
||||
@app.route("/settings/delete/profile", methods=["POST"])
|
||||
|
@ -361,8 +370,8 @@ def settings_images_banner(v):
|
|||
@validate_formkey
|
||||
def settings_delete_profile(v):
|
||||
|
||||
v.del_profile()
|
||||
|
||||
v.profileurl = None
|
||||
g.db.add(v)
|
||||
return render_template("settings_profile.html", v=v,
|
||||
msg="Profile picture successfully removed.")
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ def suicide(v, username):
|
|||
t = int(time.time())
|
||||
if v.admin_level == 0 and t - v.suicide_utc < 86400: return "", 204
|
||||
user = get_user(username)
|
||||
suicide = f"Hi there,\n\nA [concerned dramatard]({v.permalink}) reached out to us about you.\n\nWhen you're in the middle of something painful, it may feel like you don't have a lot of options. But whatever you're going through, you deserve help and there are people who are here for you.\n\nThere are resources available in your area that are free, confidential, and available 24/7:\n\n- Call, Text, or Chat with Canada's [Crisis Services Canada](https://www.crisisservicescanada.ca/en/)\n- Call, Email, or Visit the UK's [Samaritans](https://www.samaritans.org/)\n- Text CHAT to America's [Crisis Text Line](https://www.crisistextline.org/) at 741741.\nIf you don't see a resource in your area above, the moderators at r/SuicideWatch keep a comprehensive list of resources and hotlines for people organized by location. Find Someone Now\n\nIf you think you may be depressed or struggling in another way, don't ignore it or brush it aside. Take yourself and your feelings seriously, and reach out to someone.\n\nIt may not feel like it, but you have options. There are people available to listen to you, and ways to move forward.\n\nYour fellow dramatards care about you and there are people who want to help."
|
||||
suicide = f"Hi there,\n\nA [concerned dramatard]({v.url}) reached out to us about you.\n\nWhen you're in the middle of something painful, it may feel like you don't have a lot of options. But whatever you're going through, you deserve help and there are people who are here for you.\n\nThere are resources available in your area that are free, confidential, and available 24/7:\n\n- Call, Text, or Chat with Canada's [Crisis Services Canada](https://www.crisisservicescanada.ca/en/)\n- Call, Email, or Visit the UK's [Samaritans](https://www.samaritans.org/)\n- Text CHAT to America's [Crisis Text Line](https://www.crisistextline.org/) at 741741.\nIf you don't see a resource in your area above, the moderators at r/SuicideWatch keep a comprehensive list of resources and hotlines for people organized by location. Find Someone Now\n\nIf you think you may be depressed or struggling in another way, don't ignore it or brush it aside. Take yourself and your feelings seriously, and reach out to someone.\n\nIt may not feel like it, but you have options. There are people available to listen to you, and ways to move forward.\n\nYour fellow dramatards care about you and there are people who want to help."
|
||||
send_notification(1046, user, suicide)
|
||||
v.suicide_utc = t
|
||||
g.db.add(v)
|
||||
|
@ -183,7 +183,7 @@ def api_is_available(name, v):
|
|||
def user_id(id):
|
||||
|
||||
user = get_account(int(id))
|
||||
return redirect(user.permalink)
|
||||
return redirect(user.url)
|
||||
|
||||
# Allow Id of user to be queryied, and then redirect the bot to the
|
||||
# actual user api endpoint.
|
||||
|
|
|
@ -114,7 +114,7 @@
|
|||
<div class="user-info">
|
||||
<span class="comment-collapse d-md-none" onclick="collapse_comment('{{c.base36id}}')"></span>
|
||||
{% if c.banaward %} <i class="fas fa-gavel text-danger" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="Given the 1-day ban award by @{{c.banaward}}"></i> {% endif %}
|
||||
{% if c.active_flags %} <a class="btn btn-primary" style="padding:1px 5px; font-size:10px;" href="javascript:void(0)" onclick="document.getElementById('flaggers-{{c.id}}').classList.toggle('d-none')">{{c.active_flags}} Reports</a> {% endif %}
|
||||
{% if c.flags %} <a class="btn btn-primary" style="padding:1px 5px; font-size:10px;" href="javascript:void(0)" onclick="document.getElementById('flaggers-{{c.id}}').classList.toggle('d-none')">{{len(c.flags)}} Reports</a> {% endif %}
|
||||
{% if c.over_18 %}<span class="badge badge-danger text-small-extra mr-1">+18</span> {% endif %}
|
||||
{% if v and v.admin_level==6 and c.author.shadowbanned %}<i class="fas fa-user-times text-admin" data-toggle="tooltip" data-placement="bottom" title="Shadowbanned user"></i> {% endif %}
|
||||
{% if c.is_pinned %}<i class="text-admin fas fa-thumbtack fa-rotate--45" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="Pinned comment"></i> {% endif %}
|
||||
|
@ -187,7 +187,7 @@
|
|||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if c.active_flags %}
|
||||
{% if c.flags %}
|
||||
<div id="flaggers-{{c.id}}" class="flaggers d-none" style="margin: 7px; border: 1px solid #999b2e; padding: 10px; border-radius: 3px;">
|
||||
<strong style="color: #999b2e;"><i class="far fa-fw fa-flag"></i> Reported by:</strong>
|
||||
<ul style="margin-bottom: 0;">
|
||||
|
|
|
@ -79,7 +79,7 @@
|
|||
|
||||
<li class="nav-item d-flex align-items-center justify-content-center text-center">
|
||||
<div class="dropdown">
|
||||
<a class="nav-link bg-transparent py-0 pr-0" href="{{v.permalink}}" role="button" id="dropdownMenuLink" data-toggle="dropdown"
|
||||
<a class="nav-link bg-transparent py-0 pr-0" href="{{v.url}}" role="button" id="dropdownMenuLink" data-toggle="dropdown"
|
||||
aria-haspopup="true" aria-expanded="false">
|
||||
<div class="d-flex">
|
||||
<div><img src="{{v.profile_url}}" class="profile-pic-35"></div>
|
||||
|
@ -92,7 +92,7 @@
|
|||
<div class="dropdown-menu dropdown-menu-right dropdown-menu-lg-left border-0 shadow fade px-0 mt-2"
|
||||
aria-labelledby="dropdownMenuButton">
|
||||
<div class="px-2">
|
||||
<a class="dropdown-item" href="{{v.permalink}}"><i class="fas fa-user-circle fa-fw text-left mr-3"></i>My
|
||||
<a class="dropdown-item" href="{{v.url}}"><i class="fas fa-user-circle fa-fw text-left mr-3"></i>My
|
||||
profile</a>
|
||||
<a class="dropdown-item" href="/settings"><i class="fas fa-cog fa-fw text-left mr-3"></i>Settings</a>
|
||||
</div>
|
||||
|
@ -146,7 +146,7 @@
|
|||
</li>
|
||||
{% if v %}
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{{v.permalink}}"><i class="fas fa-user-circle fa-fw mr-3"></i>@{{v.username}}</a>
|
||||
<a class="nav-link" href="{{v.url}}"><i class="fas fa-user-circle fa-fw mr-3"></i>@{{v.username}}</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link {% if v.notifications_count %}position-relative{% endif %}" href="/notifications{% if not v.notifications_count %}?all=true{% elif v.notifications_count == v.post_notifications_count %}?posts=true{% endif %}">
|
||||
|
|
|
@ -48,8 +48,8 @@
|
|||
</button>
|
||||
{% if v %}
|
||||
<button type="button" class="col px-0 pr-2 btn btn-dead m-0" style="border-color: transparent !important;">
|
||||
<a href="{{v.permalink}}" class="text-decoration-none" role="button">
|
||||
<div class="text-center {% if request.path==v.permalink %}text-purple{% else %}text-muted{% endif %}">
|
||||
<a href="{{v.url}}" class="text-decoration-none" role="button">
|
||||
<div class="text-center {% if request.path==v.url %}text-purple{% else %}text-muted{% endif %}">
|
||||
<i class="fas fa-user-circle text-lg d-block"></i>
|
||||
<div class="text-small">Profile</div>
|
||||
</div>
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
</span>
|
||||
<div class="text-muted pl-3">
|
||||
<div>
|
||||
<a href="{{ma.user.permalink}}" class="font-weight-bold text-black" target="_self">@{{ma.user.username}}</a>
|
||||
<a href="{{ma.user.url}}" class="font-weight-bold text-black" target="_self">@{{ma.user.username}}</a>
|
||||
|
||||
<span>{{ma.string | safe}}</span>
|
||||
</div>
|
||||
|
|
|
@ -84,7 +84,7 @@
|
|||
|
||||
<div>
|
||||
|
||||
{% if v.can_upload_avatar %}
|
||||
{% if v.dramacoins >= 0 %}
|
||||
|
||||
<form action="/settings/images/profile" method="post" enctype="multipart/form-data">
|
||||
<input type="hidden" name="formkey" value="{{v.formkey}}">
|
||||
|
@ -112,7 +112,7 @@
|
|||
|
||||
</div>
|
||||
|
||||
{% if v.can_upload_avatar %}
|
||||
{% if v.dramacoins >= 0 %}
|
||||
|
||||
<div class="text-small-extra text-muted mt-3">JPG, PNG, GIF files are supported. Max file size is 16 MB.</div>
|
||||
|
||||
|
@ -139,7 +139,7 @@
|
|||
|
||||
<div>
|
||||
|
||||
{% if v.can_upload_banner %}
|
||||
{% if v.dramacoins >= 0 %}
|
||||
|
||||
<form action="/settings/images/banner" method="post" enctype="multipart/form-data">
|
||||
<input type="hidden" name="formkey" value="{{v.formkey}}">
|
||||
|
@ -168,7 +168,7 @@
|
|||
|
||||
</div>
|
||||
|
||||
{% if v.can_upload_banner %}
|
||||
{% if v.dramacoins >= 0 %}
|
||||
|
||||
<div class="text-small-extra text-muted mt-3">JPG, PNG, GIF files are supported. Max file size is 16 MB.</div>
|
||||
|
||||
|
|
|
@ -215,8 +215,8 @@
|
|||
|
||||
{% if p.over_18 %}<span class="badge badge-danger text-small-extra mr-1">+18</span>{% endif %}
|
||||
{% if p.private %}<span class="badge border-warning border-1 text-small-extra">unlisted</span>{% endif %}
|
||||
{% if p.is_repost %}<span class="badge border-warning border-1 text-small-extra"><a class="text-warning" href="{{p.reposts.permalink}}">repost</a></span>{% endif %}
|
||||
{% if p.active_flags %}<a class="btn btn-primary" href="javascript:void(0)" style="padding:1px 5px; font-size:10px;" onclick="document.getElementById('flaggers').classList.toggle('d-none')">{{p.active_flags}} Reports</a>{% endif %}
|
||||
{% if p.repost_id %}<span class="badge border-warning border-1 text-small-extra"><a class="text-warning" href="{{p.reposts.permalink}}">repost</a></span>{% endif %}
|
||||
{% if p.flags %}<a class="btn btn-primary" href="javascript:void(0)" style="padding:1px 5px; font-size:10px;" onclick="document.getElementById('flaggers').classList.toggle('d-none')">{{len(p.flags)}} Reports</a>{% endif %}
|
||||
<a {% if p.author.animatedname %}class="{% if p.author.patron %}patron{% else %}leaderboard{% endif %}"{% endif %} href="{{p.author.permalink}}" style="color: #{{p.author.namecolor}}; font-weight: bold;" class="user-name"> <img src="{{ p.author.profile_url }}" class="profile-pic-25 mr-2"/>{{p.author.username}}</a>{% if p.author.customtitle %} <bdi style="color: #{{p.author.titlecolor}}"> {{p.author.customtitle | safe}}</bdi>{% endif %}
|
||||
<span data-toggle="tooltip" data-placement="bottom" id="timestamp" title=""> {{p.age_string}}</span>
|
||||
({% if p.realurl(v) %}<a href="/search/posts/?q=domain%3A{{p.domain}}&sort=new&t=all" {% if v and v.newtabexternal %}target="_blank"{% endif %}>{{p.domain}}</a>{% else %}text post{% endif %})
|
||||
|
@ -359,10 +359,9 @@
|
|||
{% if v %}
|
||||
|
||||
{% if v.admin_level >=3 %}
|
||||
{% if p.is_banned or p.active_flags %}
|
||||
{% if p.is_banned %}
|
||||
<li class="list-inline-item"><a href="javascript:void(0)" onclick="post('/api/unban_post/{{p.base36id}}',callback=function(){window.location.reload(true);})"><i class="fas fa-check"></i>Approve</a></li>
|
||||
{% endif %}
|
||||
{% if not p.is_banned or p.active_flags %}
|
||||
{% else %}
|
||||
<li class="list-inline-item"><a href="javascript:void(0)" onclick="post('/api/ban_post/{{p.base36id}}',callback=function(){window.location.reload(true);})"><i class="fas fa-ban"></i>Remove</a></li>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
@ -490,7 +489,7 @@
|
|||
|
||||
</div>
|
||||
|
||||
{% if p.active_flags %}
|
||||
{% if p.flags %}
|
||||
<div id="flaggers" class="flaggers d-none" style="margin: 7px; border: 1px solid #999b2e; padding: 10px; border-radius: 3px;">
|
||||
<strong style="color: #999b2e;"><i class="far fa-fw fa-flag"></i> Reported by:</strong>
|
||||
<ul style="margin-bottom: 0;">
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
{% set score=p.score_fuzzed %}
|
||||
{% if v %}
|
||||
{% set voted=v.vote_status_on_post(p) %}
|
||||
{% set voted=p.voted %}
|
||||
{% set adjust=voted %}
|
||||
{% else %}
|
||||
{% set voted=-2 %}
|
||||
|
|
|
@ -135,8 +135,8 @@
|
|||
{% if p.is_blocking %}<i class="fas fa-user-minus text-warning" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="You're blocking this user, but you can see this post because {{'it\'s an admin post' if p.distinguish_level else 'you\'re an admin'}}."></i>{% endif %}
|
||||
{% if p.is_blocked %}<i class="fas fa-user-minus text-danger" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="This user is blocking you."></i>{% endif %}
|
||||
{% if p.private %}<span class="badge border-warning border-1 text-small-extra">unlisted</span>{% endif %}
|
||||
{% if p.is_repost %} <span class="badge border-warning border-1 text-small-extra"><a class="text-warning" href="{{p.reposts.permalink}}">repost</a></span>{% endif %}
|
||||
{% if p.active_flags %}<a class="btn btn-primary" href="javascript:void(0)" style="padding:1px 5px; font-size:10px;" onclick="document.getElementById('flaggers-{{p.id}}').classList.toggle('d-none')">{{p.active_flags}} Reports</a>{% endif %}
|
||||
{% if p.repost_id %} <span class="badge border-warning border-1 text-small-extra"><a class="text-warning" href="{{p.reposts.permalink}}">repost</a></span>{% endif %}
|
||||
{% if p.flags %}<a class="btn btn-primary" href="javascript:void(0)" style="padding:1px 5px; font-size:10px;" onclick="document.getElementById('flaggers-{{p.id}}').classList.toggle('d-none')">{{len(p.flags)}} Reports</a>{% endif %}
|
||||
<a {% if p.author.animatedname %}class="{% if p.author.patron %}patron{% else %}leaderboard{% endif %}"{% endif %} href="{{p.author.permalink}}" style="color: #{{p.author.namecolor}}; font-weight: bold;" class="user-name"><img src="{{ p.author.profile_url }}" class="profile-pic-25 mr-2"/>{{p.author.username}}</a>{% if p.author.customtitle %}<bdi style="color: #{{p.author.titlecolor}}"> {{p.author.customtitle | safe}}</bdi>{% endif %}
|
||||
<span data-toggle="tooltip" data-placement="bottom" id="timestamp-{{p.id}}" title=""> {{p.age_string}}</span>
|
||||
|
||||
|
@ -219,10 +219,9 @@
|
|||
{% if v %}
|
||||
|
||||
{% if v.admin_level >=3 %}
|
||||
{% if p.is_banned or p.active_flags %}
|
||||
{% if p.is_banned %}
|
||||
<li class="list-inline-item"><a class="text-success" id="moderate-post-{{p.base36id}}" href="javascript:void(0)" onclick="post('/api/unban_post/{{p.base36id}}',callback=function(){window.location.reload(true);})"><i class="fas fa-check text-success"></i>Approve</a></li>
|
||||
{% endif %}
|
||||
{% if not p.is_banned or p.active_flags %}
|
||||
{% else %}
|
||||
<li class="list-inline-item"><a id="moderate-post-{{p.base36id}}" href="javascript:void(0)" onclick="post('/api/ban_post/{{p.base36id}}',callback=function(){window.location.reload(true);})"><i class="fas fa-ban"></i>Remove</a></li>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
@ -329,7 +328,7 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
{% if p.active_flags %}
|
||||
{% if p.flags %}
|
||||
<div id="flaggers-{{p.id}}" class="flaggers d-none" style="margin: 7px; border: 1px solid #999b2e; padding: 10px; border-radius: 3px;">
|
||||
<strong style="color: #999b2e;"><i class="far fa-fw fa-flag"></i> Reported by:</strong>
|
||||
<ul style="margin-bottom: 0;">
|
||||
|
|
|
@ -322,9 +322,9 @@
|
|||
<small class="form-text text-muted">To post an image, use a direct image link such as i.imgur.com</small>
|
||||
</div>
|
||||
|
||||
<div {% if not v.can_submit_image %} class="d-none"{% else %} ondrop="event.preventDefault();let input=document.getElementById('file-upload');input.files=event.dataTransfer.files;input.onchange();" ondragover="event.preventDefault();"{% endif %}>
|
||||
<div {% if not v.dramacoins >= 0 %} class="d-none"{% else %} ondrop="event.preventDefault();let input=document.getElementById('file-upload');input.files=event.dataTransfer.files;input.onchange();" ondragover="event.preventDefault();"{% endif %}>
|
||||
|
||||
{% if v.can_submit_image %}
|
||||
{% if v.dramacoins >= 0 %}
|
||||
<div id="image-upload-block">
|
||||
<div><label class="mt-3">Image Upload</label></div>
|
||||
|
||||
|
@ -447,7 +447,7 @@
|
|||
});
|
||||
</script>
|
||||
|
||||
{% if v.can_submit_image %}
|
||||
{% if v.dramacoins >= 0 %}
|
||||
<script>
|
||||
document.onpaste = function(event) {
|
||||
f=document.getElementById('file-upload');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue