web/views/actions.py
author David Douard <david.douard@logilab.fr>
Mon, 22 Jul 2013 15:38:11 +0200
branchstable
changeset 9176 8139f82c8bbe
parent 8666 1dd655788ece
child 9198 c32a21bf88bb
permissions -rw-r--r--
[facets,js] fix bogus checkbox icon appearing after the first interaction (closes #2790332) This is because of the hardcoding of the data/ url.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8190
2a3c1b787688 [vreg] move base registry implementation to logilab.common. Closes #1916014
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 8128
diff changeset
     1
# copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
5421
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5001
diff changeset
     2
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5001
diff changeset
     3
#
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5001
diff changeset
     4
# This file is part of CubicWeb.
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5001
diff changeset
     5
#
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5001
diff changeset
     6
# CubicWeb is free software: you can redistribute it and/or modify it under the
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5001
diff changeset
     7
# terms of the GNU Lesser General Public License as published by the Free
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5001
diff changeset
     8
# Software Foundation, either version 2.1 of the License, or (at your option)
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5001
diff changeset
     9
# any later version.
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5001
diff changeset
    10
#
5424
8ecbcbff9777 replace logilab-common by CubicWeb in disclaimer
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5421
diff changeset
    11
# CubicWeb is distributed in the hope that it will be useful, but WITHOUT
5421
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5001
diff changeset
    12
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5001
diff changeset
    13
# FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5001
diff changeset
    14
# details.
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5001
diff changeset
    15
#
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5001
diff changeset
    16
# You should have received a copy of the GNU Lesser General Public License along
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5001
diff changeset
    17
# with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
5483
1a30c5a56256 merge good/bad versions of imported patches...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5480 5477
diff changeset
    18
"""Set of HTML base actions"""
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    19
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    20
__docformat__ = "restructuredtext en"
2121
9a14e1ee0eab cleanup
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
    21
_ = unicode
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    22
4932
dce5ebe5d598 add missing warn imports
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4583
diff changeset
    23
from warnings import warn
dce5ebe5d598 add missing warn imports
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4583
diff changeset
    24
5483
1a30c5a56256 merge good/bad versions of imported patches...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5480 5477
diff changeset
    25
from logilab.mtconverter import xml_escape
8190
2a3c1b787688 [vreg] move base registry implementation to logilab.common. Closes #1916014
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 8128
diff changeset
    26
from logilab.common.registry import objectify_predicate, yes
5483
1a30c5a56256 merge good/bad versions of imported patches...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5480 5477
diff changeset
    27
4412
eaff00ef0a71 add action to list entities of the CWEType currently displayed
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 4320
diff changeset
    28
from cubicweb.schema import display_name
8190
2a3c1b787688 [vreg] move base registry implementation to logilab.common. Closes #1916014
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 8128
diff changeset
    29
from cubicweb.predicates import (EntityPredicate,
4320
4efd4c306746 closes #345410: two_lines_rset, two_cols_rset, two_etypes_rset are badly named
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4252
diff changeset
    30
    one_line_rset, multi_lines_rset, one_etype_rset, relation_possible,
7100
0f02ad198c1b [schema views] don't propose 'view all' action for final entity types (closes #1560549)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6961
diff changeset
    31
    nonempty_rset, non_final_entity, score_entity,
631
99f5852f8604 major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents: 554
diff changeset
    32
    authenticated_user, match_user_groups, match_search_state,
5877
0c7b7b76a84f [selectors] provide a new, optimized, is_instance selector that should at some point replace implements (along with the adaptable selector)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5811
diff changeset
    33
    has_permission, has_add_permission, is_instance, debug_mode,
631
99f5852f8604 major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents: 554
diff changeset
    34
    )
8665
e65af61bde7d [uicfg] uicfg.py moves from web/ to web/views/ (prepares #2406609)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8306
diff changeset
    35
from cubicweb.web import controller, action
e65af61bde7d [uicfg] uicfg.py moves from web/ to web/views/ (prepares #2406609)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8306
diff changeset
    36
from cubicweb.web.views import uicfg, linksearch_select_url, vid_from_rset
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    37
1178
8d9b705168d3 actions specific selector
sylvain.thenault@logilab.fr
parents: 1132
diff changeset
    38
8190
2a3c1b787688 [vreg] move base registry implementation to logilab.common. Closes #1916014
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 8128
diff changeset
    39
class has_editable_relation(EntityPredicate):
1178
8d9b705168d3 actions specific selector
sylvain.thenault@logilab.fr
parents: 1132
diff changeset
    40
    """accept if some relations for an entity found in the result set is
8d9b705168d3 actions specific selector
sylvain.thenault@logilab.fr
parents: 1132
diff changeset
    41
    editable by the logged user.
8d9b705168d3 actions specific selector
sylvain.thenault@logilab.fr
parents: 1132
diff changeset
    42
8190
2a3c1b787688 [vreg] move base registry implementation to logilab.common. Closes #1916014
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 8128
diff changeset
    43
    See `EntityPredicate` documentation for behaviour when row is not specified.
1178
8d9b705168d3 actions specific selector
sylvain.thenault@logilab.fr
parents: 1132
diff changeset
    44
    """
1452
546b9884d92c delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    45
1178
8d9b705168d3 actions specific selector
sylvain.thenault@logilab.fr
parents: 1132
diff changeset
    46
    def score_entity(self, entity):
8d9b705168d3 actions specific selector
sylvain.thenault@logilab.fr
parents: 1132
diff changeset
    47
        # if user has no update right but it can modify some relation,
8d9b705168d3 actions specific selector
sylvain.thenault@logilab.fr
parents: 1132
diff changeset
    48
        # display action anyway
3504
aadeab85af7c bad merge
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3503
diff changeset
    49
        form = entity._cw.vreg['forms'].select('edition', entity._cw,
6691
17208a358bb1 [action] set mainform=False to ensure we don't consume previously posted form validation errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6459
diff changeset
    50
                                               entity=entity, mainform=False)
3476
6e927b729ae1 [uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3451
diff changeset
    51
        for dummy in form.editable_relations():
1178
8d9b705168d3 actions specific selector
sylvain.thenault@logilab.fr
parents: 1132
diff changeset
    52
            return 1
7990
a673d1d9a738 [diet] drop pre 3.6 API compatibility (but attempt to keep data cmopatibility). Closes #2017916
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7953
diff changeset
    53
        editableattrs = form.editable_attributes(strict=True)
3730
d6f95bd1032d editable-attributes return a list of 2-uple
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3720
diff changeset
    54
        for rschema, role in editableattrs:
6363
b9ec8ebc187a [web action] has_editable_relations should not filter out final relations, fix regression introduced in 6358:22c95c5ef12d
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6358
diff changeset
    55
            return 1
1178
8d9b705168d3 actions specific selector
sylvain.thenault@logilab.fr
parents: 1132
diff changeset
    56
        return 0
8d9b705168d3 actions specific selector
sylvain.thenault@logilab.fr
parents: 1132
diff changeset
    57
8190
2a3c1b787688 [vreg] move base registry implementation to logilab.common. Closes #1916014
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 8128
diff changeset
    58
@objectify_predicate
2161
200481e7b156 prepare time where it won't be mandatory to give rset to select()
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2121
diff changeset
    59
def match_searched_etype(cls, req, rset=None, **kwargs):
631
99f5852f8604 major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents: 554
diff changeset
    60
    return req.match_search_state(rset)
99f5852f8604 major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents: 554
diff changeset
    61
8190
2a3c1b787688 [vreg] move base registry implementation to logilab.common. Closes #1916014
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 8128
diff changeset
    62
@objectify_predicate
2161
200481e7b156 prepare time where it won't be mandatory to give rset to select()
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2121
diff changeset
    63
def view_is_not_default_view(cls, req, rset=None, **kwargs):
631
99f5852f8604 major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents: 554
diff changeset
    64
    # interesting if it propose another view than the current one
99f5852f8604 major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents: 554
diff changeset
    65
    vid = req.form.get('vid')
3451
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3377
diff changeset
    66
    if vid and vid != vid_from_rset(req, rset, req.vreg.schema):
631
99f5852f8604 major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents: 554
diff changeset
    67
        return 1
99f5852f8604 major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents: 554
diff changeset
    68
    return 0
99f5852f8604 major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents: 554
diff changeset
    69
8190
2a3c1b787688 [vreg] move base registry implementation to logilab.common. Closes #1916014
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 8128
diff changeset
    70
@objectify_predicate
2161
200481e7b156 prepare time where it won't be mandatory to give rset to select()
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2121
diff changeset
    71
def addable_etype_empty_rset(cls, req, rset=None, **kwargs):
631
99f5852f8604 major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents: 554
diff changeset
    72
    if rset is not None and not rset.rowcount:
99f5852f8604 major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents: 554
diff changeset
    73
        rqlst = rset.syntax_tree()
99f5852f8604 major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents: 554
diff changeset
    74
        if len(rqlst.children) > 1:
99f5852f8604 major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents: 554
diff changeset
    75
            return 0
99f5852f8604 major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents: 554
diff changeset
    76
        select = rqlst.children[0]
99f5852f8604 major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents: 554
diff changeset
    77
        if len(select.defined_vars) == 1 and len(select.solutions) == 1:
99f5852f8604 major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents: 554
diff changeset
    78
            rset._searched_etype = select.solutions[0].itervalues().next()
4087
2b8bc4cfd6ee api update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3890
diff changeset
    79
            eschema = req.vreg.schema.eschema(rset._searched_etype)
3689
deb13e88e037 follow yams 0.25 api changes to improve performance
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3495
diff changeset
    80
            if not (eschema.final or eschema.is_subobject(strict=True)) \
631
99f5852f8604 major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents: 554
diff changeset
    81
                   and eschema.has_perm(req, 'add'):
99f5852f8604 major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents: 554
diff changeset
    82
                return 1
99f5852f8604 major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents: 554
diff changeset
    83
    return 0
99f5852f8604 major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents: 554
diff changeset
    84
8267
486386d9f836 [web] Exposes the undo feature to user through a undo-history view (closes #893940)
Anthony Truchet <anthony.truchet@logilab.fr>
parents: 8190
diff changeset
    85
class has_undoable_transactions(EntityPredicate):
486386d9f836 [web] Exposes the undo feature to user through a undo-history view (closes #893940)
Anthony Truchet <anthony.truchet@logilab.fr>
parents: 8190
diff changeset
    86
    "Select entities having public (i.e. end-user) undoable transactions."
486386d9f836 [web] Exposes the undo feature to user through a undo-history view (closes #893940)
Anthony Truchet <anthony.truchet@logilab.fr>
parents: 8190
diff changeset
    87
486386d9f836 [web] Exposes the undo feature to user through a undo-history view (closes #893940)
Anthony Truchet <anthony.truchet@logilab.fr>
parents: 8190
diff changeset
    88
    def score_entity(self, entity):
8306
4da49700b06a [config, undo] Fix undo-support option migration
Anthony Truchet <anthony.truchet@logilab.fr>
parents: 8267
diff changeset
    89
        if not entity._cw.vreg.config['undo-enabled']:
8267
486386d9f836 [web] Exposes the undo feature to user through a undo-history view (closes #893940)
Anthony Truchet <anthony.truchet@logilab.fr>
parents: 8190
diff changeset
    90
            return 0
486386d9f836 [web] Exposes the undo feature to user through a undo-history view (closes #893940)
Anthony Truchet <anthony.truchet@logilab.fr>
parents: 8190
diff changeset
    91
        if entity._cw.cnx.undoable_transactions(eid=entity.eid):
486386d9f836 [web] Exposes the undo feature to user through a undo-history view (closes #893940)
Anthony Truchet <anthony.truchet@logilab.fr>
parents: 8190
diff changeset
    92
            return 1
486386d9f836 [web] Exposes the undo feature to user through a undo-history view (closes #893940)
Anthony Truchet <anthony.truchet@logilab.fr>
parents: 8190
diff changeset
    93
        else:
486386d9f836 [web] Exposes the undo feature to user through a undo-history view (closes #893940)
Anthony Truchet <anthony.truchet@logilab.fr>
parents: 8190
diff changeset
    94
            return 0
486386d9f836 [web] Exposes the undo feature to user through a undo-history view (closes #893940)
Anthony Truchet <anthony.truchet@logilab.fr>
parents: 8190
diff changeset
    95
486386d9f836 [web] Exposes the undo feature to user through a undo-history view (closes #893940)
Anthony Truchet <anthony.truchet@logilab.fr>
parents: 8190
diff changeset
    96
2470
569d6641f08c cleanup
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2439
diff changeset
    97
# generic 'main' actions #######################################################
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    98
3484
52e6c8d62ac6 fix some actions selectors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3481
diff changeset
    99
class SelectAction(action.Action):
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   100
    """base class for link search actions. By default apply on
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   101
    any size entity result search it the current state is 'linksearch'
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   102
    if accept match.
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   103
    """
3377
dd9d292b6a6d use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3293
diff changeset
   104
    __regid__ = 'select'
3484
52e6c8d62ac6 fix some actions selectors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3481
diff changeset
   105
    __select__ = (match_search_state('linksearch') & nonempty_rset()
52e6c8d62ac6 fix some actions selectors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3481
diff changeset
   106
                  & match_searched_etype())
1452
546b9884d92c delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   107
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   108
    title = _('select')
1452
546b9884d92c delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   109
    category = 'mainactions'
631
99f5852f8604 major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents: 554
diff changeset
   110
    order = 0
1452
546b9884d92c delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   111
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   112
    def url(self):
3451
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3377
diff changeset
   113
        return linksearch_select_url(self._cw, self.cw_rset)
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   114
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   115
3484
52e6c8d62ac6 fix some actions selectors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3481
diff changeset
   116
class CancelSelectAction(action.Action):
3377
dd9d292b6a6d use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3293
diff changeset
   117
    __regid__ = 'cancel'
707
21a59b468f1a __selectors__ -> __select__
sylvain.thenault@logilab.fr
parents: 696
diff changeset
   118
    __select__ = match_search_state('linksearch')
1452
546b9884d92c delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   119
631
99f5852f8604 major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents: 554
diff changeset
   120
    title = _('cancel select')
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   121
    category = 'mainactions'
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   122
    order = 10
1452
546b9884d92c delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   123
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   124
    def url(self):
3451
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3377
diff changeset
   125
        target, eid, r_type, searched_type = self._cw.search_state[1]
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3377
diff changeset
   126
        return self._cw.build_url(str(eid),
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3377
diff changeset
   127
                                  vid='edition', __mode='normal')
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   128
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   129
3484
52e6c8d62ac6 fix some actions selectors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3481
diff changeset
   130
class ViewAction(action.Action):
3377
dd9d292b6a6d use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3293
diff changeset
   131
    __regid__ = 'view'
3484
52e6c8d62ac6 fix some actions selectors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3481
diff changeset
   132
    __select__ = (action.Action.__select__ &
707
21a59b468f1a __selectors__ -> __select__
sylvain.thenault@logilab.fr
parents: 696
diff changeset
   133
                  match_user_groups('users', 'managers') &
1452
546b9884d92c delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   134
                  view_is_not_default_view() &
707
21a59b468f1a __selectors__ -> __select__
sylvain.thenault@logilab.fr
parents: 696
diff changeset
   135
                  non_final_entity())
1452
546b9884d92c delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   136
631
99f5852f8604 major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents: 554
diff changeset
   137
    title = _('view')
1452
546b9884d92c delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   138
    category = 'mainactions'
631
99f5852f8604 major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents: 554
diff changeset
   139
    order = 0
1452
546b9884d92c delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   140
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   141
    def url(self):
3451
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3377
diff changeset
   142
        params = self._cw.form.copy()
2701
afcc19c92072 fix #344895: view action should skip navigation parameters
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2161
diff changeset
   143
        for param in ('vid', '__message') + controller.NAV_FORM_PARAMETERS:
afcc19c92072 fix #344895: view action should skip navigation parameters
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2161
diff changeset
   144
            params.pop(param, None)
8128
0a927fe4541b [controllers] deprecate JSonController and implement AjaxController / ajax-func registry (closes #2110265)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 7990
diff changeset
   145
        if self._cw.ajax_request:
7744
bb956f43e8d4 closes #1901436: view/modify action in table don't work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7100
diff changeset
   146
            path = 'view'
bb956f43e8d4 closes #1901436: view/modify action in table don't work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7100
diff changeset
   147
            if self.cw_rset is not None:
bb956f43e8d4 closes #1901436: view/modify action in table don't work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7100
diff changeset
   148
                params = {'rql': self.cw_rset.printable_rql()}
bb956f43e8d4 closes #1901436: view/modify action in table don't work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7100
diff changeset
   149
        else:
bb956f43e8d4 closes #1901436: view/modify action in table don't work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7100
diff changeset
   150
            path = self._cw.relative_path(includeparams=False)
bb956f43e8d4 closes #1901436: view/modify action in table don't work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7100
diff changeset
   151
        return self._cw.build_url(path, **params)
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   152
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   153
3484
52e6c8d62ac6 fix some actions selectors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3481
diff changeset
   154
class ModifyAction(action.Action):
3377
dd9d292b6a6d use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3293
diff changeset
   155
    __regid__ = 'edit'
6358
22c95c5ef12d [web action] has_permission_update checked implicitly by has_editable_relation, don't check it twice
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6177
diff changeset
   156
    __select__ = (action.Action.__select__
7947
64719f6933d4 [action] has_editable_relation first argument is once_is_enough flag, not an action name
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7806
diff changeset
   157
                  & one_line_rset() & has_editable_relation())
1452
546b9884d92c delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   158
631
99f5852f8604 major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents: 554
diff changeset
   159
    title = _('modify')
99f5852f8604 major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents: 554
diff changeset
   160
    category = 'mainactions'
99f5852f8604 major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents: 554
diff changeset
   161
    order = 10
0
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
    def url(self):
3451
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3377
diff changeset
   164
        entity = self.cw_rset.get_entity(self.cw_row or 0, self.cw_col or 0)
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   165
        return entity.absolute_url(vid='edition')
1452
546b9884d92c delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   166
401
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   167
3484
52e6c8d62ac6 fix some actions selectors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3481
diff changeset
   168
class MultipleEditAction(action.Action):
3377
dd9d292b6a6d use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3293
diff changeset
   169
    __regid__ = 'muledit' # XXX get strange conflicts if id='edit'
4320
4efd4c306746 closes #345410: two_lines_rset, two_cols_rset, two_etypes_rset are badly named
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4252
diff changeset
   170
    __select__ = (action.Action.__select__ & multi_lines_rset() &
3484
52e6c8d62ac6 fix some actions selectors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3481
diff changeset
   171
                  one_etype_rset() & has_permission('update'))
631
99f5852f8604 major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents: 554
diff changeset
   172
99f5852f8604 major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents: 554
diff changeset
   173
    title = _('modify')
401
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   174
    category = 'mainactions'
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   175
    order = 10
1452
546b9884d92c delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   176
401
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   177
    def url(self):
7744
bb956f43e8d4 closes #1901436: view/modify action in table don't work
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7100
diff changeset
   178
        return self._cw.build_url('view', rql=self.cw_rset.printable_rql(), vid='muledit')
401
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   179
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   180
2470
569d6641f08c cleanup
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2439
diff changeset
   181
# generic "more" actions #######################################################
401
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   182
3484
52e6c8d62ac6 fix some actions selectors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3481
diff changeset
   183
class ManagePermissionsAction(action.Action):
3377
dd9d292b6a6d use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3293
diff changeset
   184
    __regid__ = 'managepermission'
3484
52e6c8d62ac6 fix some actions selectors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3481
diff changeset
   185
    __select__ = (action.Action.__select__ & one_line_rset() &
52e6c8d62ac6 fix some actions selectors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3481
diff changeset
   186
                  non_final_entity() & match_user_groups('managers'))
631
99f5852f8604 major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents: 554
diff changeset
   187
401
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   188
    title = _('manage permissions')
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   189
    category = 'moreactions'
1551
a41c1c0a9e13 fix manage permission order
sylvain.thenault@logilab.fr
parents: 1545
diff changeset
   190
    order = 15
401
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   191
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   192
    def url(self):
3451
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3377
diff changeset
   193
        return self.cw_rset.get_entity(self.cw_row or 0, self.cw_col or 0).absolute_url(vid='security')
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   194
1452
546b9884d92c delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   195
3484
52e6c8d62ac6 fix some actions selectors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3481
diff changeset
   196
class DeleteAction(action.Action):
3377
dd9d292b6a6d use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3293
diff changeset
   197
    __regid__ = 'delete'
3484
52e6c8d62ac6 fix some actions selectors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3481
diff changeset
   198
    __select__ = action.Action.__select__ & has_permission('delete')
1452
546b9884d92c delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   199
631
99f5852f8604 major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents: 554
diff changeset
   200
    title = _('delete')
1452
546b9884d92c delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   201
    category = 'moreactions'
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   202
    order = 20
1452
546b9884d92c delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   203
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   204
    def url(self):
3451
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3377
diff changeset
   205
        if len(self.cw_rset) == 1:
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3377
diff changeset
   206
            entity = self.cw_rset.get_entity(self.cw_row or 0, self.cw_col or 0)
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3377
diff changeset
   207
            return self._cw.build_url(entity.rest_path(), vid='deleteconf')
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3377
diff changeset
   208
        return self._cw.build_url(rql=self.cw_rset.printable_rql(), vid='deleteconf')
1452
546b9884d92c delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   209
546b9884d92c delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   210
3484
52e6c8d62ac6 fix some actions selectors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3481
diff changeset
   211
class CopyAction(action.Action):
3377
dd9d292b6a6d use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3293
diff changeset
   212
    __regid__ = 'copy'
3484
52e6c8d62ac6 fix some actions selectors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3481
diff changeset
   213
    __select__ = (action.Action.__select__ & one_line_rset()
52e6c8d62ac6 fix some actions selectors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3481
diff changeset
   214
                  & has_permission('add'))
1452
546b9884d92c delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   215
631
99f5852f8604 major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents: 554
diff changeset
   216
    title = _('copy')
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   217
    category = 'moreactions'
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   218
    order = 30
1452
546b9884d92c delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   219
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   220
    def url(self):
3451
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3377
diff changeset
   221
        entity = self.cw_rset.get_entity(self.cw_row or 0, self.cw_col or 0)
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   222
        return entity.absolute_url(vid='copy')
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   223
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
class AddNewAction(MultipleEditAction):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   226
    """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
   227
    add a new one
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   228
    """
3377
dd9d292b6a6d use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3293
diff changeset
   229
    __regid__ = 'addentity'
3484
52e6c8d62ac6 fix some actions selectors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3481
diff changeset
   230
    __select__ = (action.Action.__select__ &
707
21a59b468f1a __selectors__ -> __select__
sylvain.thenault@logilab.fr
parents: 696
diff changeset
   231
                  (addable_etype_empty_rset()
4462
c57c8176b8c2 reorganize, cleanup and properly document base selectors. Kill the may_add_relation selector.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4419
diff changeset
   232
                   | (multi_lines_rset() & one_etype_rset() & has_add_permission()))
707
21a59b468f1a __selectors__ -> __select__
sylvain.thenault@logilab.fr
parents: 696
diff changeset
   233
                  )
631
99f5852f8604 major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents: 554
diff changeset
   234
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   235
    category = 'moreactions'
401
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   236
    order = 40
1452
546b9884d92c delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   237
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   238
    @property
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   239
    def rsettype(self):
3451
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3377
diff changeset
   240
        if self.cw_rset:
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3377
diff changeset
   241
            return self.cw_rset.description[0][0]
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3377
diff changeset
   242
        return self.cw_rset._searched_etype
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   243
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   244
    @property
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   245
    def title(self):
3451
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3377
diff changeset
   246
        return self._cw.__('add a %s' % self.rsettype) # generated msgid
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   247
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   248
    def url(self):
7806
aa30c665bd06 [refactoring] introduce add_etype_button function to properly create button to add a new entity
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7782
diff changeset
   249
        return self._cw.vreg["etypes"].etype_class(self.rsettype).cw_create_url(self._cw)
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   250
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   251
3484
52e6c8d62ac6 fix some actions selectors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3481
diff changeset
   252
class AddRelatedActions(action.Action):
3219
be8cfc00ae04 edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2715
diff changeset
   253
    """fill 'addrelated' sub-menu of the actions box"""
3377
dd9d292b6a6d use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3293
diff changeset
   254
    __regid__ = 'addrelated'
3504
aadeab85af7c bad merge
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3503
diff changeset
   255
    __select__ = action.Action.__select__ & one_line_rset() & non_final_entity()
3219
be8cfc00ae04 edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2715
diff changeset
   256
be8cfc00ae04 edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2715
diff changeset
   257
    submenu = _('addrelated')
5241
1460d69672bc [test] fix unittest_viewselector
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5001
diff changeset
   258
    order = 17
3219
be8cfc00ae04 edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2715
diff changeset
   259
be8cfc00ae04 edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2715
diff changeset
   260
    def fill_menu(self, box, menu):
be8cfc00ae04 edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2715
diff changeset
   261
        # when there is only one item in the sub-menu, replace the sub-menu by
be8cfc00ae04 edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2715
diff changeset
   262
        # item's title prefixed by 'add'
3451
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3377
diff changeset
   263
        menu.label_prefix = self._cw._('add')
3228
7b05b2709439 [actions] refactor: extract actual_actions from fill_menu to work with table filter form
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3219
diff changeset
   264
        super(AddRelatedActions, self).fill_menu(box, menu)
7b05b2709439 [actions] refactor: extract actual_actions from fill_menu to work with table filter form
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3219
diff changeset
   265
5745
d532fe79800b [linkto action] refactor to ease overriding to control redirection
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5521
diff changeset
   266
    def redirect_params(self, entity):
d532fe79800b [linkto action] refactor to ease overriding to control redirection
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5521
diff changeset
   267
        return {'__redirectpath': entity.rest_path(), # should not be url quoted!
d532fe79800b [linkto action] refactor to ease overriding to control redirection
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5521
diff changeset
   268
                '__redirectvid': self._cw.form.get('vid', '')}
d532fe79800b [linkto action] refactor to ease overriding to control redirection
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5521
diff changeset
   269
3228
7b05b2709439 [actions] refactor: extract actual_actions from fill_menu to work with table filter form
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3219
diff changeset
   270
    def actual_actions(self):
3451
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3377
diff changeset
   271
        entity = self.cw_rset.get_entity(self.cw_row or 0, self.cw_col or 0)
3219
be8cfc00ae04 edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2715
diff changeset
   272
        eschema = entity.e_schema
5745
d532fe79800b [linkto action] refactor to ease overriding to control redirection
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5521
diff changeset
   273
        params = self.redirect_params(entity)
5521
4c53a0cb186c [actions box] enhance add related menu generation: don't propose to add relation of single cardinality where entity already have the relation set
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5426
diff changeset
   274
        for rschema, teschema, role in self.add_related_schemas(entity):
4c53a0cb186c [actions box] enhance add related menu generation: don't propose to add relation of single cardinality where entity already have the relation set
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5426
diff changeset
   275
            if rschema.role_rdef(eschema, teschema, role).role_cardinality(role) in '1?':
4c53a0cb186c [actions box] enhance add related menu generation: don't propose to add relation of single cardinality where entity already have the relation set
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5426
diff changeset
   276
                if entity.related(rschema, role):
4c53a0cb186c [actions box] enhance add related menu generation: don't propose to add relation of single cardinality where entity already have the relation set
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5426
diff changeset
   277
                    continue
4c53a0cb186c [actions box] enhance add related menu generation: don't propose to add relation of single cardinality where entity already have the relation set
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5426
diff changeset
   278
            if role == 'subject':
4c53a0cb186c [actions box] enhance add related menu generation: don't propose to add relation of single cardinality where entity already have the relation set
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5426
diff changeset
   279
                label = 'add %s %s %s %s' % (eschema, rschema, teschema, role)
5776
e7a88c97fef7 [web actions] fix recent refactoring, leading to missing redirect parameters in action's url
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5745
diff changeset
   280
                url = self.linkto_url(entity, rschema, teschema, 'object', **params)
3219
be8cfc00ae04 edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2715
diff changeset
   281
            else:
5521
4c53a0cb186c [actions box] enhance add related menu generation: don't propose to add relation of single cardinality where entity already have the relation set
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5426
diff changeset
   282
                label = 'add %s %s %s %s' % (teschema, rschema, eschema, role)
5776
e7a88c97fef7 [web actions] fix recent refactoring, leading to missing redirect parameters in action's url
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5745
diff changeset
   283
                url = self.linkto_url(entity, rschema, teschema, 'subject', **params)
e7a88c97fef7 [web actions] fix recent refactoring, leading to missing redirect parameters in action's url
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5745
diff changeset
   284
            yield self.build_action(self._cw._(label), url)
3219
be8cfc00ae04 edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2715
diff changeset
   285
be8cfc00ae04 edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2715
diff changeset
   286
    def add_related_schemas(self, entity):
be8cfc00ae04 edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2715
diff changeset
   287
        """this is actually used ui method to generate 'addrelated' actions from
be8cfc00ae04 edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2715
diff changeset
   288
        the schema.
be8cfc00ae04 edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2715
diff changeset
   289
be8cfc00ae04 edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2715
diff changeset
   290
        If you don't want any auto-generated actions, you should overrides this
be8cfc00ae04 edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2715
diff changeset
   291
        method to return an empty list. If you only want some, you can configure
be8cfc00ae04 edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2715
diff changeset
   292
        them by using uicfg.actionbox_appearsin_addmenu
be8cfc00ae04 edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2715
diff changeset
   293
        """
8666
1dd655788ece make ui configurations selectable (closes #2406609)
Florent Cayré <florent.cayre@logilab.fr>
parents: 8665
diff changeset
   294
        appearsin_addmenu = self._cw.vreg['uicfg'].select(
1dd655788ece make ui configurations selectable (closes #2406609)
Florent Cayré <florent.cayre@logilab.fr>
parents: 8665
diff changeset
   295
            'actionbox_appearsin_addmenu', self._cw, entity=entity)
3451
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3377
diff changeset
   296
        req = self._cw
3219
be8cfc00ae04 edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2715
diff changeset
   297
        eschema = entity.e_schema
be8cfc00ae04 edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2715
diff changeset
   298
        for role, rschemas in (('subject', eschema.subject_relations()),
be8cfc00ae04 edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2715
diff changeset
   299
                               ('object', eschema.object_relations())):
be8cfc00ae04 edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2715
diff changeset
   300
            for rschema in rschemas:
3689
deb13e88e037 follow yams 0.25 api changes to improve performance
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3495
diff changeset
   301
                if rschema.final:
3219
be8cfc00ae04 edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2715
diff changeset
   302
                    continue
be8cfc00ae04 edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2715
diff changeset
   303
                for teschema in rschema.targets(eschema, role):
be8cfc00ae04 edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2715
diff changeset
   304
                    if not appearsin_addmenu.etype_get(eschema, rschema,
be8cfc00ae04 edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2715
diff changeset
   305
                                                       role, teschema):
be8cfc00ae04 edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2715
diff changeset
   306
                        continue
3877
7ca53fc72a0a reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3689
diff changeset
   307
                    rdef = rschema.role_rdef(eschema, teschema, role)
7ca53fc72a0a reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3689
diff changeset
   308
                    # check the relation can be added
7ca53fc72a0a reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3689
diff changeset
   309
                    # XXX consider autoform_permissions_overrides?
7ca53fc72a0a reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3689
diff changeset
   310
                    if role == 'subject'and not rdef.has_perm(
7ca53fc72a0a reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3689
diff changeset
   311
                        req, 'add', fromeid=entity.eid):
7ca53fc72a0a reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3689
diff changeset
   312
                        continue
7ca53fc72a0a reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3689
diff changeset
   313
                    if role == 'object'and not rdef.has_perm(
7ca53fc72a0a reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3689
diff changeset
   314
                        req, 'add', toeid=entity.eid):
7ca53fc72a0a reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3689
diff changeset
   315
                        continue
7ca53fc72a0a reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3689
diff changeset
   316
                    # check the target types can be added as well
7ca53fc72a0a reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3689
diff changeset
   317
                    if teschema.may_have_permission('add', req):
3219
be8cfc00ae04 edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2715
diff changeset
   318
                        yield rschema, teschema, role
be8cfc00ae04 edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2715
diff changeset
   319
5745
d532fe79800b [linkto action] refactor to ease overriding to control redirection
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5521
diff changeset
   320
    def linkto_url(self, entity, rtype, etype, target, **kwargs):
7806
aa30c665bd06 [refactoring] introduce add_etype_button function to properly create button to add a new entity
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7782
diff changeset
   321
        return self._cw.vreg["etypes"].etype_class(etype).cw_create_url(
aa30c665bd06 [refactoring] introduce add_etype_button function to properly create button to add a new entity
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7782
diff changeset
   322
                self._cw, __linkto='%s:%s:%s' % (rtype, entity.eid, target),
aa30c665bd06 [refactoring] introduce add_etype_button function to properly create button to add a new entity
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7782
diff changeset
   323
                **kwargs)
3219
be8cfc00ae04 edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2715
diff changeset
   324
be8cfc00ae04 edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2715
diff changeset
   325
4413
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 4412
diff changeset
   326
class ViewSameCWEType(action.Action):
4412
eaff00ef0a71 add action to list entities of the CWEType currently displayed
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 4320
diff changeset
   327
    """when displaying the schema of a CWEType, offer to list entities of that type
eaff00ef0a71 add action to list entities of the CWEType currently displayed
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 4320
diff changeset
   328
    """
4413
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 4412
diff changeset
   329
    __regid__ = 'entitiesoftype'
7100
0f02ad198c1b [schema views] don't propose 'view all' action for final entity types (closes #1560549)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6961
diff changeset
   330
    __select__ = one_line_rset() & is_instance('CWEType') & score_entity(lambda x: not x.final)
4412
eaff00ef0a71 add action to list entities of the CWEType currently displayed
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 4320
diff changeset
   331
    category = 'mainactions'
eaff00ef0a71 add action to list entities of the CWEType currently displayed
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 4320
diff changeset
   332
    order = 40
eaff00ef0a71 add action to list entities of the CWEType currently displayed
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 4320
diff changeset
   333
eaff00ef0a71 add action to list entities of the CWEType currently displayed
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 4320
diff changeset
   334
    @property
eaff00ef0a71 add action to list entities of the CWEType currently displayed
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 4320
diff changeset
   335
    def etype(self):
4419
1f777d13a76b refactor to use the 3.6 API
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 4413
diff changeset
   336
        return self.cw_rset.get_entity(0,0).name
4412
eaff00ef0a71 add action to list entities of the CWEType currently displayed
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 4320
diff changeset
   337
eaff00ef0a71 add action to list entities of the CWEType currently displayed
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 4320
diff changeset
   338
    @property
eaff00ef0a71 add action to list entities of the CWEType currently displayed
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 4320
diff changeset
   339
    def title(self):
4419
1f777d13a76b refactor to use the 3.6 API
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 4413
diff changeset
   340
        return self._cw.__('view all %s') % display_name(self._cw, self.etype, 'plural').lower()
4412
eaff00ef0a71 add action to list entities of the CWEType currently displayed
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 4320
diff changeset
   341
eaff00ef0a71 add action to list entities of the CWEType currently displayed
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 4320
diff changeset
   342
    def url(self):
4419
1f777d13a76b refactor to use the 3.6 API
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 4413
diff changeset
   343
        return self._cw.build_url(self.etype)
4412
eaff00ef0a71 add action to list entities of the CWEType currently displayed
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 4320
diff changeset
   344
401
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   345
# logged user actions #########################################################
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   346
3504
aadeab85af7c bad merge
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3503
diff changeset
   347
class UserPreferencesAction(action.Action):
3377
dd9d292b6a6d use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3293
diff changeset
   348
    __regid__ = 'myprefs'
707
21a59b468f1a __selectors__ -> __select__
sylvain.thenault@logilab.fr
parents: 696
diff changeset
   349
    __select__ = authenticated_user()
1452
546b9884d92c delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   350
631
99f5852f8604 major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents: 554
diff changeset
   351
    title = _('user preferences')
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   352
    category = 'useractions'
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   353
    order = 10
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   354
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   355
    def url(self):
3451
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3377
diff changeset
   356
        return self._cw.build_url(self.__regid__)
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   357
401
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   358
3504
aadeab85af7c bad merge
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3503
diff changeset
   359
class UserInfoAction(action.Action):
3377
dd9d292b6a6d use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3293
diff changeset
   360
    __regid__ = 'myinfos'
707
21a59b468f1a __selectors__ -> __select__
sylvain.thenault@logilab.fr
parents: 696
diff changeset
   361
    __select__ = authenticated_user()
1452
546b9884d92c delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   362
6177
76aaca285e07 [views] rename Edition to Modification and personal information to profile
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 5963
diff changeset
   363
    title = _('profile')
401
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   364
    category = 'useractions'
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   365
    order = 20
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   366
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   367
    def url(self):
3451
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3377
diff changeset
   368
        return self._cw.build_url('cwuser/%s'%self._cw.user.login, vid='edition')
401
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   369
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   370
3504
aadeab85af7c bad merge
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3503
diff changeset
   371
class LogoutAction(action.Action):
3377
dd9d292b6a6d use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3293
diff changeset
   372
    __regid__ = 'logout'
707
21a59b468f1a __selectors__ -> __select__
sylvain.thenault@logilab.fr
parents: 696
diff changeset
   373
    __select__ = authenticated_user()
1452
546b9884d92c delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   374
631
99f5852f8604 major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents: 554
diff changeset
   375
    title = _('logout')
401
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   376
    category = 'useractions'
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   377
    order = 30
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   378
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   379
    def url(self):
3451
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3377
diff changeset
   380
        return self._cw.build_url(self.__regid__)
401
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   381
1452
546b9884d92c delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   382
401
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   383
# site actions ################################################################
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   384
3504
aadeab85af7c bad merge
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3503
diff changeset
   385
class ManagersAction(action.Action):
631
99f5852f8604 major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents: 554
diff changeset
   386
    __abstract__ = True
707
21a59b468f1a __selectors__ -> __select__
sylvain.thenault@logilab.fr
parents: 696
diff changeset
   387
    __select__ = match_user_groups('managers')
631
99f5852f8604 major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents: 554
diff changeset
   388
401
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   389
    category = 'siteactions'
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   390
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   391
    def url(self):
3451
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3377
diff changeset
   392
        return self._cw.build_url(self.__regid__)
401
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   393
1452
546b9884d92c delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   394
401
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   395
class SiteConfigurationAction(ManagersAction):
3377
dd9d292b6a6d use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3293
diff changeset
   396
    __regid__ = 'siteconfig'
401
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   397
    title = _('site configuration')
631
99f5852f8604 major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents: 554
diff changeset
   398
    order = 10
6961
686c59dfc401 [manage view] cleanup manage view and user menu
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6691
diff changeset
   399
    category = 'manage'
401
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   400
1452
546b9884d92c delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   401
401
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   402
class ManageAction(ManagersAction):
3377
dd9d292b6a6d use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3293
diff changeset
   403
    __regid__ = 'manage'
401
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   404
    title = _('manage')
631
99f5852f8604 major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents: 554
diff changeset
   405
    order = 20
401
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   406
bc55a104d636 cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents: 328
diff changeset
   407
3504
aadeab85af7c bad merge
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3503
diff changeset
   408
# footer actions ###############################################################
aadeab85af7c bad merge
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3503
diff changeset
   409
aadeab85af7c bad merge
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3503
diff changeset
   410
class PoweredByAction(action.Action):
3645
7272b793d7c9 3.6 updates
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3504
diff changeset
   411
    __regid__ = 'poweredby'
3495
438576c5b1d1 [ui] turn footer items into actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3272
diff changeset
   412
    __select__ = yes()
438576c5b1d1 [ui] turn footer items into actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3272
diff changeset
   413
438576c5b1d1 [ui] turn footer items into actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3272
diff changeset
   414
    category = 'footer'
438576c5b1d1 [ui] turn footer items into actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3272
diff changeset
   415
    order = 3
6459
7f46ec158c48 [i18n] uniformize footer capitalization
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6363
diff changeset
   416
    title = _('Powered by CubicWeb')
3495
438576c5b1d1 [ui] turn footer items into actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3272
diff changeset
   417
438576c5b1d1 [ui] turn footer items into actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3272
diff changeset
   418
    def url(self):
438576c5b1d1 [ui] turn footer items into actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3272
diff changeset
   419
        return 'http://www.cubicweb.org'
438576c5b1d1 [ui] turn footer items into actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3272
diff changeset
   420
5477
f79c39be0b9b [css] introducing scale and rhythm composition
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 5426
diff changeset
   421
class GotRhythmAction(action.Action):
f79c39be0b9b [css] introducing scale and rhythm composition
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 5426
diff changeset
   422
    __regid__ = 'rhythm'
5480
2d5c46e78ae9 [css] introducing scale and rhythm composition
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 5426
diff changeset
   423
    __select__ = debug_mode()
5477
f79c39be0b9b [css] introducing scale and rhythm composition
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 5426
diff changeset
   424
f79c39be0b9b [css] introducing scale and rhythm composition
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 5426
diff changeset
   425
    category = 'footer'
f79c39be0b9b [css] introducing scale and rhythm composition
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 5426
diff changeset
   426
    order = 3
f79c39be0b9b [css] introducing scale and rhythm composition
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 5426
diff changeset
   427
    title = _('Got rhythm?')
f79c39be0b9b [css] introducing scale and rhythm composition
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 5426
diff changeset
   428
f79c39be0b9b [css] introducing scale and rhythm composition
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 5426
diff changeset
   429
    def url(self):
f79c39be0b9b [css] introducing scale and rhythm composition
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 5426
diff changeset
   430
        return xml_escape(self._cw.url()+'#')
f79c39be0b9b [css] introducing scale and rhythm composition
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 5426
diff changeset
   431
f79c39be0b9b [css] introducing scale and rhythm composition
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 5426
diff changeset
   432
    def html_class(self):
f79c39be0b9b [css] introducing scale and rhythm composition
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 5426
diff changeset
   433
        self._cw.add_js('cubicweb.rhythm.js')
f79c39be0b9b [css] introducing scale and rhythm composition
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 5426
diff changeset
   434
        return 'rhythm'
3495
438576c5b1d1 [ui] turn footer items into actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3272
diff changeset
   435
8267
486386d9f836 [web] Exposes the undo feature to user through a undo-history view (closes #893940)
Anthony Truchet <anthony.truchet@logilab.fr>
parents: 8190
diff changeset
   436
2652
3753f3a07ca1 [refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2470
diff changeset
   437
## default actions ui configuration ###########################################
3753f3a07ca1 [refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2470
diff changeset
   438
3753f3a07ca1 [refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2470
diff changeset
   439
addmenu = uicfg.actionbox_appearsin_addmenu
3753f3a07ca1 [refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2470
diff changeset
   440
addmenu.tag_object_of(('*', 'relation_type', 'CWRType'), True)
3753f3a07ca1 [refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2470
diff changeset
   441
addmenu.tag_object_of(('*', 'from_entity', 'CWEType'), False)
3753f3a07ca1 [refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2470
diff changeset
   442
addmenu.tag_object_of(('*', 'to_entity', 'CWEType'), False)
3753f3a07ca1 [refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2470
diff changeset
   443
addmenu.tag_object_of(('*', 'in_group', 'CWGroup'), True)
3753f3a07ca1 [refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2470
diff changeset
   444
addmenu.tag_object_of(('*', 'bookmarked_by', 'CWUser'), True)