Ignore:
Timestamp:
30 Nov 2011, 23:13:26 (13 years ago)
Author:
Henrik Bettermann
Message:

Rebuild applicants package (1st part). Applicants now have an applicant_id and a password and can use the regular login page to enter the portal.

Add user_type attribute to SIRPPrincipal objects.

Add some permissions in students package.

Some tests are still missing and will be re-added soon.

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

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/students/authentication.py

    r7233 r7240  
    6060
    6161    @property
     62    def user_type(self):
     63        return u'student'
     64
     65    @property
    6266    def description(self):
    6367        return self.title
     
    126130            return None
    127131        account = self.getAccount(credentials['login'])
    128 
    129132        if account is None:
    130133            return None
     
    135138                             description=account.description,
    136139                             email=account.email,
    137                              phone=account.phone)
     140                             phone=account.phone,
     141                             user_type=account.user_type)
    138142
    139143    def principalInfo(self, id):
     
    266270    """
    267271    grok.implements(IAuthPluginUtility)
     272    grok.name('students_auth_setup')
    268273
    269274    def register(self, pau):
  • main/waeup.sirp/trunk/src/waeup/sirp/students/browser.py

    r7234 r7240  
    161161    grok.context(IStudentsContainer)
    162162    grok.name('index')
    163     grok.require('waeup.viewStudents')
     163    grok.require('waeup.viewStudentsContainer')
    164164    grok.template('containerpage')
    165165    label = 'Student Section'
     
    381381            email_from = self.config.email_admin
    382382        username = self.request.principal.id
     383        usertype = self.request.principal.user_type.title()
    383384        body = data['body']
    384385        #subject = u'Mail from SIRP'
    385386        subject = data['subject']
    386387        email_to = self.context.email
    387         success = send_mail(fullname,username,self.config.name,
     388        success = send_mail(fullname,username,usertype,self.config.name,
    388389                  body,email_from,email_to,subject)
    389390        if success:
     
    12711272        return
    12721273
    1273     @property
    1274     def is_student(self):
    1275         prm = get_principal_role_manager()
    1276         roles = [x[0] for x in prm.getRolesForPrincipal(self.request.principal.id)]
    1277         return 'waeup.Student' in roles
    1278 
    12791274    @grok.action('Remove selected')
    12801275    def delBedTickets(self, **data):
    1281         if self.is_student:
     1276        if getattr(self.request.principal, 'user_type', None) == 'student':
    12821277            self.flash('You are not allowed to remove bed tickets.')
    12831278            self.redirect(self.url(self.context))
     
    13051300    def selected_actions(self):
    13061301        sa = self.actions
    1307         if self.is_student:
     1302        if getattr(self.request.principal, 'user_type', None) == 'student':
    13081303            sa = [action for action in self.actions
    13091304                  if not action.label in self.officers_only_actions]
  • main/waeup.sirp/trunk/src/waeup/sirp/students/browser_templates/accommodationmanagepage.pt

    r7017 r7240  
    1818    <thead>
    1919    <tr>
    20       <th tal:condition="not: view/is_student">&nbsp;</th>
     20      <th tal:condition="not: layout/isStudent">&nbsp;</th>
    2121      <th>Session</th>
    2222      <th>Booking Date</th>
     
    2727    <tbody>
    2828      <tr tal:repeat="cl context/values">
    29          <td tal:condition="not: view/is_student">
     29         <td tal:condition="not: layout/isStudent">
    3030          <input type="checkbox"
    3131                 name="val_id"
  • main/waeup.sirp/trunk/src/waeup/sirp/students/interfaces.py

    r7221 r7240  
    123123
    124124    student_id = schema.TextLine(
    125         title = u'Student ID',
     125        title = u'Student Id',
    126126        required = False,
    127127        )
  • main/waeup.sirp/trunk/src/waeup/sirp/students/permissions.py

    r7201 r7240  
    2929    grok.name('waeup.viewStudent')
    3030
    31 class ViewStudents(grok.Permission):
    32     grok.name('waeup.viewStudents')
     31class ViewStudentsTab(grok.Permission):
     32    grok.name('waeup.viewStudentsTab')
     33
     34class ViewMyStudentDataTab(grok.Permission):
     35    grok.name('waeup.viewMyStudentDataTab')
     36
     37class ViewStudentsContainer(grok.Permission):
     38    grok.name('waeup.viewStudentsContainer')
    3339
    3440class PayStudent(grok.Permission):
     
    5864class StudentRole(grok.Role):
    5965    grok.name('waeup.Student')
    60     grok.permissions('waeup.viewAcademics')
     66    grok.permissions('waeup.viewAcademics', 'waeup.viewMyStudentDataTab')
    6167
    6268class StudentsOfficer(grok.Role):
    6369    grok.name('waeup.StudentsOfficer')
    6470    grok.title(u'Students Officer (view only)')
    65     grok.permissions('waeup.viewStudent','waeup.viewStudents')
     71    grok.permissions('waeup.viewStudent','waeup.viewStudents',
     72          'waeup.viewStudentsTab', 'waeup.viewStudentsContainer')
    6673
    6774class StudentsManager(grok.Role):
  • main/waeup.sirp/trunk/src/waeup/sirp/students/tests/test_browser.py

    r7218 r7240  
    693693        self.browser.getControl(name="form.password").value = 'mrclearsecret'
    694694        self.browser.getControl("Login").click()
    695         self.assertTrue('You logged in' in self.browser.contents)
     695        self.assertMatches('...You logged in...', self.browser.contents)
    696696        # CO can see his roles
    697697        self.browser.getLink("My Roles").click()
  • main/waeup.sirp/trunk/src/waeup/sirp/students/viewlets.py

    r7191 r7240  
    163163    grok.context(IWAeUPObject)
    164164    grok.order(4)
    165     grok.require('waeup.viewStudents')
     165    grok.require('waeup.viewStudentsTab')
    166166    grok.template('primarynavtab')
    167167
     
    200200        return ''
    201201
    202 #class HomeTab(PrimaryStudentNavTab):
    203 #    """Home-tab in primary navigation.
    204 #    """
    205 #    grok.order(1)
    206 #    grok.require('waeup.Authenticated')
    207 #    pnav = 0
    208 #    tab_title = u'Home'
    209 
    210 #class ProspectusTab(PrimaryStudentNavTab):
    211 #    """Faculties-tab in primary navigation.
    212 #    """
    213 #    grok.order(2)
    214 #    grok.require('waeup.viewAcademics')
    215 #    pnav = 1
    216 #    tab_title = u'Prospectus'
    217 
    218 #    @property
    219 #    def link_target(self):
    220 #        return self.view.application_url('faculties')
    221 
    222 class MyDataTab(PrimaryStudentNavTab):
     202class MyStudentDataTab(PrimaryStudentNavTab):
    223203    """MyData-tab in primary navigation.
    224204    """
    225205    grok.order(3)
    226     grok.require('waeup.Authenticated')
     206    grok.require('waeup.viewMyStudentDataTab')
    227207    pnav = 4
    228208    tab_title = u'My Data'
Note: See TracChangeset for help on using the changeset viewer.