Ignore:
Timestamp:
13 Feb 2011, 12:20:24 (14 years ago)
Author:
uli
Message:

Move more interfaces, disable two views and make tests work again.

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

Legend:

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

    r5753 r5758  
    2525import waeup.sirp.browser
    2626from hurry.file import HurryFile
     27from zc.sourcefactory.basic import BasicSourceFactory
    2728from zope import schema
    28 from zc.sourcefactory.basic import BasicSourceFactory
     29from zope.interface import Interface, Attribute
     30from zope.pluggableauth.interfaces import IPrincipalInfo
     31from zope.security.interfaces import IGroupClosureAwarePrincipal as IPrincipal
    2932from waeup.sirp.image.schema import ImageFile
    3033from waeup.sirp.interfaces import IWAeUPObject, SimpleWAeUPVocabulary
     
    688691        required = True,
    689692        )
     693
     694class IApplicantPrincipalInfo(IPrincipalInfo):
     695    """Infos about principals that are applicants.
     696    """
     697    reg_no = Attribute("The JAMB registration no. of the user")
     698
     699    access_code = Attribute("The Access Code the user purchased")
     700
     701class IApplicantPrincipal(IPrincipal):
     702    """A principal that is an applicant.
     703
     704    This interface extends zope.security.interfaces.IPrincipal and
     705    requires also an `id` and other attributes defined there.
     706    """
     707    reg_no = schema.TextLine(
     708        title = u'Registration number',
     709        description = u'The JAMB registration number',
     710        required = True,
     711        readonly = True)
     712
     713    access_code = schema.TextLine(
     714        title = u'Access Code',
     715        description = u'The access code purchased by the user.',
     716        required = True,
     717        readonly = True)
     718
     719class IApplicantsFormChallenger(Interface):
     720    """A challenger that uses a browser form to collect applicant
     721       credentials.
     722    """
     723    loginpagename = schema.TextLine(
     724        title = u'Loginpagename',
     725        description = u"""Name of the login form used by challenger.
     726
     727        The form must provide an ``access_code`` input field.
     728        """)
     729
     730    accesscode_field = schema.TextLine(
     731        title = u'Access code field',
     732        description = u'''Field of the login page which is looked up for
     733                          access_code''',
     734        default = u'access_code',
     735        )
     736
     737class IJAMBApplicantsFormChallenger(IApplicantsFormChallenger):
     738    """A challenger that uses a browser form to collect applicant
     739       credentials for applicants in JAMB process.
     740
     741       JAMB-screened applicants have to provide an extra registration
     742       no. provided by JAMB.
     743    """
     744    jamb_reg_no_field = schema.TextLine(
     745        title = u'JAMB registration no.',
     746        description = u'''Field of the login page which is looked up for
     747                          the JAMB registration number.''',
     748        default = u'jamb_reg_no',
     749        )
     750
     751class IApplicantSessionCredentials(Interface):
     752    """Interface for storing and accessing applicant credentials in a
     753       session.
     754    """
     755
     756    def __init__(access_code):
     757        """Create applicant session credentials."""
     758
     759    def getAccessCode():
     760        """Return the access code."""
     761
     762
     763class IJAMBApplicantSessionCredentials(IApplicantSessionCredentials):
     764    """Interface for storing and accessing JAMB applicant credentials in a
     765       session.
     766    """
     767
     768    def __init__(access_code, jamb_reg_no):
     769        """Create credentials for JAMB screened applicants."""
     770
     771    def getJAMBRegNo():
     772        """Return the JAMB registration no."""
  • main/waeup.sirp/trunk/src/waeup/sirp/applicants/jambtables/browser.py

    r5746 r5758  
    3131from waeup.sirp.interfaces import IWAeUPObject
    3232from waeup.sirp.applicants.jambtables.util import get_applicant_data
    33 from waeup.sirp.applicants.jambtables.interfaces import (
    34     IApplicant, IApplicantContainer, IApplicantPrincipal, IApplicantPDEEditData)
     33from waeup.sirp.applicants.interfaces import (
     34    IApplicant, IApplicantPrincipal, IApplicantPDEEditData)
    3535from waeup.sirp.widgets.passportwidget import (
    3636    PassportWidget, PassportDisplayWidget
     
    3939from zope.formlib.sequencewidget import ListSequenceWidget, SequenceDisplayWidget
    4040from zope.formlib.widget import CustomWidgetFactory
    41 from waeup.sirp.applicants.jambtables.applicants import ResultEntry
     41from waeup.sirp.applicants import ResultEntry
    4242from waeup.sirp.widgets.objectwidget import (
    4343    WAeUPObjectWidget, WAeUPObjectDisplayWidget)
     
    6363    MultiListDisplayWidget, subwidget=results_display_widget)
    6464
    65 class ApplicationsPage(WAeUPPage):
    66     grok.context(IApplicantContainer)
    67     grok.name('index')
    68     title = 'Applications'
    69     pnav = 1
    70    
    71     def getApplications(self):
    72         """Get a list of all stored applications.
    73         """
    74         for key, val in self.context.items():
    75             url = self.url(val)
    76             yield(dict(url=url, name=key))
    77 
    78 class AddApplicant(WAeUPAddFormPage):
    79     grok.context(IApplicantContainer)
    80     grok.name('add')
    81     form_fields = grok.AutoFields(IApplicant)
    82     form_fields['fst_sit_results'].custom_widget = list_results_widget
    83     form_fields['passport'].custom_widget = EncodingImageFileWidget
    84     label = 'Add Applicant'
    85     title = 'Add Applicant'
    86     pnav = 1
    87 
    88     @grok.action('Add applicant')
    89     def addApplicant(self, **data):
    90         from waeup.sirp.jambtables.applicants import Applicant
    91         applicant = Applicant()
    92         self.applyData(applicant, **data)
    93         # XXX: temporarily disabled.
    94         #self.context[applicant.reg_no] = applicant
    95         try:
    96             self.context[applicant.access_code] = applicant
    97         except KeyError:
    98             self.flash('The given access code is already in use!')
    99             return
    100         self.redirect(self.url(self.context))
     65#class ApplicationsPage(WAeUPPage):
     66#    grok.context(IApplicantContainer)
     67#    grok.name('index')
     68#    title = 'Applications'
     69#    pnav = 1
     70#   
     71#    def getApplications(self):
     72#        """Get a list of all stored applications.
     73#        """
     74#        for key, val in self.context.items():
     75#            url = self.url(val)
     76#            yield(dict(url=url, name=key))
     77
     78#class AddApplicant(WAeUPAddFormPage):
     79#    grok.context(IApplicantContainer)
     80#    grok.name('add')
     81#    form_fields = grok.AutoFields(IApplicant)
     82#    form_fields['fst_sit_results'].custom_widget = list_results_widget
     83#    form_fields['passport'].custom_widget = EncodingImageFileWidget
     84#    label = 'Add Applicant'
     85#    title = 'Add Applicant'
     86#    pnav = 1
     87#
     88#    @grok.action('Add applicant')
     89#    def addApplicant(self, **data):
     90#        from waeup.sirp.jambtables.applicants import Applicant
     91#        applicant = Applicant()
     92#        self.applyData(applicant, **data)
     93#        # XXX: temporarily disabled.
     94#        #self.context[applicant.reg_no] = applicant
     95#        try:
     96#            self.context[applicant.access_code] = applicant
     97#        except KeyError:
     98#            self.flash('The given access code is already in use!')
     99#            return
     100#        self.redirect(self.url(self.context))
    101101
    102102class DisplayApplicant(WAeUPDisplayFormPage):
  • main/waeup.sirp/trunk/src/waeup/sirp/applicants/jambtables/interfaces.py

    r5757 r5758  
    3939    """A container that holds JAMB data tables.
    4040    """
    41        
    4241
    4342class IApplicantPDEImportData(IApplicantBaseData):
Note: See TracChangeset for help on using the changeset viewer.