Modify ↓
#2992 closed enhancement (fixed)
Add support to webadmin for milestones - diff included in the description
Reported by: | anonymous | Owned by: | Christopher Lenz |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | general | Version: | none |
Severity: | normal | Keywords: | |
Cc: | Branch: | ||
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description
Index: webadmin/ticket.py =================================================================== --- webadmin/ticket.py (revision 3111) +++ webadmin/ticket.py (working copy) @@ -98,7 +98,81 @@ return 'admin_component.cs', None +class MilestoneAdminPage(Component): + implements(IAdminPageProvider) + + # IAdminPageProvider + def get_admin_pages(self, req): + if req.perm.has_permission('TICKET_ADMIN'): + yield ('ticket', 'Ticket System', 'milestones', 'Milestones') + + def process_admin_request(self, req, cat, page, milestone): + req.perm.assert_permission('TICKET_ADMIN') + + # Detail view? + if milestone: + mil = ticket.Milestone(self.env, milestone) + if req.method == 'POST': + if req.args.get('save'): + mil.name = req.args.get('name') + if req.args.get('time'): + mil.time = util.parse_date(req.args.get('time')) + mil.description = req.args.get('description') + mil.update() + req.redirect(self.env.href.admin(cat, page)) + elif req.args.get('cancel'): + req.redirect(self.env.href.admin(cat, page)) + + req.hdf['admin.milestone'] = { + 'name': mil.name, + 'due': mil.due and util.format_datetime(mil.due) or '', + 'description': mil.description + } + else: + if req.method == 'POST': + # Add Milestone + if req.args.get('add') and req.args.get('name'): + mil = ticket.Milestone(self.env) + mil.name = req.args.get('name') + if req.args.get('due'): + mil.time = util.parse_date(req.args.get('due')) + mil.insert() + req.redirect(self.env.href.admin(cat, page)) + + # Remove milestone + elif req.args.get('remove') and req.args.get('sel'): + sel = req.args.get('sel') + sel = isinstance(sel, list) and sel or [sel] + if not sel: + raise TracError, 'No milestone selected' + db = self.env.get_db_cnx() + for name in sel: + mil = ticket.Milestone(self.env, name, db=db) + mil.delete(db=db) + db.commit() + req.redirect(self.env.href.admin(cat, page)) + + # Set default milestone + elif req.args.get('apply'): + if req.args.get('default'): + name = req.args.get('default') + self.log.info('Setting default milestone to %s', name) + self.config.set('ticket', 'default_milestone', name) + self.config.save() + req.redirect(self.env.href.admin(cat, page)) + + default = self.config.get('ticket', 'default_milestone') + req.hdf['admin.milestones'] = \ + [{'name': m.name, + 'due': m.due and util.format_datetime(m.due) or '', + 'is_default': m.name == default, + 'href': self.env.href.admin(cat, page, m.name) + } for m in ticket.Milestone.select(self.env)] + + return 'admin_milestone.cs', None + + class VersionAdminPage(Component): implements(IAdminPageProvider) Index: webadmin/templates/admin_milestone.cs =================================================================== --- webadmin/templates/admin_milestone.cs (revision 0) +++ webadmin/templates/admin_milestone.cs (revision 0) @@ -0,0 +1,83 @@ +<h2>Manage Milestones</h2><?cs + +if:admin.milestone.name ?> + <form class="mod" id="modmil" method="post"> + <fieldset> + <legend>Modify Milestone:</legend> + <div class="field"> + <label>Name:<br /> <input type="text" name="name"value="<?cs + var:admin.milestone.name ?>" /></label> + </div> + <div class="field"> + <label>Due:<br /> <input type="text" name="due" value="<?cs + var:admin.milestone.due ?>"></label> + </div> + <div class="field"> + <label>Completed:<br /> <input type="text" name="completed" value="<?cs + var:admin.milestone.completed ?>"></label> + </div> + <div class="field"> + <fieldset class="iefix"> + <label for="description">Description (you may use <a tabindex="42" href="<?cs + var:trac.href.wiki ?>/WikiFormatting">WikiFormatting</a> here):</label> + <p><textarea id="description" name="description" class="wikitext" rows="6" cols="60"><?cs + var:admin.milestone.description ?></textarea></p> + </fieldset> + </div> + <script type="text/javascript" src="<?cs + var:chrome.href ?>/common/js/wikitoolbar.js"></script> + <div class="buttons"> + <input type="submit" name="cancel" value="Cancel"> + <input type="submit" name="save" value="Save"> + </div> + </fieldset> + </form><?cs + +else ?> + + <form class="addnew" id="addmil" method="post"> + <fieldset> + <legend>Add Milestone:</legend> + <div class="field"> + <label>Name:<input type="text" name="name" id="name"></label> + </div> + <div class="field"> + <label>Due: <input type="text" name="due" value="<?cs + var:admin.milestone.due ?>"></label> + </div> + <div class="buttons"> + <input type="submit" name="add" value="Add"> + </div> + </fieldset> + </form><?cs + + if:len(admin.milestones) ?><form method="POST"> + <table class="listing" id="millist"> + <thead> + <tr><th class="sel"> </th><th>Name</th> + <th>Time</th><th>Default</th></tr> + </thead><tbody><?cs + each:mil = admin.milestones ?> + <tr> + <td><input type="checkbox" name="sel" value="<?cs var:mil.name ?>" /></td> + <td><a href="<?cs var:mil.href ?>"><?cs var:mil.name ?></a></td> + <td><?cs var:mil.due ?></td> + <td class="default"><input type="radio" name="default" value="<?cs + var:mil.name ?>"<?cs + if:mil.is_default ?> checked="checked" <?cs /if ?>></td> + </tr><?cs + /each ?></tbody> + </table> + <div class="buttons"> + <input type="submit" name="remove" value="Remove selected items" /> + <input type="submit" name="apply" value="Apply changes" /> + </div> + <p class="help">You can remove all items from this list to completely hide + this field from the user interface.</p> + </form><?cs + else ?> + <p class="help">As long as you don't add any items to the list, this field + will remain completely hidden from the user interface.</p><?cs + /if ?><?cs + +/if ?>
Attachments (0)
Change History (4)
comment:1 by , 19 years ago
comment:2 by , 19 years ago
Component: | trac-admin → general |
---|---|
Milestone: | 0.11 |
Owner: | changed from | to
Status: | new → assigned |
comment:3 by , 19 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Patch applied in 3112. Thanks!
Note:
See TracTickets
for help on using tickets.
Better give a like to my email if you need to contact me.