generate a mod log for CCing or unCCing posts and notify OP

remotes/1693176582716663532/tmp_refs/heads/watchparty
Aevann1 2022-10-07 04:48:31 +02:00
parent e0b1d7968a
commit 3ecb1b4f9a
7 changed files with 61 additions and 14 deletions

View File

@ -6038,6 +6038,7 @@ g {
.fa-css3-alt:before{content:"\f38b"}
.fa-landscape:before{content:"\e1b5"}
.fa-user-ninja:before{content:"\f504"}
.fa-club:before{content:"\f327"}
.pronouns {
font-size: 9px;

File diff suppressed because one or more lines are too long

View File

@ -419,7 +419,17 @@ ACTIONTYPES = {
"str": 'updated marsey image',
"icon": 'fa-cat',
"color": 'bg-success'
}
},
'club_post': {
"str": 'moved post {self.target_link} to the {cc}',
"icon": 'fa-club',
"color": 'bg-success'
},
'unclub_post': {
"str": 'removed post {self.target_link} from the {cc}',
"icon": 'fa-club',
"color": 'bg-muted'
},
}
ACTIONTYPES2 = deepcopy(ACTIONTYPES)

View File

@ -28,21 +28,57 @@ import os
titleheaders = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.72 Safari/537.36"}
@app.post("/toggle_club/<pid>")
@app.post("/club_post/<pid>")
@auth_required
def toggle_club(pid, v):
def club_post(pid, v):
if not FEATURES['COUNTRY_CLUB']:
abort(403)
post = get_post(pid)
if post.author_id != v.id and v.admin_level < 2: abort(403)
post.club = not post.club
g.db.add(post)
if not post.club:
post.club = True
g.db.add(post)
if post.author_id != v.id:
ma = ModAction(
kind = "club_post",
user_id = v.id,
target_submission_id = post.id,
)
g.db.add(ma)
if post.club: return {"message": "Post has been marked as club-only!"}
else: return {"message": "Post has been unmarked as club-only!"}
message = f"@{v.username} (admin) has moved [{post.title}]({post.shortlink}) to the {CC_TITLE}!"
send_repeatable_notification(post.author_id, message)
return {"message": f"Post has been moved to the {CC_TITLE}!"}
@app.post("/unclub_post/<pid>")
@auth_required
def unclub_post(pid, v):
if not FEATURES['COUNTRY_CLUB']:
abort(403)
post = get_post(pid)
if post.author_id != v.id and v.admin_level < 2: abort(403)
if post.club:
post.club = False
g.db.add(post)
if post.author_id != v.id:
ma = ModAction(
kind = "unclub_post",
user_id = v.id,
target_submission_id = post.id,
)
g.db.add(ma)
message = f"@{v.username} (admin) has removed [{post.title}]({post.shortlink}) from the {CC_TITLE}!"
send_repeatable_notification(post.author_id, message)
return {"message": f"Post has been removed from the {CC_TITLE}!"}
@app.post("/publish/<pid>")

View File

@ -56,8 +56,8 @@
{% endif %}
{% if FEATURES['COUNTRY_CLUB'] and (v.admin_level > 1 or v.id == p.author_id) %}
<a id="club-{{p.id}}" class="dropdown-item {% if p.club %}d-none{% endif %} list-inline-item text-info" role="button" onclick="post_toast(this,'/toggle_club/{{p.id}}','club-{{p.id}}','unclub-{{p.id}}','d-none')"><i class="fas fa-eye-slash"></i>Mark club</a>
<a id="unclub-{{p.id}}" class="dropdown-item {% if not p.club %}d-none{% endif %} list-inline-item text-info" role="button" onclick="post_toast(this,'/toggle_club/{{p.id}}','club-{{p.id}}','unclub-{{p.id}}','d-none')"><i class="fas fa-eye"></i>Unmark club</a>
<a id="club-{{p.id}}" class="dropdown-item {% if p.club %}d-none{% endif %} list-inline-item text-info" role="button" onclick="post_toast(this,'/club_post/{{p.id}}','club-{{p.id}}','unclub-{{p.id}}','d-none')"><i class="fas fa-eye-slash"></i>Mark club</a>
<a id="unclub-{{p.id}}" class="dropdown-item {% if not p.club %}d-none{% endif %} list-inline-item text-info" role="button" onclick="post_toast(this,'/unclub_post/{{p.id}}','club-{{p.id}}','unclub-{{p.id}}','d-none')"><i class="fas fa-eye"></i>Unmark club</a>
{% endif %}
{% if v.admin_level > 1 %}

View File

@ -40,8 +40,8 @@
{% if FEATURES['COUNTRY_CLUB'] -%}
<button id="club3-{{p.id}}" class="{% if p.club %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-danger text-left" role="button" onclick="post_toast(this,'/toggle_club/{{p.id}}','club3-{{p.id}}','unclub3-{{p.id}}','d-none')" data-bs-dismiss="modal"><i class="fas fa-eye-slash mr-2"></i>Mark club</button>
<button id="unclub3-{{p.id}}" class="{% if not p.club %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-success text-left" role="button" onclick="post_toast(this,'/toggle_club/{{p.id}}','club3-{{p.id}}','unclub3-{{p.id}}','d-none')" data-bs-dismiss="modal"><i class="fas fa-eye mr-2"></i>Unmark club</button>
<button id="club3-{{p.id}}" class="{% if p.club %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-danger text-left" role="button" onclick="post_toast(this,'/club_post/{{p.id}}','club3-{{p.id}}','unclub3-{{p.id}}','d-none')" data-bs-dismiss="modal"><i class="fas fa-eye-slash mr-2"></i>Mark club</button>
<button id="unclub3-{{p.id}}" class="{% if not p.club %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-success text-left" role="button" onclick="post_toast(this,'/unclub_post/{{p.id}}','club3-{{p.id}}','unclub3-{{p.id}}','d-none')" data-bs-dismiss="modal"><i class="fas fa-eye mr-2"></i>Unmark club</button>
{%- endif %}
{% else %}
{% if not p.ghost %}

View File

@ -14,8 +14,8 @@
{% endif %}
{% if FEATURES['COUNTRY_CLUB'] -%}
<button id="club2-{{p.id}}" class="{% if p.club %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-info text-left" role="button" onclick="post_toast(this,'/toggle_club/{{p.id}}','club2-{{p.id}}','unclub2-{{p.id}}','d-none')" data-bs-dismiss="modal"><i class="fas fa-eye-slash mr-2"></i>Mark club</button>
<button id="unclub2-{{p.id}}" class="{% if not p.club %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-info text-left" role="button" onclick="post_toast(this,'/toggle_club/{{p.id}}','club2-{{p.id}}','unclub2-{{p.id}}','d-none')" data-bs-dismiss="modal"><i class="fas fa-eye mr-2"></i>Unmark club</button>
<button id="club2-{{p.id}}" class="{% if p.club %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-info text-left" role="button" onclick="post_toast(this,'/club_post/{{p.id}}','club2-{{p.id}}','unclub2-{{p.id}}','d-none')" data-bs-dismiss="modal"><i class="fas fa-eye-slash mr-2"></i>Mark club</button>
<button id="unclub2-{{p.id}}" class="{% if not p.club %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-info text-left" role="button" onclick="post_toast(this,'/unclub_post/{{p.id}}','club2-{{p.id}}','unclub2-{{p.id}}','d-none')" data-bs-dismiss="modal"><i class="fas fa-eye mr-2"></i>Unmark club</button>
{%- endif %}
<button id="distinguish2-{{p.id}}" class="{% if p.distinguish_level %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-left text-primary" role="button" onclick="post_toast(this,'/distinguish/{{p.id}}','distinguish2-{{p.id}}','undistinguish2-{{p.id}}','d-none')" data-bs-dismiss="modal"><i class="fas fa-crown text-center text-primary mr-2"></i>Distinguish</button>