~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to bin/ivle-enrolallusers

  • Committer: me at id
  • Date: 2009-01-15 06:08:43 UTC
  • mto: This revision was merged to the branch mainline in revision 1090.
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:branches%2Fstorm:1162
ivle.database.User: Add 'subjects', an attribute containing currently
    enrolled subjects.

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
import optparse
35
35
import logging
36
36
 
 
37
import ivle.db
37
38
import ivle.database
38
39
import ivle.pulldown_subj
39
40
 
69
70
    logging.error("Year must be numeric")
70
71
    sys.exit(1)
71
72
 
72
 
options.year = None if options.year is None else unicode(options.year)
73
 
 
74
73
for user in users:
75
74
    try:
76
75
        # Get all subjects this user is enrolled in, and add them to the DB if
77
76
        # they match one of our local subject codes
78
 
        res = ivle.pulldown_subj.enrol_user(store, user, options.year)
 
77
        res = ivle.pulldown_subj.enrol_user(user.login, options.year)
79
78
        logging.info("Enrolled user %s in %d subject%s." % (user.login, res,
80
79
                        '' if res == 1 else 's'))
81
80
    except Exception, message:
82
81
        logging.warning(str(message))
83
82
        continue
84
83
    
85
 
store.commit()
86
84
logging.info("enrolment completed successfully")