Commit 91ac771f by Muhammad Shoaib

added the delete allowance and small tweaks in the internationalization

parent 4bb08cb5
......@@ -15,15 +15,13 @@ var edx = edx || {};
this.course_id = this.$el.data('course-id');
/* this should be moved to a 'data' attribute in HTML */
this.tempate_url = '/static/proctoring/templates/add-allowance.underscore';
this.tempate_url = '/static/proctoring/templates/course_allowances.underscore';
this.template = null;
this.allowance_url = this.collection.url;
/* re-render if the model changes */
this.listenTo(this.collection, 'change', this.collectionChanged);
/* make the async call to the backend REST API */
/* after it loads, the listenTo event will file and */
/* will call into the rendering */
/* Load the static template for rendering. */
this.loadTemplateData();
this.collection.url = this.allowance_url + '/' + this.course_id;
......@@ -31,10 +29,23 @@ var edx = edx || {};
},
events: {
'click #add-allowance': 'showAddModal',
'click #remove_allowance': 'removeAllowance'
'click .remove_allowance': 'removeAllowance'
},
showAddModal: function(){
alert('here');
getCSRFToken: function() {
var cookieValue = null;
var name='csrftoken';
if (document.cookie && document.cookie != '') {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = jQuery.trim(cookies[i]);
// Does this cookie string begin with the name we want?
if (cookie.substring(0, name.length + 1) == (name + '=')) {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
break;
}
}
}
return cookieValue;
},
removeAllowance: function(event){
var element = $(event.currentTarget);
......@@ -55,9 +66,9 @@ var edx = edx || {};
'key': key
},
success: function () {
// fetch the user preferences again.
self.collection.url = self.notification_preferences_all;
self.render();
// fetch the allowances again.
self.collection.url = self.allowance_url + '/' + self.course_id;
self.hydrate();
}
}
);
......@@ -97,12 +108,11 @@ var edx = edx || {};
/* we might - at some point - add a visual element to the */
/* loading, like a spinner */
var self = this;
self.collection.fetch().done(
function(){
self.collection.fetch({
success: function () {
self.render();
}).fail(function(){
console.log('fail');
});
}
});
},
collectionChanged: function() {
this.hydrate();
......
......@@ -3,26 +3,34 @@
<a id="add-allowance" href="#" class="add blue-button">+ <%- gettext("Add Allowance") %></a>
</span>
</span>
<% var is_allowances = proctored_exam_allowances.length !== 0 %>
<% if (is_allowances) { %>
<div class="wrapper-content wrapper">
<section class="content">
<table class="allowance-table">
<thead>
<tr class="allowance-headings">
<th class="exam-name">Exam Name</th>
<th class="username">Username</th>
<th class="email">Email</th>
<th class="allowance-name">Allowance Name </th>
<th class="allowance-value">Allowance Value</th>
<th class="c_action">Actions</th>
<th class="exam-name"><%- gettext("Exam Name") %></th>
<th class="username"><%- gettext("Username") %></th>
<th class="email"><%- gettext("Email") %></th>
<th class="allowance-name"><%- gettext("Allowance Name") %> </th>
<th class="allowance-value"><%- gettext("Allowance Value") %></th>
<th class="c_action"><%- gettext("Actions") %> </th>
</tr>
</thead>
<tbody>
<% _.each(proctored_exam_allowances, function(proctored_exam_allowance){ %>
<tr class="allowance-items">
<td><%= proctored_exam_allowance.proctored_exam.exam_name %></td>
<td>
<%- interpolate(gettext(' %(exam_display_name)s '), { exam_display_name: proctored_exam_allowance.proctored_exam.exam_name }, true) %>
</td>
<td> Dummy Username </td>
<td>muhammad.shoaib@gmail.com</td>
<td><%= proctored_exam_allowance.key %></td>
<td>
<%- interpolate(gettext(' %(allowance_name)s '), { allowance_name: proctored_exam_allowance.key }, true) %>
</td>
<td><%= proctored_exam_allowance.value %></td>
<td>
<a data-exam-id="<%= proctored_exam_allowance.proctored_exam.id %>"
......@@ -32,10 +40,10 @@
</td>
</tr>
<% }); %>
</tbody>
</table>
</section>
</div>
<% } %>
......@@ -358,7 +358,7 @@ class ExamAllowanceView(AuthenticatedAPIView):
**Response Values**
* returns Nothing. deletes the allowance for the user proctored exam.
"""
# @method_decorator(require_staff)
@method_decorator(require_staff)
def get(self, request, course_id): # pylint: disable=unused-argument
"""
HTTP GET handler. Get all allowances for a course.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment