Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "feat: positive logic to the stats view" #60

Merged
merged 1 commit into from
Jul 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions eox_nelp/stats/templates/tenant_stats.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
<body>
<div id="tenant-stats"></div>
<script>
var showVideos = "true" === "${videos}";
var showCourses = "true" === "${courses}";
var showProblems = "true" === "${problems}";
var showLearners = "true" === "${learners}";
var showInstructors = "true" === "${instructors}";
var showVideos = "true" === "${showVideos}";
var showCourses = "true" === "${showCourses}";
var showProblems = "true" === "${showProblems}";
var showLearners = "true" === "${showLearners}";
var showInstructors = "true" === "${showInstructors}";
</script>
<script src="${static.url('tenant_stats/js/tenant_stats.js')}"></script>
</body>
Expand Down
12 changes: 6 additions & 6 deletions eox_nelp/stats/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,34 +29,34 @@ def test_get_default_stats(self):
- template name is as expected.
- tenant-stats div exist
"""
url_endpoint = reverse("stats-frontend:tenant")
url_endpoint = reverse("stats:tenant")

response = self.client.get(url_endpoint)

self.assertEqual(status.HTTP_200_OK, response.status_code)
self.assertEqual(self.template_name, response.templates[0].name)
self.assertContains(response, '<div id="tenant-stats"></div')

@data("videos", "courses", "problems", "instructors", "learners")
def test_filter_specific_stat(self, query_param):
@data("showVideos", "showCourse", "showProblems", "showInstructors", "showLearners")
def test_get_specific_stat(self, query_param):
"""
Test that the view render successfully when a query param is included

Expected behavior:
- Status code 200.
- template name is as expected.
- tenant-stats div exist
- the query param is 'false'
- the query param is 'true'
- CSS was included
- JS was included
"""
url_endpoint = f"{reverse('stats-frontend:tenant')}?{query_param}=false"
url_endpoint = f"{reverse('stats:tenant')}?{query_param}=true"

response = self.client.get(url_endpoint)

self.assertEqual(status.HTTP_200_OK, response.status_code)
self.assertEqual(self.template_name, response.templates[0].name)
self.assertContains(response, '<div id="tenant-stats"></div')
self.assertEqual("false", response.context[query_param])
self.assertEqual("true", response.context[query_param])
self.assertContains(response, "tenant_stats/css/tenant_stats.css")
self.assertContains(response, "tenant_stats/js/tenant_stats.js")
2 changes: 1 addition & 1 deletion eox_nelp/stats/urls.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""frontend templates urls for stats"""
"""frontend templates urls for course_experience"""
from django.urls import path

from eox_nelp.stats.views import get_tenant_stats
Expand Down
26 changes: 13 additions & 13 deletions eox_nelp/stats/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,25 @@ def get_tenant_stats(request):
By default this show nothing since this requires the specific query para to show the content.

Examples:
by default the view render all componets: /eox-nelp/stats/tenant/
renders just video card /eox-nelp/stats/tenant/?showVideos=true

filter components: eg dont show videos and courses.
/eox-nelp/stats/tenant/?videos=false&courses=false
render multiple components
/eox-nelp/stats/tenant/?showVideos=true&showCourses=true&showInstructors=true

The available options are:
videos
courses
learners
instructors
problems
showVideos
showCourses
showLearners
showInstructors
showProblems
"""

context = {
"courses": "true",
"videos": "true",
"problems": "true",
"learners": "true",
"instructors": "true",
"showCourses": "false",
"showVideos": "false",
"showProblems": "false",
"showLearners": "false",
"showInstructors": "false",
Comment on lines +32 to +36
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"showCourses": "false",
"showVideos": "false",
"showProblems": "false",
"showLearners": "false",
"showInstructors": "false",
"showCourses": "true",
"showVideos": "true",
"showProblems": "true",
"showLearners": "true",
"showInstructors": "true",

This woul be true to be positive

}
context.update(request.GET.dict())

Expand Down
2 changes: 1 addition & 1 deletion eox_nelp/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@
include('eox_nelp.course_experience.frontend.urls', namespace='course-experience-frontend'),
),
path('api/stats/', include('eox_nelp.stats.api.urls', namespace='stats-api')),
path('frontend/stats/', include('eox_nelp.stats.urls', namespace='stats-frontend')),
path('stats/', include('eox_nelp.stats.urls', namespace='stats')),
]