Changeset 6622


Ignore:
Timestamp:
24 Aug 2011, 20:25:44 (13 years ago)
Author:
Henrik Bettermann
Message:

Add some basic UI stuff to start and to play with.

Location:
main/waeup.sirp/trunk/src/waeup/sirp
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/README.txt

    r6621 r6622  
    3333  >>> u['students']
    3434  <waeup.sirp.students.container.StudentsContainer object at 0x...>
    35 
    36   >>> u['hostels']
    37   <waeup.sirp.hostel.hostelcontainer.HostelContainer object at 0x...>
    3835
    3936We can export universities. For this we lookup an appropriate exporter
  • main/waeup.sirp/trunk/src/waeup/sirp/applicants/browser.py

    r6598 r6622  
    458458
    459459class ApplicantAddFormPage(WAeUPAddFormPage):
    460     """Add-form to add certificate to a department.
     460    """Add-form to add an applicant.
    461461    """
    462462    grok.context(IApplicantsContainer)
  • main/waeup.sirp/trunk/src/waeup/sirp/permissions.py

    r6202 r6622  
    4040    grok.name('waeup.viewStudents')
    4141
     42class ManageStudents(grok.Permission):
     43    grok.name('waeup.manageStudents')
     44
    4245# Local Roles
    4346class DepartmentOfficer(grok.Role):
     
    5861                     'waeup.View', 'waeup.Public','waeup.manageACBatches',
    5962                     'waeup.manageDataCenter','waeup.managePortalSettings',
    60                      'waeup.manageApplications', 'waeup.handleApplication')
     63                     'waeup.manageApplications', 'waeup.handleApplication',
     64                     'waeup.viewStudents', 'waeup.manageStudents')
    6165
    6266def getRoles():
  • main/waeup.sirp/trunk/src/waeup/sirp/students/browser.py

    r6621 r6622  
    2424from zope.securitypolicy.interfaces import IPrincipalRoleManager
    2525from zope.traversing.browser import absoluteURL
     26from zope.component import (
     27    createObject,)
    2628
    2729from hurry.workflow.interfaces import IWorkflowInfo, IWorkflowState
     
    6062    MultiListWidget, MultiListDisplayWidget)
    6163from waeup.sirp.students.interfaces import (
    62     IStudentsContainer,
     64    IStudentsContainer, IStudent,
     65    )
     66from waeup.sirp.students.students import (
     67    Student,
    6368    )
    6469
     
    8691    grok.require('waeup.viewStudents')
    8792    grok.template('studentscontainerpage')
    88     pnav = 3
    8993
    90     form_fields = grok.AutoFields(IStudentsContainer).omit('title')
     94    form_fields = grok.AutoFields(IStudentsContainer)
    9195    #form_fields['description'].custom_widget = ReSTDisplayWidget
    9296
     
    98102    def label(self):
    99103        return self.title
     104
     105class StudentssContainerManageActionButton(ManageActionButton):
     106    grok.order(1)
     107    grok.context(IStudentsContainer)
     108    grok.view(StudentsContainerPage)
     109    grok.require('waeup.manageStudents')
     110    text = 'Manage students'
     111
     112class StudentsContainerManagePage(WAeUPDisplayFormPage):
     113    """The standard view for regular student containers.
     114    """
     115    grok.context(IStudentsContainer)
     116    grok.name('manage')
     117    grok.require('waeup.manageStudents')
     118    grok.template('studentscontainerpage')
     119
     120    form_fields = grok.AutoFields(IStudentsContainer)
     121
     122    @property
     123    def title(self):
     124        return "Students"
     125
     126    @property
     127    def label(self):
     128        return self.title
     129
     130    @grok.action('Add student', validator=NullValidator)
     131    def addStudent(self, **data):
     132        self.redirect(self.url(self.context, 'addstudent'))
     133        return
     134
     135class StudentAddFormPage(WAeUPAddFormPage):
     136    """Add-form to add a student.
     137    """
     138    grok.context(IStudentsContainer)
     139    grok.require('waeup.manageStudents')
     140    grok.name('addstudent')
     141    grok.template('studentaddpage')
     142    form_fields = grok.AutoFields(IStudent)
     143    title = 'Students'
     144    label = 'Add student'
     145
     146    @grok.action('Create student record')
     147    def addStudent(self, **data):
     148        student_id = self.request.form.get('form.student_id')
     149        student = createObject(u'waeup.Student')
     150        self.applyData(student, **data)
     151        #import pdb; pdb.set_trace()
     152        try:
     153            self.context[student_id] = student
     154        except KeyError:
     155            self.flash('The student id chosen already exists.')
     156            return
     157        self.redirect(self.url(self.context[student_id], 'index'))
     158        return
     159
     160class DisplayStudent(WAeUPDisplayFormPage):
     161    grok.context(IStudent)
     162    grok.name('index')
     163    grok.require('waeup.viewStudents')
     164    form_fields = grok.AutoFields(IStudent)
     165
     166    @property
     167    def title(self):
     168        return 'Student: %s' % self.context.name
     169
     170    @property
     171    def label(self):
     172        return self.context.name
  • main/waeup.sirp/trunk/src/waeup/sirp/students/browser_templates/studentscontainerpage.pt

    r6621 r6622  
    11<h2 tal:content="view/label">Title</h2>
    22
     3<form method="POST">
    34<table class="zebra" tal:condition="layout/isAuthenticated">
    45  <tbody>
     
    1314      </tr>
    1415    </tal:block>
     16      <tr>
     17        <td>
     18            <div class="actionButtons" tal:condition="view/availableActions">
     19                <span tal:repeat="action view/actions" tal:omit-tag="">
     20                    <input tal:replace="structure action/render"/>
     21                </span>
     22            </div>
     23        </td>
     24      </tr>
    1525  </tbody>
    1626</table>
     27</form>
  • main/waeup.sirp/trunk/src/waeup/sirp/students/interfaces.py

    r6621 r6622  
    88    """Representation of a student.
    99    """
     10    student_id = schema.TextLine(
     11        title = u'Student Id',
     12        default = u'None',
     13        required = True,
     14        )
     15
    1016    name = schema.TextLine(
    1117        title = u'Name of student',
     
    1319        required = True,
    1420        )
     21
    1522
    1623class IStudentsContainer(IWAeUPObject):
  • main/waeup.sirp/trunk/src/waeup/sirp/students/tests/test_browser.py

    r6621 r6622  
    104104        # Anonymous users can't access students containers
    105105        self.assertRaises(
     106            Unauthorized, self.browser.open, self.container_path)
     107        self.assertRaises(
    106108            Unauthorized, self.browser.open, self.manage_container_path)
    107109        return
     
    114116        self.assertEqual(self.browser.headers['Status'], '200 Ok')
    115117        self.assertEqual(self.browser.url, self.container_path)
     118        self.browser.getLink("Manage students").click()
     119        self.assertEqual(self.browser.headers['Status'], '200 Ok')
     120        self.assertEqual(self.browser.url, self.manage_container_path)
    116121        return
     122
     123    def test_add_students(self):
     124        # Managers can add students
     125        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
     126        self.add_student_path = self.container_path + '/addstudent'
     127        self.container_manage_path = self.container_path + '/@@manage'
     128        self.browser.open(self.container_manage_path)
     129        self.browser.getControl("Add student").click()
     130        self.assertEqual(self.browser.headers['Status'], '200 Ok')
     131        self.assertEqual(self.browser.url, self.add_student_path)
     132        self.browser.getControl(name="form.student_id").value = 'A123456'
     133        self.browser.getControl(name="form.name").value = 'Bob Tester'
     134        self.browser.getControl("Create student record").click()
Note: See TracChangeset for help on using the changeset viewer.