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

« back to all changes in this revision

Viewing changes to bin/ivle-enrol

  • Committer: William Grant
  • Date: 2011-08-24 08:24:36 UTC
  • Revision ID: me@williamgrant.id.au-20110824082436-2kthurhl385pegut
natty needs --include=ubuntu-keyring,gnupg in debootstrap. Fix jailbuilder to cope.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
import os
26
26
import sys
27
27
 
 
28
from ivle.config import Config
28
29
from ivle.database import get_store, Subject, Semester, Offering, User
29
30
 
30
31
def die(error):
32
33
    sys.exit(1)
33
34
 
34
35
if len(sys.argv) not in (5, 6):
35
 
    print >> sys.stderr, '''usage: %s <login> <subjectcode> <year> <semester> [role]
 
36
    print >> sys.stderr, '''usage: %s <login> <subjectcode> <year> <semestercode> [role]
36
37
 
37
38
'role' should be one of student (the default), tutor or lecturer.
38
39
If an enrolment already exists, it will be reactivated and its role set.''' \
39
40
                         % os.path.basename(sys.argv[0])
40
41
    sys.exit()
41
42
 
42
 
store = get_store()
 
43
store = get_store(Config())
43
44
 
44
45
user = User.get_by_login(store, sys.argv[1])
45
46
if user is None:
48
49
offering = store.find(Offering,
49
50
                    Subject.code == unicode(sys.argv[2]),
50
51
                    Semester.year == unicode(sys.argv[3]),
51
 
                    Semester.semester == unicode(sys.argv[4]),
 
52
                    Semester.code == unicode(sys.argv[4]),
52
53
                    Offering.subject_id == Subject.id,
53
54
                    Offering.semester_id == Semester.id).one()
54
55
if not offering: