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

« back to all changes in this revision

Viewing changes to bin/ivle-enrol

  • Committer: Matt Giuca
  • Date: 2010-07-28 06:09:00 UTC
  • Revision ID: matt.giuca@gmail.com-20100728060900-6a0lcuexcv1juh5r
ivle/webapp/submit/submit.html: Rewrote error message when an offering could not be found to submit to. This can have one of several causes, and the old error assumed it was because you weren't in a subject dir. Now enumerates the possible reasons. (LP: #526853)

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: