numerous updates

This commit is contained in:
Ross
2022-05-20 20:26:02 +01:00
parent 0373b22e78
commit 77ccdbc92a
246 changed files with 22615 additions and 2409 deletions
+2 -1
View File
@@ -19,7 +19,8 @@
{% if request.user.is_authenticated %}
<a href="{% url 'generic:manage_cids' %}">Cids</a> /
<a href="{% url 'generic:manage_cid_exams' %}">Cids (exams)</a> /
<a href="{% url 'generic:group_view' %}">Groups</a> /
<a href="{% url 'generic:cid_group_view' %}">Cid Groups</a> /
<a href="{% url 'generic:user_group_view' %}">User Groups</a> /
{% endif %}
{% endblock %}
@@ -1,9 +1,9 @@
{% extends 'generic/base.html' %}
{% block content %}
<h2>Groups</h2>
<h2>Cid Groups</h2>
<p>
<a href="{% url 'generic:group_create' %}">Create new group</a>
<a href="{% url 'generic:cid_group_create' %}">Create new group</a>
</p>
{% for group in groups %}
<p>{{group.name}}
@@ -15,7 +15,7 @@
">Email candidate results</button>
<button class="url-button" data-url="{% url 'generic:group_email_results_resend' pk=group.pk %}
">Resend candidate results</button>
<button class="url-button" data-url="{% url 'generic:group_update' pk=group.pk %}
<button class="url-button" data-url="{% url 'generic:cid_group_update' pk=group.pk %}
">Edit</button>
</p>
{% endfor %}
@@ -29,8 +29,8 @@
</script>
{% if view_all %}
<a href="{% url 'generic:group_view' %}">View active</a>
<a href="{% url 'generic:cid_group_view' %}">View active</a>
{% else %}
<a href="{% url 'generic:group_view_all' %}">View all</a>
<a href="{% url 'generic:cid_group_view_all' %}">View all</a>
{% endif %}
{% endblock %}
+28 -2
View File
@@ -1,6 +1,8 @@
<div class="card text-white bg-dark">
<h3>CID candidates</h3>
{% if cid_users %}
<p>{{cid_user_count}} candidates.</p>
<p>{{cid_user_count}} CID candidates.</p>
<ol>
{% for cid in cid_users %}
@@ -16,8 +18,32 @@
{% endfor %}
</ol>
{% else %}
<p>This exam has no candidates. Add some with the below link.</p>
<p>This exam has no CID candidates. Add some with the below link.</p>
{% endif %}
<a href="{% url exam.app_name|add:':exam_cids_edit' exam.pk %}">Edit Exam CIDs</a>
</div>
<br/>
<div class="card text-white bg-dark">
<h3>User candidates</h3>
{% if user_users %}
<p>{{user_user_count}} User candidates.</p>
<ol>
{% for user in user_users %}
<li>{{user.username}}
Email: {{user.email}}
</li>
{% endfor %}
</ol>
{% else %}
<p>This exam has no User candidates. Add some with the below link.</p>
{% endif %}
<a href="{% url exam.app_name|add:':exam_users_edit' exam.pk %}">Edit Exam Users</a>
</div>
@@ -0,0 +1,72 @@
<h3>Users</h3>
{% if groups %}
Users from the following groups are available: {% for group in groups %}<a href='{{group.get_absolute_url}}'>{{group}}</a>{% endfor %} .
<ol>
{% for user in current_user_users %}
<li class="current">{{user.username}} /
Email: {{user.email}} <button class="toggle-btn" data-pk="{{user.pk}}" data-user="{{user.username}}">Toggle</button>
</li>
{% endfor %}
{% for user in available_user_users %}
<li>{{user.username}} /
Email: {{user.email}} <button class="toggle-btn" data-pk="{{user.pk}}" data-user="{{user.username}}">Toggle</button>
</li>
{% endfor %}
</ol>
{% else %}
This exam is not associated with any user groups. Edit and add a group to enable user management.
{% endif %}
<script>
$(document).ready(() => {
$(".toggle-btn").click((el) => {
parent = $(el.target).parent()
$.ajax({
url: "{% url exam.app_name|add:':exam_json_edit' exam.pk %}",
data: {
csrfmiddlewaretoken: "{{csrf_token}}",
edit_user_user: el.target.dataset.pk,
add: !parent.hasClass("current"),
},
type: "POST",
dataType: "json",
})
// $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly
.done(function (data) {
console.log(data);
if (data.status == "success") {
if (data.added) {
parent.addClass("current");
toastr.info(`User ${el.target.dataset.user} added to exam`)
} else {
parent.removeClass("current");
toastr.info(`User ${el.target.dataset.user} removed from exam`)
}
}
})
.always(function () {
})
});
})
</script>
<style>
.current {
color: lightgray;
}
.current::after {
content: "[ADDED TO EXAM]"
}
button {
padding: 0;
}
</style>
+36
View File
@@ -0,0 +1,36 @@
{% extends 'generic/base.html' %}
{% block content %}
<h2>User Groups</h2>
<p>
<a href="{% url 'generic:user_group_create' %}">Create new group</a>
</p>
{% for group in groups %}
<p>{{group.name}}
{% comment %} <button class="url-button" data-url="{% url 'generic:group_email' pk=group.pk %}
">Email candidate details</button>
<button class="url-button" data-url="{% url 'generic:group_email_resend' pk=group.pk %}
">Resend candidate details</button>
<button class="url-button" data-url="{% url 'generic:group_email_results' pk=group.pk %}
">Email candidate results</button>
<button class="url-button" data-url="{% url 'generic:group_email_results_resend' pk=group.pk %}
">Resend candidate results</button> {% endcomment %}
<button class="url-button" data-url="{% url 'generic:user_group_update' pk=group.pk %}
">Edit</button>
</p>
{% endfor %}
<script type="text/javascript">
$(".url-button").click((evt) => {
window.location = evt.currentTarget.dataset.url;
})
</script>
{% if view_all %}
<a href="{% url 'generic:user_group_view' %}">View active</a>
{% else %}
<a href="{% url 'generic:user_group_view_all' %}">View all</a>
{% endif %}
{% endblock %}
+31
View File
@@ -0,0 +1,31 @@
{% extends "generic/base.html" %}
<!-- {% load static from static %} -->
{% block css %}
{% endblock %}
{% block js %}
<!--<script type="text/javascript" src="/admin/jsi18n/"></script>-->
{{form.media}}
<script type="text/javascript">
</script>
<!-- {{ form.media }} -->
{% endblock %}
{% block content %}
<h2>Add / Edit Group / {{userusergroup.name}}</h2>
Use this form to create / edit a CID user group.
<form action="" method="post" enctype="multipart/form-data" id="condition-form">
{% csrf_token %}
<table>
{{ form.as_table }}
</table>
<input type="submit" class="submit-button" value="Submit" name="submit">
<h3>Users</h3>
{{userusergroup.GetGroupUsers}}
</form>
{% endblock %}