Pagination styling and "max users" signup limit
This commit is contained in:
parent
252737f846
commit
a7a292a84c
|
@ -213,6 +213,7 @@ class Config(models.Model):
|
||||||
|
|
||||||
signup_allowed: bool = True
|
signup_allowed: bool = True
|
||||||
signup_text: str = ""
|
signup_text: str = ""
|
||||||
|
signup_max_users: int = 0
|
||||||
content_warning_text: str = "Content Warning"
|
content_warning_text: str = "Content Warning"
|
||||||
|
|
||||||
post_length: int = 500
|
post_length: int = 500
|
||||||
|
|
|
@ -1538,15 +1538,15 @@ form .post {
|
||||||
.pagination {
|
.pagination {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
gap: 1em;
|
gap: 1em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.load-more {
|
.pagination .count {
|
||||||
margin: 10px 0;
|
display: inline-block;
|
||||||
text-align: center;
|
color: var(--color-text-dull);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@media (max-width: 920px),
|
@media (max-width: 920px),
|
||||||
(display-mode: standalone) {
|
(display-mode: standalone) {
|
||||||
div.columns {
|
div.columns {
|
||||||
|
|
|
@ -12,11 +12,11 @@
|
||||||
|
|
||||||
<div class="pagination">
|
<div class="pagination">
|
||||||
{% if page_obj.has_previous %}
|
{% if page_obj.has_previous %}
|
||||||
<div class="load-more"><a class="button" href=".?page={{ page_obj.previous_page_number }}">Previous Page</a></div>
|
<a class="button" href=".?page={{ page_obj.previous_page_number }}">Previous Page</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if page_obj.has_next %}
|
{% if page_obj.has_next %}
|
||||||
<div class="load-more"><a class="button" href=".?page={{ page_obj.next_page_number }} {% if config_identity.infinite_scroll %}hx-trigger="revealed"{% endif %}">Next Page</a></div>
|
<a class="button" href=".?page={{ page_obj.next_page_number }} {% if config_identity.infinite_scroll %}hx-trigger="revealed"{% endif %}">Next Page</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -24,10 +24,13 @@
|
||||||
{% empty %}
|
{% empty %}
|
||||||
<p class="option empty">There are no federation links yet.</p>
|
<p class="option empty">There are no federation links yet.</p>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
<div class="load-more">
|
<div class="pagination">
|
||||||
{% if page_obj.has_previous %}
|
{% if page_obj.has_previous %}
|
||||||
<a class="button" href=".?page={{ page_obj.previous_page_number }}">Previous Page</a>
|
<a class="button" href=".?page={{ page_obj.previous_page_number }}">Previous Page</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if page_obj.paginator.count %}
|
||||||
|
<span class="count">{{ page_obj.paginator.count }} domain{{page_obj.paginator.count|pluralize }}</span>
|
||||||
|
{% endif %}
|
||||||
{% if page_obj.has_next %}
|
{% if page_obj.has_next %}
|
||||||
<a class="button" href=".?page={{ page_obj.next_page_number }}">Next Page</a>
|
<a class="button" href=".?page={{ page_obj.next_page_number }}">Next Page</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -37,10 +37,13 @@
|
||||||
{% empty %}
|
{% empty %}
|
||||||
<p class="option empty">There are no hashtags yet.</p>
|
<p class="option empty">There are no hashtags yet.</p>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
<div class="load-more">
|
<div class="pagination">
|
||||||
{% if page_obj.has_previous %}
|
{% if page_obj.has_previous %}
|
||||||
<a class="button" href=".?page={{ page_obj.previous_page_number }}">Previous Page</a>
|
<a class="button" href=".?page={{ page_obj.previous_page_number }}">Previous Page</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if page_obj.paginator.count %}
|
||||||
|
<span class="count">{{ page_obj.paginator.count }} hashtag{{page_obj.paginator.count|pluralize }}</span>
|
||||||
|
{% endif %}
|
||||||
{% if page_obj.has_next %}
|
{% if page_obj.has_next %}
|
||||||
<a class="button" href=".?page={{ page_obj.next_page_number }}">Next Page</a>
|
<a class="button" href=".?page={{ page_obj.next_page_number }}">Next Page</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -38,10 +38,13 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</p>
|
</p>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
<div class="load-more">
|
<div class="pagination">
|
||||||
{% if page_obj.has_previous %}
|
{% if page_obj.has_previous %}
|
||||||
<a class="button" href=".?page={{ page_obj.previous_page_number }}{% if local_only %}&local_only=true{% endif %}{% if query %}&query={{ query }}{% endif %}">Previous Page</a>
|
<a class="button" href=".?page={{ page_obj.previous_page_number }}{% if local_only %}&local_only=true{% endif %}{% if query %}&query={{ query }}{% endif %}">Previous Page</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if page_obj.paginator.count %}
|
||||||
|
<span class="count">{{ page_obj.paginator.count }} identit{{page_obj.paginator.count|pluralize:"y,ies" }}</span>
|
||||||
|
{% endif %}
|
||||||
{% if page_obj.has_next %}
|
{% if page_obj.has_next %}
|
||||||
<a class="button" href=".?page={{ page_obj.next_page_number }}{% if local_only %}&local_only=true{% endif %}{% if query %}&query={{ query }}{% endif %}">Next Page</a>
|
<a class="button" href=".?page={{ page_obj.next_page_number }}{% if local_only %}&local_only=true{% endif %}{% if query %}&query={{ query }}{% endif %}">Next Page</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -39,10 +39,13 @@
|
||||||
There are no unused invites.
|
There are no unused invites.
|
||||||
</p>
|
</p>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
<div class="load-more">
|
<div class="pagination">
|
||||||
{% if page_obj.has_previous %}
|
{% if page_obj.has_previous %}
|
||||||
<a class="button" href=".?page={{ page_obj.previous_page_number }}">Previous Page</a>
|
<a class="button" href=".?page={{ page_obj.previous_page_number }}">Previous Page</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if page_obj.paginator.count %}
|
||||||
|
<span class="count">{{ page_obj.paginator.count }} invite{{page_obj.paginator.count|pluralize }}</span>
|
||||||
|
{% endif %}
|
||||||
{% if page_obj.has_next %}
|
{% if page_obj.has_next %}
|
||||||
<a class="button" href=".?page={{ page_obj.next_page_number }}">Next Page</a>
|
<a class="button" href=".?page={{ page_obj.next_page_number }}">Next Page</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -31,10 +31,13 @@
|
||||||
There are no {% if all %}reports yet{% else %}unresolved reports{% endif %}.
|
There are no {% if all %}reports yet{% else %}unresolved reports{% endif %}.
|
||||||
</p>
|
</p>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
<div class="load-more">
|
<div class="pagination">
|
||||||
{% if page_obj.has_previous %}
|
{% if page_obj.has_previous %}
|
||||||
<a class="button" href=".?page={{ page_obj.previous_page_number }}{% if all %}&all=true{% endif %}">Previous Page</a>
|
<a class="button" href=".?page={{ page_obj.previous_page_number }}{% if all %}&all=true{% endif %}">Previous Page</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if page_obj.paginator.count %}
|
||||||
|
<span class="count">{{ page_obj.paginator.count }} report{{page_obj.paginator.count|pluralize }}</span>
|
||||||
|
{% endif %}
|
||||||
{% if page_obj.has_next %}
|
{% if page_obj.has_next %}
|
||||||
<a class="button" href=".?page={{ page_obj.next_page_number }}{% if all %}&all=true{% endif %}">Next Page</a>
|
<a class="button" href=".?page={{ page_obj.next_page_number }}{% if all %}&all=true{% endif %}">Next Page</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -30,10 +30,13 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</p>
|
</p>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
<div class="load-more">
|
<div class="pagination">
|
||||||
{% if page_obj.has_previous %}
|
{% if page_obj.has_previous %}
|
||||||
<a class="button" href=".?page={{ page_obj.previous_page_number }}">Previous Page</a>
|
<a class="button" href=".?page={{ page_obj.previous_page_number }}">Previous Page</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if page_obj.paginator.count %}
|
||||||
|
<span class="count">{{ page_obj.paginator.count }} user{{page_obj.paginator.count|pluralize }}</span>
|
||||||
|
{% endif %}
|
||||||
{% if page_obj.has_next %}
|
{% if page_obj.has_next %}
|
||||||
<a class="button" href=".?page={{ page_obj.next_page_number }}">Next Page</a>
|
<a class="button" href=".?page={{ page_obj.next_page_number }}">Next Page</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
</span>
|
</span>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
<div class="load-more">
|
<div class="pagination">
|
||||||
{% if page_obj.has_previous %}
|
{% if page_obj.has_previous %}
|
||||||
<a class="button" href=".?page={{ page_obj.previous_page_number }}">Previous Page</a>
|
<a class="button" href=".?page={{ page_obj.previous_page_number }}">Previous Page</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -97,7 +97,9 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
{% if page_obj.has_next %}
|
{% if page_obj.has_next %}
|
||||||
<div class="load-more"><a class="button" href=".?page={{ page_obj.next_page_number }}">Next Page</a></div>
|
<div class="pagination">
|
||||||
|
<a class="button" href=".?page={{ page_obj.next_page_number }}">Next Page</a>
|
||||||
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -76,6 +76,10 @@ class BasicSettings(AdminSettingsPage):
|
||||||
"help_text": "Shown above the signup form.\nUse Markdown for formatting.",
|
"help_text": "Shown above the signup form.\nUse Markdown for formatting.",
|
||||||
"display": "textarea",
|
"display": "textarea",
|
||||||
},
|
},
|
||||||
|
"signup_max_users": {
|
||||||
|
"title": "Maximum User Limit",
|
||||||
|
"help_text": "Signups will be auto-disabled if your server grows to this many users.\nUse 0 for unlimited.",
|
||||||
|
},
|
||||||
"restricted_usernames": {
|
"restricted_usernames": {
|
||||||
"title": "Restricted Usernames",
|
"title": "Restricted Usernames",
|
||||||
"help_text": "Usernames that only admins can register for identities. One per line.",
|
"help_text": "Usernames that only admins can register for identities. One per line.",
|
||||||
|
@ -109,6 +113,7 @@ class BasicSettings(AdminSettingsPage):
|
||||||
],
|
],
|
||||||
"Signups": [
|
"Signups": [
|
||||||
"signup_allowed",
|
"signup_allowed",
|
||||||
|
"signup_max_users",
|
||||||
"signup_text",
|
"signup_text",
|
||||||
],
|
],
|
||||||
"Posts": [
|
"Posts": [
|
||||||
|
|
|
@ -79,17 +79,25 @@ class Signup(FormView):
|
||||||
return email
|
return email
|
||||||
|
|
||||||
def dispatch(self, request, token=None, *args, **kwargs):
|
def dispatch(self, request, token=None, *args, **kwargs):
|
||||||
|
# See if we have an invite token
|
||||||
if token:
|
if token:
|
||||||
self.invite = get_object_or_404(Invite, token=token)
|
self.invite = get_object_or_404(Invite, token=token)
|
||||||
if not self.invite.valid:
|
if not self.invite.valid:
|
||||||
raise Http404()
|
raise Http404()
|
||||||
else:
|
else:
|
||||||
self.invite = None
|
self.invite = None
|
||||||
|
# Calculate if we're at or over the user limit
|
||||||
|
self.at_max_users = False
|
||||||
|
if (
|
||||||
|
Config.system.signup_max_users
|
||||||
|
and User.objects.count() >= Config.system.signup_max_users
|
||||||
|
):
|
||||||
|
self.at_max_users = True
|
||||||
return super().dispatch(request, *args, **kwargs)
|
return super().dispatch(request, *args, **kwargs)
|
||||||
|
|
||||||
def form_valid(self, form):
|
def form_valid(self, form):
|
||||||
# Don't allow anything if there's no invite and no signup allowed
|
# Don't allow anything if there's no invite and no signup allowed
|
||||||
if not Config.system.signup_allowed and not self.invite:
|
if (not Config.system.signup_allowed or self.at_max_users) and not self.invite:
|
||||||
return self.render_to_response(self.get_context_data())
|
return self.render_to_response(self.get_context_data())
|
||||||
# Make the new user
|
# Make the new user
|
||||||
user = User.objects.create(email=form.cleaned_data["email"])
|
user = User.objects.create(email=form.cleaned_data["email"])
|
||||||
|
@ -113,7 +121,7 @@ class Signup(FormView):
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
if not Config.system.signup_allowed and not self.invite:
|
if (not Config.system.signup_allowed or self.at_max_users) and not self.invite:
|
||||||
del context["form"]
|
del context["form"]
|
||||||
if Config.system.signup_text:
|
if Config.system.signup_text:
|
||||||
context["signup_text"] = mark_safe(
|
context["signup_text"] = mark_safe(
|
||||||
|
|
Loading…
Reference in New Issue