Skip to content

Commit

Permalink
feat/unpublish questionnaire
Browse files Browse the repository at this point in the history
  • Loading branch information
kevlanyo committed Aug 7, 2024
1 parent 7f32ab0 commit bfed20c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 30 deletions.
2 changes: 1 addition & 1 deletion survey/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
views.edit_data, name='edit-data'),
path('web/delete-data/<int:q_id>/',
views.delete_question, name='delete-data'),
path('web/publish-questionnaire/<int:q_id>/',
path('web/publish-questionnaire/<int:q_id>/<str:q_action>/',
views.publish_questionnaire, name='publish-questionnaires'),
path('web/add-question/<int:q_id>/',
views.add_question, name='add-question'),
Expand Down
6 changes: 2 additions & 4 deletions survey/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1427,8 +1427,7 @@ def questionnaire(request):
elif user.access_level.id == 2:
fac = Partner_Facility.objects.filter(
partner__in=Partner_User.objects.filter(user=user).values_list('name', flat=True))
q = Facility_Questionnaire.objects.filter(facility_id__in=fac.values_list('facility_id', flat=True)
).values_list('questionnaire_id').distinct()
q = Facility_Questionnaire.objects.filter(facility_id__in=fac.values_list('facility_id', flat=True)).values_list('questionnaire_id').distinct()
quest = Questionnaire.objects.filter(
id__in=q).order_by('-created_at')
count = quest.count()
Expand All @@ -1452,8 +1451,7 @@ def questionnaire(request):
elif user.access_level.id == 5:
fac = Partner_Facility.objects.filter(
partner__in=Partner_User.objects.filter(user=user).values_list('name', flat=True))
q = Facility_Questionnaire.objects.filter(facility_id__in=fac.values_list('facility_id', flat=True)
).values_list('questionnaire_id').distinct()
q = Facility_Questionnaire.objects.filter(facility_id__in=fac.values_list('facility_id', flat=True)).values_list('questionnaire_id').distinct()
quest = Questionnaire.objects.filter(
id__in=q).order_by('-created_at')
count = quest.count()
Expand Down
49 changes: 24 additions & 25 deletions templates/survey/questionnaires.html
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,11 @@ <h3 class="mb-0">Questionnaire List</h3>
<thead class="thead-light">
<tr>
<th>Name</th>
<th scope="col">Status</th>
<th scope="col">Active till</th>
<th scope="col">Number of Questions</th>
<th scope="col">Target App</th>
<th scope="col">Published</th>
<th scope="col">Number of Questions</th>
<th scope="col">Status</th>
<th scope="col">Active till</th>
<th scope="col"></th>
</tr>
</thead>
Expand All @@ -126,6 +126,9 @@ <h3 class="mb-0">Questionnaire List</h3>
{% for foo in quest %}
<tr class="view">
<td>{{ foo.name }}</td>
<td>{{ foo.target_app }}</td>
<td>{{ foo.is_published }}</td>
<td>{{ foo.number_of_questions }}</td>
<td>{% if foo.is_active %}
<span class="badge badge-dot mr-4">
<i class="bg-success"></i>
Expand All @@ -140,9 +143,6 @@ <h3 class="mb-0">Questionnaire List</h3>
{% endif %}
</td>
<td>{{ foo.active_till }}</td>
<td>{{ foo.number_of_questions }}</td>
<td>{{ foo.target_app }}</td>
<td>{{ foo.is_published }}</td>
{% if u.access_level.id == 5 %}
{% if perms.survey.change_questionnaire %}
<td class="text-right">
Expand Down Expand Up @@ -282,11 +282,11 @@ <h3>Questionnaire Description</h3>
<tr>
<th scope="col"></th>
<th >Name</th>
<th scope="col">Status</th>
<th scope="col">Active till</th>
<th scope="col">Number of Questions</th>
<th scope="col">Target App</th>
<th scope="col">Published</th>
<th scope="col">Number of Questions</th>
<th scope="col">Status</th>
<th scope="col">Active till</th>
</tr>
</thead>
<tbody class="list">
Expand Down Expand Up @@ -334,21 +334,6 @@ <h3>Questionnaire Description</h3>
</div>
</td>
<td>{{ foo.name }}</td>
<td>{% if foo.is_active %}
<span class="badge badge-dot mr-4">
<i class="bg-success"></i>
<span class="status">Active</span>
</span>
{% else %}
<span class="badge badge-dot mr-4">
<i class="bg-warning"></i>
<span class="status">Inactive</span>
</span>

{% endif %}
</td>
<td>{{ foo.active_till }}</td>
<td>{{ foo.number_of_questions }}</td>
<td>{{ foo.target_app }}</td>
<td>
{% if foo.is_published %}
Expand All @@ -364,7 +349,21 @@ <h3>Questionnaire Description</h3>

{% endif %}
</td>

<td>{{ foo.number_of_questions }}</td>
<td>{% if foo.is_active %}
<span class="badge badge-dot mr-4">
<i class="bg-success"></i>
<span class="status">Active</span>
</span>
{% else %}
<span class="badge badge-dot mr-4">
<i class="bg-warning"></i>
<span class="status">Inactive</span>
</span>

{% endif %}
</td>
<td>{{ foo.active_till }}</td>
</tr>
<tr class="fold">
<td colspan="7">
Expand Down

0 comments on commit bfed20c

Please sign in to comment.