Changeset 6795 for main


Ignore:
Timestamp:
19 Sep 2011, 08:39:58 (13 years ago)
Author:
Henrik Bettermann
Message:

Implement CourseTicketAddFormPage?.

Location:
main/waeup.sirp/trunk/src/waeup/sirp/students
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/students/browser.py

    r6794 r6795  
    3535    IStudentPersonal, IStudentBase, IStudentStudyCourse, IStudentPayments,
    3636    IStudentAccommodation, IStudentClearanceEdit, IStudentStudyLevel,
     37    ICourseTicket, ICourseTicketAdd,
    3738    )
    3839from waeup.sirp.students.catalog import search
    3940from waeup.sirp.students.workflow import CLEARANCE
    40 from waeup.sirp.students.studylevel import StudentStudyLevel
     41from waeup.sirp.students.studylevel import StudentStudyLevel, CourseTicket
    4142from waeup.sirp.students.vocabularies import StudyLevelSource
    4243
     
    592593    pnav = 4
    593594    taboneactions = ['Save','Cancel']
    594     tabtwoactions = ['Remove selected tickets','Cancel']
    595     tabthreeactions = ['Add course ticket']
     595    tabtwoactions = ['Add course ticket','Remove selected tickets','Cancel']
    596596
    597597    def update(self):
     
    615615
    616616    @grok.action('Add course ticket')
    617     def addStudyLevel(self, **data):
    618         # We need a ticket catalog
    619         return
    620 
    621         #course_code = self.request.form.get('addticket', None)
    622         #try:
    623         #    self.context.addCourseTicket(
    624         #        self.context.certificate,studylevel)
    625         #except KeyError:
    626         #    self.flash('This ticket exists.')
    627         #self.redirect(self.url(self.context, u'@@manage')+'#tab-2')
    628         #return
     617    def addCourseTicket(self, **data):
     618        self.redirect(self.url(self.context, '@@add'))
    629619
    630620    @grok.action('Remove selected tickets')
     
    651641        self.redirect(self.url(self.context, u'@@manage')+'#tab-2')
    652642        return
     643
     644class CourseTicketAddFormPage(WAeUPAddFormPage):
     645    """Add a department to a faculty.
     646    """
     647    grok.context(IStudentStudyLevel)
     648    grok.name('add')
     649    grok.require('waeup.manageStudents')
     650    label = 'Add course ticket'
     651    form_fields = grok.AutoFields(ICourseTicketAdd).omit('grade', 'score')
     652    pnav = 4
     653
     654    @property
     655    def title(self):
     656        return 'Study Level %s' % self.context.level_title
     657
     658    @grok.action('Add course ticket')
     659    def addCourseTicket(self, **data):
     660        ticket = CourseTicket()
     661        #import pdb; pdb.set_trace()
     662        course = data['course']
     663        ticket.core_or_elective = data['core_or_elective']
     664        ticket.level = self.context.level
     665        ticket.code = course.code
     666        ticket.title = course.title
     667        ticket.faculty = course.__parent__.__parent__.__parent__.title
     668        ticket.department = course.__parent__.__parent__.title
     669        ticket.credits = course.credits
     670        ticket.passmark = course.passmark
     671        ticket.semester = course.semester
     672        try:
     673            self.context.addCourseTicket(ticket)
     674        except KeyError:
     675            self.flash('The ticket exists.')
     676            return
     677        self.redirect(self.url(self.context, u'@@manage')+'#tab-2')
     678        return
     679
     680    @grok.action('Cancel')
     681    def cancel(self, **data):
     682        self.redirect(self.url(self.context))
    653683
    654684class PaymentsDisplayFormPage(WAeUPDisplayFormPage):
  • main/waeup.sirp/trunk/src/waeup/sirp/students/browser_templates/studylevelmanagepage.pt

    r6794 r6795  
    100100  </div>
    101101
    102   <br /><br /><br />
    103 
    104   <div>
    105     <span class="actionButtons" tal:condition="view/availableActions">
    106       <span tal:repeat="action view/actions"
    107             tal:omit-tag="">
    108         <input tal:condition="python:action.label in view.tabthreeactions"
    109                tal:replace="structure action/render"/>
    110       </span>
    111     </span>
    112 
    113   </div>
    114 
    115102</div>
    116103</div>
  • main/waeup.sirp/trunk/src/waeup/sirp/students/interfaces.py

    r6793 r6795  
    66from waeup.sirp.interfaces import IWAeUPObject
    77from waeup.sirp.schema import TextLineChoice
     8from waeup.sirp.university.vocabularies import CourseSource
    89from waeup.sirp.students.vocabularies import (
    910  CertificateSource, academic_sessions_vocab, verdicts, StudyLevelSource,
     
    225226        required = False,
    226227        )
    227 
    228228
    229229class ICourseTicket(IWAeUPObject):
     
    238238    faculty = Attribute('faculty of the original course')
    239239    department = Attribute('department of the original course')
    240     core_or_elective = Attribute('core_or_elective of the original course referrer')
    241240    level = Attribute('level of the original course referrer')
     241
     242    core_or_elective = schema.Bool(
     243        title = u'Mandatory',
     244        default = False,
     245        required = False,
     246        readonly = False,
     247        )
    242248
    243249    score = schema.Int(
     
    255261        )
    256262
     263class ICourseTicketAdd(ICourseTicket):
     264    """An interface for adding course tickets
     265
     266    """
     267    course = schema.Choice(
     268        title = u'Course',
     269        source = CourseSource(),
     270        readonly = False,
     271        )
     272
    257273class IStudentAccommodation(IWAeUPObject):
    258274    """A container for student accommodation objects.
  • main/waeup.sirp/trunk/src/waeup/sirp/students/studycourse.py

    r6791 r6795  
    5151            if val.level != studylevel.level:
    5252                continue
    53             ticket = CourseTicket(
    54                 val.getCourseCode(),
    55                 val.course.title,
    56                 val.course.credits,
    57                 val.course.passmark,
    58                 val.course.semester,
    59                 val.course.__parent__.__parent__.__parent__.title,
    60                 val.course.__parent__.__parent__.title,
    61                 val.level,
    62                 val.core_or_elective)
     53            ticket = CourseTicket()
     54            ticket.code = val.getCourseCode()
     55            ticket.level = val.level
     56            ticket.core_or_elective = val.core_or_elective
     57            ticket.title = val.course.title
     58            ticket.faculty = val.course.__parent__.__parent__.__parent__.title
     59            ticket.department = val.course.__parent__.__parent__.title
     60            ticket.credits = val.course.credits
     61            ticket.passmark = val.course.passmark
     62            ticket.semester = val.course.semester
    6363            self[str(studylevel.level)][val.getCourseCode()] = ticket
    6464        return
  • main/waeup.sirp/trunk/src/waeup/sirp/students/studylevel.py

    r6783 r6795  
    3535        super(StudentStudyLevel, self).__init__()
    3636        self.level = None
     37        self.validation_date = None
     38        self.validated_by = None
    3739        return
    3840
     
    6971    grok.provides(ICourseTicket)
    7072
    71     def __init__(self, code, title, credits,
    72         passmark, semester, faculty, department, level, core_or_elective):
    73 
     73    def __init__(self):
    7474        super(CourseTicket, self).__init__()
    75         self.title = title
    76         self.code = code
    77         self.faculty = faculty
    78         self.department = department
    79         self.level = level
    80         self.credits = credits
    81         self.passmark = passmark
    82         self.semester = semester
    83         self.core_or_elective = core_or_elective
     75        self.code = None
     76        self.level = None
     77        self.title = None
     78        self.faculty = None
     79        self.department = None
     80        self.credits = None
     81        self.passmark = None
     82        self.semester = None
    8483        return
    8584
  • main/waeup.sirp/trunk/src/waeup/sirp/students/tests/test_student.py

    r6783 r6795  
    3737        self.studycourse = StudentStudyCourse()
    3838        self.studylevel = StudentStudyLevel()
    39         self.courseticket = CourseTicket('CERT', 'Title', 100, 10, 40, 1,
    40             'Faculty', 'Department', True)
     39        self.courseticket = CourseTicket()
    4140        self.payments = StudentPayments()
    4241        self.accommodation = StudentAccommodation()
Note: See TracChangeset for help on using the changeset viewer.