@@ -1549,7 +1549,9 @@ shows the use of ``ctx``.
1549
1549
in the query checks above would look like::
1550
1550
1551
1551
def filter_query(db, userid, klass):
1552
- return [{'filterspec': {'private_for': ['-1', userid]}}]
1552
+ return [{'filterspec': {
1553
+ 'private_for': ['-1', userid]
1554
+ }}]
1553
1555
1554
1556
This would be called by the framework for all queries found when
1555
1557
displaying queries. It filters for all queries where the
@@ -1570,10 +1572,11 @@ shows the use of ``ctx``.
1570
1572
"or" condition, the user has access if either the ``private_for``
1571
1573
check passes *or* the user is the creator of the query.
1572
1574
1573
- Now consider an example where we have a class ``organisation`` and the
1574
- ``issue`` class has a ``Link`` to ``organisation`` as has the ``user``
1575
- class. Users may only see issues that belong to their own
1576
- ``organisation``. A ``check`` function for this would be::
1575
+ Consider an example where we have a class structure where both the
1576
+ ``issue`` class and the ``user`` class include a reference to an
1577
+ ``organization`` class. Users are permitted to view only those
1578
+ issues that are associated with their respective organizations. A
1579
+ check function or this could look like::
1577
1580
1578
1581
def view_issue(db, userid, itemid):
1579
1582
user = db.user.getnode(userid)
@@ -1589,7 +1592,9 @@ shows the use of ``ctx``.
1589
1592
user = db.user.getnode(userid)
1590
1593
if not user.organisation:
1591
1594
return []
1592
- return [{'filterspec': {'organisation': user.organisation}}]
1595
+ return [{'filterspec': {
1596
+ 'organisation': user.organisation
1597
+ }}]
1593
1598
1594
1599
This filters for all issues where the organisation is the same as the
1595
1600
organisation of the user. Note how the filter fails early returning an
0 commit comments