Changeset 7795


Ignore:
Timestamp:
8 Mar 2012, 03:30:30 (13 years ago)
Author:
uli
Message:

Merge changes from ulif-schoolgrades back into trunk.

Location:
main/waeup.sirp/trunk
Files:
7 edited
4 copied

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk

  • main/waeup.sirp/trunk/src/waeup/sirp/applicants/interfaces.py

    r7708 r7795  
    1818"""Interfaces of the university application package.
    1919"""
    20 
    2120from grokcore.content.interfaces import IContainer
    22 
     21from zc.sourcefactory.basic import BasicSourceFactory
     22from zc.sourcefactory.contextual import BasicContextualSourceFactory
    2323from zope import schema
    24 from zope.interface import Interface, Attribute, implements, directlyProvides
    2524from zope.component import getUtilitiesFor, queryUtility, getUtility
    2625from zope.catalog.interfaces import ICatalog
     26from zope.interface import Interface, Attribute, implements, directlyProvides
    2727from zope.schema.interfaces import (
    2828    ValidationError, ISource, IContextSourceBinder)
    29 from zc.sourcefactory.basic import BasicSourceFactory
    30 from zc.sourcefactory.contextual import BasicContextualSourceFactory
    3129from waeup.sirp.schema import TextLineChoice
    3230from waeup.sirp.interfaces import (
    3331    ISIRPObject, year_range, validate_email, academic_sessions_vocab)
    3432from waeup.sirp.interfaces import MessageFactory as _
     33from waeup.sirp.payments.interfaces import IOnlinePayment
     34from waeup.sirp.schoolgrades import ResultEntryField
     35from waeup.sirp.students.vocabularies import (
     36    lgas_vocab, CertificateSource, GenderSource)
    3537from waeup.sirp.university.vocabularies import (
    3638    course_levels, AppCatSource)
    37 from waeup.sirp.students.vocabularies import (
    38     lgas_vocab, CertificateSource, GenderSource)
    39 from waeup.sirp.payments.interfaces import IOnlinePayment
    4039
    4140#: Maximum upload size for applicant passport photographs (in bytes)
     
    7776    return source
    7877directlyProvides(contextual_reg_num_source, IContextSourceBinder)
     78
    7979
    8080class AppCatCertificateSource(CertificateSource):
     
    360360    state, depending on use-case.
    361361
    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 
     362    This base interface is also implemented by the
     363    :class:`waeup.sirp.students.StudentApplication` class in the
     364    students package. Thus, these are the data which are saved after
     365    admission.
     366    """
    367367    applicant_id = schema.TextLine(
    368368        title = _(u'Applicant Id'),
     
    430430        required = False,
    431431        )
     432    school_grades = schema.List(
     433        title = _(u'School Grades'),
     434        value_type = ResultEntryField(),
     435        required = True,
     436        default = [],
     437        )
    432438
    433439    #
  • main/waeup.sirp/trunk/src/waeup/sirp/applicants/tests/test_browser.py

    r7685 r7795  
    752752        self.browser.open(self.edit_path)
    753753        self.assertTrue(
    754             '<option selected="selected" value="CERT1">' in self.browser.contents)
     754            '<option selected="selected" value="CERT1">'
     755            in self.browser.contents)
     756
     757    def test_school_grades(self):
     758        # we can add school grades
     759        self.login()
     760        self.browser.open(self.edit_path)
     761        self.fill_correct_values() # Fill other fields
     762        # add a new (empty) row with subject/grade
     763        self.browser.getControl(name="form.school_grades.add").click()
     764        # pick first subject (after <no value>)...
     765        ctrl_subj = self.browser.getControl(
     766            name="form.school_grades.0.subject")
     767        ctrl_subj.value = [ctrl_subj.options[1]]
     768        display_subj = ctrl_subj.displayOptions[1]
     769        # pick first grade (after <no value>)...
     770        ctrl_grade = self.browser.getControl(
     771            name="form.school_grades.0.grade")
     772        ctrl_grade.value = [ctrl_grade.options[1]]
     773        display_grade = ctrl_grade.displayOptions[1]
     774        # save everything
     775        self.browser.getControl("Save").click()
     776        self.assertTrue(
     777            '<input type="hidden" name="form.school_grades.count" value="1" />'
     778            in self.browser.contents)
     779        # we can also see the new subject/grade in display view
     780        self.browser.open(self.view_path)
     781        self.assertTrue(
     782            display_subj in self.browser.contents)
     783        self.assertTrue(
     784            display_grade in self.browser.contents)
     785        return
    755786
    756787class ApplicantRegisterTests(ApplicantsFullSetup):
  • main/waeup.sirp/trunk/src/waeup/sirp/interfaces.py

    r7730 r7795  
    3131from zope.container.interfaces import INameChooser
    3232from zope.interface import Interface, Attribute, implements
     33from zope.schema.interfaces import IObject
    3334from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm
    3435
     
    7980    )
    8081
     82SUBJECTS = dict(math=_(u'Math'),
     83                bio=_(u'Biology'),
     84                eng=_(u'English'),
     85                )
     86class SubjectSource(BasicSourceFactory):
     87    def getValues(self):
     88        return sorted(SUBJECTS.keys())
     89    def getTitle(self, value):
     90        return SUBJECTS.get(value, None)
     91
     92GRADES = {'A':_(u'Very Good'),
     93          'B':_(u'Good'),
     94          'C':_(u'Satisfactory'),
     95          'D':_(u'Sufficient'),
     96          'E':_(u'Fail'),
     97          }
     98class GradeSource(BasicSourceFactory):
     99    def getValues(self):
     100        return sorted(GRADES.keys())
     101    def getTitle(self, value):
     102        return GRADES.get(value, None)
     103
    81104# Define a valiation method for email addresses
    82105class NotAnEmailAddress(schema.ValidationError):
     
    145168        return value
    146169
     170class IResultEntry(Interface):
     171    """A school grade entry.
     172    """
     173    subject = schema.Choice(
     174        title = _(u'Subject'),
     175        source = SubjectSource(),
     176        )
     177    grade = schema.Choice(
     178        title = _(u'Grade'),
     179        source = GradeSource(),
     180        )
     181
     182class IResultEntryField(IObject):
     183    """A zope.schema-like field for usage in interfaces.
     184
     185    Marker interface to distuingish result entries from ordinary
     186    object fields. Needed for registration of widgets.
     187    """
     188
    147189class ISIRPUtils(Interface):
    148190    """A collection of methods which are subject to customization.
     
    9701012        required = True,
    9711013        )
    972 
  • main/waeup.sirp/trunk/src/waeup/sirp/widgets/objectwidget.pt

    r5328 r7795  
    1   <td class="row" tal:repeat="widget context/subwidgets">
    2     <span tal:define="error widget/error"
    3           tal:replace="structure error" tal:condition="error" />
    4     <span tal:replace="structure widget" />
    5   </td>
     1  <div class="row">
     2    <span tal:repeat="widget context/subwidgets">
     3      <span tal:define="error widget/error"
     4            tal:replace="structure error" tal:condition="error" />
     5      <span tal:replace="structure widget" />
     6    </span>
     7  </div>
  • main/waeup.sirp/trunk/src/waeup/sirp/widgets/objectwidget.py

    r7321 r7795  
    6060        return SIRPObjectWidgetView(self, request)
    6161
     62
    6263class SIRPObjectDisplayWidget(SIRPObjectWidget):
    6364
  • main/waeup.sirp/trunk/src/waeup/sirp/widgets/tests/test_objectwidget.py

    r7501 r7795  
    2121import unittest
    2222import sys
    23 from zope.component import testing
    2423from zope.interface import Interface, implements
    2524from zope.interface.verify import verifyClass
     
    4544    name = TextLine()
    4645    email = TextLine()
    47    
     46
    4847class TestContact(object):
    4948    implements(ITestContact)
     
    5150class ITestContent(Interface):
    5251    foo = Object(
    53         ITestContact, 
     52        ITestContact,
    5453        title = u'Foo Title',
    5554        description = u'',
    5655        )
    57    
     56
    5857class ObjectWidgetInputErrorView(object):
    5958    implements(IWidgetInputErrorView)
     
    8281        provideAdapter(TextWidget, (ITextLine, IDefaultBrowserLayer),
    8382                       IInputWidget)
    84        
     83
    8584        class TestObject(object):
    8685            implements(ITestContent)
     
    120119        error_html = widget.error()
    121120        if sys.version_info < (2, 5):
    122             self.assertTrue("email: <zope.formlib.interfaces.Mis" 
     121            self.assertTrue("email: <zope.formlib.interfaces.Mis"
    123122                             in error_html)
    124123            self.assertTrue("name: <zope.formlib.interfaces.Miss"
     
    161160        widget1, widget2 = widget.subwidgets()
    162161        self.assertTrue(widget1 is name_widget)
    163        
    164        
     162
     163
    165164class ObjectDisplayWidgetTest(BrowserWidgetTest):
    166165    """Documents and tests the display variant of object widget.
     
    184183        # adapter that can turn nearly any object into an ITraversable.
    185184        provideAdapter(DefaultTraversable, (None,), ITraversable)
    186        
     185
    187186        class TestObject(object):
    188187            implements(ITestContent)
     
    206205                       IDisplayWidget)
    207206
    208        
     207
    209208    def test_interfaces(self):
    210         from zope.interface.verify import DoesNotImplement
    211209        self.assertTrue(IDisplayWidget.providedBy(self._widget))
    212210        self.assertFalse(IInputWidget.providedBy(self._widget))
     
    219217
    220218        check_list = [
    221             '<td', 'class=', 'row',
     219            '<div', 'class=', 'row',
     220            '<span',
    222221            'Foo Name',
    223             '</td>', '<td', 'class=', 'row',
     222            '</span>', '<span',
    224223            'foo@foo.test',
    225             '</td>']
    226         self.verifyResult(widget(), check_list, inorder=True)   
     224            '</div>']
     225        self.verifyResult(widget(), check_list, inorder=True)
    227226
    228227def test_suite():
Note: See TracChangeset for help on using the changeset viewer.