Skip to content

Commit

Permalink
User details
Browse files Browse the repository at this point in the history
  • Loading branch information
fsoest committed Jan 11, 2025
1 parent 1d7deda commit 5b356d7
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 1 deletion.
2 changes: 1 addition & 1 deletion S1/waitinglists/templates/waitinglists/management.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ <h6><a href="{% url 'total_waiting_list' module.id %}">{{ module.name }}</a></h6
<div class="col-8">
<h4>Quiz Timeouts</h4>
{% for user in timeout_users %}
{{ user.first_name }} {{ user.last_name }}
<a href="{% url 'user_details' user.username %}">{{ user.first_name }} {{ user.last_name }}</a>
{% endfor %}
</div>
</div>
Expand Down
53 changes: 53 additions & 0 deletions S1/waitinglists/templates/waitinglists/user_detail.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{% extends "waitinglists/base.html" %}
{% load extra_templates %}

{% block title %}S1 Training{% endblock %}

{% block content %}
<div class="container mt-4">
<div class="row">

<div class="col-6">
<h4>Modules 1/3-4</h4>
<table class="table table-striped">
<thead>
<tr>
<th>Module</th>
<th>Completion</th>
</tr>
</thead>
<tbody>
<tr>
<td>Module 1</td>
<td>{{ modules_completed.0 }}</td>
</tr>
<tr>
<td>Module 3</td>
<td>{{ modules_completed.1 }}</td>
</tr>
<tr>
<td>Module 4</td>
<td>{{ modules_completed.2 }}</td>
</tr>
</tbody>
</table>
</div>

<div class="col-6">
<h4>Module 2</h4>
<div class="card">
<div class="card-body">
{% for k, v in module_2_detail.items %}
{% if v.1 %}
<p> Module {{ k }} completed on {{ v.0|format_date }} </p>
{% else %}
<p>Module {{ k }} not completed</p>
{% endif %}
{% endfor %}
</div>
</div>
</div>

</div>
</div>
{% endblock %}
1 change: 1 addition & 0 deletions S1/waitinglists/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@
name="total_waiting_list",
),
path("update_module", views.update_module_2, name="update_module"),
path("<int:user_id>/details", views.user_details, name="user_details"),
]
28 changes: 28 additions & 0 deletions S1/waitinglists/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from pathlib import Path

from django.contrib.auth.decorators import login_required, user_passes_test
from django.contrib.auth.models import User
from django.forms import modelformset_factory
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import render, get_object_or_404, redirect
Expand Down Expand Up @@ -358,6 +359,33 @@ def management(request):
return HttpResponse(template.render(context, request))


@user_passes_test(is_mentor)
def user_detail(request, user_id):
user = User.objects.get(username=user_id)
mod2_quizzes, _ = module_2_completion(user, fetch=True)
module_list = Module.objects.all().order_by("name")
modules_completed = []
for module in module_list:
try:
entry = WaitingList.objects.get(user=user, module=module)
if entry.completed:
modules_completed.append(True)
else:
modules_completed.append(False)
except:
modules_completed.append(False)
context = {
"user": user,
"prefer_en": request.user.userdetail.en_preferred,
"authenticated": request.user.is_authenticated,
"is_mentor": is_mentor(request.user),
"module_2_detail": mod2_quizzes,
"modules_completed": modules_completed,
}
template = loader.get_template("waitinglists/user_detail.html")
return HttpResponse(template.render(context, request))


@user_passes_test(is_mentor)
def total_waiting_list(request, module_id):
waiting_list_entries = WaitingList.objects.filter(
Expand Down

0 comments on commit 5b356d7

Please sign in to comment.