allow comment editing by JL5

master
Aevann 2023-08-15 23:22:46 +03:00
parent a6adbd8e5e
commit 2c19f5922c
6 changed files with 13 additions and 11 deletions

View File

@ -516,7 +516,7 @@ class User(Base):
if isinstance(target, Comment) and not target.post: return False
if self.id == target.author_id: return True
if not isinstance(target, Post): return False
return bool(self.admin_level >= PERMS['POST_EDITING'])
return bool(self.admin_level >= PERMS['POST_COMMENT_EDITING'])
@property
@lazy

View File

@ -417,7 +417,7 @@ PERMS = { # Minimum admin_level to perform action.
'PROGSTACK': 5,
'ADMIN_ADD': 5,
'USER_BLACKLIST': 5,
'POST_EDITING': 5,
'POST_COMMENT_EDITING': 5,
'VIEW_PATRONS': 5,
'BLACKJACK_NOTIFICATIONS': 5,
'IGNORE_BADGE_BLACKLIST': 5,
@ -786,7 +786,7 @@ elif SITE == 'watchpeopledie.tv':
FEATURES['BOTS'] = False
PERMS['HOLE_CREATE'] = 2
PERMS['POST_EDITING'] = 2
PERMS['POST_COMMENT_EDITING'] = 2
PERMS['USER_BLACKLIST'] = 6
SUB_BANNER_LIMIT = 69420

View File

@ -617,7 +617,9 @@ def edit_comment(cid, v):
and v.admin_level < PERMS["IGNORE_1WEEk_EDITING_LIMIT"] and v.id not in EXEMPT_FROM_1WEEK_EDITING_LIMIT:
abort(403, "You can't edit comments older than 1 week!")
if c.author_id != v.id: abort(403)
if c.author_id != v.id and v.admin_level < PERMS['POST_COMMENT_EDITING']:
abort(403)
if not c.parent_post and not c.wall_user_id:
abort(403)

View File

@ -398,14 +398,14 @@
<button type="button" id="save-{{c.id}}" class="btn caction py-0 nobackground px-1 {% if c.id not in v.saved_comment_idlist %}d-md-inline-block{% endif %} text-muted d-none" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/save_comment/{{c.id}}','save-{{c.id}}','unsave-{{c.id}}','d-md-inline-block')"><i class="fas fa-save"></i>Save {% if c.num_savers %}<span data-bs-toggle="tooltip" data-bs-placement="bottom" title="Number of users who saved this comment">[{{c.num_savers}}]</span>{% endif %}</button>
{% endif %}
{% if c.parent_post or c.wall_user_id %}
{% if v and c.author_id == v.id %}
{% if v and (c.parent_post or c.wall_user_id) %}
{% if c.author_id == v.id or v.admin_level >= PERMS['POST_COMMENT_EDITING'] %}
<button type="button" class="btn caction py-0 nobackground px-1 text-muted" data-nonce="{{g.nonce}}" data-onclick="toggleEdit('{{c.id}}')"><i class="fas fa-edit fa-fw"></i>Edit</button>
<button type="button" id="undelete-{{c.id}}" class="btn caction py-0 nobackground px-1 text-muted {% if not c.deleted_utc %}d-none{% endif %}" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/undelete/comment/{{c.id}}','delete-{{c.id}}','undelete-{{c.id}}','d-none')" data-toggleelement=".comment-{{c.id}}-only" data-toggleattr="deleted"><i class="fas fa-trash-alt fa-fw"></i>Undelete</button>
<button type="button" id="delete-{{c.id}}" class="btn caction py-0 nobackground px-1 text-muted {% if c.deleted_utc %}d-none{% endif %}" data-bs-toggle="modal" data-bs-target="#deleteCommentModal" data-nonce="{{g.nonce}}" data-onclick="delete_commentModal(this, '{{c.id}}')"><i class="fas fa-trash-alt fa-fw"></i>Delete</button>
{% elif v and c.body %}
{% elif c.body %}
<button type="button" class="btn caction py-0 nobackground px-1 text-muted" data-nonce="{{g.nonce}}" data-onclick="expandMarkdown('{{c.fullname}}')"><i class="fas text-expand-icon-{{c.fullname}} fa-expand-alt"></i><span class="expand-text-{{c.fullname}}">View source</span></button>
{% endif %}
{% endif %}
@ -593,7 +593,7 @@
<button type="button" id="unsave2-{{c.id}}" class="list-group-item {% if c.id not in v.saved_comment_idlist %}d-none{% endif %}" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/unsave_comment/{{c.id}}','save2-{{c.id}}','unsave2-{{c.id}}','d-none')" data-bs-dismiss="modal"><i class="fas fa-save mr-2"></i>Unsave {% if c.num_savers %}<span data-bs-toggle="tooltip" data-bs-placement="bottom" title="Number of users who saved this comment">[{{c.num_savers}}]</span>{% endif %}</button>
{% if c.author_id == v.id %}
{% if c.author_id == v.id or v.admin_level >= PERMS['POST_COMMENT_EDITING'] %}
<button type="button" data-bs-dismiss="modal" data-nonce="{{g.nonce}}" data-onclick="toggleEdit('{{c.id}}')" class="list-group-item"><i class="fas fa-edit mr-2"></i>Edit</button>
<button type="button" id="undelete2-{{c.id}}" class="{% if not c.deleted_utc %}d-none{% endif %} list-group-item text-success" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/undelete/comment/{{c.id}}', 'delete2-{{c.id}}', 'undelete2-{{c.id}}','d-none')" data-toggleelement=".comment-{{c.id}}-only" data-toggleattr="deleted" data-bs-dismiss="modal"><i class="far fa-trash-alt text-success mr-2"></i>Undelete</button>

View File

@ -38,7 +38,7 @@
<ul class="list-group post-actions">
{% if v.id==p.author_id %}
<button type="button" class="nobackground btn btn-link btn-block btn-lg text-left text-muted" data-bs-dismiss="modal" data-nonce="{{g.nonce}}" data-onclick="togglePostEdit('{{p.id}}')"><i class="far fa-edit text-center text-muted mr-2"></i>Edit</button>
{% elif p.body and v.admin_level < PERMS['POST_EDITING'] %}
{% elif p.body and v.admin_level < PERMS['POST_COMMENT_EDITING'] %}
<button type="button" class="nobackground btn btn-link btn-block btn-lg text-left text-muted" data-bs-dismiss="modal" data-nonce="{{g.nonce}}" data-onclick="expandMarkdown('{{p.fullname}}')"><i class="fas text-expand-icon-{{p.fullname}} fa-expand-alt text-center mr-2"></i><span class="expand-text-{{p.fullname}}">View source</span></button>
{% endif %}
@ -268,7 +268,7 @@
</div>
</div>
{% if v and v.id != p.author_id and p.body and not v_forbid_deleted and v.admin_level < PERMS['POST_EDITING'] %}
{% if v and v.id != p.author_id and p.body and not v_forbid_deleted and v.admin_level < PERMS['POST_COMMENT_EDITING'] %}
<div autocomplete="off" class="markdown d-none border my-2 p-3 rounded" id="markdown-{{p.fullname}}" readonly>{{p.body.strip()}}</div>
{% endif %}

View File

@ -13,7 +13,7 @@
<a href="{{p.oauth_app.permalink}}/posts" class="nobackground btn btn-link btn-block btn-lg text-muted text-left text-info"><i class="far fa-code text-center text-info mr-2"></i>API App</a>
{% endif %}
{% if (request.path.startswith('/post/') or request.path.startswith('/h/')) and v.admin_level >= PERMS['POST_EDITING'] and p.id %}
{% if (request.path.startswith('/post/') or request.path.startswith('/h/')) and v.admin_level >= PERMS['POST_COMMENT_EDITING'] and p.id %}
<button type="button" class="nobackground btn btn-link btn-block btn-lg text-left text-muted" data-bs-dismiss="modal" data-nonce="{{g.nonce}}" data-onclick="togglePostEdit('{{p.id}}')"><i class="far fa-edit text-center text-muted mr-2"></i>Edit</button>
{% endif %}