Changeset 7761


Ignore:
Timestamp:
6 Mar 2012, 03:31:52 (13 years ago)
Author:
uli
Message:

Some stuff to start school grade support. Messy, but a beginning. At least manage and edit of applicants provide some school grade selections.

Location:
main/waeup.sirp/branches/ulif-schoolgrades/src/waeup/sirp/applicants
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/branches/ulif-schoolgrades/src/waeup/sirp/applicants/applicant.py

    r7686 r7761  
    3737from waeup.sirp.applicants.workflow import application_states_dict
    3838
     39from waeup.sirp.applicants.interfaces import IResultEntry
     40from zope.schema.fieldproperty import FieldProperty
     41class ResultEntry(grok.Model):
     42    grok.implements(IResultEntry)
     43    subject = FieldProperty(IResultEntry['subject'])
     44    grade = FieldProperty(IResultEntry['grade'])
     45
     46    #def __init__(self, subject=None, grade=None):
     47    #    self.subject = subject
     48    #    self.grade = grade
     49
    3950class Applicant(grok.Container):
    4051    grok.implements(IApplicant,IApplicantEdit)
  • main/waeup.sirp/branches/ulif-schoolgrades/src/waeup/sirp/applicants/browser.py

    r7741 r7761  
    638638    return True
    639639
     640from waeup.sirp.applicants.interfaces import IResultEntry
     641from waeup.sirp.widgets.objectwidget import SIRPObjectWidget
     642from waeup.sirp.applicants.applicant import ResultEntry
     643from zope.formlib.widget import CustomWidgetFactory
     644from zope.formlib.widgets import ListSequenceWidget
     645entry_widget = CustomWidgetFactory(SIRPObjectWidget, ResultEntry)
     646sw = CustomWidgetFactory(ListSequenceWidget, subwidget=entry_widget)
     647
    640648class ApplicantManageFormPage(SIRPEditFormPage):
    641649    """A full edit view for applicant data.
     
    649657    form_fields['applicant_id'].for_display = True
    650658    form_fields['phone'].custom_widget = PhoneWidget
     659    form_fields['school_grades'].custom_widget = sw
    651660    grok.template('applicanteditpage')
    652661    manage_applications = True
     
    780789    form_fields['phone'].custom_widget = PhoneWidget
    781790    form_fields['applicant_id'].for_display = True
     791    form_fields['school_grades'].custom_widget = sw
    782792    grok.template('applicanteditpage')
    783793    manage_applications = False
  • main/waeup.sirp/branches/ulif-schoolgrades/src/waeup/sirp/applicants/interfaces.py

    r7708 r7761  
    7878directlyProvides(contextual_reg_num_source, IContextSourceBinder)
    7979
     80SUBJECTS = dict(math=_(u'Math'),
     81                bio=_(u'Biology'),
     82                eng=_(u'English'),
     83                )
     84class SubjectSource(BasicSourceFactory):
     85    def getValues(self):
     86        return sorted(SUBJECTS.keys())
     87    def getTitle(self, value):
     88        return SUBJECTS.get(value, None)
     89
     90GRADES = {'A':_(u'Very Good'),
     91          'B':_(u'Good'),
     92          'C':_(u'Satisfactory'),
     93          'D':_(u'Sufficient'),
     94          'E':_(u'Fail'),
     95          }
     96class GradeSource(BasicSourceFactory):
     97    def getValues(self):
     98        return sorted(GRADES.keys())
     99    def getTitle(self, value):
     100        return GRADES.get(value, None)
     101
    80102class AppCatCertificateSource(CertificateSource):
    81103    """An application certificate source delivers all courses which belong to
     
    352374    'provider'].order =  IApplicantsContainer['provider'].order
    353375
     376class IResultEntry(Interface):
     377    subject = schema.Choice(
     378        title = _(u'Subject'),
     379        source = SubjectSource(),
     380        )
     381    #subject = schema.TextLine(
     382    #    title = _(u'Subject'),
     383    #    )
     384    grade = schema.Choice(
     385        title = _(u'Grafde'),
     386        source = GradeSource(),
     387        )
     388    #grade = schema.TextLine(
     389    #    title = _(u'Grade'),
     390    #    )
     391
    354392class IApplicantBaseData(ISIRPObject):
    355393    """The data for an applicant.
     
    360398    state, depending on use-case.
    361399
    362     This base interface is also implemented by the StudentApplication
    363     class in the students package. Thus, these are the data which are saved
    364     after admission.
    365     """
    366 
     400    This base interface is also implemented by the
     401    :class:`waeup.sirp.students.StudentApplication` class in the
     402    students package. Thus, these are the data which are saved after
     403    admission.
     404    """
    367405    applicant_id = schema.TextLine(
    368406        title = _(u'Applicant Id'),
     
    430468        required = False,
    431469        )
     470    school_grades = schema.List(
     471        title = _(u'School Grades'),
     472        value_type = schema.Object(
     473            schema = IResultEntry),
     474        required = True,
     475        default = [],
     476        )
     477    #school_grades = schema.Dict(
     478    #    title = _(u'School Grades'),
     479    #    key_type = schema.TextLine(
     480    #        title = _(u'Subject'),
     481    #        ),
     482    #    value_type = schema.TextLine(
     483    #        title = _(u'Grade'),
     484    #        )
     485    #    )
    432486
    433487    #
Note: See TracChangeset for help on using the changeset viewer.