Changeset c3902a in indico


Ignore:
Timestamp:
06/23/11 17:27:11 (2 years ago)
Author:
Pedro Ferreira <jose.pedro.ferreira@…>
Branches:
master, burotel, hello-world-walkthrough, ipv6, v0.98-series, v0.98.2, v0.98.3, v0.98b1, v0.98b2, v0.99, 051b2622c51afb171a1dedb46a0df4fbb0cbd02e, 0da0c1403bae8e51d8229f460181c71b9e6dda72
Children:
f9bbd4
Parents:
c21134
git-author:
Adrian Moennich <jerome.ernst.monnich@…> (05/03/11 11:57:14)
git-committer:
Pedro Ferreira <jose.pedro.ferreira@…> (06/23/11 17:27:11)
Message:

[FTR] Add roombooking managers

  • they have (almost) full admin permissions in the roombooking module
  • they cannot modify the RB ZODB settings though
  • fixes #375

Conflicts:

indico/MaKaC/plugins/RoomBooking/options.py
indico/MaKaC/webinterface/rh/roomBooking.py

Location:
indico/MaKaC
Files:
1 added
8 edited

Legend:

Unmodified
Added
Removed
  • indico/MaKaC/plugins/RoomBooking/options.py

    rc21134 rc3902a  
    7373    ("notificationBefore", {"description" : _("Trigger start notifications X minutes before the booking starts. Changes will not affect existing bookings"), 
    7474                           "type": int, 
    75                            "defaultValue": 0} ) 
    76 ] 
     75                           "defaultValue": 0} ), 
     76    ( "Managers", {"description": "Users and Groups authorised to administrate/manage the roombooking module (create/delete/edit all rooms/bookings)", 
     77                                  "type": 'usersGroups', 
     78                                  "defaultValue": [], 
     79                                  "editable": True, 
     80                                  "visible": True}), 
     81    ( "AuthorisedUsersGroups", {"description": "Users and Groups authorised for roombooking module", 
     82                                "type": 'usersGroups', 
     83                                "defaultValue": [], 
     84                                "editable": True, 
     85                                "visible": True})] 
  • indico/MaKaC/rb_reservation.py

    rc21134 rc3902a  
    11531153        if not user: 
    11541154            return False 
    1155         can = user.isAdmin() or \ 
     1155        can = user.isRBAdmin() or \ 
    11561156            self.isOwnedBy( user ) or \ 
    11571157            self.room.isOwnedBy( user ) 
     
    11621162        if user == None: 
    11631163            return False 
    1164         return self.isOwnedBy( user ) or user.isAdmin() 
     1164        return self.isOwnedBy( user ) or user.isRBAdmin() 
    11651165 
    11661166    def canReject( self, user ): 
     
    11681168        if user == None: 
    11691169            return False 
    1170         return self.room.isOwnedBy( user ) or user.isAdmin() 
     1170        return self.room.isOwnedBy( user ) or user.isRBAdmin() 
    11711171 
    11721172    def canDelete( self, user ): 
     
    11741174        if user == None: 
    11751175            return False 
    1176         return user.isAdmin() 
     1176        return user.isRBAdmin() 
    11771177 
    11781178    def isOwnedBy( self, avatar ): 
  • indico/MaKaC/rb_room.py

    rc21134 rc3902a  
    524524 
    525525        if (self.isOwnedBy( user ) and self.isActive) \ 
    526                or user.isAdmin(): 
     526               or user.isRBAdmin(): 
    527527            return True 
    528528        return False 
     
    544544            return False 
    545545        if (self.isOwnedBy( user ) and self.isActive) \ 
    546                or user.isAdmin(): 
     546               or user.isRBAdmin(): 
    547547            return True 
    548548        return False 
     
    557557        if isinstance( accessWrapper, AccessWrapper ): 
    558558            if accessWrapper.getUser(): 
    559                 return accessWrapper.getUser().isAdmin() 
     559                return accessWrapper.getUser().isRBAdmin() 
    560560            else: 
    561561                return False 
    562562        elif isinstance( accessWrapper, Avatar ): 
    563             return accessWrapper.isAdmin() 
     563            return accessWrapper.isRBAdmin() 
    564564 
    565565        raise MaKaCError('canModify requires either AccessWrapper or Avatar object') 
  • indico/MaKaC/user.py

    rc21134 rc3902a  
    5454from xml.dom.minidom import parseString 
    5555from copy import deepcopy 
     56from MaKaC.plugins.base import PluginsHolder 
    5657 
    5758"""Contains the classes that implement the user management subsystem 
     
    13211322        if al.isAdmin( self ): 
    13221323            return True 
     1324        return False 
     1325 
     1326    def isRBAdmin(self): 
     1327        """ 
     1328        Convenience method for checking whether this user is an admin for the RB module. 
     1329        Returns bool. 
     1330        """ 
     1331        if self.isAdmin(): 
     1332            return True 
     1333        for entity in PluginsHolder().getPluginType('RoomBooking').getOption('Managers').getValue(): 
     1334            if (isinstance(entity, Group) and entity.containsUser(self)) or \ 
     1335                (isinstance(entity, Avatar) and entity == self): 
     1336                return True 
    13231337        return False 
    13241338 
  • indico/MaKaC/webinterface/pages/admins.py

    r181d5f rc3902a  
    137137        self._setActiveTab() 
    138138 
    139         frame = WAdminFrame() 
     139        if self._rh._getUser().isAdmin(): 
     140            frame = WAdminFrame() 
     141        else: 
     142            frame = WRBAdminFrame() 
    140143        p = { "body": self._getPageContent( params ), 
    141144              "sideMenu": self._sideMenu.getHTML() } 
     
    232235    def getTitleTabPixels( self ): 
    233236        return 260 
     237 
     238class WRBAdminFrame(WAdminFrame): 
     239    pass 
    234240 
    235241class WPAdmins( WPAdminsBase ): 
     
    21132119        self._tabCtrl = wcomponents.TabControl() 
    21142120 
    2115         self._subTabRoomBooking = self._tabCtrl.newTab( "booking", _("Room Booking"), \ 
    2116                 urlHandlers.UHRoomBookingPluginAdmin.getURL() ) 
    2117         self._subTabMain = self._subTabRoomBooking.newSubTab( "main", _("Main"), \ 
    2118                 urlHandlers.UHRoomBookingPluginAdmin.getURL() ) 
     2121        if self._rh._getUser().isAdmin(): 
     2122            self._subTabRoomBooking = self._tabCtrl.newTab( "booking", _("Room Booking"), \ 
     2123                    urlHandlers.UHRoomBookingPluginAdmin.getURL() ) 
     2124            self._subTabMain = self._subTabRoomBooking.newSubTab( "main", _("Main"), \ 
     2125                    urlHandlers.UHRoomBookingPluginAdmin.getURL() ) 
     2126        else: 
     2127            self._subTabRoomBooking = self._tabCtrl.newTab( "booking", _("Room Booking"), \ 
     2128                    urlHandlers.UHRoomBookingAdmin.getURL() ) 
    21192129        self._subTabConfig = self._subTabRoomBooking.newSubTab( "configuration", _("Configuration"), \ 
    21202130                urlHandlers.UHRoomBookingAdmin.getURL() ) 
    21212131        self._subTabRoomMappers = self._tabCtrl.newTab( "mappers", _("Room Mappers"), \ 
    21222132                urlHandlers.UHRoomMappers.getURL() ) 
     2133 
     2134    def _getNavigationDrawer(self): 
     2135        if self._rh._getUser().isAdmin(): 
     2136            return wcomponents.WSimpleNavigationDrawer(_("Room Booking Admin"), urlHandlers.UHRoomBookingPluginAdmin.getURL, bgColor="white") 
     2137        return wcomponents.WSimpleNavigationDrawer(_("Room Booking Admin"), urlHandlers.UHRoomBookingAdmin.getURL, bgColor="white") 
    21232138 
    21242139    def _getPageContent(self, params): 
     
    24542469        self._subTabRoomBooking.setActive() 
    24552470 
     2471    def _getSiteArea(self): 
     2472        return 'Room Booking Administration' 
     2473 
    24562474class WPRoomBookingPluginAdmin( WPRoomBookingPluginAdminBase ): 
    24572475 
  • indico/MaKaC/webinterface/pages/roomBooking.py

    rc21134 rc3902a  
    144144                                        urlHandlers.UHRoomBookingBookingList.getURL( ofMyRooms = True, onlyPrebookings = True, autoCriteria = True ), 
    145145                                        enabled=self._showResponsible) 
     146        if self._rh._getUser().isRBAdmin(): 
     147            self._adminSect = wcomponents.SideMenuSection(_("Administration"), \ 
     148                                            urlHandlers.UHRoomBookingAdmin.getURL() ) 
     149            self._adminOpt = wcomponents.SideMenuItem(_("Administration"), \ 
     150                                            urlHandlers.UHRoomBookingAdmin.getURL() ) 
    146151 
    147152 
     
    159164        self._bookingsOpt.addItem( self._usersBookings ) 
    160165        self._bookingsOpt.addItem( self._usersPrebookings ) 
     166        self._leftMenu.addSection( self._adminSect ) 
     167        self._adminSect.addItem( self._adminOpt ) 
    161168        return self._leftMenu 
    162169 
  • indico/MaKaC/webinterface/rh/roomBooking.py

    rc21134 rc3902a  
    628628        if self._getUser() == None: 
    629629            self._checkSessionUser() 
    630         elif not self._getUser().isAdmin(): 
     630        elif not self._getUser().isRBAdmin(): 
    631631            raise MaKaCError( "You are not authorized to take this action." ) 
    632632 
     
    864864 
    865865        # only admins can choose to consult non-active rooms 
    866         if self._getUser() and self._getUser().isAdmin() and params.get( 'isActive', None ) != "on": 
     866        if self._getUser() and self._getUser().isRBAdmin() and params.get( 'isActive', None ) != "on": 
    867867            self._isActive = None 
    868868 
     
    12601260        # (i.e. user is logged in) 
    12611261        if self._doProcess: 
    1262             if not self._candResv.room.isActive and not self._getUser().isAdmin(): 
     1262            if not self._candResv.room.isActive and not self._getUser().isRBAdmin(): 
    12631263                raise FormValuesError( "You are not authorized to book this room." ) 
    12641264 
     
    14011401        else: 
    14021402            RHRoomBookingBase._checkProtection(self) 
    1403             if not self._candResv.room.isActive and not self._getUser().isAdmin(): 
     1403            if not self._candResv.room.isActive and not self._getUser().isRBAdmin(): 
    14041404                raise MaKaCError( "You are not authorized to book this room." ) 
    14051405 
     
    17411741        # (Responsible can not cancel a booking!) 
    17421742        if ( not self._resv.isOwnedBy( user ) ) and \ 
    1743             ( not self._getUser().isAdmin() ): 
     1743            ( not self._getUser().isRBAdmin() ): 
    17441744                raise MaKaCError( "You are not authorized to take this action." ) 
    17451745 
     
    17801780        # Only user/admin can cancell a booking occurrence 
    17811781        # (Owner can not reject his own booking, he should cancel instead) 
    1782         if self._resv.createdBy != user.getId() and (not user.isAdmin()): 
     1782        if self._resv.createdBy != user.getId() and (not user.isRBAdmin()): 
    17831783                raise MaKaCError( "You are not authorized to take this action." ) 
    17841784 
     
    18191819        # (Owner can not reject his own booking, he should cancel instead) 
    18201820        if ( not self._resv.room.isOwnedBy( user ) ) and \ 
    1821             ( not self._getUser().isAdmin() ): 
     1821            ( not self._getUser().isRBAdmin() ): 
    18221822                raise MaKaCError( "You are not authorized to take this action." ) 
    18231823 
     
    18531853        # (Owner can not reject his own booking, he should cancel instead) 
    18541854        if ( not user.getRooms() ) and \ 
    1855             ( not self._getUser().isAdmin() ): 
     1855            ( not self._getUser().isRBAdmin() ): 
    18561856                raise MaKaCError( "You are not authorized to take this action." ) 
    18571857 
     
    19071907            # Only responsible and admin can ACCEPT 
    19081908            if ( not self._resv.room.isOwnedBy( user ) ) and \ 
    1909                 ( not self._getUser().isAdmin() ): 
     1909                ( not self._getUser().isRBAdmin() ): 
    19101910                raise MaKaCError( "You are not authorized to take this action." ) 
    19111911 
     
    21922192        # (Owner can not reject his own booking, he should cancel instead) 
    21932193        if ( not self._resv.room.isOwnedBy( user ) ) and \ 
    2194             ( not self._getUser().isAdmin() ): 
     2194            ( not self._getUser().isRBAdmin() ): 
    21952195                raise MaKaCError( "You are not authorized to take this action." ) 
    21962196 
  • indico/MaKaC/webinterface/rh/roomMappers.py

    rbdd862 rc3902a  
    2222import MaKaC.roomMapping as roomMapping 
    2323import MaKaC.webinterface.urlHandlers as urlHandlers 
    24 import MaKaC.errors as erros 
    2524import MaKaC.webinterface.rh.admins as admins 
    2625from MaKaC.webinterface import locators 
     26from MaKaC.errors import AccessError 
    2727 
    2828 
    2929class RHRoomMapperProtected( admins.RHAdminBase ): 
    30     pass 
     30    def _checkProtection( self ): 
     31        if self._getUser() is None: 
     32            self._checkSessionUser() 
     33        elif not self._getUser().isRBAdmin(): 
     34            raise AccessError( "You are not authorized to take this action." ) 
    3135 
    3236class RHRoomMappers( RHRoomMapperProtected ): 
     
    3640        admins.RHAdminBase._checkParams( self, params ) 
    3741        self._params = params 
    38      
     42 
    3943    def _process( self ): 
    4044        p = adminPages.WPRoomMapperList( self, self._params ) 
    4145        return p.display() 
    42          
     46 
    4347 
    4448class RHRoomMapperBase( RHRoomMapperProtected ): 
    45      
     49 
    4650    def _checkParams( self, params ): 
    4751        RHRoomMapperProtected._checkParams( self, params ) 
     
    5155class RHRoomMapperDetails( RHRoomMapperBase ): 
    5256    _uh = urlHandlers.UHRoomMapperDetails 
    53      
     57 
    5458    def _process( self ): 
    5559        p = adminPages.WPRoomMapperDetails( self, self._roomMapper ) 
     
    5963class RHRoomMapperModification( RHRoomMapperBase ): 
    6064    _uh = urlHandlers.UHRoomMapperModification 
    61      
     65 
    6266    def _process( self ): 
    6367        p = adminPages.WPRoomMapperModification( self, self._roomMapper ) 
     
    6771class RHRoomMapperPerformModification( RHRoomMapperBase ): 
    6872    _uh = urlHandlers.UHRoomMapperPerformModification 
    69      
     73 
    7074    def _process( self ): 
    7175        self._roomMapper.setValues(self._getRequestParams()) 
     
    7579class RHRoomMapperCreation( RHRoomMapperProtected ): 
    7680    _uh = urlHandlers.UHNewRoomMapper 
    77      
     81 
    7882    def _process( self ): 
    7983        p = adminPages.WPRoomMapperCreation( self ) 
     
    8387class RHRoomMapperPerformCreation( RHRoomMapperProtected ): 
    8488    _uh = urlHandlers.UHRoomMapperPerformCreation 
    85      
     89 
    8690    def _process( self ): 
    8791        rm = roomMapping.RoomMapper() 
     
    9094        rmh.add( rm ) 
    9195        self._redirect( urlHandlers.UHRoomMapperDetails.getURL( rm ) ) 
    92          
    93      
    94      
    95  
    96  
    97  
Note: See TracChangeset for help on using the changeset viewer.