Changeset 474


Ignore:
Timestamp:
08/09/10 14:27:19 (14 years ago)
Author:
bas
Message:

fine tuning of permission model in:

  • TICKET_APPEND
  • TICKET_CHGPROP

So email2trac will honour the permission set by the trac permission model if set in email2trac.conf. see #214, #198

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/email2trac.py.in

    r472 r474  
    583583########## TRAC ticket functions  ###########################################################
    584584
    585         def check_permission_participants(self, tkt):
     585        def check_permission_participants(self, tkt, action):
    586586                """
    587587                Check if the mailer is allowed to update the ticket
     
    595595
    596596                perm = PermissionSystem(self.env)
    597                 if perm.check_permission('TICKET_MODIFY', self.author):
     597                if perm.check_permission(action, self.author):
    598598                        self.logger.debug('ALLOW, %s has trac permission to update the ticket' %(self.author))
    599599
    600600                        return True
    601 
    602                 else:
    603                         return False
    604601               
    605 
    606602                # Is the updater in the CC?
    607603                try:
     
    614610
    615611                except KeyError:
    616                         return False
     612                        pass
     613
     614                return False
    617615
    618616        def check_permission(self, tkt, action):
     
    621619          - TICKET_CREATE
    622620          - TICKET_MODIFY
     621          - TICKET_APPEND
     622          - TICKET_CHGPROP
    623623
    624624                There are three models:
     
    638638
    639639                elif self.parameters.ticket_permission_system in ['update_restricted_to_participants']:
    640                         if action in ['TICKET_MODIFY']:
    641                                 return (self.check_permission_participants(tkt))       
    642                         else:
    643                                 return True
     640                        return (self.check_permission_participants(tkt, action))       
    644641
    645642                # Default is to allow everybody ticket updates and ticket creation
     
    648645
    649646
    650         def update_ticket_fields(self, ticket, user_dict, use_default=None):
     647        def update_ticket_fields(self, ticket, user_dict, new_ticket=None):
    651648                """
    652649                This will update the ticket fields. It will check if the
     
    656653                        - If the value supplied is valid for the ticket field.
    657654                          If not then there are two options:
    658                            1) Skip the value (use_default=None)
    659                            2) Set default value for field (use_default=1)
     655                           1) Skip the value (new_ticket=None)
     656                           2) Set default value for field (new_ticket=1)
    660657                """
    661658                self.logger.debug("function update_ticket_fields")
     659
     660                ## Check only permission model on ticket updates
     661                #
     662                if not new_ticket:
     663                        if self.parameters.ticket_permission_system:
     664                                if not self.check_permission(ticket, 'TICKET_CHGPROP'):
     665                                        self.logger.info('Reporter: %s has no permission to change ticket properties' %self.author)
     666                                        return False
    662667
    663668                # Build a system dictionary from the ticket fields
     
    706711                                                # Must we set a default if value is not allowed
    707712                                                #
    708                                                 if use_default:
     713                                                if new_ticket:
    709714                                                        value = self.get_config('ticket', 'default_%s' %(field) )
    710715
     
    773778                #
    774779                if self.parameters.ticket_permission_system:
    775                         if not self.check_permission(tkt, 'TICKET_MODIFY'):
    776                                 self.logger.info('Reporter: %s has no permission to modify tickets' %self.author)
     780                        if not self.check_permission(tkt, 'TICKET_APPEND'):
     781                                self.logger.info('Reporter: %s has no permission to add comments or attachments to tickets' %self.author)
    777782                                return False
    778783
     
    925930                                        self.print_unicode(s)
    926931
    927                 self.update_ticket_fields(ticket, user_dict, use_default=1)
     932                self.update_ticket_fields(ticket, user_dict, new_ticket=1)
    928933
    929934                if 'status' not in user_dict.keys():
Note: See TracChangeset for help on using the changeset viewer.