Modify

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#8479 closed enhancement (fixed)

Children inheriting tickets from parents

Reported by: plt Owned by: walnut
Priority: normal Component: ChildTicketsPlugin
Severity: normal Keywords:
Cc: Trac Release: 0.11

Description (last modified by rjollos)

Hi, I'm working on a rollout of trac and i'm using child tickets. I have a number of custom fields that I need to be applied to child tickets so i've hacked the code a bit and added it in. Can i just checkout the code and then check it back in with the mods? This is the section of code i've modified.

                    # Can user create a new ticket? If not, just display title (ie. no 'create' button).
                    if 'TICKET_CREATE' in req.perm(ticket.resource):
                        #PLT - Moved form to here 20110208
                        form_fields = [
                            tag.input(type="submit", name="childticket", value="Create", title="Create a child ticket"),
                            tag.input(type="hidden", name="parent", value='#'+str(ticket.id)),
                            tag.input(type="hidden", name="milestone", value=default_child_milestone),
                            tag.input(type="hidden", name="type", value=default_child_type),
                            tag.input(type="hidden", name="foobar", value=default_child_type),
                        ]
                        #Added fields based on the inherit list in the config
                        for field in self.config.getlist('childtickets', 'parent.%s.inherit' % ticket['type']):
                            form_fields.append(
                                tag.input(type="hidden", name="%s" % field, value=ticket[field]),
                            )
                        snippet.append(tag.div(
                            tag.form(
                                tag.div(
                                    form_fields, #Read in form fields from variable
                                    class_="inlinebuttons"),
                                method="get", action=req.href.newticket(),
                                ),
                            tag.h3("Child Tickets",id="comment:child_tickets"),
                            ))
                    else:
                        snippet.append(tag.div(tag.h3("Child Tickets",id="comment:child_tickets")))

I've moved the form fields to a list and appended additional fields from the config

Pete

Attachments (4)

childticketsplugin.py.diff (3.2 KB) - added by plt 4 years ago.
parent ticket with ticket type buttons.png (61.0 KB) - added by plt 4 years ago.
parent ticket with ticket type buttons.2.png (61.0 KB) - added by plt 4 years ago.
perTypeButtons.png (61.0 KB) - added by plt 4 years ago.

Download all attachments as: .zip

Change History (11)

comment:1 Changed 4 years ago by rjollos

  • Description modified (diff)

Attaching diff is always preferred so that the maintainer can see exactly what you have modified and directly apply the patch to the source.

Changed 4 years ago by plt

comment:2 Changed 4 years ago by plt

  • Type changed from defect to enhancement

Hi, I've tidied up the code and attached as a diff. Changes i've made are Added a list of fields to inherit to trac.ini.

 parent.enhancement.inherit = field1,field2,field3

will cause these fields to be passed to the child ticket Changed the Create ticket button if a restrict_child_type directive is supplied. You get a set of buttons, one for each child type. It could be tidied up a bit as the buttons are close together. Screenshot coming in a minute.

Changed 4 years ago by plt

comment:3 Changed 4 years ago by walnut

  • Status changed from new to assigned

Hi Pete

Many thanks - I think the changes are brilliant. The ability to define the inherited values from a list is a feature a couple of people have asked for (unfortunately I've not had too much time lately for this - my firm now uses 'another' ticketing system!) and your changes address their requirements.

I've actually changed the code a bit and I've dropped the 'inherit_milestone' option (it seems superfluous given the generic 'inherit' option).

Being able to see exactly what sub-ticket types can be created is also a great idea (I think the buttons look ok - I might just change the background colour a bit perhaps??)

Thanks again, I'll checkin the changes and make it available as a new release (1.1.0)

Regards Mark

comment:4 Changed 4 years ago by walnut

(In [9850]) fixes: #8479, #8460, #8311

  • Release 1.1.0
  • 'parent.type.inherit_milestone is no longer supported and replaced with 'inherit = list' option now.
  • 'parent.type.inherit = list' allows you to define a list of inherited fields (including 'summary', 'description' and custom fields)
  • 'parent.type.restrict_child_types = list' now overrides 'default_child_type' and, if used presents a series of buttons for creation of child tickets.
  • If no 'restrict_child_types' list is given in trac.ini, then the default 'Create' button now shows 'New Child Ticket'.
  • Many thanks to Pete 'plt' (see #8479) for his work on this and this contribution.

comment:5 Changed 4 years ago by walnut

  • Resolution set to fixed
  • Status changed from assigned to closed

Version 1.1.0 is now committed and available - please let me know if there are any problems & thanks again for the contribution.

Regards Mark

comment:6 Changed 4 years ago by anonymous

  • Cc liltor@… added; anonymous removed

comment:7 Changed 4 years ago by anonymous

  • Cc anonymous added; liltor@… removed

Add Comment

Modify Ticket

Action
as closed The owner will remain walnut.
The resolution will be deleted. Next status will be 'reopened'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.