Add event type filters and custom message templates for I Done This.

Review Request #8961 — Created Oct. 18, 2017 and updated

Information

rbintegrations
master
e92b70c...

Reviewers

This change provides some customization for messages posted to I Done This.

Event types can be filtered so that only some kinds of activity get posted,
while others do not. For example, the "Reply published" event can be disabled
to reduce noise in I Done This from every single reply getting published.

The posted messages can also be customized independently for every event type.
An empty message causes a fallback to the default format string, which is shown
below the text field for reference. Parameters such as the review request ID,
summary, and URL are substituted into placeholder strings, or omitted from the
final message. The syntax for placeholders is from string.Template, which is
limited and safer compared to other kinds of string formatting.

New unit tests were added to verify the added functionality, and some existing
tests were updated to test individual event type filtering.

All unit tests pass.

Manually tested event type filtering. Choosing "All events" posts all activity
as before. Choosing a subset of event types only posts those events.

Also specified some custom message template strings and verified that they get
formatted and posted to I Done This, or cause appropriate validation errors.


Description From Last Updated

I don't know that the word hash clarifies anything.

brenniebrennie

Do we want to wrap the template strings with <code> e.g. <dt><code>...</code></dt> ?

brenniebrennie

W503 line break before binary operator

reviewbotreviewbot

E251 unexpected spaces around keyword / parameter equals

reviewbotreviewbot

E251 unexpected spaces around keyword / parameter equals

reviewbotreviewbot

You could just have entry_type=None in the arguments list instead of using kwargs.pop here.

daviddavid

Needs the return type (unicode)

daviddavid

Add a blank line after this.

daviddavid

Instead of str(e), this should use six.text_type(e). You can get that by adding from django.utils import six in the imports.

daviddavid

str -> six.text_type. Also add a blank line after this.

daviddavid

Can we rewrap this a bit? return [ RBIntegrationsExtension.instance.get_bundle_id( 'idonethis-integration-config-form-view'), ]

daviddavid

This can be dedented 4 spaces (there's only ever one return value).

daviddavid

Add a blank line after this.

daviddavid

Add a trailing comma on this line?

daviddavid

Add a blank line after this.

daviddavid

Add a blank line after this.

daviddavid

/**

daviddavid

/**

daviddavid

This should be in the imperative mood ("Render the view"). This also should have a: Returns: IDoneThisIntegrationConfigFormView: This object, for …

daviddavid

If #id_events is a child of #content-main form (which I believe it should be), you can use this.$ for a …

daviddavid

/**

daviddavid

This coment should probably go above the if key.startswith line.

daviddavid
Checks run (1 failed, 1 succeeded)
flake8 failed.
JSHint passed.

flake8

brennie
  1. 
      
  2. Show all issues

    I don't know that the word hash clarifies anything.

    1. You're right, that's an implementation detail (in the API they are called hash_id). This really applies to the first review request, so I'll change it there.

  3. rbintegrations/idonethis/forms.py (Diff revision 1)
     
     
    Show all issues

    Do we want to wrap the template strings with <code> e.g. <dt><code>...</code></dt> ?

    1. Sure, it looks better that way. I also changed from dl to table to lay things out horizontally for clarity.

  4. 
      
MU
david
  1. These are pretty much all just trivial style issues.

    1. Thanks, all fixed.

  2. rbintegrations/idonethis/forms.py (Diff revision 2)
     
     
    Show all issues

    You could just have entry_type=None in the arguments list instead of using kwargs.pop here.

  3. rbintegrations/idonethis/forms.py (Diff revision 2)
     
     
    Show all issues

    Needs the return type (unicode)

  4. rbintegrations/idonethis/forms.py (Diff revision 2)
     
     
    Show all issues

    Add a blank line after this.

  5. rbintegrations/idonethis/forms.py (Diff revision 2)
     
     
    Show all issues

    Instead of str(e), this should use six.text_type(e). You can get that by adding from django.utils import six in the imports.

  6. rbintegrations/idonethis/forms.py (Diff revision 2)
     
     
    Show all issues

    str -> six.text_type. Also add a blank line after this.

  7. rbintegrations/idonethis/forms.py (Diff revision 2)
     
     
     
    Show all issues

    Can we rewrap this a bit?

    return [
        RBIntegrationsExtension.instance.get_bundle_id(
            'idonethis-integration-config-form-view'),
    ]
    
  8. rbintegrations/idonethis/forms.py (Diff revision 2)
     
     
    Show all issues

    This can be dedented 4 spaces (there's only ever one return value).

  9. rbintegrations/idonethis/forms.py (Diff revision 2)
     
     
    Show all issues

    Add a blank line after this.

  10. rbintegrations/idonethis/forms.py (Diff revision 2)
     
     
    Show all issues

    Add a trailing comma on this line?

  11. rbintegrations/idonethis/integration.py (Diff revision 2)
     
     
    Show all issues

    Add a blank line after this.

  12. rbintegrations/idonethis/tests.py (Diff revision 2)
     
     
    Show all issues

    Add a blank line after this.

  13. Show all issues

    /**

  14. Show all issues

    /**

  15. Show all issues

    This should be in the imperative mood ("Render the view").

    This also should have a:

    Returns:
        IDoneThisIntegrationConfigFormView:
        This object, for chaining.
    
    1. Some older files in Review Board also need to be updated :)
      I was using reviewboard/static/rb/js/admin/views/webhookFormView.js as a template for this functionality.

  16. Show all issues

    If #id_events is a child of #content-main form (which I believe it should be), you can use this.$ for a more efficient query.

  17. Show all issues

    /**

  18. 
      
MU
david
  1. One little nit left.

  2. rbintegrations/idonethis/forms.py (Diff revision 3)
     
     
    Show all issues

    This coment should probably go above the if key.startswith line.

  3. 
      
MU
Review request changed