web/views/actions.py
author sylvain.thenault@logilab.fr
Thu, 16 Apr 2009 18:51:14 +0200
changeset 1385 41fe68a4f94c
parent 1248 4a8c5f8ddff5
child 1263 01152fffd593
permissions -rw-r--r--
merge
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,
1213
06789a89f91f adding action to startup schema view. this action enables to
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 554
diff changeset
    11
                                       authenticated_user, none_rset,
554
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)
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    85
    schema_action = 'update'
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    86
    order = 10
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    87
    
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    88
    id = 'edit'
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    89
    title = _('modify')
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    90
    
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    91
    @classmethod
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    92
    def has_permission(cls, entity, action):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    93
        if entity.has_perm(action):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    94
            return True
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    95
        # if user has no update right but it can modify some relation,
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    96
        # display action anyway
401
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
    97
        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
    98
                                                   'add'):
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    99
            return True
401
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   100
        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
   101
            ('primary', 'secondary'), 'add'):
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   102
            if not rschema.is_final():
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   103
                return True
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   104
        return False
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   105
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   106
    def url(self):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   107
        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
   108
        return entity.absolute_url(vid='edition')
401
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   109
        
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
class MultipleEditAction(EntityAction):
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   112
    category = 'mainactions'
431
18b4dd650ef8 massive selector update
sylvain.thenault@logilab.fr
parents: 401
diff changeset
   113
    __selectors__ = (two_lines_rset, one_etype_rset,
401
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   114
                     searchstate_accept)
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   115
    schema_action = 'update'
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   116
    order = 10
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   117
    
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   118
    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
   119
    title = _('modify')
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   120
    
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   121
    def url(self):
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   122
        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
   123
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
# generic secondary actions ###################################################
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   126
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   127
class ManagePermissions(LinkToEntityAction):
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   128
    accepts = ('Any',)
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   129
    category = 'moreactions'
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   130
    id = 'addpermission'
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   131
    title = _('manage permissions')
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   132
    order = 100
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   133
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   134
    etype = 'EPermission'
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   135
    rtype = 'require_permission'
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   136
    target = 'object'
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   137
    
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   138
    def url(self):
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   139
        return self.rset.get_entity(0, 0).absolute_url(vid='security')
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   140
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
class DeleteAction(EntityAction):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   143
    category = 'moreactions' 
254
b1eda3dd844a more selector renaming
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 237
diff changeset
   144
    __selectors__ = (searchstate_accept,)
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   145
    schema_action = 'delete'
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   146
    order = 20
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   147
    
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   148
    id = 'delete'
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   149
    title = _('delete')
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   150
    
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   151
    def url(self):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   152
        if len(self.rset) == 1:
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   153
            entity = self.rset.get_entity(0, 0)
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   154
            return self.build_url(entity.rest_path(), vid='deleteconf')
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   155
        return self.build_url(rql=self.rset.printable_rql(), vid='deleteconf')
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   156
    
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
class CopyAction(EntityAction):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   159
    category = 'moreactions'
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   160
    schema_action = 'add'
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   161
    order = 30
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   162
    
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   163
    id = 'copy'
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   164
    title = _('copy')
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   165
    
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   166
    def url(self):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   167
        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
   168
        return entity.absolute_url(vid='copy')
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   169
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
class AddNewAction(MultipleEditAction):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   172
    """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
   173
    add a new one
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   174
    """
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   175
    category = 'moreactions'
401
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   176
    id = 'addentity'
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   177
    order = 40
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   178
    
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   179
    def etype_rset_selector(cls, req, rset, **kwargs):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   180
        if rset is not None and not rset.rowcount:
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   181
            rqlst = rset.syntax_tree()
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   182
            if len(rqlst.children) > 1:
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   183
                return 0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   184
            select = rqlst.children[0]
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   185
            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
   186
                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
   187
                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
   188
                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
   189
                       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
   190
                    return 1
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   191
        return 0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   192
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   193
    def has_add_perm_selector(cls, req, rset, **kwargs):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   194
        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
   195
        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
   196
               and eschema.has_perm(req, 'add'):
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   197
            return 1
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   198
        return 0
254
b1eda3dd844a more selector renaming
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents: 237
diff changeset
   199
    __selectors__ = (match_search_state,
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   200
                     chainfirst(etype_rset_selector,
431
18b4dd650ef8 massive selector update
sylvain.thenault@logilab.fr
parents: 401
diff changeset
   201
                                chainall(two_lines_rset, one_etype_rset,
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   202
                                         has_add_perm_selector)))
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   203
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   204
    @property
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   205
    def rsettype(self):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   206
        if self.rset:
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   207
            return self.rset.description[0][0]
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   208
        return self.rset._searched_etype
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   209
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   210
    @property
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   211
    def title(self):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   212
        return self.req.__('add a %s' % self.rsettype) # generated msgid
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   213
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   214
    def url(self):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   215
        return self.build_url('add/%s' % self.rsettype)
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   216
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   217
401
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   218
# logged user actions #########################################################
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   219
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   220
class UserPreferencesAction(Action):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   221
    category = 'useractions'
431
18b4dd650ef8 massive selector update
sylvain.thenault@logilab.fr
parents: 401
diff changeset
   222
    __selectors__ = authenticated_user,
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   223
    order = 10
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   224
    
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   225
    id = 'myprefs'
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   226
    title = _('user preferences')
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   227
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   228
    def url(self):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   229
        return self.build_url(self.id)
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   230
401
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   231
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   232
class UserInfoAction(Action):
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   233
    category = 'useractions'
431
18b4dd650ef8 massive selector update
sylvain.thenault@logilab.fr
parents: 401
diff changeset
   234
    __selectors__ = authenticated_user,
401
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   235
    order = 20
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   236
    
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   237
    id = 'myinfos'
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   238
    title = _('personnal informations')
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   239
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   240
    def url(self):
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   241
        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
   242
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
class LogoutAction(Action):
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   245
    category = 'useractions'
431
18b4dd650ef8 massive selector update
sylvain.thenault@logilab.fr
parents: 401
diff changeset
   246
    __selectors__ = authenticated_user,
401
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   247
    order = 30
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   248
    
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   249
    id = 'logout'
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   250
    title = _('logout')
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   251
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   252
    def url(self):
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   253
        return self.build_url(self.id)
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   254
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
# site actions ################################################################
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   257
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   258
class ManagersAction(Action):
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   259
    category = 'siteactions'
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   260
    __abstract__ = True
431
18b4dd650ef8 massive selector update
sylvain.thenault@logilab.fr
parents: 401
diff changeset
   261
    __selectors__ = match_user_group,
401
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   262
    require_groups = ('managers',)
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   263
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   264
    def url(self):
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   265
        return self.build_url(self.id)
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   266
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
class SiteConfigurationAction(ManagersAction):
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   269
    order = 10
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   270
    id = 'siteconfig'
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   271
    title = _('site configuration')
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   272
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
class ManageAction(ManagersAction):
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   275
    order = 20
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   276
    id = 'manage'
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   277
    title = _('manage')
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   278
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
class ViewSchemaAction(Action):
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   281
    category = 'siteactions'
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   282
    id = 'schema'
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   283
    title = _("site schema")
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   284
    __selectors__ = yes,
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   285
    order = 30
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   286
    
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   287
    def url(self):
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   288
        return self.build_url(self.id)
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   289
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
# content type specific actions ###############################################
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   292
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   293
class FollowAction(EntityAction):
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   294
    category = 'mainactions'
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   295
    accepts = ('Bookmark',)
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   296
    
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   297
    id = 'follow'
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   298
    title = _('follow')
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   299
    
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   300
    def url(self):
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   301
        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
   302
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   303
class UserPreferencesEntityAction(EntityAction):
431
18b4dd650ef8 massive selector update
sylvain.thenault@logilab.fr
parents: 401
diff changeset
   304
    __selectors__ = EntityAction.__selectors__ + (one_line_rset, match_user_group,)
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   305
    require_groups = ('owners', 'managers')
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   306
    category = 'mainactions'
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   307
    accepts = ('EUser',)
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   308
    
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   309
    id = 'prefs'
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   310
    title = _('preferences')
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   311
    
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   312
    def url(self):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   313
        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
   314
        return self.build_url('euser/%s'%login, vid='epropertiesform')
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   315
1213
06789a89f91f adding action to startup schema view. this action enables to
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 554
diff changeset
   316
# schema view action
1248
4a8c5f8ddff5 only show owl action when displaying the schema view
sylvain.thenault@logilab.fr
parents: 1213
diff changeset
   317
def schema_view(cls, req, rset, row=None, col=None, view=None,
4a8c5f8ddff5 only show owl action when displaying the schema view
sylvain.thenault@logilab.fr
parents: 1213
diff changeset
   318
                **kwargs):
4a8c5f8ddff5 only show owl action when displaying the schema view
sylvain.thenault@logilab.fr
parents: 1213
diff changeset
   319
    if view is None or not view.id == 'schema':
4a8c5f8ddff5 only show owl action when displaying the schema view
sylvain.thenault@logilab.fr
parents: 1213
diff changeset
   320
        return 0
4a8c5f8ddff5 only show owl action when displaying the schema view
sylvain.thenault@logilab.fr
parents: 1213
diff changeset
   321
    return 1
1213
06789a89f91f adding action to startup schema view. this action enables to
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 554
diff changeset
   322
06789a89f91f adding action to startup schema view. this action enables to
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 554
diff changeset
   323
class DownloadOWLSchemaAction(Action):
06789a89f91f adding action to startup schema view. this action enables to
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 554
diff changeset
   324
    category = 'mainactions'
06789a89f91f adding action to startup schema view. this action enables to
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 554
diff changeset
   325
    id = 'download_as_owl'
06789a89f91f adding action to startup schema view. this action enables to
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 554
diff changeset
   326
    title = _('download schema as owl')
1248
4a8c5f8ddff5 only show owl action when displaying the schema view
sylvain.thenault@logilab.fr
parents: 1213
diff changeset
   327
    __selectors__ = none_rset, schema_view
1213
06789a89f91f adding action to startup schema view. this action enables to
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 554
diff changeset
   328
   
06789a89f91f adding action to startup schema view. this action enables to
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 554
diff changeset
   329
    def url(self):
06789a89f91f adding action to startup schema view. this action enables to
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 554
diff changeset
   330
        return self.build_url('view', vid='owl')
06789a89f91f adding action to startup schema view. this action enables to
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents: 554
diff changeset
   331