Opened 3 years ago

Closed 3 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:


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/, 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/

    3434        users = UserManager(self.env).get_active_users()
    3535        caption = self.get_caption()
    3636        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')
    3841        if action:
     42            if action == 'notify':
     43                notify_create = self.checkbox_import(req.args.get('notify_create'))
     44                self.set_notify('create', notify_create)
     46                notify_change = self.checkbox_import(req.args.get('notify_change'))
     47                self.set_notify('change', notify_change)
     49                notify_delete = self.checkbox_import(req.args.get('notify_delete'))
     50                self.set_notify('delete', notify_delete)
    3952            if action == 'rename':
    4053                caption = req.args.get('caption')
    4154                self.set_caption(caption)
    7891        return 'team_dispatcher_admin.html', {
    7992            'teams': teams,
    8093            'users': users,
    81             'caption': caption
     94            'caption': caption,
     95            'notify_create': notify_create,
     96            'notify_change': notify_change,
     97            'notify_delete': notify_delete
    8298        }
    84100    # INavigationContributor methods
    103119    def set_teams(self, teams):
    104120        self.config.set('ticket-custom', 'ttd.options', '|'.join(teams))
     123    def get_notify(self, config):
     124        return self.config.getbool('team-dispatcher', 'notify_on_' + config)
     126    def set_notify(self, config, notify):
     127        self.config.set('team-dispatcher', 'notify_on_' + config, str(notify).lower())
     130    def checkbox_import(self, checkbox):
     131        if checkbox == 'on':
     132            return True
     133        else:
     134            return False
  • ttd/templates/team_dispatcher_admin.html

    1313  <body>
    1414    <h2>Manage Ticket Teams</h2>
     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>
    1650    <form id="modcaption" class="addnew" method="post" action="">
    1751      <fieldset>
    1852        <legend>Edit Caption:</legend>

Attachments (0)

Change History (3)

comment:1 Changed 3 years ago by Ryan J Ollos

Owner: changed from Alexander von Bremen-Kühne to Ryan J Ollos
Status: newaccepted

Looks good! I'll test it out and try to commit later today.

comment:2 Changed 3 years ago by Ryan J Ollos

In 13595:

0.3dev: Add notification configuration settings to the admin page. Refs #11516.

Patch by asdorsey.

comment:3 in reply to:  description Changed 3 years ago by Ryan J Ollos

Resolution: fixed
Status: acceptedclosed

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.

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain Ryan J Ollos.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment

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

Note: See TracTickets for help on using tickets.