Ignore:
Timestamp:
26 Aug 2011, 08:00:10 (13 years ago)
Author:
Henrik Bettermann
Message:

Add interfaces for clearance and personal data.
Add display and manage views.

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

    r6629 r6631  
    4545from waeup.sirp.browser.resources import datepicker, tabs, datatable
    4646from waeup.sirp.browser.viewlets import (
    47     ManageActionButton, PrimaryNavTab, LeftSidebarLink, AddActionButton,
     47    ManageActionButton, PrimaryNavTab, LeftSidebarLink,
     48    AddActionButton, ActionButton,
    4849    )
    4950from waeup.sirp.image.browser.widget import (
     
    6263    MultiListWidget, MultiListDisplayWidget)
    6364from waeup.sirp.students.interfaces import (
    64     IStudentsContainer, IStudent,
     65    IStudentsContainer, IStudent, IStudentClearance,
     66    IStudentPersonal, IStudentBase
    6567    )
    6668from waeup.sirp.students.students import (
     
    220222        return
    221223
    222 class DisplayStudent(WAeUPDisplayFormPage):
     224class StudentBaseDisplayFormPage(WAeUPDisplayFormPage):
     225    """ Page to display student base data
     226    """
    223227    grok.context(IStudent)
    224228    grok.name('index')
    225229    grok.require('waeup.viewStudents')
    226     form_fields = grok.AutoFields(IStudent)
    227 
    228     @property
    229     def title(self):
    230         return 'Student: %s' % self.context.name
    231 
    232     @property
    233     def label(self):
    234         return self.context.name
     230    form_fields = grok.AutoFields(IStudentBase)
     231
     232    @property
     233    def title(self):
     234        return 'Student: %s' % self.context.name
     235
     236    @property
     237    def label(self):
     238        return '%s: Base Data' % self.context.name
     239
     240class StudentBaseManageActionButton(ManageActionButton):
     241    grok.order(1)
     242    grok.context(IStudent)
     243    grok.view(StudentBaseDisplayFormPage)
     244    grok.require('waeup.manageStudents')
     245    text = 'Edit base data'
     246    target = 'edit_base'
     247
     248class StudentClearanceViewActionButton(ActionButton):
     249    grok.order(2)
     250    icon = 'actionicon_view.png'
     251    grok.context(IStudent)
     252    grok.view(StudentBaseDisplayFormPage)
     253    grok.require('waeup.viewStudents')
     254    text = 'View clearance data'
     255    target = 'view_clearance'
     256
     257class StudentPersonalViewActionButton(ActionButton):
     258    grok.order(3)
     259    icon = 'actionicon_view.png'
     260    grok.context(IStudent)
     261    grok.view(StudentBaseDisplayFormPage)
     262    grok.require('waeup.viewStudents')
     263    text = 'View personal data'
     264    target = 'view_personal'
     265
     266class StudentBaseManageFormPage(WAeUPEditFormPage):
     267    """ View to edit student base data
     268    """
     269    grok.context(IStudent)
     270    grok.name('edit_base')
     271    grok.require('waeup.manageStudents')
     272    form_fields = grok.AutoFields(IStudentBase).omit('student_id')
     273    #grok.template('editstudentbase')
     274    label = 'Edit base data'
     275
     276    @property
     277    def title(self):
     278        return 'Student: %s' % self.context.name
     279
     280class StudentClearanceDisplayFormPage(WAeUPDisplayFormPage):
     281    """ Page to display student clearance data
     282    """
     283    grok.context(IStudent)
     284    grok.name('view_clearance')
     285    grok.require('waeup.viewStudents')
     286    form_fields = grok.AutoFields(IStudentClearance)
     287
     288    @property
     289    def title(self):
     290        return 'Student: %s' % self.context.name
     291
     292    @property
     293    def label(self):
     294        return '%s: Clearance Data' % self.context.name
     295
     296class StudentClearanceManageActionButton(ManageActionButton):
     297    grok.order(1)
     298    grok.context(IStudent)
     299    grok.view(StudentClearanceDisplayFormPage)
     300    grok.require('waeup.manageStudents')
     301    text = 'Edit clearance data'
     302    target = 'edit_clearance'
     303
     304class StudentClearanceManageFormPage(WAeUPEditFormPage):
     305    """ Page to edit student clearance data
     306    """
     307    grok.context(IStudent)
     308    grok.name('edit_clearance')
     309    grok.require('waeup.viewStudents')
     310    form_fields = grok.AutoFields(IStudentClearance)
     311    label = 'Edit clearance data'
     312
     313    @property
     314    def title(self):
     315        return 'Student: %s' % self.context.name
     316
     317class StudentPersonalDisplayFormPage(WAeUPDisplayFormPage):
     318    """ Page to display student personal data
     319    """
     320    grok.context(IStudent)
     321    grok.name('view_personal')
     322    grok.require('waeup.viewStudents')
     323    form_fields = grok.AutoFields(IStudentPersonal)
     324
     325    @property
     326    def title(self):
     327        return 'Student: %s' % self.context.name
     328
     329    @property
     330    def label(self):
     331        return '%s: Personal Data' % self.context.name
     332
     333class StudentPersonalManageActionButton(ManageActionButton):
     334    grok.order(1)
     335    grok.context(IStudent)
     336    grok.view(StudentPersonalDisplayFormPage)
     337    grok.require('waeup.manageStudents')
     338    text = 'Edit personal data'
     339    target = 'edit_personal'
     340
     341class StudentPersonalManageFormPage(WAeUPEditFormPage):
     342    """ Page to edit student clearance data
     343    """
     344    grok.context(IStudent)
     345    grok.name('edit_personal')
     346    grok.require('waeup.viewStudents')
     347    form_fields = grok.AutoFields(IStudentPersonal)
     348    label = 'Edit personal data'
     349
     350    @property
     351    def title(self):
     352        return 'Student: %s' % self.context.name
  • main/waeup.sirp/trunk/src/waeup/sirp/students/browser_templates/studentaddpage.pt

    r6622 r6631  
    99        <td><label for="form.student_id">Student Id:</label></td>
    1010        <td>
    11          <input name="form.student_id" type="text" size="10" maxlength="10"
     11         <input name="form.student_id" type="text" size="7" maxlength="7"
    1212                value="" />
    1313        </td>
    1414      </tr>
    1515      <tr>
    16         <td><label for="form.name">Name:</label></td>
     16        <td><label for="form.name">Full Name:</label></td>
    1717        <td>
    18          <input name="form.name" type="text" size="10" maxlength="10"
     18         <input name="form.name" type="text" size="30" maxlength="30"
    1919                value="" />
    2020        </td>
  • main/waeup.sirp/trunk/src/waeup/sirp/students/browser_templates/studentscontainermanagepage.pt

    r6626 r6631  
    3131        <tr tal:repeat="item view/hitlist">
    3232          <td><input type="checkbox" name="entries"
    33                      tal:attributes="value item/student_id" /></td>
    34           <td tal:content="item/student_id">A123456</td>
     33                     tal:attributes="value item/context/__name__" /></td>
     34          <td> <a tal:attributes="href item/url">
     35          <span tal:content="item/student_id">A123456</span></a>
     36        </td>
    3537          <td tal:content="item/name">Bob</td>
    3638        </tr>
  • main/waeup.sirp/trunk/src/waeup/sirp/students/browser_templates/studentscontainerpage.pt

    r6630 r6631  
    2929      <tbody>
    3030        <tr tal:repeat="item view/hitlist">
    31           <td tal:content="item/student_id">A123456</td>
     31          <td> <a tal:attributes="href item/url">
     32          <span tal:content="item/student_id">A123456</span></a>
     33        </td>
    3234          <td tal:content="item/name">Bob</td>
    3335        </tr>
  • main/waeup.sirp/trunk/src/waeup/sirp/students/interfaces.py

    r6622 r6631  
    55from waeup.sirp.interfaces import IWAeUPObject
    66
    7 class IStudent(IWAeUPObject):
    8     """Representation of a student.
     7class IStudentBase(IWAeUPObject):
     8    """Representation of student base data.
    99    """
    1010    student_id = schema.TextLine(
     
    1515
    1616    name = schema.TextLine(
    17         title = u'Name of student',
     17        title = u'Full Name',
    1818        default = u'Nobody',
    1919        required = True,
    2020        )
    2121
     22class IStudentClearance(IWAeUPObject):
     23    """Representation of student clearance data.
     24    """
     25
     26    date_of_birth = schema.Date(
     27        title = u'Date of Birth',
     28        required = True,
     29        )
     30
     31class IStudentPersonal(IWAeUPObject):
     32    """Representation of student personal data.
     33    """
     34
     35    perm_address = schema.Date(
     36        title = u'Permanent Address',
     37        required = False,
     38        )
     39
     40class IStudent(IStudentBase,IStudentClearance,IStudentPersonal):
     41    """Representation of a student.
     42    """
    2243
    2344class IStudentsContainer(IWAeUPObject):
  • main/waeup.sirp/trunk/src/waeup/sirp/students/tests/test_browser.py

    r6626 r6631  
    7171        setSite(app)
    7272
     73
     74        # Add student
     75        student = Student()
     76        student.name = u'Anna Tester'
     77        student.student_id = u'Z654321'
     78        self.app['students'][student.student_id] = student
     79
    7380        self.container_path = 'http://localhost/app/students'
    7481        self.manage_container_path = self.container_path + '/@@manage'
    7582        self.add_student_path = self.container_path + '/addstudent'
     83        self.student_path = self.container_path + '/Z654321'
     84        self.manage_student_path = self.student_path + '/edit_base'
     85        self.clearance_student_path = self.student_path + '/view_clearance'
     86        self.personal_student_path = self.student_path + '/view_personal'
     87        self.edit_clearance_student_path = self.student_path + '/edit_clearance'
     88        self.edit_personal_student_path = self.student_path + '/edit_personal'
    7689
    7790        # Populate university
     
    166179        self.assertTrue('No student found' in self.browser.contents)
    167180
     181class StudentUITests(StudentsFullSetup):
     182    # Tests for Student class views and pages
     183
     184    layer = FunctionalLayer
     185
     186    def test_manage_access(self):
     187        # Managers can access the pages of students
     188        # and can perform actions
     189        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
     190        self.browser.open(self.student_path)
     191        self.assertEqual(self.browser.headers['Status'], '200 Ok')
     192        self.assertEqual(self.browser.url, self.student_path)
     193        self.browser.getLink("Edit base data").click()
     194        self.assertEqual(self.browser.headers['Status'], '200 Ok')
     195        self.assertEqual(self.browser.url, self.manage_student_path)
     196        self.browser.open(self.student_path)
     197        self.browser.getLink("View clearance data").click()
     198        self.assertEqual(self.browser.headers['Status'], '200 Ok')
     199        self.assertEqual(self.browser.url, self.clearance_student_path)
     200        self.browser.getLink("Edit clearance data").click()
     201        self.assertEqual(self.browser.headers['Status'], '200 Ok')
     202        self.assertEqual(self.browser.url, self.edit_clearance_student_path)
     203        self.browser.open(self.student_path)
     204        self.browser.getLink("View personal data").click()
     205        self.assertEqual(self.browser.headers['Status'], '200 Ok')
     206        self.assertEqual(self.browser.url, self.personal_student_path)
     207        self.browser.getLink("Edit personal data").click()
     208        self.assertEqual(self.browser.headers['Status'], '200 Ok')
     209        self.assertEqual(self.browser.url, self.edit_personal_student_path)
     210        return
Note: See TracChangeset for help on using the changeset viewer.