From a7bb61639abd56f3f617e29771e7269ac04f376b Mon Sep 17 00:00:00 2001 From: "J.-S. Caux" <J.S.Caux@uva.nl> Date: Fri, 8 Mar 2019 07:59:35 +0100 Subject: [PATCH] Beautify forums with pills --- forums/templates/forums/forum_as_li.html | 3 ++- forums/templates/forums/forum_detail.html | 5 ++++- forums/templates/forums/forum_list.html | 3 ++- forums/templates/forums/post_card.html | 2 +- forums/views.py | 2 +- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/forums/templates/forums/forum_as_li.html b/forums/templates/forums/forum_as_li.html index 8248b2fc2..b5e2eca3b 100644 --- a/forums/templates/forums/forum_as_li.html +++ b/forums/templates/forums/forum_as_li.html @@ -1,5 +1,6 @@ -<li> +<li class="d-flex justify-content-between"> <a href="{{ forum.get_absolute_url }}">{{ forum }}</a> + <span class="badge badge-secondary badge-pill">{% with nr_posts=forum.nr_posts %}{{ nr_posts }} post{{ nr_posts|pluralize }}{% endwith %}</span> {% if forum.child_forums.all|length > 0 %} <ul class="list-unstyled forumList"> {% for child in forum.child_forums.all %} diff --git a/forums/templates/forums/forum_detail.html b/forums/templates/forums/forum_detail.html index a3cd6c99f..425c78890 100644 --- a/forums/templates/forums/forum_detail.html +++ b/forums/templates/forums/forum_detail.html @@ -17,7 +17,10 @@ {% block content %} <div class="row"> <div class="col-12"> - <h3 class="highlight">{{ forum.name }}</h3> + <h3 class="highlight d-flex justify-content-between"> + {{ forum.name }} + <span class="badge badge-primary badge-pill">{% with nr_posts=forum.nr_posts %}{{ nr_posts }} post{{ nr_posts|pluralize }}{% endwith %}</span> + </h3> {% if forum.parent %} <p>Parent: <a href="{{ forum.parent.get_absolute_url }}">{{ forum.parent }}</a></p> diff --git a/forums/templates/forums/forum_list.html b/forums/templates/forums/forum_list.html index c3176627a..aa5e8373a 100644 --- a/forums/templates/forums/forum_list.html +++ b/forums/templates/forums/forum_list.html @@ -26,8 +26,9 @@ <div class="card-columns"> {% for forum in object_list %} <div class="card"> - <div class="card-header"> + <div class="card-header d-flex justify-content-between"> <a href="{{ forum.get_absolute_url }}">{{ forum }}</a> + <span class="badge badge-primary badge-pill">{{ forum.nr_posts }} posts</span> </div> <div class="card-body"> Forum description diff --git a/forums/templates/forums/post_card.html b/forums/templates/forums/post_card.html index 369974ed8..772719e15 100644 --- a/forums/templates/forums/post_card.html +++ b/forums/templates/forums/post_card.html @@ -19,7 +19,7 @@ </div> {% if post.followup_posts.all|length > 0 %} <div class="followupPosts"> - <h3>Replies [{{ post.nr_followups }}]:</h3> + <h3><span class="badge badge-primary badge-pill">{% with nr_followups=post.nr_followups %}{{ nr_followups }} repl{{ nr_followups|pluralize:"y,ies" }}{% endwith %}</span></h3> {% for followup in post.followup_posts.all %} {% include 'forums/post_card.html' with post=followup %} {% endfor %} diff --git a/forums/views.py b/forums/views.py index 402656dd9..25fee032b 100644 --- a/forums/views.py +++ b/forums/views.py @@ -56,7 +56,7 @@ class ForumDeleteView(PermissionRequiredMixin, DeleteView): """ A Forum can only be deleted if it does not have any descendants. Upon deletion, all object-level permissions associated to the - Forum are explicitly removed. + Forum are explicitly removed, to avoid orphaned permissions. """ forum = get_object_or_404(Forum, slug=self.kwargs.get('slug')) groups_perms_dict = get_groups_with_perms(forum, attach_perms=True) -- GitLab