Changes between Version 2 and Version 3 of TicketOwnerGroupPatch


Ignore:
Timestamp:
Jul 9, 2010, 7:45:54 PM (4 years ago)
Author:
xpech
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • TicketOwnerGroupPatch

    v2 v3  
    1111[ticket]
    1212restrict_owner_groups = owners,TICKET_ADMIN
    13 }}}
    14 
    15 The diff :
    16 {{{
    17 
    18 Index: trac/ticket/api.py
    19 ===================================================================
    20 --- trac/ticket/api.py  (revision 9948)
    21 +++ trac/ticket/api.py  (working copy)
    22 @@ -16,6 +16,7 @@
    23  
    24  import copy
    25  import re
    26 +import string
    27  
    28  from genshi.builder import tag
    29  
    30 @@ -169,6 +170,9 @@
    31          doc="""Ordered list of workflow controllers to use for ticket actions
    32              (''since 0.11'').""")
    33  
    34 +    restrict_owner_groups = ListOption('ticket', 'restrict_owner_groups', None,
    35 +        doc= """List of groups of users to fill the owner field of tickets when use a drop-down menu.""")
    36 +
    37      restrict_owner = BoolOption('ticket', 'restrict_owner', 'false',
    38          """Make the owner field of tickets use a drop-down menu.
    39          Be sure to understand the performance implications before activating
    40 @@ -389,9 +393,24 @@
    41          """Restrict given owner field to be a list of users having
    42          the TICKET_MODIFY permission (for the given ticket)
    43          """
    44 -        if self.restrict_owner:
    45 +        self.log.debug('eventually_restrict_owner')
    46 +        if self.restrict_owner_groups:
    47 +            self.log.debug('eventually_restrict_owner : use group')
    48              field['type'] = 'select'
    49              possible_owners = []
    50 +            db = self.env.get_db_cnx()
    51 +            cursor = db.cursor()
    52 +            query = "SELECT username from permission where action in ('%s') AND username NOT IN (select action from permission)" % string.joinfields(self.restrict_owner_groups,"','")
    53 +            self.log.debug('query %s ' % query)
    54 +            cursor.execute(query)
    55 +            possible_owners = cursor.fetchall()
    56 +            possible_owners.sort()
    57 +            self.log.debug('possible_owners %s ' % possible_owners)
    58 +            field['options'] = possible_owners
    59 +            field['optional'] = True
    60 +        elif self.restrict_owner:
    61 +            field['type'] = 'select'
    62 +            possible_owners = []
    63              for user in PermissionSystem(self.env) \
    64                      .get_users_with_permission('TICKET_MODIFY'):
    65                  if not ticket or \
    66 Index: trac/ticket/default_workflow.py
    67 ===================================================================
    68 --- trac/ticket/default_workflow.py     (revision 9948)
    69 +++ trac/ticket/default_workflow.py     (working copy)
    70 @@ -17,6 +17,7 @@
    71  # Author: Eli Carter
    72  
    73  import pkg_resources
    74 +import string
    75  
    76  from genshi.builder import tag
    77  
    78 @@ -236,11 +237,20 @@
    79          if 'set_owner' in operations:
    80              id = 'action_%s_reassign_owner' % action
    81              selected_owner = req.args.get(id, req.authname)
    82 -
    83              if this_action.has_key('set_owner'):
    84                  owners = [x.strip() for x in
    85                            this_action['set_owner'].split(',')]
    86 +            elif self.config.getlist('ticket', 'restrict_owner_groups',None) :
    87 +                groups = self.config.getlist('ticket', 'restrict_owner_groups',None)
    88 +                db = self.env.get_db_cnx()
    89 +                cursor = db.cursor()
    90 +                query = "SELECT username from permission where action in ('%s')" % string.joinfields(groups,"','")
    91 +                cursor.execute(query)
    92 +                owners = cursor.fetchall()
    93 +                owners.sort()
    94 +                self.log.debug("owners:%s" % owners)
    95              elif self.config.getbool('ticket', 'restrict_owner'):
    96 +                self.log.debug('Use restrict_owner ')
    97                  perm = PermissionSystem(self.env)
    98                  owners = perm.get_users_with_permission('TICKET_MODIFY')
    99                  owners.sort()
    10013}}}
    10114
     
    12033{{{
    12134[ticket]
     35
    12236restrict_owner = yes
     37
    12338restrict_owner_groups = owners,TRAC_ADMIN
     39
    12440}}}
    12541