Ignore:
Timestamp:
13 Dec 2011, 17:26:35 (13 years ago)
Author:
Henrik Bettermann
Message:

Start implementation of applicant copier.

Reorganize interfaces in the applicants package. We need a base interface which can be used in the students package too, for storing the application data. The upcoming StudentApplication? class has to implement the IApplicantBaseData interface. So, data fields have to be isolated.

Location:
main/waeup.sirp/trunk/src/waeup/sirp/applicants
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/applicants/applicant.py

    r7321 r7338  
    2020from grok import index
    2121from zope.component.interfaces import IFactory
     22from zope.component import createObject
    2223from zope.securitypolicy.interfaces import IPrincipalRoleManager
    2324from zope.interface import implementedBy
     
    7576        else:
    7677            return '%s %s' % (self.firstname, self.lastname)
     78
     79    def createStudent(self):
     80        """Create a student object from applicatnt data
     81        and copy applicant object.
     82        """
     83        student = createObject(u'waeup.Student')
     84        site = grok.getSite()
     85
     86        site['students'].addStudent(student)
     87        student.fullname = self.fullname
     88        return student.student_id
    7789
    7890# Set all attributes of Applicant required in IApplicant as field
  • main/waeup.sirp/trunk/src/waeup/sirp/applicants/interfaces.py

    r7331 r7338  
    282282    the derived interfaces below, which set more fields to required
    283283    state, depending on use-case.
    284     """
     284
     285    This base interface is also implemented by the StudentApplication
     286    class in the students package. Thus, these are the data which are saved
     287    after admission.
     288    """
     289
     290    applicant_id = schema.TextLine(
     291        title = u'Applicant Id',
     292        required = False,
     293        readonly = False,
     294        )
     295    reg_number = TextLineChoice(
     296        title = u'JAMB Registration Number',
     297        readonly = False,
     298        required = True,
     299        default = None,
     300        source = contextual_reg_num_source,
     301        )
     302    access_code = schema.TextLine(
     303        title = u'Access Code',
     304        required = False,
     305        readonly = True,
     306        )
     307    firstname = schema.TextLine(
     308        title = u'First Name',
     309        required = True,
     310        )
     311    middlenames = schema.TextLine(
     312        title = u'Middle Names',
     313        required = False,
     314        )
     315    lastname = schema.TextLine(
     316        title = u'Last Name (Surname)',
     317        required = True,
     318        )
     319    date_of_birth = schema.Date(
     320        title = u'Date of Birth',
     321        required = True,
     322        )
     323    lga = schema.Choice(
     324        source = lgas_vocab,
     325        title = u'State/LGA',
     326        default = 'foreigner',
     327        required = True,
     328        )
     329    sex = schema.Choice(
     330        title = u'Sex',
     331        source = GenderSource(),
     332        default = u'm',
     333        required = True,
     334        )
     335    email = schema.ASCIILine(
     336        title = u'Email',
     337        required = True,
     338        constraint=validate_email,
     339        )
     340    phone = schema.TextLine(
     341        title = u'Phone',
     342        description = u'',
     343        required = False,
     344        )
     345    course1 = schema.Choice(
     346        title = u'1st Choice Course of Study',
     347        source = CertificateSource(),
     348        required = True,
     349        )
     350    course2 = schema.Choice(
     351        title = u'2nd Choice Course of Study',
     352        source = CertificateSource(),
     353        required = False,
     354        )
     355
     356    #
     357    # Data to be imported after screening
     358    #
     359    screening_score = schema.Int(
     360        title = u'Screening Score',
     361        required = False,
     362        )
     363    screening_venue = schema.TextLine(
     364        title = u'Screening Venue',
     365        required = False,
     366        )
     367    course_admitted = schema.Choice(
     368        title = u'Admitted Course of Study',
     369        source = CertificateSource(),
     370        default = None,
     371        required = False,
     372        )
     373    notice = schema.Text(
     374        title = u'Notice',
     375        required = False,
     376        )
     377
     378class IApplicantProcessData(IApplicantBaseData):
     379    """An applicant.
     380
     381    Here we add process attributes and methods to the base data.
     382    """
     383
    285384    history = Attribute('Object history, a list of messages.')
    286385    state = Attribute('The application state of an applicant')
     
    294393        """
    295394
    296     applicant_id = schema.TextLine(
    297         title = u'Applicant Id',
    298         required = False,
    299         readonly = False,
    300         )
    301     reg_number = TextLineChoice(
    302         title = u'JAMB Registration Number',
    303         readonly = False,
    304         required = True,
    305         default = None,
    306         source = contextual_reg_num_source,
    307         )
    308     access_code = schema.TextLine(
    309         title = u'Access Code',
    310         required = False,
    311         readonly = True,
    312         )
    313     firstname = schema.TextLine(
    314         title = u'First Name',
    315         required = True,
    316         )
    317     middlenames = schema.TextLine(
    318         title = u'Middle Names',
    319         required = False,
    320         )
    321     lastname = schema.TextLine(
    322         title = u'Last Name (Surname)',
    323         required = True,
    324         )
    325     date_of_birth = schema.Date(
    326         title = u'Date of Birth',
    327         required = True,
    328         )
    329     lga = schema.Choice(
    330         source = lgas_vocab,
    331         title = u'State/LGA',
    332         default = 'foreigner',
    333         required = True,
    334         )
    335     sex = schema.Choice(
    336         title = u'Sex',
    337         source = GenderSource(),
    338         default = u'm',
    339         required = True,
    340         )
    341     email = schema.ASCIILine(
    342         title = u'Email',
    343         required = True,
    344         constraint=validate_email,
    345         )
    346     phone = schema.TextLine(
    347         title = u'Phone',
    348         description = u'',
    349         required = False,
    350         )
    351     course1 = schema.Choice(
    352         title = u'1st Choice Course of Study',
    353         source = CertificateSource(),
    354         required = True,
    355         )
    356     course2 = schema.Choice(
    357         title = u'2nd Choice Course of Study',
    358         source = CertificateSource(),
    359         required = False,
    360         )
    361 
    362     #
    363     # Process Data
    364     #
    365     screening_score = schema.Int(
    366         title = u'Screening Score',
    367         required = False,
    368         )
    369     screening_venue = schema.TextLine(
    370         title = u'Screening Venue',
    371         required = False,
    372         )
    373     course_admitted = schema.Choice(
    374         title = u'Admitted Course of Study',
    375         source = CertificateSource(),
    376         default = None,
    377         required = False,
    378         )
    379     notice = schema.Text(
    380         title = u'Notice',
    381         required = False,
    382         )
    383395    student_id = schema.TextLine(
    384396        title = u'Student Id',
     
    391403        )
    392404
    393 class IApplicant(IApplicantBaseData):
     405class IApplicant(IApplicantProcessData):
    394406    """An applicant.
    395407
     
    399411    """
    400412
    401 class IApplicantEdit(IApplicantBaseData):
     413class IApplicantEdit(IApplicantProcessData):
    402414    """An applicant.
    403415
     
    443455        readonly = True,
    444456        )
     457
     458    def createStudent():
     459        """Create a student object from applicatnt data
     460        and copy applicant object.
     461        """
    445462
    446463class IApplicantUpdateByRegNo(IApplicant):
Note: See TracChangeset for help on using the changeset viewer.