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_text: str = ""
|
||||
signup_max_users: int = 0
|
||||
content_warning_text: str = "Content Warning"
|
||||
|
||||
post_length: int = 500
|
||||
|
|
|
@ -1538,15 +1538,15 @@ form .post {
|
|||
.pagination {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
gap: 1em;
|
||||
}
|
||||
|
||||
.load-more {
|
||||
margin: 10px 0;
|
||||
text-align: center;
|
||||
.pagination .count {
|
||||
display: inline-block;
|
||||
color: var(--color-text-dull);
|
||||
}
|
||||
|
||||
|
||||
@media (max-width: 920px),
|
||||
(display-mode: standalone) {
|
||||
div.columns {
|
||||
|
|
|
@ -12,11 +12,11 @@
|
|||
|
||||
<div class="pagination">
|
||||
{% 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 %}
|
||||
|
||||
{% 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 %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
|
|
@ -24,10 +24,13 @@
|
|||
{% empty %}
|
||||
<p class="option empty">There are no federation links yet.</p>
|
||||
{% endfor %}
|
||||
<div class="load-more">
|
||||
<div class="pagination">
|
||||
{% if page_obj.has_previous %}
|
||||
<a class="button" href=".?page={{ page_obj.previous_page_number }}">Previous Page</a>
|
||||
{% 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 %}
|
||||
<a class="button" href=".?page={{ page_obj.next_page_number }}">Next Page</a>
|
||||
{% endif %}
|
||||
|
|
|
@ -37,10 +37,13 @@
|
|||
{% empty %}
|
||||
<p class="option empty">There are no hashtags yet.</p>
|
||||
{% endfor %}
|
||||
<div class="load-more">
|
||||
<div class="pagination">
|
||||
{% if page_obj.has_previous %}
|
||||
<a class="button" href=".?page={{ page_obj.previous_page_number }}">Previous Page</a>
|
||||
{% 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 %}
|
||||
<a class="button" href=".?page={{ page_obj.next_page_number }}">Next Page</a>
|
||||
{% endif %}
|
||||
|
|
|
@ -38,10 +38,13 @@
|
|||
{% endif %}
|
||||
</p>
|
||||
{% endfor %}
|
||||
<div class="load-more">
|
||||
<div class="pagination">
|
||||
{% 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>
|
||||
{% 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 %}
|
||||
<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 %}
|
||||
|
|
|
@ -39,10 +39,13 @@
|
|||
There are no unused invites.
|
||||
</p>
|
||||
{% endfor %}
|
||||
<div class="load-more">
|
||||
<div class="pagination">
|
||||
{% if page_obj.has_previous %}
|
||||
<a class="button" href=".?page={{ page_obj.previous_page_number }}">Previous Page</a>
|
||||
{% 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 %}
|
||||
<a class="button" href=".?page={{ page_obj.next_page_number }}">Next Page</a>
|
||||
{% endif %}
|
||||
|
|
|
@ -31,10 +31,13 @@
|
|||
There are no {% if all %}reports yet{% else %}unresolved reports{% endif %}.
|
||||
</p>
|
||||
{% endfor %}
|
||||
<div class="load-more">
|
||||
<div class="pagination">
|
||||
{% if page_obj.has_previous %}
|
||||
<a class="button" href=".?page={{ page_obj.previous_page_number }}{% if all %}&all=true{% endif %}">Previous Page</a>
|
||||
{% 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 %}
|
||||
<a class="button" href=".?page={{ page_obj.next_page_number }}{% if all %}&all=true{% endif %}">Next Page</a>
|
||||
{% endif %}
|
||||
|
|
|
@ -30,10 +30,13 @@
|
|||
{% endif %}
|
||||
</p>
|
||||
{% endfor %}
|
||||
<div class="load-more">
|
||||
<div class="pagination">
|
||||
{% if page_obj.has_previous %}
|
||||
<a class="button" href=".?page={{ page_obj.previous_page_number }}">Previous Page</a>
|
||||
{% 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 %}
|
||||
<a class="button" href=".?page={{ page_obj.next_page_number }}">Next Page</a>
|
||||
{% endif %}
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
</span>
|
||||
{% endfor %}
|
||||
|
||||
<div class="load-more">
|
||||
<div class="pagination">
|
||||
{% if page_obj.has_previous %}
|
||||
<a class="button" href=".?page={{ page_obj.previous_page_number }}">Previous Page</a>
|
||||
{% endif %}
|
||||
|
|
|
@ -97,7 +97,9 @@
|
|||
{% endfor %}
|
||||
|
||||
{% 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 %}
|
||||
|
||||
{% endblock %}
|
||||
|
|
|
@ -76,6 +76,10 @@ class BasicSettings(AdminSettingsPage):
|
|||
"help_text": "Shown above the signup form.\nUse Markdown for formatting.",
|
||||
"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": {
|
||||
"title": "Restricted Usernames",
|
||||
"help_text": "Usernames that only admins can register for identities. One per line.",
|
||||
|
@ -109,6 +113,7 @@ class BasicSettings(AdminSettingsPage):
|
|||
],
|
||||
"Signups": [
|
||||
"signup_allowed",
|
||||
"signup_max_users",
|
||||
"signup_text",
|
||||
],
|
||||
"Posts": [
|
||||
|
|
|
@ -79,17 +79,25 @@ class Signup(FormView):
|
|||
return email
|
||||
|
||||
def dispatch(self, request, token=None, *args, **kwargs):
|
||||
# See if we have an invite token
|
||||
if token:
|
||||
self.invite = get_object_or_404(Invite, token=token)
|
||||
if not self.invite.valid:
|
||||
raise Http404()
|
||||
else:
|
||||
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)
|
||||
|
||||
def form_valid(self, form):
|
||||
# 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())
|
||||
# Make the new user
|
||||
user = User.objects.create(email=form.cleaned_data["email"])
|
||||
|
@ -113,7 +121,7 @@ class Signup(FormView):
|
|||
|
||||
def get_context_data(self, **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"]
|
||||
if Config.system.signup_text:
|
||||
context["signup_text"] = mark_safe(
|
||||
|
|
Loading…
Reference in New Issue