remotes/1693045480750635534/spooky-22
Aevann1 2021-07-26 00:11:26 +02:00
parent 8a4e41f450
commit f72025f9b9
11 changed files with 22 additions and 90 deletions

View File

@ -146,18 +146,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}/"
@property
def any_descendants_live(self):
if self.replies == []:
return False
if any([not x.is_banned and x.deleted_utc == 0 for x in self.replies]):
return True
else:
return any([x.any_descendants_live for x in self.replies])
def rendered_comment(self, v=None, render_replies=True,
standalone=False, level=1, **kwargs):
@ -205,7 +193,7 @@ class Comment(Base, Age_times, Scores, Stndrd, Fuzzing):
'id': self.base36id,
'fullname': self.fullname,
'level': self.level,
'author_name': self.author.username if not self.author.deleted_utc > 0 else None,
'author_name': self.author.username,
'body': self.body,
'body_html': self.body_html,
'is_archived': self.is_archived,
@ -405,14 +393,10 @@ class Comment(Base, Age_times, Scores, Stndrd, Fuzzing):
return data
@property
def is_exiled_for(self):
return self.__dict__.get('_is_exiled_for', None)
@property
@lazy
def is_op(self):
return self.author_id==self.post.author_id and not self.author.deleted_utc > 0 and not self.post.author.deleted_utc > 0 and not self.post.deleted_utc
return self.author_id==self.post.author_id

View File

@ -68,10 +68,7 @@ class ModAction(Base, Stndrd, Age_times):
@property
def target_link(self):
if self.target_user:
if self.target_user.deleted_utc:
return "[deleted user]"
else:
return f'<a href="{self.target_user.permalink}">{self.target_user.username}</a>'
return f'<a href="{self.target_user.permalink}">{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:
@ -117,14 +114,7 @@ class ModAction(Base, Stndrd, Age_times):
@property
def permalink(self):
return f"/log/{self.base36id}"
@property
def title_text(self):
if self.user.deleted_utc:
return f"[deleted user] {self.actiontype['title'].format(self=self)}"
else:
return f"@{self.user.username} {self.actiontype['title'].format(self=self)}"
return f"/log/{self.base36id}"

View File

@ -265,7 +265,7 @@ class Submission(Base, Stndrd, Age_times, Scores, Fuzzing):
@property
def json_raw(self):
data = {'author_name': self.author.username if not self.author.deleted_utc > 0 else None,
data = {'author_name': self.author.username,
'permalink': self.permalink,
'is_banned': bool(self.is_banned),
'deleted_utc': self.deleted_utc,

View File

@ -610,22 +610,12 @@ class User(Base, Stndrd, Age_times):
'ban_reason': self.ban_reason,
'id': self.base36id
}
elif self.deleted_utc:
return {'username': self.username,
'permalink': self.permalink,
'deleted_utc': True,
'id': self.base36id
}
return self.json_raw
@property
def json(self):
data = self.json_core
if self.deleted_utc > 0 or self.is_banned:
return data
data["badges"] = [x.json_core for x in self.badges]
data['dramacoins'] = int(self.dramacoins)
data['post_count'] = self.post_count
@ -637,20 +627,6 @@ class User(Base, Stndrd, Age_times):
def can_use_darkmode(self):
return True
# return self.referral_count or self.has_earned_darkmode or
# self.has_badge(16) or self.has_badge(17)
@property
def is_valid(self):
if self.is_banned and self.unban_utc == 0:
return False
elif self.deleted_utc:
return False
else:
return True
def ban(self, admin=None, reason=None, days=0):
if days > 0:

View File

@ -60,8 +60,7 @@ def login_post():
if "@" in username:
account = g.db.query(User).filter(
User.email.ilike(username),
User.deleted_utc == False).first()
User.email.ilike(username)).first()
else:
account = get_user(username, graceful=True)
@ -69,10 +68,6 @@ def login_post():
time.sleep(random.uniform(0, 2))
return render_template("login.html", failed=True, i=random_image())
if account.deleted_utc:
time.sleep(random.uniform(0, 2))
return render_template("login.html", failed=True, i=random_image())
# test password
if request.form.get("password"):
@ -417,8 +412,7 @@ def post_forgot():
user = g.db.query(User).filter(
User.username.ilike(username),
User.email.ilike(email),
User.deleted_utc == False).first()
User.email.ilike(email)).first()
if user:
# generate url

View File

@ -55,7 +55,6 @@ def searchlisting(criteria, v=None, page=1, t="None", sort="top", b=None):
posts=posts.filter(
Submission.author_id==get_user(criteria['author']).id,
User.is_private==False,
User.deleted_utc==False
)
if 'domain' in criteria:

View File

@ -264,13 +264,6 @@ def u_username(username, v=None):
g.db.add(view)
if u.deleted_utc > 0 and (not v or v.admin_level < 3):
return {'html': lambda: render_template("userpage_deleted.html",
u=u,
v=v),
'api': lambda: {"error": "That user deactivated their account."}
}
if u.is_private and (not v or (v.id != u.id and v.admin_level < 3)):
return {'html': lambda: render_template("userpage_private.html",
u=u,

View File

@ -124,7 +124,7 @@
{% if c.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 comment because {{'it\'s an admin comment' if c.distinguish_level else 'you\'re an admin'}}."></i>&nbsp;{% endif %}
{% if c.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, but you can see this comment because {{'it\'s an admin comment' if c.distinguish_level else 'you\'re an admin'}}."></i>&nbsp;{% endif %}
{% if c.author.deleted_utc > 0 %}[deleted account]{% else %}<a {% if c.author.animatedname %}class="{% if c.author.patron %}patron{% else %}leaderboard{% endif %}"{% endif %} style="color:#{{c.author.namecolor}}; font-size:12px; font-weight:bold;" href="/@{{c.author.username}}"><img src="{{ c.author.profile_url }}" class="profile-pic-25 mr-2"/>{{c.author.username}}</a>{% if c.author.customtitle %}&nbsp;<bdi style="color: #{{c.author.titlecolor}}">&nbsp;{{c.author.customtitle | safe}}</bdi>{% endif %}{% endif %}
<a {% if c.author.animatedname %}class="{% if c.author.patron %}patron{% else %}leaderboard{% endif %}"{% endif %} style="color:#{{c.author.namecolor}}; font-size:12px; font-weight:bold;" href="/@{{c.author.username}}"><img src="{{ c.author.profile_url }}" class="profile-pic-25 mr-2"/>{{c.author.username}}</a>{% if c.author.customtitle %}&nbsp;<bdi style="color: #{{c.author.titlecolor}}">&nbsp;{{c.author.customtitle | safe}}</bdi>{% endif %}
<span id="timestamp-{{c.id}}" data-toggle="tooltip" data-placement="bottom" title="" class="time-stamp">&nbsp;{{c.age_string}}</span>
{% if c.edited_utc %}

View File

@ -39,11 +39,7 @@
</span>
<div class="text-muted pl-3">
<div>
{% if not ma.user.deleted_utc > 0 %}
<a href="{{ma.user.permalink}}" class="font-weight-bold text-black" target="_self">@{{ma.user.username}}</a>
{% else %}
[deleted user]
{% endif %}
<a href="{{ma.user.permalink}}" class="font-weight-bold text-black" target="_self">@{{ma.user.username}}</a>
<span>{{ma.string | safe}}</span>
</div>

View File

@ -26,23 +26,23 @@
<meta property="og:type" content="article" />
{% if comment_info and not comment_info.is_banned and not linked_comment.deleted_utc > 0 %}
<title>{{'@'+comment_info.author.username if not comment_info.author.deleted_utc > 0 else '[deleted account]'}} comments on "{{title}} - Drama"</title>
<title>{{'@'+comment_info.author.username comments on "{{title}} - Drama"</title>
<meta property="og:article:author" content="{{'@'+comment_info.author.username if not comment_info.author.deleted_utc > 0 else '[deleted account]'}}" />
<meta property="og:article:author" content="{{'@'+comment_info.author.username}}" />
<meta property="article:published_time" content="{{comment_info.created_datetime}}" />
{% if comment_info.edited_utc %}<meta property="article:modified_time" content="{{comment_info.edited_string}}" />{% endif %}
<meta property="og:description" name="description" content="{{comment_info.body}}" />
<meta property="og:author" name="author" content="{{'@'+comment_info.author.username if not comment_info.author.deleted_utc > 0 else '[deleted account]'}}" />
<meta property="og:title" content="{{'@'+comment_info.author.username if not comment_info.author.deleted_utc > 0 else '[deleted account]'}} comments on {{title}} - Drama" />
<meta property="og:author" name="author" content="{{'@'+comment_info.author.username}}" />
<meta property="og:title" content="{{'@'+comment_info.author.username}} comments on {{title}} - Drama" />
<meta property="og:image" content="{% if p.is_image %}{{p.realurl(v)}}{% elif p.has_thumb%}{{p.thumb_url}}{% else %}{{'/assets/images/preview.png' | full_link}}{% endif %}" />
<meta property="og:url" content="{{comment_info.permalink | full_link}}" />
<meta property="og:site_name" content="rdrama.net" />
<meta name="twitter:card" content="summary" />
<meta name="twitter:site" content="@drama">
<meta name="twitter:title" content="{{'@'+comment_info.author.username if not comment_info.author.deleted_utc > 0 else '[deleted account]'}} comments on {{title}} - Drama" />
<meta name="twitter:creator" content="{{'@'+comment_info.author.username if not comment_info.author.deleted_utc > 0 else '[deleted account]'}}">
<meta name="twitter:title" content="{{'@'+comment_info.author.username}} comments on {{title}} - Drama" />
<meta name="twitter:creator" content="{{'@'+comment_info.author.username}}">
<meta name="twitter:description" content="{{comment_info.body}}" />
<meta name="twitter:image" content="{% if p.is_image %}{{p.realurl(v)}}{% elif p.has_thumb%}{{p.thumb_url}}{% else %}{{'/assets/images/preview.png' | full_link}}{% endif %}" />
<meta name="twitter:url" content="{{p.permalink | full_link}}" />
@ -55,11 +55,11 @@
<title>{{title | safe}} - Drama</title>
<meta property="og:article:author" content="{{'@'+p.author.username if not p.author.deleted_utc > 0 else '[deleted account]'}}" />
<meta property="og:article:author" content="{{'@'+p.author.username}}" />
<meta property="article:published_time" content="{{p.created_iso}}" />
{% if p.edited_utc %}<meta property="article:modified_time" content="{{p.edited_string}}" />{% endif %}
<meta property="og:description" name="description" content="{{p.body}}" />
<meta property="og:author" name="author" content="{{'@'+p.author.username if not p.author.deleted_utc > 0 else '[deleted account]'}}" />
<meta property="og:author" name="author" content="{{'@'+p.author.username}}" />
<meta property="og:title" content="{{title}} - Drama" />
<meta property="og:image" content="{% if p.is_image %}{{p.realurl(v)}}{% elif p.has_thumb%}{{p.thumb_url}}{% else %}{{'/assets/images/preview.png' | full_link}}{% endif %}" />
<meta property="og:url" content="{{p.permalink | full_link}}" />
@ -68,7 +68,7 @@
<meta name="twitter:card" content="summary_large_image"/>
<meta name="twitter:site" content="@drama">
<meta name="twitter:title" content="{{title}} - Drama" />
<meta name="twitter:creator" content="{{'@'+p.author.username if not p.author.deleted_utc > 0 else '[deleted account]'}}">
<meta name="twitter:creator" content="{{'@'+p.author.username}}">
<meta name="twitter:description" content="{{p.body}}" />
<meta name="twitter:image" content="{% if p.is_image %}{{p.realurl(v)}}{% elif p.has_thumb %}{{p.thumb_url}}{% else %}{{'/assets/images/preview.png' | full_link}}{% endif %}" />
<meta name="twitter:url" content="{{p.permalink | full_link}}" />
@ -96,7 +96,7 @@
<div class="modal-body">
<ul class="list-group post-actions">
{% if not (v and v.id==p.author_id) %}
<button class="btn btn-link btn-block btn-lg text-left text-muted" data-toggle="modal" data-dismiss="modal" data-target="#reportPostModal" onclick="report_postModal('{{p.base36id}}','{{'@'+p.author.username if not p.author.deleted_utc > 0 else '[deleted account]'}}')" class="d-block"><i class="far fa-flag text-center text-muted mr-3"></i>Report</button>
<button class="btn btn-link btn-block btn-lg text-left text-muted" data-toggle="modal" data-dismiss="modal" data-target="#reportPostModal" onclick="report_postModal('{{p.base36id}}','{{'@'+p.author.username}}')" class="d-block"><i class="far fa-flag text-center text-muted mr-3"></i>Report</button>
{% endif %}
{% if v and v.id==p.author_id %}
{% if p.private %}
@ -217,7 +217,7 @@
{% 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.author.deleted_utc > 0 %}[deleted account]{% else %}&nbsp;<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">&nbsp;&nbsp;<img src="{{ p.author.profile_url }}" class="profile-pic-25 mr-2"/>{{p.author.username}}</a>{% if p.author.customtitle %}&nbsp;<bdi style="color: #{{p.author.titlecolor}}">&nbsp;{{p.author.customtitle | safe}}</bdi>{% endif %}{% endif %}
&nbsp;<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">&nbsp;&nbsp;<img src="{{ p.author.profile_url }}" class="profile-pic-25 mr-2"/>{{p.author.username}}</a>{% if p.author.customtitle %}&nbsp;<bdi style="color: #{{p.author.titlecolor}}">&nbsp;{{p.author.customtitle | safe}}</bdi>{% endif %}
<span data-toggle="tooltip" data-placement="bottom" id="timestamp" title="">&nbsp;{{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 %})

View File

@ -137,7 +137,7 @@
{% if p.private %}<span class="badge border-warning border-1 text-small-extra">unlisted</span>{% endif %}
{% if p.is_repost %}&nbsp;<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.author.deleted_utc > 0 %}[deleted account]{% else %}&nbsp;<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}}">&nbsp;&nbsp;{{p.author.customtitle | safe}}</bdi>{% endif %}{% endif %}
&nbsp;<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}}">&nbsp;&nbsp;{{p.author.customtitle | safe}}</bdi>{% endif %}
<span data-toggle="tooltip" data-placement="bottom" id="timestamp-{{p.id}}" title="">&nbsp;{{p.age_string}}</span>
&nbsp;
({% if p.realurl(v) %}<a href="/search/posts/?q=domain%3A{{p.domain}}&sort=new&t=all" target="_blank">{{p.domain}}</a>{% else %}text post{% endif %})
@ -375,7 +375,7 @@
{% endif %}
{% if not (v and v.id==p.author_id) %}
<button class="btn btn-link btn-block btn-lg text-left text-muted" data-toggle="modal" data-dismiss="modal" data-target="#reportPostModal" onclick="report_postModal('{{p.base36id}}','{{'@'+p.author.username if not p.author.deleted_utc > 0 else '[deleted account]'}}')" class="d-block"><i class="far fa-flag text-center text-muted mr-3"></i>Report</button>
<button class="btn btn-link btn-block btn-lg text-left text-muted" data-toggle="modal" data-dismiss="modal" data-target="#reportPostModal" onclick="report_postModal('{{p.base36id}}','{{'@'+p.author.username}}')" class="d-block"><i class="far fa-flag text-center text-muted mr-3"></i>Report</button>
{% endif %}
{% if v and v.id==p.author_id %}
<button class="btn btn-link btn-block btn-lg text-info text-left" id="pin-post-{{p.base36id}}" href="javascript:void(0)" onclick="post('/api/pin/{{p.base36id}}',callback=function(){window.location.reload(true);})"><i class="fas fa-thumbtack text-center text-muted mr-3"></i>{% if p.is_pinned %}Unpin from your profile{% else %}Pin to your profile{% endif %}</button>