Is it also possible to include the following:

return [ticket['status'], 'username'] in ['test', 'accepted_for_test', 
ticket['reporter'], ticket['owner']]

Such that I could allow a user to view tickets, based on status and also 
the tickets he is been assigned to or he reported?

I tried doing this, but I see that he could not view any tickets now, 
because of the following modification.

regards,

SF

On Friday, May 19, 2017 at 12:28:52 PM UTC+2, toto200891 wrote:
>
> Thank you so much, it worked.
>
> On Friday, May 19, 2017 at 11:16:50 AM UTC+2, Cooke, Mark wrote:
>>
>> > -----Original Message----- 
>> > From: trac-...@googlegroups.com [mailto:trac-...@googlegroups.com] On 
>> > Behalf Of toto200891 
>> > 
>> > Hi, 
>> > 
>> > I was working on ticket view on trac 0.12.7. I had used the following 
>> shown 
>> > plugin to create a permission TICKET_VIEW_STATUS and allow the user to 
>> see 
>> > the tickets with status "test". 
>> > 
>> > # -*- 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_VIEW_STATUS'] 
>> > 
>> > 
>> >     # 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_VIEW_STATUS' 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' 
>> > 
>> > 
>> > Now I would like to add another status to this code like 
>> "Accepted_for_test" 
>> > , for so I just tried changing the last line as follows: 
>> > 
>> > 
>> > return ticket['status']=='test', 'accepted_for_test' 
>>
>> Python allows you to return multiple values, so you have effectively 
>> returned a tuple of a Boolean (the result of the comparison) and a constant 
>> string. 
>>
>> Try something like this: 
>>
>> > return ticket['status'] in ['test', 'accepted_for_test'] 
>>
>> ~ Mark C 
>>
>> > But by doing the following change, Now the user is able to view all 
>> tickets, 
>> > which I was not expecting. Is there any problem with the syntax? or I 
>> am 
>> > missing something? Kindly guide me in this regard. 
>> > 
>> > 
>> > Regards, 
>> > SF 
>> > 
>> > -- 
>> > 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 trac-users+...@googlegroups.com. 
>> > To post to this group, send email to trac-...@googlegroups.com. 
>> > Visit this group at https://groups.google.com/group/trac-users. 
>> > For more options, visit https://groups.google.com/d/optout. 
>>
>>

-- 
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 trac-users+unsubscr...@googlegroups.com.
To post to this group, send email to trac-users@googlegroups.com.
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