web/views/actions.py
branch3.0
changeset 431 18b4dd650ef8
parent 401 bc55a104d636
child 554 f412343c89ad
equal deleted inserted replaced
430:6fbc0ab79a2d 431:18b4dd650ef8
    53                               vid='edition', __mode='normal')
    53                               vid='edition', __mode='normal')
    54 
    54 
    55 
    55 
    56 class ViewAction(Action):
    56 class ViewAction(Action):
    57     category = 'mainactions'    
    57     category = 'mainactions'    
    58     __selectors__ = (in_group_selector, searchstate_accept)
    58     __selectors__ = (match_user_group, searchstate_accept)
    59     require_groups = ('users', 'managers')
    59     require_groups = ('users', 'managers')
    60     order = 0
    60     order = 0
    61     
    61     
    62     id = 'view'
    62     id = 'view'
    63     title = _('view')
    63     title = _('view')
   108         return entity.absolute_url(vid='edition')
   108         return entity.absolute_url(vid='edition')
   109         
   109         
   110 
   110 
   111 class MultipleEditAction(EntityAction):
   111 class MultipleEditAction(EntityAction):
   112     category = 'mainactions'
   112     category = 'mainactions'
   113     __selectors__ = (two_lines_rset, oneetyperset_selector,
   113     __selectors__ = (two_lines_rset, one_etype_rset,
   114                      searchstate_accept)
   114                      searchstate_accept)
   115     schema_action = 'update'
   115     schema_action = 'update'
   116     order = 10
   116     order = 10
   117     
   117     
   118     id = 'muledit' # XXX get strange conflicts if id='edit'
   118     id = 'muledit' # XXX get strange conflicts if id='edit'
   196                and eschema.has_perm(req, 'add'):
   196                and eschema.has_perm(req, 'add'):
   197             return 1
   197             return 1
   198         return 0
   198         return 0
   199     __selectors__ = (match_search_state,
   199     __selectors__ = (match_search_state,
   200                      chainfirst(etype_rset_selector,
   200                      chainfirst(etype_rset_selector,
   201                                 chainall(two_lines_rset, oneetyperset_selector,
   201                                 chainall(two_lines_rset, one_etype_rset,
   202                                          has_add_perm_selector)))
   202                                          has_add_perm_selector)))
   203 
   203 
   204     @property
   204     @property
   205     def rsettype(self):
   205     def rsettype(self):
   206         if self.rset:
   206         if self.rset:
   217 
   217 
   218 # logged user actions #########################################################
   218 # logged user actions #########################################################
   219 
   219 
   220 class UserPreferencesAction(Action):
   220 class UserPreferencesAction(Action):
   221     category = 'useractions'
   221     category = 'useractions'
   222     __selectors__ = not_anonymous_selector,
   222     __selectors__ = authenticated_user,
   223     order = 10
   223     order = 10
   224     
   224     
   225     id = 'myprefs'
   225     id = 'myprefs'
   226     title = _('user preferences')
   226     title = _('user preferences')
   227 
   227 
   229         return self.build_url(self.id)
   229         return self.build_url(self.id)
   230 
   230 
   231 
   231 
   232 class UserInfoAction(Action):
   232 class UserInfoAction(Action):
   233     category = 'useractions'
   233     category = 'useractions'
   234     __selectors__ = not_anonymous_selector,
   234     __selectors__ = authenticated_user,
   235     order = 20
   235     order = 20
   236     
   236     
   237     id = 'myinfos'
   237     id = 'myinfos'
   238     title = _('personnal informations')
   238     title = _('personnal informations')
   239 
   239 
   241         return self.build_url('euser/%s'%self.req.user.login, vid='edition')
   241         return self.build_url('euser/%s'%self.req.user.login, vid='edition')
   242 
   242 
   243 
   243 
   244 class LogoutAction(Action):
   244 class LogoutAction(Action):
   245     category = 'useractions'
   245     category = 'useractions'
   246     __selectors__ = not_anonymous_selector,
   246     __selectors__ = authenticated_user,
   247     order = 30
   247     order = 30
   248     
   248     
   249     id = 'logout'
   249     id = 'logout'
   250     title = _('logout')
   250     title = _('logout')
   251 
   251 
   256 # site actions ################################################################
   256 # site actions ################################################################
   257 
   257 
   258 class ManagersAction(Action):
   258 class ManagersAction(Action):
   259     category = 'siteactions'
   259     category = 'siteactions'
   260     __abstract__ = True
   260     __abstract__ = True
   261     __selectors__ = in_group_selector,
   261     __selectors__ = match_user_group,
   262     require_groups = ('managers',)
   262     require_groups = ('managers',)
   263 
   263 
   264     def url(self):
   264     def url(self):
   265         return self.build_url(self.id)
   265         return self.build_url(self.id)
   266 
   266 
   299     
   299     
   300     def url(self):
   300     def url(self):
   301         return self.rset.get_entity(self.row or 0, self.col or 0).actual_url()
   301         return self.rset.get_entity(self.row or 0, self.col or 0).actual_url()
   302 
   302 
   303 class UserPreferencesEntityAction(EntityAction):
   303 class UserPreferencesEntityAction(EntityAction):
   304     __selectors__ = EntityAction.__selectors__ + (one_line_rset, in_group_selector,)
   304     __selectors__ = EntityAction.__selectors__ + (one_line_rset, match_user_group,)
   305     require_groups = ('owners', 'managers')
   305     require_groups = ('owners', 'managers')
   306     category = 'mainactions'
   306     category = 'mainactions'
   307     accepts = ('EUser',)
   307     accepts = ('EUser',)
   308     
   308     
   309     id = 'prefs'
   309     id = 'prefs'