Hi,

Will this policy allow a user with TICKET_VIEW_STATUS permission to view 
tickets whose status is TEST? Please have a look at policy below:

# -*- coding: utf-8 -*-
#
# Copyright (C) 2017 Edgewall Software
# All rights reserved.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at http://trac.edgewall.org/wiki/TracLicense.
#
# This software consists of voluntary contributions made by many
# individuals. For the exact contribution history, see the revision
# history and logs, available at http://trac.edgewall.org/log/.

from trac.core import *
from trac.perm import IPermissionPolicy, IPermissionRequestor
from trac.resource import ResourceNotFound
from trac.ticket.model import Ticket


class StatusDeskPolicy(Component):
    """Provides a permission for restricting ticket actions to the
    ticket owner.
    """

    implements(IPermissionPolicy, IPermissionRequestor)

    # IPermissionRequestor methods

    def get_permission_actions(self):
        return ['TICKET_STATUS_VIEW']

    # IPermissionPolicy methods

    def check_permission(self, action, username, resource, perm):
        if username != 'anonymous' and \
                action == 'TICKET_VIEW' and \
                'TICKET_ADMIN' not in perm:
            if 'TICKET_STATUS_VIEW' in perm:
                if resource is None or \
                        resource.realm == 'ticket' and \
                        resource.id is None:
                    return True
                elif resource.realm == 'ticket' and \
                        resource.id is not None:
                    try:
                        ticket = Ticket(self.env, resource.id)
                    except ResourceNotFound:
                        pass
                    else:
                        return ticket['Status'] == test

END OF MESSAGE

Regards,

SF

On Tuesday, May 16, 2017 at 10:02:38 AM UTC+2, RjOllos wrote:
>
>
>
> On Tue, May 16, 2017 at 12:22 AM toto200891 <[email protected] 
> <javascript:>> wrote:
>
>> Hi
>>
>> Same like SupportPolicy, is it possible to restrict the view of tickets 
>> to users based on Ticket status? As in, if there is certain group named 
>> testers, and tickets with being status TESTING, should only be viewed to 
>> testers and they should not be able to see all the new tickets. Is this 
>> possible?
>>
>> Regards,
>> SF
>>
>
> Yes, you can write a permission policy that restricts based on 
> ticket['status'] and req.authname (username).
>
> Examples of permission policies:
>
> https://trac.edgewall.org/wiki/TracDev/PluginDevelopment/ExtensionPoints/trac.perm.IPermissionPolicy
> https://trac.edgewall.org/wiki/CookBook/PermissionPolicies 
>
> - Ryan
>

-- 
You received this message because you are subscribed to the Google Groups "Trac 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/trac-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to