Skip to content

Commit

Permalink
Revert "feat: positive logic to the stats view"
Browse files Browse the repository at this point in the history
This reverts commit d9090a8.
  • Loading branch information
andrey-canon committed Jul 5, 2023
1 parent e060b70 commit 426bf2f
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 26 deletions.
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",
}
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')),
]

0 comments on commit 426bf2f

Please sign in to comment.