Trac is being migrated to new services! Issues can be found in our new
YouTrack instance and WIKI pages can be found on our
website.
| File ReporterClose.py, 1.4 KB (added by datallah, 15 years ago) |
|
Plugin for 0.11 to enable additonal permissions for the ticket reporter
|
| Line | |
|---|
| 1 | |
|---|
| 2 | from trac.core import implements, Component |
|---|
| 3 | from trac.perm import IPermissionPolicy |
|---|
| 4 | |
|---|
| 5 | class ReporterCloseTicketPermissionPolicy(Component): |
|---|
| 6 | """Provides a the user who reported a ticket with the ability to close the |
|---|
| 7 | ticket and update the description and propertoes even if normally the |
|---|
| 8 | permissions wouldn't allow this. |
|---|
| 9 | |
|---|
| 10 | Don't forget to add `ReporterCloseTicketPermissionPolicy` to the permission_policies |
|---|
| 11 | option in [trac]. You will also need to allow the 'resolve' action to take place for 'TICKET_CHGPROP'. |
|---|
| 12 | |
|---|
| 13 | The workflow |
|---|
| 14 | [trac] |
|---|
| 15 | permission_policies = DefaultPermissionPolicy,LegacyAttachmentPolicy,ReporterCloseTicketPermissionPolicy |
|---|
| 16 | """ |
|---|
| 17 | |
|---|
| 18 | implements(IPermissionPolicy) |
|---|
| 19 | |
|---|
| 20 | # IPermissionPolicy methods |
|---|
| 21 | def check_permission(self, action, username, resource, perm): |
|---|
| 22 | if username != 'anonymous' and action in ['TICKET_CHGPROP', 'TICKET_EDIT_DESCRIPTION'] \ |
|---|
| 23 | and resource.realm == 'ticket' and resource.id is not None: |
|---|
| 24 | db = self.env.get_db_cnx() |
|---|
| 25 | cursor = db.cursor() |
|---|
| 26 | cursor.execute("SELECT reporter, status FROM ticket WHERE id=%s", |
|---|
| 27 | (resource.id,)) |
|---|
| 28 | for reporter, status in cursor: |
|---|
| 29 | if status != 'closed' and reporter == username: |
|---|
| 30 | return True |
|---|
| 31 | |
|---|
| 32 | return None |
|---|
| 33 | |
|---|
Download in other formats:
All information, including names and email addresses, entered onto this website or sent to mailing lists affiliated with this website will be public. Do not post confidential information, especially passwords!