diff --git a/shynet/dashboard/mixins.py b/shynet/dashboard/mixins.py index 7a56d3b..ed374a1 100644 --- a/shynet/dashboard/mixins.py +++ b/shynet/dashboard/mixins.py @@ -5,16 +5,14 @@ from django.utils import timezone class DateRangeMixin: - def get_start_date(self, use_default=True): + def get_start_date(self): if self.request.GET.get("startDate") != None: found_time = timezone.datetime.strptime( self.request.GET.get("startDate"), "%Y-%m-%d" ) return timezone.make_aware(datetime.combine(found_time, time.min)) - elif use_default == True: - return timezone.now() - timezone.timedelta(days=30) else: - return None + return timezone.now() - timezone.timedelta(days=30) def get_end_date(self): if self.request.GET.get("endDate") != None: @@ -29,6 +27,4 @@ class DateRangeMixin: data = super().get_context_data(**kwargs) data["start_date"] = self.get_start_date() data["end_date"] = self.get_end_date() - start_date = self.get_start_date(False) - data["date_query_params"] = f"?startDate={start_date.strftime('%Y-%m-%d')}&endDate={self.get_end_date().strftime('%Y-%m-%d')}" if start_date is not None else "" return data diff --git a/shynet/dashboard/templates/base.html b/shynet/dashboard/templates/base.html index a3b5379..cff7d83 100644 --- a/shynet/dashboard/templates/base.html +++ b/shynet/dashboard/templates/base.html @@ -41,10 +41,8 @@

Services

{% for service in user.owning_services.all %} - {% url 'dashboard:service' service.uuid as url %} - {% with url_full=date_query_params|default:''|prepend_string:url %} - {% include 'dashboard/includes/sidebar_portal.html' with label=service.name|truncatechars:16 url=url_full icon=service.link|iconify %} - {% endwith %} + {% contextual_url 'dashboard:service' service.uuid as url %} + {% include 'dashboard/includes/sidebar_portal.html' with label=service.name|truncatechars:16 url=url icon=service.link|iconify %} {% endfor %} {% endif %} @@ -62,7 +60,7 @@

Collaborations

{% for service in user.collaborating_services.all %} - {% url 'dashboard:service' service.uuid as url %} + {% contextual_url 'dashboard:service' service.uuid as url %} {% include 'dashboard/includes/sidebar_portal.html' with label=service.name|truncatechars:20 url=url %} {% endfor %} diff --git a/shynet/dashboard/templates/dashboard/includes/date_range.html b/shynet/dashboard/templates/dashboard/includes/date_range.html index 1591f04..c4b0741 100644 --- a/shynet/dashboard/templates/dashboard/includes/date_range.html +++ b/shynet/dashboard/templates/dashboard/includes/date_range.html @@ -2,7 +2,7 @@ - +