WL-135 added the migration for the expiration_date field in the coupons model
added the functionality of adding the expiration date, and also handled in the shopping cart when the user try to add the expired coupon code in the shopping cart added expiration date in the coupons list in the ecommerce page added the unit tests and jasmine tests fix the quality issues and rebased with master regenerated the migration file with a different number i18n and verified te course mode changes suggested by stephan
This commit is contained in:
committed by
Muhammad Shoaib
parent
30b572b1b1
commit
10f8d8c097
@@ -49,6 +49,12 @@
|
||||
<input class="field readonly" id="coupon_course_id" type="text" name="course_id" value="${section_data['course_id'] | h}"
|
||||
readonly aria-required="true"/>
|
||||
</li>
|
||||
<li class="field full-width" id="add-coupon-modal-field-expiry">
|
||||
<input id="expiry-check" type="checkbox" value="true" />
|
||||
<label for="expiry-check">${_('Add expiration date')}</label>
|
||||
<input type="text" id="coupon_expiration_date" value="" class="field" name="expiration_date"
|
||||
aria-required="true"/>
|
||||
</li>
|
||||
|
||||
</ol>
|
||||
</fieldset>
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<%! from django.utils.translation import ugettext as _ %>
|
||||
<%! from datetime import datetime, timedelta %>
|
||||
<%! import pytz %>
|
||||
<%page args="section_data"/>
|
||||
<%include file="add_coupon_modal.html" args="section_data=section_data" />
|
||||
<%include file="edit_coupon_modal.html" args="section_data=section_data" />
|
||||
@@ -95,6 +97,7 @@
|
||||
<tr class="coupons-headings">
|
||||
<th class="c_code">${_("Code")}</th>
|
||||
<th class="c_dsc">${_("Description")}</th>
|
||||
<th class="c_expiry">${_("Expiry Date")}</th>
|
||||
<th class="c_discount">${_("Discount (%)")}</th>
|
||||
<th class="c_count">${_("Redeem Count")}</th>
|
||||
<th class="c_action">${_("Actions")}</th>
|
||||
@@ -102,14 +105,21 @@
|
||||
</thead>
|
||||
<tbody>
|
||||
%for coupon in section_data['coupons']:
|
||||
<% current_date = datetime.now(pytz.UTC) %>
|
||||
<% coupon_expiry_date = coupon.expiration_date %>
|
||||
%if coupon.is_active == False:
|
||||
<tr class="coupons-items inactive_coupon">
|
||||
%else:
|
||||
%elif coupon_expiry_date is not None and current_date >= coupon_expiry_date:
|
||||
<tr class="coupons-items expired_coupon">
|
||||
%else:
|
||||
<tr class="coupons-items">
|
||||
%endif
|
||||
<td>${coupon.code}</td>
|
||||
<td>${coupon.description}</td>
|
||||
<td>${coupon.percentage_discount}</td>
|
||||
<td>${_('{code}').format(code=coupon.code)}</td>
|
||||
<td>${_('{description}').format(description=coupon.description)}</td>
|
||||
<td>
|
||||
${coupon.display_expiry_date}
|
||||
</td>
|
||||
<td>${_('{discount}').format(discount=coupon.percentage_discount)}</td>
|
||||
<td>${ coupon.couponredemption_set.filter(order__status='purchased').count() }</td>
|
||||
<td><a data-item-id="${coupon.id}" class='remove_coupon' href='#'>[x]</a><a href="#edit-modal" data-item-id="${coupon.id}" class="edit-right">${_('Edit')}</a></td>
|
||||
</tr>
|
||||
@@ -184,7 +194,7 @@
|
||||
}
|
||||
if($('#invoice_number').val() == "") {
|
||||
$('#error-msg').attr('class','error-msgs')
|
||||
$('#error-msg').html("${_("Invoice number should not be empty.")}").show();
|
||||
$('#error-msg').html("${_('Invoice number should not be empty.')}").show();
|
||||
return
|
||||
}
|
||||
$.ajax({
|
||||
@@ -224,6 +234,12 @@
|
||||
$('input#edit_coupon_discount').val(data.coupon_discount);
|
||||
$('textarea#edit_coupon_description').val(data.coupon_description);
|
||||
$('input#edit_coupon_course_id').val(data.coupon_course_id);
|
||||
if (data.expiry_date) {
|
||||
$('input#edit_coupon_expiration_date').val(data.expiry_date);
|
||||
}
|
||||
else {
|
||||
$('input#edit_coupon_expiration_date').val("${_('Never Expires')}");
|
||||
}
|
||||
$('#edit-modal-trigger').click();
|
||||
},
|
||||
error: function(jqXHR, textStatus, errorThrown) {
|
||||
@@ -459,6 +475,7 @@
|
||||
var coupon_discount = $.trim($('#coupon_discount').val());
|
||||
var course_id = $.trim($('#coupon_course_id').val());
|
||||
var description = $.trim($('#coupon_description').val());
|
||||
var expiration_date = $.trim($('#coupon_expiration_date').val());
|
||||
|
||||
// Check if empty of not
|
||||
if (code === '') {
|
||||
@@ -485,7 +502,8 @@
|
||||
"code" : code,
|
||||
"discount": coupon_discount,
|
||||
"course_id": course_id,
|
||||
"description": description
|
||||
"description": description,
|
||||
"expiration_date": expiration_date
|
||||
},
|
||||
url: "${section_data['ajax_add_coupon']}",
|
||||
success: function (data) {
|
||||
|
||||
@@ -49,6 +49,12 @@
|
||||
<input class="field readonly" id="edit_coupon_course_id" type="text" name="course_id" value=""
|
||||
readonly aria-required="true"/>
|
||||
</li>
|
||||
|
||||
<li class="field" id="edit-coupon-modal-field-expiration-date">
|
||||
<label for="edit_coupon_expiration_date">${_("Expiration Date")}</label>
|
||||
<input class="field readonly" id="edit_coupon_expiration_date" type="text" name="expiration_date" value=""
|
||||
readonly aria-required="true"/>
|
||||
</li>
|
||||
</ol>
|
||||
</fieldset>
|
||||
|
||||
|
||||
@@ -53,6 +53,7 @@
|
||||
<%static:js group='application'/>
|
||||
|
||||
## Backbone classes declared explicitly until RequireJS is supported
|
||||
<script type="text/javascript" src="${static.url('js/instructor_dashboard/ecommerce.js')}"></script>
|
||||
<script type="text/javascript" src="${static.url('js/models/notification.js')}"></script>
|
||||
<script type="text/javascript" src="${static.url('js/views/notification.js')}"></script>
|
||||
<script type="text/javascript" src="${static.url('js/views/file_uploader.js')}"></script>
|
||||
|
||||
Reference in New Issue
Block a user