Skip to content

Commit

Permalink
Change license timezone to Pacific time on admin and licensors page (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Shubhangi committed Jul 6, 2018
1 parent df95504 commit 246a6d6
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 19 deletions.
17 changes: 9 additions & 8 deletions app/templates/admin/administer-user-modal.jade
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ block modal-body-content
th ID
th Shared by
th Type
th Issued
th Start
th End
th Issued (PT)
th Start (PT)
th End (PT)
th Used
for prepaid in view.prepaids.models
tr
Expand All @@ -73,13 +73,13 @@ block modal-body-content
else
| -
td= prepaid.get('type')
td= moment(new Date(parseInt(prepaid.id.substring(0, 8), 16) * 1000)).utc().format('l')
td= moment.timezone(new Date(parseInt(prepaid.id.substring(0, 8), 16) * 1000)).tz('America/Los_Angeles').format('l')
td
if prepaid.get('startDate')
= moment(prepaid.get('startDate')).utc().format('l')
= moment.timezone(prepaid.get('startDate')).tz('America/Los_Angeles').format('l')
td
if prepaid.get('endDate')
= moment(prepaid.get('endDate')).utc().format('l')
= moment.timezone(prepaid.get('endDate')).tz('America/Los_Angeles').format('l')
td #{(prepaid.get('redeemers') || []).length} / #{prepaid.get('maxRedeemers') || 0}
hr

Expand All @@ -93,6 +93,7 @@ block modal-body-content
.alert.alert-success Licenses created!

else
h4.small(style="max-width: 700px") *All licenses granted after July 9, 2018 start and end at 12am PT on the date listed. All licenses that were granted before that date start and end at 5pm PT on the date previous to the date indicated.
.form-group
label
span Number of Licenses
Expand All @@ -102,12 +103,12 @@ block modal-body-content
label
span Start Date
=" "
input(type="date" name="startDate" value=moment().format('YYYY-MM-DD'))
input(type="date" name="startDate" value=moment.timezone().tz('America/Los_Angeles').format('YYYY-MM-DD'))
.form-group
label
span End Date
=" "
input(type="date" name="endDate" value=moment().add(1, 'year').format('YYYY-MM-DD'))
input(type="date" name="endDate" value=moment.timezone().tz('America/Los_Angeles').add(1, 'year').format('YYYY-MM-DD'))
.form-group
button#add-seats-btn.btn.btn-primary Add Licenses
hr
Expand Down
4 changes: 2 additions & 2 deletions app/templates/courses/enrollments-view.jade
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,11 @@ mixin prepaidCard(prepaid, className)
hr
i.small-details
.pull-left(data-i18n="teacher.start_date")
.pull-right= moment(prepaid.get('startDate')).utc().format('ll')
.pull-right= moment(prepaid.get('startDate')).format('ll')
.clearfix

.pull-left(data-i18n="teacher.end_date")
.pull-right= moment(prepaid.get('endDate')).utc().format('ll')
.pull-right= moment(prepaid.get('endDate')).format('ll')
.clearfix
if prepaid.get('type') === 'course'
.share-details.small-details.m-b-2
Expand Down
1 change: 1 addition & 0 deletions app/vendor.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ require('bower_components/validated-backbone-mediator/backbone-mediator.js');
window.TreemaUtils = require('exports-loader?TreemaUtils!bower_components/treema/treema-utils.js'); // TODO webpack: Try to extract this
import 'bower_components/treema/treema.css'
window.moment = require('bower_components/moment/min/moment-with-locales.min.js');
window.moment.timezone = require('moment-timezone');
window.$.i18n = window.i18n = require('bower_components/i18next/i18next.js');
require('bower_components/cookieconsent/build/cookieconsent.min.js')// TODO webpack: Try to extract this
import 'bower_components/cookieconsent/build/cookieconsent.min.css'// TODO webpack: Try to extract this
Expand Down
17 changes: 10 additions & 7 deletions app/views/LicensorViewComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ div.licensor.container(v-if="!$store.getters['me/isAdmin'] && !$store.getters['m
div.licensor.container(v-else)
h3 Create New License
form#prepaid-form
h4.small(style="max-width: 700px") *All licenses granted after July 9, 2018 start and end at 12am PT on the date listed. All licenses that were granted before that date start and end at 5pm PT on the date previous to the date indicated.
.form-group
label.small
| Teacher email
Expand Down Expand Up @@ -41,8 +42,8 @@ div.licensor.container(v-else)
th.border ID
th.border Creator
th.border Type
th.border Start
th.border End
th.border Start (PT)
th.border End (PT)
th.border Used
tr(v-for = "prepaid in prepaids")
td.border {{prepaid._id}}
Expand Down Expand Up @@ -181,7 +182,7 @@ div.licensor.container(v-else)
<script lang="coffee">
co = require('co')
api = require 'core/api'
moment = require('moment')
moment.timezone = require('moment-timezone')
Prepaids = require 'collections/Prepaids'
forms = require 'core/forms'
Expand Down Expand Up @@ -221,6 +222,8 @@ module.exports = Vue.extend({
user = yield api.users.getByEmail({email})
attrs = data
attrs.maxRedeemers = parseInt(data.maxRedeemers)
attrs.startDate = moment.timezone.tz(data.startDate, "America/Los_Angeles").toISOString()
attrs.endDate = moment.timezone.tz(data.endDate, "America/Los_Angeles").toISOString()
_.extend(attrs, {
type: 'course'
creator: user._id
Expand Down Expand Up @@ -252,8 +255,8 @@ module.exports = Vue.extend({
forms.setErrorToProperty(el, 'showLicense', 'No licenses found for this user')
return
for prepaid in this.prepaids
prepaid.startDate = moment(prepaid.startDate).utc().format('l')
prepaid.endDate = moment(prepaid.endDate).utc().format('l')
prepaid.startDate = moment.timezone(prepaid.startDate).tz('America/Los_Angeles').format('l')
prepaid.endDate = moment.timezone(prepaid.endDate).tz('America/Los_Angeles').format('l')
Vue.set(prepaid, 'used' , (prepaid.redeemers || []).length)
catch err
Expand Down Expand Up @@ -408,9 +411,9 @@ module.exports = Vue.extend({
computed:
timestampStart: ->
return moment().format('YYYY-MM-DD')
return moment.timezone().tz('America/Los_Angeles').format('YYYY-MM-DD')
timestampEnd: ->
return moment().add(1, 'year').format('YYYY-MM-DD')
return moment.timezone().tz('America/Los_Angeles').add(1, 'year').format('YYYY-MM-DD')
})
Expand Down
4 changes: 2 additions & 2 deletions app/views/admin/AdministerUserModal.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ module.exports = class AdministerUserModal extends ModalView
return unless _.all(_.values(attrs))
return unless attrs.maxRedeemers > 0
return unless attrs.endDate and attrs.startDate and attrs.endDate > attrs.startDate
attrs.startDate = new Date(attrs.startDate).toISOString()
attrs.endDate = new Date(attrs.endDate).toISOString()
attrs.startDate = moment.timezone.tz(attrs.startDate, "America/Los_Angeles").toISOString()
attrs.endDate = moment.timezone.tz(attrs.endDate, "America/Los_Angeles").toISOString()
_.extend(attrs, {
type: 'course'
creator: @user.id
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
"marked": "~0.3.0",
"method-override": "^2.3.7",
"moment": "~2.19.0",
"moment-timezone": "~0.5.21",
"mongodb": "^2.0.28",
"mongoose": "^4.5.3",
"mongoose-cache": "nwinter/mongoose-cache#master",
Expand Down

0 comments on commit 246a6d6

Please sign in to comment.