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/browser
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/browser/layout.py

    r7195 r7240  
    3232from waeup.sirp.browser.theming import get_all_themes, WAeUPThemeGray1
    3333from waeup.sirp.students.interfaces import IStudentNavigation
     34from waeup.sirp.applicants.interfaces import IApplicant
    3435from waeup.sirp.authentication import get_principal_role_manager
    3536
     
    163164        if usertitle == 'Unauthenticated User':
    164165            return u'Anonymous User'
    165         elif usertitle == 'Applicant':
    166             return self.request.principal.id
    167166        return usertitle
    168167
     
    172171        userid = self.request.principal.id
    173172        return userid
     173
     174    def isStudent(self):
     175        usertype = getattr(self.request.principal, 'user_type', None)
     176        if not usertype:
     177            return False
     178        return self.request.principal.user_type == 'student'
     179
     180    def isApplicant(self):
     181        usertype = getattr(self.request.principal, 'user_type', None)
     182        if not usertype:
     183            return False
     184        return self.request.principal.user_type == 'applicant'
    174185
    175186    def getStudentName(self):
     
    180191        return
    181192
    182     def isStudent(self):
    183         prm = get_principal_role_manager()
    184         roles = [x[0] for x in
    185             prm.getRolesForPrincipal(self.request.principal.id)]
    186         return 'waeup.Student' in roles
     193    def getApplicantName(self):
     194        """Return the applicant name.
     195        """
     196        if IApplicant.providedBy(self.context):
     197            return self.context.fullname
     198        return
    187199
    188200    def update(self):
     
    209221
    210222    def render(self):
    211         if self.isStudent() or not self.isAuthenticated():
     223        if self.isStudent() or self.isApplicant() or not self.isAuthenticated():
    212224            return self.studenttemp.render(self)
    213225        return self.stafftemp.render(self)
  • main/waeup.sirp/trunk/src/waeup/sirp/browser/pages.py

    r7234 r7240  
    150150    camefrom = None
    151151
    152     def isStudent(self):
    153         prm = get_principal_role_manager()
    154         roles = [x[0] for x in prm.getRolesForPrincipal(self.request.principal.id)]
    155         return 'waeup.Student' in roles
    156 
    157152    def update(self, SUBMIT=None, camefrom=None):
    158153        self.camefrom = camefrom
     
    160155            if self.request.principal.id != 'zope.anybody':
    161156                self.flash('You logged in.')
    162                 if self.isStudent():
     157                if self.request.principal.user_type == 'student':
    163158                    rel_link = '/students/%s' % self.request.principal.id
     159                    self.redirect(self.application_url() + rel_link)
     160                    return
     161                elif self.request.principal.user_type == 'applicant':
     162                    container, application_number = self.request.principal.id.split('_')
     163                    rel_link = '/applicants/%s/%s' % (
     164                        container, application_number)
    164165                    self.redirect(self.application_url() + rel_link)
    165166                    return
     
    222223            email_from = self.config.email_admin
    223224        username = self.request.principal.id
     225        usertype = getattr(self.request.principal,
     226                           'user_type', 'system').title()
    224227        body = data['body']
    225228        email_to = self.config.email_admin
    226229        subject = self.config.email_subject
    227         success = send_mail(fullname,username,self.config.name,
     230        success = send_mail(fullname,username,usertype,self.config.name,
    228231                  body,email_from,email_to,subject)
    229232        if success:
     
    248251        email_to = self.config.email_admin
    249252        subject = self.config.email_subject
    250         success = send_mail(fullname,username,self.config.name,
     253        usertype = u'Anonymous'
     254        success = send_mail(fullname,username,usertype,self.config.name,
    251255                  body,email_from,email_to,subject)
    252256        if success:
     
    467471            email_from = self.config.email_admin
    468472        username = self.request.principal.id
     473        usertype = getattr(self.request.principal,
     474                           'user_type', 'system').title()
    469475        body = data['body']
    470476        email_to = self.context.email
    471477        subject = self.config.email_subject
    472         success = send_mail(fullname,username,self.config.name,
     478        success = send_mail(fullname,username,usertype,self.config.name,
    473479                  body,email_from,email_to,subject)
    474480        if success:
  • main/waeup.sirp/trunk/src/waeup/sirp/browser/static/waeup-base.css

    r7135 r7240  
    7070
    7171.studentmenu {
    72   text-align: center;
     72  text-align: left;
    7373  line-height: 2;
    7474}
  • main/waeup.sirp/trunk/src/waeup/sirp/browser/templates/studentsitelayout.pt

    r7184 r7240  
    5656
    5757        <div class="yui-b">
    58           <div class="block" tal:condition="layout/getStudentName">
     58          <div class="block" >
    5959            <div class="studentmenu">
    60               <tal:left content="structure provider:top_student" />
     60              <div tal:condition="layout/getStudentName"
     61                   tal:replace="structure provider:top_student">
     62                Student Links
     63              </div>
     64              <div tal:content="structure provider:actionbar">
     65                Student Actions
     66              </div>
    6167            </div>
    6268          </div>
     
    8995                  <div tal:replace="structure view/content"> THE CONTENT
    9096                  </div>
    91                   <span tal:replace="structure provider:actionbar"></span>
    9297                </div>
    9398              </div>
Note: See TracChangeset for help on using the changeset viewer.