Add approved date to job profile

This commit is contained in:
Michael Schmatz 2014-07-16 10:51:44 -07:00
parent 87a24d3c48
commit bb3c583300
4 changed files with 7 additions and 2 deletions

View file

@ -46,6 +46,10 @@ module.exports = class User extends CocoModel
)
cache[id] = user
user
set: ->
if arguments[0] is 'jobProfileApproved' and @get("jobProfileApproved") is false and not @get("jobProfileApprovedDate")
@set "jobProfileApprovedDate", (new Date()).toISOString()
super arguments...
# callbacks can be either success or error
@getByIDOrSlug: (idOrSlug, force, callbacks={}) ->

View file

@ -156,6 +156,7 @@ _.extend UserSchema.properties,
type: 'boolean'
description: 'Should this candidate be prominently featured on the site?'
jobProfileApproved: {title: 'Job Profile Approved', type: 'boolean', description: 'Whether your profile has been approved by CodeCombat.'}
jobProfileApprovedDate: c.date {title: 'Approved date', description: 'The date that the candidate was approved'}
jobProfileNotes: {type: 'string', maxLength: 1000, title: 'Our Notes', description: 'CodeCombat\'s notes on the candidate.', format: 'markdown', default: ''}
employerAt: c.shortString {description: 'If given employer permissions to view job candidates, for which employer?'}
signedEmployerAgreement: c.object {},

View file

@ -322,7 +322,7 @@ module.exports = class ProfileView extends View
return unless me.isAdmin()
approved = not @user.get 'jobProfileApproved'
@user.set 'jobProfileApproved', approved
res = @user.save {jobProfileApproved: approved}, {patch: true}
res = @user.patch()
res.success (model, response, options) => @render()
toggleJobProfileActive: ->

View file

@ -35,7 +35,7 @@ UserHandler = class UserHandler extends Handler
getEditableProperties: (req, document) ->
props = super req, document
props.push 'permissions' unless config.isProduction
props.push 'jobProfileApproved', 'jobProfileNotes' if req.user.isAdmin() # Admins naturally edit these
props.push 'jobProfileApproved', 'jobProfileNotes','jobProfileApprovedDate' if req.user.isAdmin() # Admins naturally edit these
props.push privateProperties... if req.user.isAdmin() # Admins are mad with power
props