web/views/actions.py
author sylvain.thenault@logilab.fr
Wed, 11 Feb 2009 14:57:24 +0100
changeset 580 b453a6a1c3d1
parent 554 f412343c89ad
child 631 99f5852f8604
child 1213 06789a89f91f
permissions -rw-r--r--
update copyright
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
     1
"""Set of HTML base actions
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
     2
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
     3
:organization: Logilab
401
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
     4
:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
     5
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
     6
"""
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
     7
__docformat__ = "restructuredtext en"
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
     8
554
f412343c89ad [actions] import * : just say no
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 431
diff changeset
     9
from cubicweb.common.selectors import (searchstate_accept, match_user_group, yes,
f412343c89ad [actions] import * : just say no
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 431
diff changeset
    10
                                       one_line_rset, two_lines_rset, one_etype_rset,
f412343c89ad [actions] import * : just say no
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 431
diff changeset
    11
                                       authenticated_user,
f412343c89ad [actions] import * : just say no
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 431
diff changeset
    12
                                       match_search_state, chainfirst, chainall)
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    13
554
f412343c89ad [actions] import * : just say no
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 431
diff changeset
    14
from cubicweb.web.action import Action, EntityAction,  LinkToEntityAction
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    15
from cubicweb.web.views import linksearch_select_url, linksearch_match
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    16
from cubicweb.web.views.baseviews import vid_from_rset
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    17
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    18
_ = unicode
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    19
401
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
    20
# generic primary actions #####################################################
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    21
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    22
class SelectAction(EntityAction):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    23
    """base class for link search actions. By default apply on
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    24
    any size entity result search it the current state is 'linksearch'
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    25
    if accept match.
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    26
    """
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    27
    category = 'mainactions'    
254
b1eda3dd844a more selector renaming
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 237
diff changeset
    28
    __selectors__ = (searchstate_accept,)
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    29
    search_states = ('linksearch',)
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    30
    order = 0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    31
    
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    32
    id = 'select'
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    33
    title = _('select')
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    34
    
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    35
    @classmethod
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    36
    def accept_rset(cls, req, rset, row, col):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    37
        return linksearch_match(req, rset)
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    38
    
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    39
    def url(self):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    40
        return linksearch_select_url(self.req, self.rset)
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    41
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    42
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    43
class CancelSelectAction(Action):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    44
    category = 'mainactions'
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    45
    search_states = ('linksearch',)
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    46
    order = 10
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    47
    
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    48
    id = 'cancel'
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    49
    title = _('cancel select')
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    50
    
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    51
    def url(self):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    52
        target, link_eid, r_type, searched_type = self.req.search_state[1]
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    53
        return self.build_url(rql="Any X WHERE X eid %s" % link_eid,
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    54
                              vid='edition', __mode='normal')
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    55
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    56
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    57
class ViewAction(Action):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    58
    category = 'mainactions'    
431
18b4dd650ef8 massive selector update
sylvain.thenault@logilab.fr
parents: 401
diff changeset
    59
    __selectors__ = (match_user_group, searchstate_accept)
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    60
    require_groups = ('users', 'managers')
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    61
    order = 0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    62
    
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    63
    id = 'view'
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    64
    title = _('view')
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    65
    
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    66
    @classmethod
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    67
    def accept_rset(cls, req, rset, row, col):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    68
        # interesting if it propose another view than the current one
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    69
        vid = req.form.get('vid')
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    70
        if vid and vid != vid_from_rset(req, rset, cls.schema):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    71
            return 1
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    72
        return 0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    73
    
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    74
    def url(self):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    75
        params = self.req.form.copy()
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    76
        params.pop('vid', None)
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    77
        params.pop('__message', None)
401
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
    78
        return self.build_url(self.req.relative_path(includeparams=False),
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
    79
                              **params)
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    80
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    81
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    82
class ModifyAction(EntityAction):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    83
    category = 'mainactions'
254
b1eda3dd844a more selector renaming
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 237
diff changeset
    84
    __selectors__ = (one_line_rset, searchstate_accept)
b1eda3dd844a more selector renaming
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 237
diff changeset
    85
    #__selectors__ = searchstate_accept,
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    86
    schema_action = 'update'
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    87
    order = 10
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    88
    
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    89
    id = 'edit'
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    90
    title = _('modify')
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    91
    
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    92
    @classmethod
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    93
    def has_permission(cls, entity, action):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    94
        if entity.has_perm(action):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    95
            return True
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    96
        # if user has no update right but it can modify some relation,
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    97
        # display action anyway
401
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
    98
        for dummy in entity.srelations_by_category(('generic', 'metadata'),
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
    99
                                                   'add'):
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   100
            return True
401
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   101
        for rschema, targetschemas, role in entity.relations_by_category(
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   102
            ('primary', 'secondary'), 'add'):
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   103
            if not rschema.is_final():
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   104
                return True
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   105
        return False
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   106
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   107
    def url(self):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   108
        entity = self.rset.get_entity(self.row or 0, self.col or 0)
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   109
        return entity.absolute_url(vid='edition')
401
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   110
        
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   111
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   112
class MultipleEditAction(EntityAction):
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   113
    category = 'mainactions'
431
18b4dd650ef8 massive selector update
sylvain.thenault@logilab.fr
parents: 401
diff changeset
   114
    __selectors__ = (two_lines_rset, one_etype_rset,
401
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   115
                     searchstate_accept)
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   116
    schema_action = 'update'
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   117
    order = 10
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   118
    
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   119
    id = 'muledit' # XXX get strange conflicts if id='edit'
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   120
    title = _('modify')
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   121
    
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   122
    def url(self):
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   123
        return self.build_url('view', rql=self.rset.rql, vid='muledit')
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   124
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   125
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   126
# generic secondary actions ###################################################
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   127
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   128
class ManagePermissions(LinkToEntityAction):
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   129
    accepts = ('Any',)
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   130
    category = 'moreactions'
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   131
    id = 'addpermission'
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   132
    title = _('manage permissions')
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   133
    order = 100
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   134
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   135
    etype = 'EPermission'
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   136
    rtype = 'require_permission'
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   137
    target = 'object'
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   138
    
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   139
    def url(self):
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   140
        return self.rset.get_entity(0, 0).absolute_url(vid='security')
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   141
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   142
    
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   143
class DeleteAction(EntityAction):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   144
    category = 'moreactions' 
254
b1eda3dd844a more selector renaming
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 237
diff changeset
   145
    __selectors__ = (searchstate_accept,)
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   146
    schema_action = 'delete'
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   147
    order = 20
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   148
    
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   149
    id = 'delete'
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   150
    title = _('delete')
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   151
    
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   152
    def url(self):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   153
        if len(self.rset) == 1:
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   154
            entity = self.rset.get_entity(0, 0)
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   155
            return self.build_url(entity.rest_path(), vid='deleteconf')
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   156
        return self.build_url(rql=self.rset.printable_rql(), vid='deleteconf')
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   157
    
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   158
        
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   159
class CopyAction(EntityAction):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   160
    category = 'moreactions'
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   161
    schema_action = 'add'
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   162
    order = 30
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   163
    
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   164
    id = 'copy'
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   165
    title = _('copy')
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   166
    
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   167
    def url(self):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   168
        entity = self.rset.get_entity(self.row or 0, self.col or 0)
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   169
        return entity.absolute_url(vid='copy')
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   170
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   171
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   172
class AddNewAction(MultipleEditAction):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   173
    """when we're seeing more than one entity with the same type, propose to
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   174
    add a new one
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   175
    """
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   176
    category = 'moreactions'
401
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   177
    id = 'addentity'
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   178
    order = 40
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   179
    
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   180
    def etype_rset_selector(cls, req, rset, **kwargs):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   181
        if rset is not None and not rset.rowcount:
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   182
            rqlst = rset.syntax_tree()
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   183
            if len(rqlst.children) > 1:
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   184
                return 0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   185
            select = rqlst.children[0]
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   186
            if len(select.defined_vars) == 1 and len(select.solutions) == 1:
328
02abf429dd91 don't show add new action for composed objects
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 254
diff changeset
   187
                rset._searched_etype = select.solutions[0].itervalues().next()
02abf429dd91 don't show add new action for composed objects
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 254
diff changeset
   188
                eschema = cls.schema.eschema(rset._searched_etype)
02abf429dd91 don't show add new action for composed objects
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 254
diff changeset
   189
                if not (eschema.is_final() or eschema.is_subobject(strict=True)) \
02abf429dd91 don't show add new action for composed objects
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 254
diff changeset
   190
                       and eschema.has_perm(req, 'add'):
02abf429dd91 don't show add new action for composed objects
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 254
diff changeset
   191
                    return 1
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   192
        return 0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   193
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   194
    def has_add_perm_selector(cls, req, rset, **kwargs):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   195
        eschema = cls.schema.eschema(rset.description[0][0])
328
02abf429dd91 don't show add new action for composed objects
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 254
diff changeset
   196
        if not (eschema.is_final() or eschema.is_subobject(strict=True)) \
02abf429dd91 don't show add new action for composed objects
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 254
diff changeset
   197
               and eschema.has_perm(req, 'add'):
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   198
            return 1
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   199
        return 0
254
b1eda3dd844a more selector renaming
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 237
diff changeset
   200
    __selectors__ = (match_search_state,
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   201
                     chainfirst(etype_rset_selector,
431
18b4dd650ef8 massive selector update
sylvain.thenault@logilab.fr
parents: 401
diff changeset
   202
                                chainall(two_lines_rset, one_etype_rset,
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   203
                                         has_add_perm_selector)))
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   204
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   205
    @property
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   206
    def rsettype(self):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   207
        if self.rset:
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   208
            return self.rset.description[0][0]
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   209
        return self.rset._searched_etype
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   210
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   211
    @property
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   212
    def title(self):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   213
        return self.req.__('add a %s' % self.rsettype) # generated msgid
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   214
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   215
    def url(self):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   216
        return self.build_url('add/%s' % self.rsettype)
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   217
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   218
401
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   219
# logged user actions #########################################################
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   220
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   221
class UserPreferencesAction(Action):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   222
    category = 'useractions'
431
18b4dd650ef8 massive selector update
sylvain.thenault@logilab.fr
parents: 401
diff changeset
   223
    __selectors__ = authenticated_user,
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   224
    order = 10
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   225
    
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   226
    id = 'myprefs'
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   227
    title = _('user preferences')
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   228
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   229
    def url(self):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   230
        return self.build_url(self.id)
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   231
401
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   232
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   233
class UserInfoAction(Action):
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   234
    category = 'useractions'
431
18b4dd650ef8 massive selector update
sylvain.thenault@logilab.fr
parents: 401
diff changeset
   235
    __selectors__ = authenticated_user,
401
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   236
    order = 20
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   237
    
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   238
    id = 'myinfos'
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   239
    title = _('personnal informations')
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   240
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   241
    def url(self):
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   242
        return self.build_url('euser/%s'%self.req.user.login, vid='edition')
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   243
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   244
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   245
class LogoutAction(Action):
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   246
    category = 'useractions'
431
18b4dd650ef8 massive selector update
sylvain.thenault@logilab.fr
parents: 401
diff changeset
   247
    __selectors__ = authenticated_user,
401
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   248
    order = 30
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   249
    
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   250
    id = 'logout'
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   251
    title = _('logout')
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   252
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   253
    def url(self):
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   254
        return self.build_url(self.id)
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   255
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   256
    
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   257
# site actions ################################################################
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   258
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   259
class ManagersAction(Action):
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   260
    category = 'siteactions'
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   261
    __abstract__ = True
431
18b4dd650ef8 massive selector update
sylvain.thenault@logilab.fr
parents: 401
diff changeset
   262
    __selectors__ = match_user_group,
401
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   263
    require_groups = ('managers',)
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   264
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   265
    def url(self):
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   266
        return self.build_url(self.id)
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   267
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   268
    
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   269
class SiteConfigurationAction(ManagersAction):
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   270
    order = 10
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   271
    id = 'siteconfig'
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   272
    title = _('site configuration')
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   273
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   274
    
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   275
class ManageAction(ManagersAction):
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   276
    order = 20
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   277
    id = 'manage'
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   278
    title = _('manage')
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   279
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   280
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   281
class ViewSchemaAction(Action):
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   282
    category = 'siteactions'
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   283
    id = 'schema'
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   284
    title = _("site schema")
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   285
    __selectors__ = yes,
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   286
    order = 30
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   287
    
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   288
    def url(self):
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   289
        return self.build_url(self.id)
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   290
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   291
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   292
# content type specific actions ###############################################
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   293
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   294
class FollowAction(EntityAction):
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   295
    category = 'mainactions'
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   296
    accepts = ('Bookmark',)
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   297
    
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   298
    id = 'follow'
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   299
    title = _('follow')
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   300
    
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   301
    def url(self):
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   302
        return self.rset.get_entity(self.row or 0, self.col or 0).actual_url()
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   303
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   304
class UserPreferencesEntityAction(EntityAction):
431
18b4dd650ef8 massive selector update
sylvain.thenault@logilab.fr
parents: 401
diff changeset
   305
    __selectors__ = EntityAction.__selectors__ + (one_line_rset, match_user_group,)
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   306
    require_groups = ('owners', 'managers')
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   307
    category = 'mainactions'
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   308
    accepts = ('EUser',)
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   309
    
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   310
    id = 'prefs'
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   311
    title = _('preferences')
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   312
    
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   313
    def url(self):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   314
        login = self.rset.get_entity(self.row or 0, self.col or 0).login
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   315
        return self.build_url('euser/%s'%login, vid='epropertiesform')
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   316