custom group for ticket permission

10 views
Skip to first unread message

Jean Marie

unread,
Oct 7, 2008, 8:28:46 AM10/7/08
to Trac Users
Hi trac users,

is it possible to set a user defined group as permision for a ticket
status instead of using the pre-defined permission TICKET_MODIFY. I
want only certain user to perferm certain ticket actions.

I've created a group 'grp_developer' and assigned the developer user
to this group. After this i set the permission TICKET_MODIFY to
'grp_developer'.

And no i want to use the group as a ticket permission.

<blah>.permissions = grp_developer

Thanks for any hints and best regards
Jean Marie

Bas van der Vlies

unread,
Oct 7, 2008, 9:41:57 AM10/7/08
to trac-...@googlegroups.com

Jean Marie

There is a plugin on trac-hacks called unixgroups. So if you installed
trac on a unix/linux box you can use it.

I have made a patch for it so it can handle sites that have a centralized
user administration which have many groups. If you want it i can email it
to you.


Regards

--
********************************************************************
* Bas van der Vlies e-mail: ba...@sara.nl *
* SARA - Academic Computing Services Amsterdam, The Netherlands *
********************************************************************

Rainer Sokoll

unread,
Oct 7, 2008, 9:48:32 AM10/7/08
to trac-...@googlegroups.com
On Tue, Oct 07, 2008 at 05:28:46AM -0700, Jean Marie wrote:

> is it possible to set a user defined group as permision for a ticket
> status instead of using the pre-defined permission TICKET_MODIFY. I
> want only certain user to perferm certain ticket actions.

Maybe http://trac-hacks.org/wiki/BlackMagicTicketTweaksPlugin is what
you are looking for?
I've never tried it.

Rainer

Jean Marie

unread,
Oct 8, 2008, 4:59:35 AM10/8/08
to Trac Users
Hi,

On 7 Okt., 15:48, Rainer Sokoll <r.sok...@intershop.de> wrote:
> Maybehttp://trac-hacks.org/wiki/BlackMagicTicketTweaksPluginis what
> you are looking for?

i already use BlackMagicTicketTweaksPluginis for customizing the
appearance of certain ticket fields. It also provides to permit a
field from being changed by non-priviliged users. But that's not what
i want.

I want to disallow a group of user to select a certain action for a
ticket, e.g. a developer is not allowed to close a ticket.

Anyway, thanks for your answer.

Best regards
Jean Marie

Jean Marie

unread,
Oct 8, 2008, 4:59:48 AM10/8/08
to Trac Users
Hi,

On 7 Okt., 15:48, Rainer Sokoll <r.sok...@intershop.de> wrote:
> Maybehttp://trac-hacks.org/wiki/BlackMagicTicketTweaksPluginis what
> you are looking for?

Rainer Sokoll

unread,
Oct 8, 2008, 5:12:27 AM10/8/08
to trac-...@googlegroups.com
On Wed, Oct 08, 2008 at 01:59:48AM -0700, Jean Marie wrote:

> I want to disallow a group of user to select a certain action for a
> ticket, e.g. a developer is not allowed to close a ticket.

I have a similar issue. A developer must not close a ticket, instead,
once he marked a ticket "resolved", the ticket must go over to the QA
people. They will perform their tests and finally, either close the
ticket or re-assign it to the developer.
This is still not resolved for me (has not prio number 1), but I think
it is doable by changing the default workflow.

Rainer

Jani Tiainen

unread,
Oct 8, 2008, 5:24:32 AM10/8/08
to trac-...@googlegroups.com
Rainer Sokoll kirjoitti:

Correct.

First you need to create new permission, e.g. TICKET_CLOSE.

Then you need to create group in trac what has that permission (or
assign permission to certain users).

Finally use permission property in new trac workflow to enable close
action only for TICKET_CLOSE permission.

like putting (replacing existing) following piece to workflow-section:

resolve = new,assigned,reopened -> closed
resolve.operations = set_resolution
resolve.permissions = TICKET_CLOSE

if you want to create "group" you do it this way in trac-admin (or by
using webadmin):

permission add my_group TICKET_CLOSE
permission add dev1 my_group
permission add dev2 my_group


very simple.

--
Jani Tiainen

"Tein sein mihin näillä lahjoilla pystyin.
Tein sen, en yhtään enempää." - Martti Servo & Napander

Stephen Moretti

unread,
Oct 8, 2008, 5:28:06 AM10/8/08
to trac-...@googlegroups.com


2008/10/8 Jani Tiainen <red...@gmail.com>


Rainer Sokoll kirjoitti:
> On Wed, Oct 08, 2008 at 01:59:48AM -0700, Jean Marie wrote:
>
>> I want to disallow a group of user to select a certain action for a
>> ticket, e.g. a developer is not allowed to close a ticket.
>
> I have a similar issue. A developer must not close a ticket, instead,
> once he marked a ticket "resolved", the ticket must go over to the QA
> people. They will perform their tests and finally, either close the
> ticket or re-assign it to the developer.
> This is still not resolved for me (has not prio number 1), but I think
> it is doable by changing the default workflow.

Correct.

First you need to create new permission, e.g. TICKET_CLOSE.

And to create your own permissions : 

Please note the comment by PythonGuy about formating...  I still need to get around sorting out the code display on my blog.... :/

Jani Tiainen

unread,
Oct 8, 2008, 5:55:24 AM10/8/08
to trac-...@googlegroups.com
Stephen Moretti kirjoitti:
>
>
> 2008/10/8 Jani Tiainen <red...@gmail.com <mailto:red...@gmail.com>>

>
>
> Rainer Sokoll kirjoitti:
> > On Wed, Oct 08, 2008 at 01:59:48AM -0700, Jean Marie wrote:
> >
> >> I want to disallow a group of user to select a certain action for a
> >> ticket, e.g. a developer is not allowed to close a ticket.
> >
> > I have a similar issue. A developer must not close a ticket, instead,
> > once he marked a ticket "resolved", the ticket must go over to the QA
> > people. They will perform their tests and finally, either close the
> > ticket or re-assign it to the developer.
> > This is still not resolved for me (has not prio number 1), but I
> think
> > it is doable by changing the default workflow.
>
> Correct.
>
> First you need to create new permission, e.g. TICKET_CLOSE.
>
>
> And to create your own permissions :
> http://nil.checksite.co.uk/post.cfm/trac-0-11-creating-your-own-permissions

Doesn't that BlackMagicTicketPlugin make possible to create arbitary
permissions for tickets?

Stephen Moretti

unread,
Oct 8, 2008, 6:02:52 AM10/8/08
to trac-...@googlegroups.com


2008/10/8 Jani Tiainen <red...@gmail.com>


Stephen Moretti kirjoitti:
>
>
> 2008/10/8 Jani Tiainen <red...@gmail.com <mailto:red...@gmail.com>>
>
>
>     Rainer Sokoll kirjoitti:
>      > On Wed, Oct 08, 2008 at 01:59:48AM -0700, Jean Marie wrote:
>      >
>      >> I want to disallow a group of user to select a certain action for a
>      >> ticket, e.g. a developer is not allowed to close a ticket.
>      >
>      > I have a similar issue. A developer must not close a ticket, instead,
>      > once he marked a ticket "resolved", the ticket must go over to the QA
>      > people. They will perform their tests and finally, either close the
>      > ticket or re-assign it to the developer.
>      > This is still not resolved for me (has not prio number 1), but I
>     think
>      > it is doable by changing the default workflow.
>
>     Correct.
>
>     First you need to create new permission, e.g. TICKET_CLOSE.
>
>
> And to create your own permissions :
> http://nil.checksite.co.uk/post.cfm/trac-0-11-creating-your-own-permissions

Doesn't that BlackMagicTicketPlugin make possible to create arbitary
permissions for tickets?

 TBH - I haven't looked at BlackMagicTicketPlugin yet, but, and this is the first time I've looked, the wiki does seem to suggest this.
Using BMTP just for this would make me nervous.... 

Jean Marie

unread,
Oct 8, 2008, 6:06:17 AM10/8/08
to Trac Users
> Doesn't that BlackMagicTicketPlugin make possible to create arbitary
> permissions for tickets?

With 'BlackMagicTicketPlugin' currently you can only control single
fields of a ticket.

Best regards
Jean Marie

Thomas Moschny

unread,
Oct 8, 2008, 6:12:54 AM10/8/08
to trac-...@googlegroups.com
2008/10/8 Jani Tiainen <red...@gmail.com>:

> Doesn't that BlackMagicTicketPlugin make possible to create arbitary
> permissions for tickets?

Side note: Does it really enforce permissions or does it rather make
fields un-editable via Genshi transformations? This is not the same.

- Thomas

Jean Marie

unread,
Oct 8, 2008, 6:21:27 AM10/8/08
to Trac Users
Hi Jani,

> First you need to create new permission, e.g. TICKET_CLOSE.

How can i do this?

Best regards
Jean Marie

Jean Marie

unread,
Oct 8, 2008, 8:19:10 AM10/8/08
to Trac Users
> > First you need to create new permission, e.g. TICKET_CLOSE.
>
> How can i do this?

I found an intermediate solution by "hacking" the database:

INSERT INTO permission (username, action) VALUES ("group_qa",
"TICKET_CLOSE");

After this, the manuall added permissions assignment is visible in the
admin section and also the trac-admin shows me this assignment.

In trac.ini i've set:
[ticket-workflow]
close.permissions = TICKET_CLOSE

Now only users that are members of group "group_qa" are able to close
a ticket.

For the moment this solution is fine by me. Are there any doubts about
this solution?

Maybe there'll be a more elegant way of adding user defined
permissions.

Best regards
Jean Marie

yoh...@gmail.com

unread,
Oct 8, 2008, 9:36:35 AM10/8/08
to Trac Users
AHH, bad idea.

stated about 3 responses up :
again, note his code isn't formatted properly for python on that web
site.

in this thread:
http://groups.google.com/group/trac-users/browse_thread/thread/79b11813a0cd25ab/e1710f4f7dc76cf3?hl=en&lnk=gst&q=custom+permissions#e1710f4f7dc76cf3
I posted a copy of it, which "should" be formatted. however, it is
a google email group, so ymmv

create that python file (modified for your permission(s) , drop it in
your plugins directory, restart your server, and you should be good
to go. you may need to enable the plugin in the web admin, I forget.

additionally, you MAY want to take a look at the "enterprise-workflow"
in the contrib directory, which has a resloved->verfied type workflow,
plus a special ticket handler to prevent the person that resolved a
ticket from verifying it. Maybe combine the 2.

we implement a custom workflow with resolved->verified. but we don't
enforce who verifies, since this step is basically author testing/
verification it was merged into the trunk. we have a separate qa step
that tests irrespective of tickets.

gctrekker

unread,
Feb 13, 2009, 11:34:14 AM2/13/09
to yoh...@gmail.com, trac-...@googlegroups.com
I am trying to add TICKET_CLOSE as a new permission. I tried what was
listed in this thread from the archive (shown at end of this posting)
but it does not work for me.
The thread said it was a bad idea to "hack" the database with the
"INSERT INTO permission" commands and said to use a simple plugin.

-------------------------------------------
I stopped our apache2 driver.
I added a mypermissions.py into our <track environment>/plugins
directory, here is the contents:

# mypermissions.py
#
# Use to add other permissions.
#
# Using to add a TICKET_CLOSE permission.
#
# Drop this file in the plugins directory, restart the server,
# and the permission(s) should be available. According to
# what I have found in the Trac Users group under Google groups.

from trac.core import Component, implements
from trac.perm import IPermissionRequestor

class MyPermissions(Component):
implements(IPermissionRequestor)

def get_permission_actions(self):
# return ('MY_FIRST_PERM', 'MY_SECOND_PERM')
return ('TICKET_CLOSE')

-------------------------------------
I modified the trac.ini [components] and [ticket-workflow]; here are
the diffs:

> diff trac.ini trac_TICKET_CLOSE.ini
34a35
> mypermissions.* = enabled
181c182
< close.permissions = TICKET_ADMIN
---
> close.permissions = TICKET_CLOSE
186c187
< close_new.permissions = TICKET_ADMIN
---
> close_new.permissions = TICKET_CLOSE

-----------------------------------------
I restarted apache2 and things did not work.
I got an "Oops... " when trying to view an issue that said, "Trac
detected an internal error: IndexError: string index out of range"

The trac.log file had this added after attempting to view the issue:

2009-02-13 07:23:27,291 Trac[main] ERROR: string index out of range
Traceback (most recent call last):
File "/usr/local/lib64/python2.5/site-packages/Trac-0.11.2-py2.5.egg/
trac/web/main.py", line 432, in _dispatch_request
dispatcher.dispatch(req)
File "/usr/local/lib64/python2.5/site-packages/Trac-0.11.2-py2.5.egg/
trac/web/main.py", line 204, in dispatch
resp = chosen_handler.process_request(req)
File "/usr/local/lib64/python2.5/site-packages/Trac-0.11.2-py2.5.egg/
trac/ticket/web_ui.py", line 181, in process_request
return self._process_ticket_request(req)
File "/usr/local/lib64/python2.5/site-packages/Trac-0.11.2-py2.5.egg/
trac/ticket/web_ui.py", line 530, in _process_ticket_request
get_reporter_id(req, 'author'), field_changes)
File "/usr/local/lib64/python2.5/site-packages/Trac-0.11.2-py2.5.egg/
trac/ticket/web_ui.py", line 1168, in _insert_ticket_data
fields = self._prepare_fields(req, ticket)
File "/usr/local/lib64/python2.5/site-packages/Trac-0.11.2-py2.5.egg/
trac/ticket/web_ui.py", line 1080, in _prepare_fields
TicketSystem(self.env).eventually_restrict_owner(field, ticket)
File "/usr/local/lib64/python2.5/site-packages/Trac-0.11.2-py2.5.egg/
trac/ticket/api.py", line 320, in eventually_restrict_owner
.get_users_with_permission('TICKET_MODIFY'):
File "/usr/local/lib64/python2.5/site-packages/Trac-0.11.2-py2.5.egg/
trac/perm.py", line 384, in get_users_with_permission
for child in action[1]:
IndexError: string index out of range

---------------------------------
When I used Trac / Admin / Permission and looked at the permission
selections, I saw things like:

BROWSER_VIEW
C
C
CHANGESET_VIEW
CONFIG_FILE
E
E
EMIAL_VIEW
FILE_VIEW
I
K
L
LOG_VIEW
and it goes on

---------------------------------------
I quickly stopped apache2, restored the trac.ini to what it had been,
and removed mypermissions.py and .pyc files from the plugin directory
and restarted apache2.

I do not understand what the mypermissions.py file is doing.

What am I missing or doing wrong? Is the mypermissions.py script
correct? Is my entry in the script for 'TICKET_CLOSE' correct? Do I
need brackets instead of parens since I am only adding one value?

Thanks in advance.

On Oct 8 2008, 7:36 am, yoh...@gmail.com wrote:
> On Oct 8, 7:19 am, Jean Marie <jeanmari...@gmx.net> wrote:
>
> > > > First you need to create new permission, e.g. TICKET_CLOSE.
>
> > > How can i do this?
>
> > I found an intermediate solution by "hacking" the database:
>
> > INSERT INTO permission (username, action) VALUES ("group_qa",
> > "TICKET_CLOSE");
>
> > After this, the manuall added permissions assignment is visible in the
> > admin section and also the trac-admin shows me this assignment.
>
> > In trac.ini i've set:
> > [ticket-workflow]
> > close.permissions = TICKET_CLOSE
>
> > Now only users that are members of group "group_qa" are able to close
> > a ticket.
>
> > For the moment this solution is fine by me. Are there any doubts about
> > this solution?
>
> > Maybe there'll be a more elegant way of adding user defined
> > permissions.
>
> > Best regards
> > Jean Marie
>
> AHH, bad idea.
>
> stated about 3 responses up :
>
> >And to create your own permissions :

> >http://nil.checksite.co.uk/post.cfm/trac-0-11-creating-your-own-permi...


>
> again, note his code isn't formatted properly for python on that web
> site.
>

> in this thread:http://groups.google.com/group/trac-users/browse_thread/thread/79b118...

gctrekker

unread,
Feb 13, 2009, 11:55:20 AM2/13/09
to Trac Users
I found my problem. I need brackets instead of the parens in
mypermissions.py

I changed it to have brackets and placed the mypermissions.py in the
plugins directory.
The Trac / Admin / Permission now has it included.

Now I can install the modified trac.ini file.

Ethan Jucovy

unread,
Feb 13, 2009, 5:54:09 PM2/13/09
to gctr...@gmail.com, trac-...@googlegroups.com
On Fri, Feb 13, 2009 at 11:55 AM, gctrekker <gctr...@gmail.com> wrote:

I found my problem.  I need brackets instead of the parens in
mypermissions.py

Parens (which create a tuple, while brackets create a list) would work too, but to create a tuple with one element you need a trailing comma.  So it would be

>         return ('TICKET_CLOSE',)

instead of

>         return ('TICKET_CLOSE')

That special syntax is necessary because ('TICKET_CLOSE') is actually just interpreted by Python as 'TICKET_CLOSE'.

Hope this helps.  For more info: http://docs.python.org/tutorial/datastructures.html#tuples-and-sequences

-Ethan

Reply all
Reply to author
Forward
0 new messages