Modify ↓
Opened 11 years ago
Closed 11 years ago
#11516 closed enhancement (fixed)
Add notification configuration options to admin page
Reported by: | Adam Dorsey - NOAA Affiliate | Owned by: | Ryan J Ollos |
---|---|---|---|
Priority: | normal | Component: | TicketTeamDispatcherPlugin |
Severity: | normal | Keywords: | |
Cc: | Ryan J Ollos | Trac Release: |
Description
I decided to attempt adding the new notification config options to the web admin page. Following is the diff from my environment.
A few notes:
- The method I used to select/deselect the checkboxes is probably pretty hacky, but it's the only method I could find that worked well. I'm sure there's a better method that I have missed.
- The field looks a little rough, but I couldn't find a decent way of arranging the options that didn't look bad. I will defer to someone who doesn't suck at web layouts for that.
- I would have used the Option class in ttd/admin.py, but according to Trac #9967 that method only allows getting options, not setting them.
Please let me know if there are any changes that need to be made to clean this up.
-
ttd/admin.py
34 34 users = UserManager(self.env).get_active_users() 35 35 caption = self.get_caption() 36 36 teams = self.get_teams() 37 notify_create = self.get_notify('create') 38 notify_change = self.get_notify('change') 39 notify_delete = self.get_notify('delete') 37 40 38 41 if action: 42 if action == 'notify': 43 notify_create = self.checkbox_import(req.args.get('notify_create')) 44 self.set_notify('create', notify_create) 45 46 notify_change = self.checkbox_import(req.args.get('notify_change')) 47 self.set_notify('change', notify_change) 48 49 notify_delete = self.checkbox_import(req.args.get('notify_delete')) 50 self.set_notify('delete', notify_delete) 51 39 52 if action == 'rename': 40 53 caption = req.args.get('caption') 41 54 self.set_caption(caption) … … 78 91 return 'team_dispatcher_admin.html', { 79 92 'teams': teams, 80 93 'users': users, 81 'caption': caption 94 'caption': caption, 95 'notify_create': notify_create, 96 'notify_change': notify_change, 97 'notify_delete': notify_delete 82 98 } 83 99 84 100 # INavigationContributor methods … … 103 119 def set_teams(self, teams): 104 120 self.config.set('ticket-custom', 'ttd.options', '|'.join(teams)) 105 121 self.config.save() 122 123 def get_notify(self, config): 124 return self.config.getbool('team-dispatcher', 'notify_on_' + config) 125 126 def set_notify(self, config, notify): 127 self.config.set('team-dispatcher', 'notify_on_' + config, str(notify).lower()) 128 self.config.save() 129 130 def checkbox_import(self, checkbox): 131 if checkbox == 'on': 132 return True 133 else: 134 return False -
ttd/templates/team_dispatcher_admin.html
13 13 <body> 14 14 <h2>Manage Ticket Teams</h2> 15 15 16 <form id="notifications" class="addnew" method="post" action=""> 17 <fieldset> 18 <legend>Notification Settings:</legend> 19 <div class="field"> 20 <label>Notify on ticket creation: 21 <py:choose test="notify_create"> 22 <input py:when="True" type="checkbox" name="notify_create" checked="on"/> 23 <input py:when="False" type="checkbox" name="notify_create"/> 24 </py:choose> 25 </label> 26 </div> 27 <div class="field"> 28 <label>Notify on ticket modification: 29 <py:choose test="notify_change"> 30 <input py:when="True" type="checkbox" name="notify_change" checked="on"/> 31 <input py:when="False" type="checkbox" name="notify_change"/> 32 </py:choose> 33 </label> 34 </div> 35 <div class="field"> 36 <label>Notify on ticket deletion: 37 <py:choose test="notify_delete"> 38 <input py:when="True" type="checkbox" name="notify_delete" checked="on"/> 39 <input py:when="False" type="checkbox" name="notify_delete"/> 40 </py:choose> 41 </label> 42 </div> 43 <div class="buttons"> 44 <input type="hidden" name="action" value="notify" /> 45 <input type="submit" value="${_('Save')}" /> 46 </div> 47 </fieldset> 48 </form> 49 16 50 <form id="modcaption" class="addnew" method="post" action=""> 17 51 <fieldset> 18 52 <legend>Edit Caption:</legend>
Attachments (0)
Change History (3)
comment:1 Changed 11 years ago by
Owner: | changed from Alexander von Bremen-Kühne to Ryan J Ollos |
---|---|
Status: | new → accepted |
comment:3 Changed 11 years ago by
Resolution: | → fixed |
---|---|
Status: | accepted → closed |
Replying to asdorsey:
- The field looks a little rough, but I couldn't find a decent way of arranging the options that didn't look bad. I will defer to someone who doesn't suck at web layouts for that.
I'm not particularly savvy at web layouts either, but I tweaked your patch a little before committing. Please let me know if you spot any areas that can be improved.
Note: See
TracTickets for help on using
tickets.
Looks good! I'll test it out and try to commit later today.