incubator-bloodhound-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Apache Bloodhound" <bloodhound-...@incubator.apache.org>
Subject Re: [Apache Bloodhound] #136: Widget error for product page with no versions defined
Date Fri, 13 Jul 2012 15:42:03 GMT
#136: Widget error for product page with no versions defined
------------------------+--------------------
  Reporter:  gjm        |      Owner:  nobody
      Type:  defect     |     Status:  new
  Priority:  major      |  Milestone:
 Component:  dashboard  |    Version:
Resolution:             |   Keywords:
------------------------+--------------------

Comment (by gjm):

 I might suggest this as a possible solution to pull out the parts of the
 existing solution for when there is no query string and apply it to where
 there is a query string:

 {{{
 #!diff
 Index: bloodhound_dashboard/bhdashboard/widgets/ticket.py
 ===================================================================
 --- bloodhound_dashboard/bhdashboard/widgets/ticket.py  (revision 1361197)
 +++ bloodhound_dashboard/bhdashboard/widgets/ticket.py  (working copy)
 @@ -101,7 +101,34 @@
                    'view')
          fieldnm, query, verbose, threshold, maxitems, title, view = \
                  self.bind_params(name, options, *params)
 -        if query is None :
 +
 +        field_maps = {'type': {'admin_url': 'type',
 +                               'title': 'Types',
 +                               },
 +                      'status': {'admin_url': None,
 +                                 'title': 'Statuses',
 +                                 },
 +                      'priority': {'admin_url': 'priority',
 +                                   'title': 'Priorities',
 +                                   },
 +                      'milestone': {'admin_url': 'milestones',
 +                                    'title': 'Milestones',
 +                                    },
 +                      'component': {'admin_url': 'components',
 +                                    'title': 'Components',
 +                                    },
 +                      'version': {'admin_url': 'versions',
 +                                  'title': 'Versions',
 +                                  },
 +                      'severity': {'admin_url': 'severity',
 +                                   'title': 'Severities',
 +                                   },
 +                      'resolution': {'admin_url': 'resolution',
 +                                     'title': 'Resolutions',
 +                                     },
 +                      }
 +        _field = []
 +        def check_field_name():
              if fieldnm is None:
                  raise InvalidWidgetArgument('field', 'Missing ticket
 field')
              tsys = self.env[TicketSystem]
 @@ -109,33 +136,9 @@
                  raise TracError(_('Error loading ticket system
 (disabled?)'))
              for field in tsys.get_ticket_fields():
                  if field['name'] == fieldnm:
 +                    _field.append(field)
                      break
              else:
 -                field_maps = {'type': {'admin_url': 'type',
 -                                       'title': 'Types',
 -                                       },
 -                              'status': {'admin_url': None,
 -                                         'title': 'Statuses',
 -                                         },
 -                              'priority': {'admin_url': 'priority',
 -                                           'title': 'Priorities',
 -                                           },
 -                              'milestone': {'admin_url': 'milestones',
 -                                            'title': 'Milestones',
 -                                            },
 -                              'component': {'admin_url': 'components',
 -                                            'title': 'Components',
 -                                            },
 -                              'version': {'admin_url': 'versions',
 -                                          'title': 'Versions',
 -                                          },
 -                              'severity': {'admin_url': 'severity',
 -                                           'title': 'Severities',
 -                                           },
 -                              'resolution': {'admin_url': 'resolution',
 -                                             'title': 'Resolutions',
 -                                             },
 -                              }
                  if fieldnm in field_maps:
                      admin_suffix = field_maps.get(fieldnm)['admin_url']
                      if 'TICKET_ADMIN' in req.perm and admin_suffix is not
 None:
 @@ -158,6 +161,13 @@
                  else:
                      raise InvalidWidgetArgument('field',
                              'Unknown ticket field %s' % (fieldnm,))
 +            return None
 +
 +        if query is None :
 +            data = check_field_name()
 +            if data is not None:
 +                return data
 +            field = _field[0]
              if field.get('custom'):
                  sql = "SELECT COALESCE(value, ''), count(COALESCE(value,
 ''))" \
                          " FROM ticket_custom " \
 @@ -182,8 +192,12 @@
          else:
              query = Query.from_string(self.env, query, group=fieldnm)
              if query.group is None:
 +                data = check_field_name()
 +                if data is not None:
 +                    return data
                  raise InvalidWidgetArgument('field',
                          'Invalid ticket field for ticket groups')
 +
              fieldnm = query.group
              sql, v = query.get_sql()
              sql = "SELECT COALESCE(%(name)s, '') ,
 count(COALESCE(%(name)s, ''))"\
 }}}

 Any improvements?

-- 
Ticket URL: <https://issues.apache.org/bloodhound/ticket/136#comment:1>
Apache Bloodhound <https://issues.apache.org/bloodhound/>
The Apache Bloodhound (incubating) issue tracker

Mime
View raw message