.
This commit is contained in:
@@ -15,11 +15,13 @@
|
||||
</div>
|
||||
|
||||
<span id="manage-span">
|
||||
{% render_table table %}
|
||||
{% render_table table %}
|
||||
</span>
|
||||
|
||||
<details>
|
||||
<summary><h3>Add/Edit CID users</h3></summary>
|
||||
<summary>
|
||||
<h3>Add/Edit CID users</h3>
|
||||
</summary>
|
||||
<button id="add-exams-selected-cids">Change selected exams</button>
|
||||
<button id="clear-exams-selected-cids">Clear selected exams</button>
|
||||
<button id="activate-selected-cids">Activate selected</button>
|
||||
@@ -29,7 +31,7 @@
|
||||
<p>Select exams below to add user to.</p>
|
||||
<div class="exam-selectors">
|
||||
<span>
|
||||
Physics Exams<br/>
|
||||
Physics Exams<br />
|
||||
<select id="physics-exams" multiple="multiple">
|
||||
{% for name, id in physics_exams %}
|
||||
<option value="{{id}}">{{name}}</option>
|
||||
@@ -38,7 +40,7 @@
|
||||
</select>
|
||||
</span>
|
||||
<span>
|
||||
Rapid Exams<br/>
|
||||
Rapid Exams<br />
|
||||
<select id="rapid-exams" multiple="multiple">
|
||||
{% for name, id in rapid_exams %}
|
||||
<option value="{{id}}">{{name}}</option>
|
||||
@@ -47,7 +49,7 @@
|
||||
</select>
|
||||
</span>
|
||||
<span>
|
||||
Sba Exams<br/>
|
||||
Sba Exams<br />
|
||||
<select id="sbas-exams" multiple="multiple">
|
||||
{% for name, id in sba_exams %}
|
||||
<option value="{{id}}">{{name}}</option>
|
||||
@@ -56,7 +58,7 @@
|
||||
</select>
|
||||
</span>
|
||||
<span>
|
||||
Long Exams<br/>
|
||||
Long Exams<br />
|
||||
<select id="longs-exams" multiple="multiple">
|
||||
{% for name, id in longs_exams %}
|
||||
<option value="{{id}}">{{name}}</option>
|
||||
@@ -65,7 +67,7 @@
|
||||
</select>
|
||||
</span>
|
||||
<span>
|
||||
Anatomy Exams<br/>
|
||||
Anatomy Exams<br />
|
||||
<select id="anatomy-exams" multiple="multiple">
|
||||
{% for name, id in anatomy_exams %}
|
||||
<option value="{{id}}">{{name}}</option>
|
||||
@@ -77,22 +79,20 @@
|
||||
|
||||
</div>
|
||||
<div>
|
||||
Groups<br/>
|
||||
<select id="cid-groups">
|
||||
<option value="">----</option>
|
||||
{% for name, id in cid_user_groups %}
|
||||
<option value="{{id}}">{{name}}</option>
|
||||
{% endfor %}
|
||||
Groups<br />
|
||||
<select id="cid-groups">
|
||||
<option value="">----</option>
|
||||
{% for name, id in cid_user_groups %}
|
||||
<option value="{{id}}">{{name}}</option>
|
||||
{% endfor %}
|
||||
|
||||
</select>
|
||||
<button id="add-group">Add Group to users</button>
|
||||
</select>
|
||||
<button id="add-group">Add Group to users</button>
|
||||
</div>
|
||||
<button id="add-new-cids">Add New (Blank) Users</button>
|
||||
<input type="number" id="add-number" value="number to add"><br/>
|
||||
<input type="number" id="add-number" value="number to add"><br />
|
||||
<button id="add-new-emails">Add New Users From Email</button>
|
||||
<textarea id="emails-input" name="emails" rows="4" cols="50">
|
||||
Enter emails here
|
||||
</textarea>
|
||||
<textarea id="emails-input" name="emails" rows="4" cols="50">Enter emails here</textarea>
|
||||
</details>
|
||||
|
||||
{% endblock %}
|
||||
@@ -100,54 +100,54 @@
|
||||
{% block js %}
|
||||
<script>
|
||||
|
||||
function postAjax(data) {
|
||||
function postAjax(data) {
|
||||
|
||||
$.ajax({
|
||||
url: "{% url 'generic:manage_cid_users' %}",
|
||||
data: data,
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
})
|
||||
// $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly
|
||||
.done(function (data) {
|
||||
console.log(data);
|
||||
$.ajax({
|
||||
url: "{% url 'generic:manage_cid_users' %}",
|
||||
data: data,
|
||||
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") {
|
||||
toastr.info('Added/Updated');
|
||||
location.reload();
|
||||
}
|
||||
// show some message according to the response.
|
||||
// For eg. A message box showing that the status has been changed
|
||||
})
|
||||
.always(function () {
|
||||
console.log('[Done]');
|
||||
})
|
||||
if (data.status == "success") {
|
||||
toastr.info('Added/Updated');
|
||||
location.reload();
|
||||
}
|
||||
// show some message according to the response.
|
||||
// For eg. A message box showing that the status has been changed
|
||||
})
|
||||
.always(function () {
|
||||
console.log('[Done]');
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
function getGenericData() {
|
||||
selected_cids = []
|
||||
$("#manage-span tbody input:checked").each((n, el) => {
|
||||
selected_cids.push(parseInt(el.value));
|
||||
})
|
||||
return {
|
||||
csrfmiddlewaretoken: "{{ csrf_token }}",
|
||||
physics_exams: JSON.stringify($("#physics-exams").val()),
|
||||
rapid_exams: JSON.stringify($("#rapid-exams").val()),
|
||||
sba_exams: JSON.stringify($("#sbas-exams").val()),
|
||||
longs_exams: JSON.stringify($("#longs-exams").val()),
|
||||
anatomy_exams: JSON.stringify($("#anatomy-exams").val()),
|
||||
cid_groups: JSON.stringify($("#cid-groups").val()),
|
||||
delete: false,
|
||||
emails: JSON.stringify(false),
|
||||
number_to_create: 0,
|
||||
activate: false,
|
||||
deactivate: false,
|
||||
add_exams: false,
|
||||
clear_exams: false,
|
||||
toggle_internal: false,
|
||||
selected_cids: JSON.stringify(selected_cids),
|
||||
}
|
||||
selected_cids = []
|
||||
$("#manage-span tbody input:checked").each((n, el) => {
|
||||
selected_cids.push(parseInt(el.value));
|
||||
})
|
||||
return {
|
||||
csrfmiddlewaretoken: "{{ csrf_token }}",
|
||||
physics_exams: JSON.stringify($("#physics-exams").val()),
|
||||
rapid_exams: JSON.stringify($("#rapid-exams").val()),
|
||||
sba_exams: JSON.stringify($("#sbas-exams").val()),
|
||||
longs_exams: JSON.stringify($("#longs-exams").val()),
|
||||
anatomy_exams: JSON.stringify($("#anatomy-exams").val()),
|
||||
cid_groups: JSON.stringify($("#cid-groups").val()),
|
||||
delete: false,
|
||||
emails: JSON.stringify(false),
|
||||
number_to_create: 0,
|
||||
activate: false,
|
||||
deactivate: false,
|
||||
add_exams: false,
|
||||
clear_exams: false,
|
||||
toggle_internal: false,
|
||||
selected_cids: JSON.stringify(selected_cids),
|
||||
}
|
||||
}
|
||||
|
||||
$(document).ready(function () {
|
||||
@@ -196,7 +196,7 @@
|
||||
|
||||
n = $("#add-number").get(0).value;
|
||||
|
||||
if (n < 1) {
|
||||
if (n < 1) {
|
||||
toastr.info("You need to enter how many users to add.");
|
||||
return
|
||||
}
|
||||
@@ -214,9 +214,10 @@
|
||||
.exam-selectors {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.exam-selectors select {
|
||||
height: 200px;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user