Skip to content

Commit 8727cd2

Browse files
committed
handle new school years using externalService courses
Email is temp disabled, since I don't really know if all this stuff works cleanly.
1 parent 9f1c274 commit 8727cd2

File tree

4 files changed

+49
-63
lines changed

4 files changed

+49
-63
lines changed

client/app/app.coffee

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,6 @@ class @App
1818
NotificationsManager.hideAll()
1919

2020
# == Modals ==
21-
Template.newSchoolYearModal.helpers classes: -> classes()
22-
23-
Template.newSchoolYearModal.events
24-
"change": (event) ->
25-
target = $(event.target)
26-
checked = target.is ":checked"
27-
classId = target.attr "classid"
28-
29-
target.find("span").css color: if checked then "lightred" else "white"
30-
3121
Template.addTicketModal.helpers
3222
body: -> Session.get('addTicketModalContent') ? ''
3323

client/app/app.html

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -92,35 +92,6 @@ <h4 class="modal-title">Vakken</h4>
9292
</div>
9393
</template>
9494

95-
<template name="newSchoolYearModal">
96-
<div class="modal fade" aria-hidden="true" id="newSchoolYearModal">
97-
<div class="modal-dialog">
98-
<div class="modal-content">
99-
<div class="modal-header">
100-
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
101-
<h4 class="modal-title">Nieuw Schooljaar</h4>
102-
</div>
103-
<div class="modal-body">
104-
<h4 style="text-align: center; margin-bottom: 20px;">Welken vakken moeten er weg?<small><br>Vakken kan je zometeen toevoegen.</small></h4>
105-
{{#each classes}}
106-
<div class="classRemoveRow">
107-
<label>
108-
<input type="checkbox" classId="{{_id._str}}">
109-
<span id="checkboxLabel">
110-
{{name}}
111-
</span>
112-
</label>
113-
</div>
114-
{{/each}}
115-
</div>
116-
<div class="modal-footer">
117-
<button type="button" class="btn btn-primary" id="goButton">Okido</button>
118-
</div>
119-
</div>
120-
</div>
121-
</div>
122-
</template>
123-
12495
<template name="addTicketModal">
12596
<div class="modal fade" aria-hidden="true" id="addTicketModal">
12697
<div class="modal-dialog">

client/app/setup/setup.coffee

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,14 @@ setupItems = [
7979
name: 'externalServices'
8080
async: no
8181
onDone: (cb) ->
82+
# well, this externalServices global shit stuff is a fucking mess.
83+
8284
schoolId = _(externalServices.get())
8385
.map (s) -> s.profileData()?.schoolId
8486
.find _.negate _.isUndefined
8587

88+
schoolId ?= getUserField Meteor.userId(), 'profile.schoolId'
89+
8690
done = (success) ->
8791
if success?
8892
addProgress 'externalServices', -> cb yes
@@ -193,26 +197,7 @@ setupItems = [
193197
}
194198

195199
{
196-
# TODO: implement this, it should open a modal that asks
197-
# if the current schoolyear is over, if so we can ask the user to follow the setup
198-
# with stuff as `externalServices` and `externalClasses` again.
199-
name: 'newSchoolYear'
200-
func: ->
201-
return undefined
202-
203-
alertModal(
204-
"Hey!",
205-
Locals["nl-NL"].NewSchoolYear(),
206-
DialogButtons.Ok,
207-
{ main: "verder" },
208-
{ main: "btn-primary" },
209-
{ main: (->) },
210-
no
211-
)
212-
}
213-
214-
{
215-
name: 'first-use'
200+
name: 'final'
216201
func: ->
217202
addProgress 'first-use', ->
218203
name = getUserField Meteor.userId(), 'profile.firstName'
@@ -231,10 +216,6 @@ running = undefined
231216
setupProgress = getUserField Meteor.userId(), 'setupProgress'
232217
return undefined unless setupProgress?
233218

234-
setupProgress = setupProgress.concat [
235-
'newSchoolYear' # TODO: Dunno how're going to do this shit
236-
]
237-
238219
running = _.filter setupItems, (item) -> item.name not in setupProgress
239220

240221
if running.length > 0

server/cronJobs.coffee

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,3 +180,47 @@ SyncedCron.add
180180
Date.today()
181181
Date.today().addDays 14
182182
)
183+
184+
SyncedCron.add
185+
name: 'Handle new schoolyears'
186+
schedule: (parser) -> parser.recur().on(4).hour()
187+
job: ->
188+
userIds = Meteor.users.find({
189+
'profile.firstName': $ne: ''
190+
}, {
191+
fields:
192+
_id: 1
193+
'profile.firstName': 1
194+
emails: 1
195+
}).map (u) -> u._id
196+
197+
for userId in userIds
198+
courses = functions.getCourses userId
199+
current = _.find courses, (c) -> c.inside new Date
200+
next = _.find courses, (c) -> c.from > new Date
201+
202+
if current? and Date.today().addDays(-1) < current.start
203+
###
204+
loginUrl = 'https://app.simplyHomework.nl/login'
205+
sendMail user, 'Nieuw schooljaar', """
206+
Hey #{user.profile.firstName}!
207+
208+
Zo te zien is het nieuwe schooljaar zojuist voor je begonnen.
209+
We hopen dat simplyHomework je dit jaar weer kan helpen met school! :)
210+
211+
Je moet wel even eerst de setup doorlopen (ongeveer 2 minuten) op: <a href='#{loginurl}'>#{loginurl}</a>
212+
213+
Success dit schooljaar!
214+
"""
215+
###
216+
Meteor.users.update(
217+
userId
218+
$pullAll: setupProgress: [
219+
'externalServices'
220+
'extractInfo'
221+
'getExternalClasses'
222+
]
223+
)
224+
225+
# REVIEW: do we want to send a message here? If so, what?
226+
# else unless next?

0 commit comments

Comments
 (0)