Skip to content

Commit

Permalink
detailed metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
Ederporto committed Feb 16, 2024
1 parent d047d67 commit 158d57b
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 0 deletions.
22 changes: 22 additions & 0 deletions metrics/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,28 @@ def test_show_metrics_per_project(self):
response = self.client.get(url)
self.assertIn("dataset", str(response.context))

def test_show_detailed_metrics_per_project_fails_if_user_doesnt_have_permission(self):
self.client.login(username=self.username, password=self.password)
Project.objects.create(text="Project", current_poa=True)
url = reverse("metrics:detailed_per_project")

response = self.client.get(url)

self.assertEqual(response.status_code, 302)
self.assertRedirects(response, f"{reverse('login')}?next={url}")

def test_show_detailed_metrics_per_project_succeds_if_user_have_permission(self):
permission = Permission.objects.get(codename="delete_logentry")
self.user.user_permissions.add(permission)
self.client.login(username=self.username, password=self.password)
Project.objects.create(text="Project", current_poa=True)
url = reverse("metrics:detailed_per_project")

response = self.client.get(url)

self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, "metrics/list_metrics_per_project.html")

def test_show_plan_of_activities_and_its_operational_metrics_if_they_exist(self):
self.client.login(username=self.username, password=self.password)
project = Project.objects.create(text="Plan of activities", current_poa=True)
Expand Down
1 change: 1 addition & 0 deletions metrics/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
path('about', views.about, name='about'),
path('activities_plan', views.show_activities_plan, name='show_activities'),
path('metrics_per_project', views.show_metrics_per_project, name='per_project'),
path('detailed_metrics_per_project', views.show_detailed_metrics_per_project, name='detailed_per_project'),
path('update_metrics', views.update_metrics_relations, name='update_metrics'),
path('metrics_reports/<int:metric_id>', views.metrics_reports, name='metrics_reports'),
path("trimester", views.export_trimester_report, name="export_reports_per_trimester"),
Expand Down
12 changes: 12 additions & 0 deletions metrics/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,18 @@ def show_metrics_per_project(request):
return render(request, "metrics/list_metrics_per_project.html", context)


@login_required
@permission_required("admin.delete_logentry")
def show_detailed_metrics_per_project(request):
context = {
"poa_dataset": {},
"dataset": get_metrics_and_aggregate_per_project(Q(active=True)),
"title": _("Show metrics per project")
}
return render(request, "metrics/list_metrics_per_project.html", context)



@login_required
@permission_required("metrics.view_metric")
def metrics_reports(request, metric_id):
Expand Down
3 changes: 3 additions & 0 deletions report/templates/report/list_reports.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
<div class="w3-row">
<div class="w3-row">
<div class="w3-half" style="text-align: center">
{% if perms.admin.delete_logentry %}
<a title="{% trans 'Track metrics by management' %}" href="{% url 'metrics:detailed_per_project' %}"><button type="button" class="btn100 btn-round btn-update"><i class="fa-solid fa-chart-column"></i> {% trans 'Track metrics by management' %}</button></a>
{% endif %}
<a title="{% trans 'Track metrics by project' %}" href="{% url 'metrics:per_project' %}"><button type="button" class="btn100 btn-round btn-view"><i class="fa-solid fa-bullseye"></i> {% trans 'Track metrics by project' %}</button></a>
<a title="{% trans 'Export all reports' %}" href="{% url 'report:export_all_reports' %}"><button type="button" class="btn100 btn-round btn-export"><i class="fa-solid fa-file-export"></i> {% trans 'Export all reports' %}</button></a>
</div>
Expand Down

0 comments on commit 158d57b

Please sign in to comment.