Changeset 10540


Ignore:
Timestamp:
27 Aug 2013, 20:08:27 (11 years ago)
Author:
Henrik Bettermann
Message:

Extend CourseManageFormPage? to enable local role assignment.

Location:
main/waeup.kofa/trunk/src/waeup/kofa/browser
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/browser/browser.txt

    r10438 r10540  
    726726  True
    727727
     728We can grant local roles:
     729
     730  >>> browser.open('http://localhost/myuniversity/faculties/TF/TD/courses/COURSE1/manage')
     731  >>> browser.getControl(name="user").value = ['bob']
     732  >>> browser.getControl(
     733  ...     name="local_role").value = ['waeup.local.Lecturer']
     734  >>> browser.getControl("Add local role").click()
     735  >>> print browser.contents
     736  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
     737  ...<td>bob</td>
     738  ...
     739
     740On the portal user page the new local role is displayed:
     741
     742  >>> browser.getLink("Portal Users").click()
     743  >>> print browser.contents
     744  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
     745  ...<td>Lecturer:...
     746  ...
     747
     748The local role can be removed again:
     749
     750  >>> browser.open('http://localhost/myuniversity/faculties/TF/TD/courses/COURSE1/manage')
     751  >>> ctrl = browser.getControl(name='role_id')
     752  >>> browser.getControl("Remove selected local roles").click()
     753  >>> print browser.contents
     754  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
     755  ...No local role selected...
     756  ...
     757
     758  >>> browser.open('http://localhost/myuniversity/faculties/TF/TD/courses/COURSE1/manage')
     759  >>> ctrl = browser.getControl(name='role_id')
     760  >>> ctrl.getControl(value='bob|waeup.local.Lecturer').selected = True
     761  >>> browser.getControl("Remove selected local roles").click()
     762  >>> print browser.contents
     763  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
     764  ...Local role successfully removed...
     765  ...
     766
    728767Deleting courses
    729768----------------
  • main/waeup.kofa/trunk/src/waeup/kofa/browser/pages.py

    r10244 r10540  
    21112111    grok.name('manage')
    21122112    grok.require('waeup.manageAcademics')
     2113    grok.template('coursemanagepage')
    21132114    label = _(u'Edit course')
    21142115    pnav = 1
     2116    taboneactions = [_('Save'),_('Cancel')]
     2117    tabtwoactions1 = [_('Remove selected local roles')]
     2118    tabtwoactions2 = [_('Add local role')]
    21152119
    21162120    form_fields = grok.AutoFields(ICourse)
     2121
     2122    def update(self):
     2123        tabs.need()
     2124        self.tab1 = self.tab2 = ''
     2125        qs = self.request.get('QUERY_STRING', '')
     2126        if not qs:
     2127            qs = 'tab1'
     2128        setattr(self, qs, 'active')
     2129        warning.need()
     2130        datatable.need()
     2131        return super(CourseManageFormPage, self).update()
    21172132
    21182133    @action(_('Save'), style='primary')
     
    21242139        self.redirect(self.url(self.context))
    21252140        return
     2141
     2142    def getLocalRoles(self):
     2143        roles = ILocalRolesAssignable(self.context)
     2144        return roles()
     2145
     2146    def getUsers(self):
     2147        return get_all_users()
     2148
     2149    def getUsersWithLocalRoles(self):
     2150        return get_users_with_local_roles(self.context)
     2151
     2152    @action(_('Add local role'), validator=NullValidator)
     2153    def addLocalRole(self, **data):
     2154        return add_local_role(self, 2, **data)
     2155
     2156    @action(_('Remove selected local roles'))
     2157    def delLocalRoles(self, **data):
     2158        return del_local_roles(self,2,**data)
    21262159
    21272160#
Note: See TracChangeset for help on using the changeset viewer.