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

« back to all changes in this revision

Viewing changes to bin/ivle-enrol

  • Committer: Matt Giuca
  • Date: 2009-02-24 02:02:03 UTC
  • mto: This revision was merged to the branch mainline in revision 1119.
  • Revision ID: matt.giuca@gmail.com-20090224020203-aqdcjnsj6y7wl32o
Added a new look to the IVLE header bar. Mmmm... Web 2.0.
Added top-level directory image-source, containing SVG and script files for
    generating the images.
ivle/webapp/coremedia/images: Added 'chrome' directory containing the rendered
    images.
Modified ivle/webapp/base/ivle-headings.html and
    ivle/webapp/coremedia/ivle.css to support the new images.
    Note that the H1 and H2 at the top of the page are no longer displayed
    (and their custom styles have been removed). There is a heading image
    instead.

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
29
 
from ivle.database import get_store, Subject, Semester, Offering, User
 
28
from ivle.database import get_store, Subject, Semester, Offering, User, \
 
29
                          AlreadyEnrolledError
30
30
 
31
31
def die(error):
32
32
    print >> sys.stderr, '%s: %s' % (os.path.basename(sys.argv[0]), error)
33
33
    sys.exit(1)
34
34
 
35
 
if len(sys.argv) not in (5, 6):
36
 
    print >> sys.stderr, '''usage: %s <login> <subjectcode> <year> <semestercode> [role]
37
 
 
38
 
'role' should be one of student (the default), tutor or lecturer.
39
 
If an enrolment already exists, it will be reactivated and its role set.''' \
 
35
if len(sys.argv) != 5:
 
36
    print >> sys.stderr, "usage: %s <login> <subjectcode> <year> <semester>" \
40
37
                         % os.path.basename(sys.argv[0])
41
38
    sys.exit()
42
39
 
43
 
store = get_store(Config())
 
40
store = get_store()
44
41
 
45
42
user = User.get_by_login(store, sys.argv[1])
46
43
if user is None:
49
46
offering = store.find(Offering,
50
47
                    Subject.code == unicode(sys.argv[2]),
51
48
                    Semester.year == unicode(sys.argv[3]),
52
 
                    Semester.code == unicode(sys.argv[4]),
 
49
                    Semester.semester == unicode(sys.argv[4]),
53
50
                    Offering.subject_id == Subject.id,
54
51
                    Offering.semester_id == Semester.id).one()
55
52
if not offering:
56
53
    die("subject offering not found")
57
54
 
58
 
role = unicode(sys.argv[5]) if len(sys.argv) == 6 else u'student'
59
 
 
 
55
if not offering.semester.active:
 
56
    die("cannot enrol - semester inactive")
 
57
    
60
58
try:
61
 
    offering.enrol(user, role)
 
59
    offering.enrol(user)
62
60
except AlreadyEnrolledError:
63
61
    die("already enrolled")
64
62