merge holes pages and create_hole and make holes and ping group pages identical

master
Aevann 2024-04-09 21:00:28 +02:00
parent 6e75613579
commit 8c010bc662
6 changed files with 89 additions and 113 deletions

View File

@ -7704,12 +7704,6 @@ thead {
}
}
@media (min-width: 768px) {
#group-warning {
max-width: 50%
}
}
input[type="search"]::-webkit-search-cancel-button {
display: none;
}

View File

@ -366,16 +366,6 @@ def remove_mod(v, hole):
return {"message": f"@{user.username} has been removed as a mod!"}
@app.get("/create_hole")
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400)
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400, key_func=get_ID)
@auth_required
def create_sub(v):
if not v.can_create_hole:
abort(403)
return render_template("hole/create_hole.html", v=v, cost=HOLE_COST)
@app.post("/create_hole")
@limiter.limit('1/second', scope=rpath)
@limiter.limit('1/second', scope=rpath, key_func=get_ID)
@ -672,7 +662,7 @@ def hole_marsey(v, hole):
def subs(v):
holes = g.db.query(Hole, func.count(Post.hole)).outerjoin(Post, Hole.name == Post.hole).group_by(Hole.name).order_by(Hole.created_utc).all()
total_users = g.db.query(User).count()
return render_template('hole/holes.html', v=v, holes=holes, total_users=total_users)
return render_template('hole/holes.html', v=v, cost=HOLE_COST, holes=holes, total_users=total_users)
@app.post("/hole_pin/<int:pid>")
@limiter.limit('1/second', scope=rpath)

View File

@ -1,76 +1,73 @@
{% extends "default.html" %}
{% block pagetitle %}Ping Groups{% endblock %}
{% block content %}
<div class="px-3">
<h3 class="mt-3">Create Ping Group</h3>
<form class="mt-3" action="/create_group" method="post" data-nonce="{{g.nonce}}" data-onsubmit="sendFormXHRReload(this)">
<div class="container pb-0" style="background-color: transparent !important">
<div class="row">
<div class="col col-md-6 px-0 pt-3 py-md-0">
<div class="body">
<input hidden name="formkey" value="{{v|formkey}}" class="notranslate" translate="no">
<label for="group-name">Group Name</label>
<input autocomplete="off" id="group-name" minlength="3" maxlength="25" pattern='[a-zA-Z0-9_\-]*' class="form-control" type="text" name="name" required>
<small class="form-text text-muted">3-25 characters, including letters, numbers, _ , and -</small>
<div class="footer">
<div class="d-flex">
<button type="submit" class="btn btn-primary ml-auto" {% if v.marseybux + v.coins < cost %}disabled{% endif %}>Create Group</button>
</div>
<p class="mt-2 mr-1 ml-3" style="float: right"><b>Cost</b>: {{cost}} coins or marseybux</p>
<h3 class="mt-3 ml-3">Create Ping Group</h3>
<form class="mt-3" action="/create_group" method="post" data-nonce="{{g.nonce}}" data-onsubmit="sendFormXHRReload(this)">
<div class="container pb-0" style="background-color: transparent !important">
<div class="row">
<div class="col col-md-6 px-3 pt-3 py-md-0">
<div class="body">
<input hidden name="formkey" value="{{v|formkey}}" class="notranslate" translate="no">
<label for="group-name">Group Name</label>
<input autocomplete="off" id="group-name" minlength="3" maxlength="25" pattern='[a-zA-Z0-9_\-]*' class="form-control" type="text" name="name" required>
<small class="form-text text-muted">3-25 characters, including letters, numbers, _ , and -</small>
<div class="footer">
<p class="text-danger mt-2">
Warning: ping groups can get usurped from their owners if they spend more than a month not reviewing membership applications.
</p>
<div class="d-flex">
<button type="submit" class="btn btn-primary ml-auto" {% if v.marseybux + v.coins < cost %}disabled{% endif %}>Create Group</button>
</div>
<p class="mt-2 mr-1 ml-3" style="float: right"><b>Cost</b>: {{cost}} coins or marseybux</p>
</div>
</div>
</div>
</div>
</form>
<p id="group-warning" class="text-danger">
Warning: ping groups can get usurped from their owners if they spend more than a month not reviewing membership applications.
</p>
<h3 class="mt-5 mb-3">Ping Groups</h3>
<div class="overflow-x-auto">
<table class="ping-groups">
<thead>
<tr>
<th>#</th>
<th>Name</th>
<th class="members">Members</th>
<th>Description</th>
<th>Created on</th>
</tr>
</thead>
<tbody>
{% for group in groups %}
<tr>
<td>{{loop.index}}</td>
<td>{{group.name}}</td>
<td class="unbreakable">
<a href="/!{{group}}">{{group.member_ids | length}}</a>
{% if v.id != group.owner_id %}
<button id="leave-{{group}}" type="button" class="ml-3 ml-md-5 btn btn-primary {% if v.id not in group.membership_user_ids %}d-none{% endif %}" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/!{{group}}/leave','leave-{{group}}','apply-{{group}}','d-none')">
{%- if v.id in group.member_ids or group.name in ('verifiedrich', 'focusgroup') -%}
Leave
{%- else -%}
Cancel Application
{%- endif -%}
</button>
<button id="apply-{{group}}" type="button" class="ml-3 ml-md-5 {% if v.id in group.membership_user_ids %}d-none{% endif %} btn btn-primary" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/!{{group}}/apply','leave-{{group}}','apply-{{group}}','d-none')">{% if group.name not in ('verifiedrich', 'focusgroup') %}Apply to {% endif %}Join</button>
{% endif %}
</td>
<td>
{% if group.description_html %}
{{group.description_html | safe}}
{% endif %}
</td>
<td data-time="{{group.created_utc}}"></td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</form>
<h3 class="mt-5 mb-3">Ping Groups</h3>
<div class="overflow-x-auto">
<table class="ping-groups">
<thead>
<tr>
<th>#</th>
<th>Name</th>
<th class="members">Members</th>
<th>Description</th>
<th>Created on</th>
</tr>
</thead>
<tbody>
{% for group in groups %}
<tr>
<td>{{loop.index}}</td>
<td>{{group.name}}</td>
<td class="unbreakable">
<a href="/!{{group}}">{{group.member_ids | length}}</a>
{% if v.id != group.owner_id %}
<button id="leave-{{group}}" type="button" class="ml-3 ml-md-5 btn btn-primary {% if v.id not in group.membership_user_ids %}d-none{% endif %}" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/!{{group}}/leave','leave-{{group}}','apply-{{group}}','d-none')">
{%- if v.id in group.member_ids or group.name in ('verifiedrich', 'focusgroup') -%}
Leave
{%- else -%}
Cancel Application
{%- endif -%}
</button>
<button id="apply-{{group}}" type="button" class="ml-3 ml-md-5 {% if v.id in group.membership_user_ids %}d-none{% endif %} btn btn-primary" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/!{{group}}/apply','leave-{{group}}','apply-{{group}}','d-none')">{% if group.name not in ('verifiedrich', 'focusgroup') %}Apply to {% endif %}Join</button>
{% endif %}
</td>
<td>
{% if group.description_html %}
{{group.description_html | safe}}
{% endif %}
</td>
<td data-time="{{group.created_utc}}"></td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endblock %}

View File

@ -1,29 +0,0 @@
{% extends "default.html" %}
{% block pagetitle %}Create a hole{% endblock %}
{% block content %}
<form class="mt-3" id="submitform" action="/create_hole" method="post" data-nonce="{{g.nonce}}">
<div class="container">
<div class="row justify-content-center mb-4 pb-6">
<div class="col col-md-6 p-3 py-md-0">
<h1 class="d-mob-none">Create a hole</h1>
<h3 class=" d-md-none">Create a hole</h3>
<div class="body">
<input hidden name="formkey" value="{{v|formkey}}" class="notranslate" translate="no">
<label for="create-hole-name">Hole Name</label>
<input autocomplete="off" minlength="3" maxlength="25" pattern='[a-zA-Z0-9_\-]*' class="form-control" id="create-hole-name" type="text" name="name" required>
<small class="form-text text-muted">3-25 characters, including letters, numbers, _ , and -</small>
{% if HOLE_INACTIVITY_DELETION %}
<p class="text-danger mt-2">Warning: holes get automatically deleted if they spend 7 days with no new posts.</p>
{% endif %}
<div class="footer">
<div class="d-flex">
<button type="submit" class="btn btn-primary ml-auto" {% if cost > v.coins + v.marseybux %}disabled{% endif %}>Create Hole</button>
</div>
<p class="mt-2 mr-1" style="float: right"><b>Cost</b>: {{cost}} coins or marseybux</p>
</div>
</div>
</div>
</div>
</div>
</form>
{% endblock %}

View File

@ -1,7 +1,32 @@
{% extends "default.html" %}
{% block pagetitle %}Hole List{% endblock %}
{% block content %}
<h5 class="mt-3 mb-1">Hole List</h5>
<h3 class="mt-3 ml-3">Create Hole</h3>
<form class="mt-3" id="submitform" action="/create_hole" method="post" data-nonce="{{g.nonce}}">
<div class="container pb-0">
<div class="row mb-4">
<div class="col col-md-6 p-3 py-md-0">
<div class="body">
<input hidden name="formkey" value="{{v|formkey}}" class="notranslate" translate="no">
<label for="create-hole-name">Hole Name</label>
<input autocomplete="off" minlength="3" maxlength="25" pattern='[a-zA-Z0-9_\-]*' class="form-control" id="create-hole-name" type="text" name="name" required>
<small class="form-text text-muted">3-25 characters, including letters, numbers, _ , and -</small>
{% if HOLE_INACTIVITY_DELETION or True %}
<p class="text-danger mt-2">Warning: holes get automatically deleted if they spend 7 days with no new posts.</p>
{% endif %}
<div class="footer">
<div class="d-flex">
<button type="submit" class="btn btn-primary ml-auto" {% if cost > v.coins + v.marseybux %}disabled{% endif %}>Create Hole</button>
</div>
<p class="mt-2 mr-1" style="float: right"><b>Cost</b>: {{cost}} coins or marseybux</p>
</div>
</div>
</div>
</div>
</div>
</form>
<h3 class="mb-3">Holes</h3>
<div class="overflow-x-auto">
<table>
<thead>

View File

@ -80,7 +80,6 @@
<span id="sidebar--directory--subhead">Emojis & Art | Info Megathreads</span>
</a>
<a class="btn btn-primary btn-block mb-3" href="/holes">BROWSE HOLES</a>
<a class="btn btn-primary btn-block mb-3" href="/create_hole">CREATE HOLE</a>
{% if hole %}
<br>