Skip to content

Commit

Permalink
feat: add show expired button
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonGrace2282 committed Oct 5, 2024
1 parent 5b0b822 commit 226a2a0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
6 changes: 3 additions & 3 deletions intranet/apps/dashboard/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def get_announcements_list(request, context) -> list[Announcement | Event]:
# Show all announcements if user has admin permissions and the
# show_all GET argument is given.
announcements = Announcement.objects.all()
elif context["show_expired"] or context["show_all"]:
elif context["show_expired"]:
announcements = Announcement.objects.visible_to_user(user)
else:
announcements = Announcement.objects.visible_to_user(user).filter(expiration_date__gt=timezone.now())
Expand Down Expand Up @@ -530,7 +530,7 @@ def dashboard_view(request, show_widgets=True, show_expired=False, show_hidden_c
events_admin = user.has_admin_permission("events")

if not show_expired:
show_expired = "show_expired" in request.GET
show_expired = request.GET.get("show_expired") == "1"

show_all = request.GET.get("show_all", "0") != "0"
if "show_all" not in request.GET and request.user.is_eighthoffice:
Expand Down Expand Up @@ -610,7 +610,7 @@ def dashboard_view(request, show_widgets=True, show_expired=False, show_hidden_c
elif show_expired:
dashboard_title = dashboard_header = "Announcement Archive"
view_announcements_url = "announcements_archive"
elif show_hidden_club:
if show_hidden_club:
dashboard_title = dashboard_header = "Club Announcements"
view_announcements_url = "club_announcements"
else:
Expand Down
10 changes: 9 additions & 1 deletion intranet/templates/dashboard/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,21 @@ <h2>{{ dashboard_header }}</h2>
Post
</a>
{% endif %}
{% if request.GET.show_expired == "1" %}
<a class="button" href="{% url view_announcements_url %}?{% query_transform request show_expired=0 %}">
<i class="fas fa-times"></i> Don't Show Expired
</a>
{% else %}
<a class="button" href="{% url view_announcements_url %}?{% query_transform request show_expired=1 %}">
Show Expired
</a>
{% endif %}
{% else %}
<a class="button announcement-request" href="{% url 'request_announcement' %}">
<i class="far fa-file-alt"></i>
Request Post
</a>
{% endif %}

{% endif %}
{% endif %}
</span>
Expand Down

0 comments on commit 226a2a0

Please sign in to comment.