Changeset 1984


Ignore:
Timestamp:
05/15/09 13:00:29 (5 years ago)
Author:
jdsiiro
Message:

Adding new Permission Policy to the TicketModerator to hide the "I have
files to attach..." checkbox on the New Ticket page (resolves #3826, see
also discussion for #3824).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trac-plugins/TicketModerator/trunk/ticketmoderator/api.py

    r1951 r1984  
    2727from trac.db.schema import Table, Column, Index 
    2828from trac.env import IEnvironmentSetupParticipant 
    29 from trac.perm import PermissionSystem, IPermissionRequestor 
     29from trac.perm import PermissionSystem, IPermissionRequestor, IPermissionPolicy 
    3030from trac.resource import ResourceNotFound 
    3131from trac.ticket.api import ITicketManipulator 
     
    7070    implements( IEnvironmentSetupParticipant, IPermissionRequestor,  
    7171                ITemplateProvider, ITicketManipulator, IAttachmentManipulator, 
    72                 IRequestFilter, ILegacyAttachmentPolicyDelegate ) 
     72                IRequestFilter, ILegacyAttachmentPolicyDelegate, 
     73                IPermissionPolicy ) 
    7374 
    7475    default_moderator = Option('ticketmoderator', 'default_moderator', '', 
     
    245246                               (username, resource)) 
    246247            return decision 
     248 
     249    # IPermissionPolicy methods 
     250    def check_permission(self, action, username, resource, perm): 
     251        if not resource or resource.realm != 'attachment': 
     252            return 
     253        if action != 'ATTACHMENT_CREATE' or resource.parent.realm != 'ticket': 
     254            return 
     255        return 'TICKET_APPEND' in perm(resource.parent) and \ 
     256               ( 'MODERATOR_UNMODERATED' in perm(resource.parent) or \ 
     257                 self.config.getbool('ticketmoderator', \ 
     258                                     'unmoderated_attachments') ); 
    247259 
    248260 
Note: See TracChangeset for help on using the changeset viewer.