add some more detials to user management
This commit is contained in:
@@ -1,77 +1,85 @@
|
|||||||
|
|
||||||
<h3>Users</h3>
|
<h3>Users</h3>
|
||||||
{% if groups %}
|
{% if groups %}
|
||||||
Users from the following groups are available: {% for group in groups %}<a href='{{group.get_absolute_url}}'>{{group}}</a>, {% endfor %} .
|
Users from the following groups are available: {% for group in groups %}<a href='{{group.get_absolute_url}}'>{{group}}</a>, {% endfor %} .
|
||||||
{% else %}
|
{% else %}
|
||||||
This exam is not associated with any user groups. <a href="{% url exam.app_name|add:':exam_update' exam.pk %}">Edit and add a group</a> to enable user management.
|
This exam is not associated with any user groups. <a href="{% url exam.app_name|add:':exam_update' exam.pk %}">Edit and add a group</a> to enable user management.
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<ol>
|
<ol>
|
||||||
{% for user in current_user_users %}
|
{% for user in current_user_users %}
|
||||||
|
|
||||||
<li class="current">{{user.username}} /
|
<li class="current">{{user.username}} /
|
||||||
Email: {{user.email}} <button class="toggle-btn" data-pk="{{user.pk}}" data-user="{{user.username}}">Toggle</button>
|
Email: {{user.email}}
|
||||||
</li>
|
{% if user.userprofile.grade %}
|
||||||
|
[{{user.userprofile.grade}}]
|
||||||
|
{% endif %}
|
||||||
|
<button class="toggle-btn" data-pk="{{user.pk}}" data-user="{{user.username}}">Toggle</button>
|
||||||
|
</li>
|
||||||
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% for user in available_user_users %}
|
{% for user in available_user_users %}
|
||||||
|
|
||||||
<li>{{user.username}} /
|
<li>{{user.username}} /
|
||||||
Email: {{user.email}} <button class="toggle-btn" data-pk="{{user.pk}}" data-user="{{user.username}}">Toggle</button>
|
Email: {{user.email}}
|
||||||
</li>
|
{% if user.userprofile.grade %}
|
||||||
|
[{{user.userprofile.grade}}]
|
||||||
|
{% endif %}
|
||||||
|
<button class="toggle-btn" data-pk="{{user.pk}}" data-user="{{user.username}}">Toggle</button>
|
||||||
|
</li>
|
||||||
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ol>
|
</ol>
|
||||||
|
|
||||||
<p><button class="toggle-all-btn">Toggle all</button></p>
|
<p><button class="toggle-all-btn">Toggle all</button></p>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(() => {
|
$(document).ready(() => {
|
||||||
$(".toggle-all-btn").click((el) => {
|
$(".toggle-all-btn").click((el) => {
|
||||||
$(".toggle-btn").click();
|
$(".toggle-btn").click();
|
||||||
});
|
});
|
||||||
$(".toggle-btn").click((el) => {
|
$(".toggle-btn").click((el) => {
|
||||||
parent = $(el.target).parent()
|
parent = $(el.target).parent()
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "{% url exam.app_name|add:':exam_json_edit' exam.pk %}",
|
url: "{% url exam.app_name|add:':exam_json_edit' exam.pk %}",
|
||||||
data: {
|
data: {
|
||||||
csrfmiddlewaretoken: "{{csrf_token}}",
|
csrfmiddlewaretoken: "{{csrf_token}}",
|
||||||
edit_user_user: el.target.dataset.pk,
|
edit_user_user: el.target.dataset.pk,
|
||||||
add: !parent.hasClass("current"),
|
add: !parent.hasClass("current"),
|
||||||
},
|
},
|
||||||
type: "POST",
|
type: "POST",
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
})
|
})
|
||||||
// $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly
|
// $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly
|
||||||
.done(function (data) {
|
.done(function (data) {
|
||||||
console.log(data);
|
console.log(data);
|
||||||
|
|
||||||
if (data.status == "success") {
|
if (data.status == "success") {
|
||||||
if (data.added) {
|
if (data.added) {
|
||||||
parent.addClass("current");
|
parent.addClass("current");
|
||||||
toastr.info(`User ${el.target.dataset.user} added to exam`)
|
toastr.info(`User ${el.target.dataset.user} added to exam`)
|
||||||
} else {
|
} else {
|
||||||
parent.removeClass("current");
|
parent.removeClass("current");
|
||||||
toastr.info(`User ${el.target.dataset.user} removed from exam`)
|
toastr.info(`User ${el.target.dataset.user} removed from exam`)
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
.always(function () {
|
})
|
||||||
})
|
.always(function () {
|
||||||
|
})
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
<style>
|
<style>
|
||||||
.current {
|
.current {
|
||||||
color: lightgray;
|
color: lightgray;
|
||||||
}
|
}
|
||||||
.current::after {
|
.current::after {
|
||||||
content: "[ADDED TO EXAM]"
|
content: "[ADDED TO EXAM]"
|
||||||
}
|
}
|
||||||
|
|
||||||
button {
|
button {
|
||||||
padding: 0;
|
padding: 0;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
Reference in New Issue
Block a user