#304: Default product is not the default option in the ticket quick create or
newticket form
---------------------------+-----------------------
Reporter: rjollos | Owner: rjollos
Type: defect | Status: accepted
Priority: minor | Milestone: Release 8
Component: multiproduct | Version: 0.3.0
Resolution: | Keywords:
---------------------------+-----------------------
Comment (by rjollos):
This issue was raised again on the
[http://markmail.org/thread/f6uvq7xye7rg2sqb mailing list]. One of the
comments on the mailing list was //For instance when opening a new ticket,
the Product selected by default is not the one which has the "default"
attribute.// This seems like a reasonable requirement for the QCT when at
global scope. When at product scope, the selected product by default is
the product at the current scope. There is some discussion about this in
#569, and related changes in [1496179].
The following change resolves the issue,
{{{#!diff
diff --git a/bloodhound_theme/bhtheme/theme.py
b/bloodhound_theme/bhtheme/theme.
index 3c5aa1a..7f15a15 100644
--- a/bloodhound_theme/bhtheme/theme.py
+++ b/bloodhound_theme/bhtheme/theme.py
@@ -486,7 +486,8 @@ class QuickCreateTicketDialog(Component):
if self.env.product:
product_field['value'] = self.env.product.prefix
else:
- product_field['value'] = product_field['options'][0]
+ product_field['value'] = \
+ self.env.config.get('ticket', 'default_product')
product_field['options_desc'] = [
ProductEnvironment.lookup_env(self.env,
p).product.name
for p in product_field['options']
}}}
However, we shouldn't have to set the default value, that should be
handled by `trac.ticket.api:TicketSystem.fields`. The `default_product`
doesn't get set because `default_product` is not defined in the
`TicketSystem` class. It is not defined anywhere, so we also don't see
documentation listed at !Guide/Ini#ticket-section.
We could fix this by just adding `default_product` to the
`trac.ticket.api:TicketSystem` class, see
[https://github.com/rjollos/bloodhound/commit/29cee781 29cee781] . It is
not ideal to change `trac/ticket/api.py`, but we've already done that by
introducing `ITicketFieldProvider`. It might be possible to subclass
`TicketSystem` and add `default_product` to
`trac.ticket.api:ProductTicketSystem`, like was done for the
`BatchModifyModule` in [1511771].
Related issue: One possible source of confusion for users is that
`default_product` should be set to a product prefix. We can see from #568
that users might even try to set an option that has "prefix" in the name
to the product name rather than the prefix. The most user-friendly
solution would probably be to accept either a product prefix or name for
the option.
--
Ticket URL: <https://issues.apache.org/bloodhound/ticket/304#comment:6>
Apache Bloodhound <https://issues.apache.org/bloodhound/>
The Apache Bloodhound issue tracker