Commits on Jul 21, 2016
  1. @chipx86

    Merge branch 'release-0.10.x'

    chipx86 committed Jul 20, 2016
Commits on Jul 20, 2016
  1. @chipx86

    Fix unit tests regressions involving SiteConfiguration and HTML output.

    The Features change broke all unit tests that deal with
    `SiteConfiguration`. This happened because `djblets.features`, which
    is put into `INSTALLED_APPS`, would import `djblets.features.checkers`,
    which imported `SiteConfiguration`.
    
    It's not valid for a module in `INSTALLED_APPS` to directly or indirectly
    import a model. While this didn't actually break things in Django 1.6,
    it does in 1.7 and higher, due to more strict behavior for model
    loading. This import ended up preventing `SiteConfiguration` from being
    properly synchronized to the database.
    
    To fix this, the SiteConfiguration import has been moved into the
    function that needs it.
    
    There were also two other HTML-related failures.
    
    1) There was a check in the conditions tests that broke due to the
       addition of newlines in generated HTML for one of the widgets we use.
       We now use `assertHTMLEqual()` to perform a more suitable check.
    
    2) We allowed use of an older Pygments releases, but tested against
       newer HTML. We're now requiring a more modern version in
       dev-requirements.txt.
    
    Testing Done:
    Unit tests pass against Django 1.6 and 1.8.
    
    Reviewed at https://reviews.reviewboard.org/r/8300/
    chipx86 committed Jul 20, 2016
  2. @chipx86

    Merge branch 'release-0.10.x'

    chipx86 committed Jul 20, 2016
  3. @chipx86
  4. @chipx86

    Fix unit test failures for WebAPITokens due to model conflicts.

    When running the entire test suite for Djblets, we'd see errors with
    certain field accesses on BaseWebAPIToken subclasses. This was due to
    the Django model metaclass machinery causing issues when two models
    shared the same name.
    
    To solve this, we're doing what all other test models do: Giving them
    their own unique names. This results in all the unit tests passing.
    
    Testing Done:
    Unit tests pass.
    
    Reviewed at https://reviews.reviewboard.org/r/8280/
    chipx86 committed Jul 11, 2016
  5. @chipx86

    Add infrastructure to help apps offer extension testing functionality.

    This provides some new classes that applications can use to help
    extension authors write unit tests for their extensions.
    
    There's a new test runner class that handles setting up a Django
    environment, configuring basic Djblets settings, and handling static
    media collection. This can easily form the base test runner for any
    Django applications, not just those with extensions, but it's also
    useful for extension test cases.
    
    There's also a new mixin for unit test: ExtensionTestCaseMixin. This
    makes it easy to get a registered/enabled extension instance for a given
    extension class, so that unit tests can be written utilizing that
    extension.
    
    Documentation has been written on making use of these in a product.
    
    Based on work by Weijie Sun.
    
    Testing Done:
    Updated Review Board to make use of this and modified Power Pack to use
    the new infrastructure. I successfully completed a unit test run.
    
    Built the docs and read through them. Tested the code samples.
    
    Reviewed at https://reviews.reviewboard.org/r/8290/
    chipx86 committed Jul 19, 2016
  6. @chipx86

    Update Djblets doc building for beanbag-docutils and new Django 1.6 d…

    …ocs.
    
    This updates our Djblets docs building to use beanbag-docutils instead
    of bundling a bunch of extensions, cleaning up some of the tree.
    
    It also switches us over to a fork of the Django 1.6 docs, hosted on
    readthedocs.org. The official Django website no longer hosts docs for
    unsupported versions of Django, so we're switching to this fork in order
    to ensure that we're still linking to appropriate docs.
    
    Testing Done:
    Built the docs successfully.
    
    Tested that references to Django docs were working.
    
    Reviewed at https://reviews.reviewboard.org/r/8292/
    chipx86 committed Jul 19, 2016
  7. @chipx86

    Update ExtensionInfo to be able to work with or without entrypoints.

    ExtensionInfo, the internal class for storing various bits of data about
    an extension (paths, names, metadata, etc.) previously required the use
    of a Python EntryPoint in order to retrieve the data. This made unit
    tests more annoying than they should have been.
    
    Now, ExtensionInfo's constructor takes the extension class, package
    name, and metadata. A new `create_from_entrypoint()` class method has
    been added for using an EntryPoint. The old constructor still accepts
    one as well, but will warn about deprecated usage first.
    
    Some unit tests have also been updated to make use of this, and to test
    the old behavior (modernizing some of the checks while there).
    
    Testing Done:
    Djblets and Review Board unit tests pass.
    
    Made use of this with the new, upcoming extension testing support.
    
    Reviewed at https://reviews.reviewboard.org/r/8288/
    chipx86 committed Jul 18, 2016
  8. @chipx86

    Add infrastructure to help apps offer extension testing functionality.

    This provides some new classes that applications can use to help
    extension authors write unit tests for their extensions.
    
    There's a new test runner class that handles setting up a Django
    environment, configuring basic Djblets settings, and handling static
    media collection. This can easily form the base test runner for any
    Django applications, not just those with extensions, but it's also
    useful for extension test cases.
    
    There's also a new mixin for unit test: ExtensionTestCaseMixin. This
    makes it easy to get a registered/enabled extension instance for a given
    extension class, so that unit tests can be written utilizing that
    extension.
    
    Documentation has been written on making use of these in a product.
    
    Based on work by Weijie Sun.
    
    Testing Done:
    Updated Review Board to make use of this and modified Power Pack to use
    the new infrastructure. I successfully completed a unit test run.
    
    Built the docs and read through them. Tested the code samples.
    
    Reviewed at https://reviews.reviewboard.org/r/8290/
    chipx86 committed Jul 19, 2016
  9. @chipx86

    Update Djblets doc building for beanbag-docutils and new Django 1.6 d…

    …ocs.
    
    This updates our Djblets docs building to use beanbag-docutils instead
    of bundling a bunch of extensions, cleaning up some of the tree.
    
    It also switches us over to a fork of the Django 1.6 docs, hosted on
    readthedocs.org. The official Django website no longer hosts docs for
    unsupported versions of Django, so we're switching to this fork in order
    to ensure that we're still linking to appropriate docs.
    
    Testing Done:
    Built the docs successfully.
    
    Tested that references to Django docs were working.
    
    Reviewed at https://reviews.reviewboard.org/r/8292/
    chipx86 committed Jul 19, 2016
Commits on Jul 18, 2016
  1. @chipx86

    Include the djblets-forms static bundles for all admin change pages.

    The admin change pages now include the djblets-forms CSS/JavaScript
    bundles, allowing the conditions widget (and future widgets) to be
    immediately usable on every page based on this template. This includes
    database change pages and the integrations configuration pages.
    
    Testing Done:
    Dropped the widget onto a couple of pages. Saw the styles were correct
    and I could interact with the widget.
    
    Reviewed at https://reviews.reviewboard.org/r/8283/
    chipx86 committed Jul 18, 2016
  2. @chipx86

    Add a form field for configuring conditions.

    This introduces a new Django form field that allows users to view and
    configure conditions. This is presented as a JavaScript-backed widget
    that shows each condition as a row containing drop-downs for the choice
    and operator, and a field for the value. Below these are a button for
    adding new condition rows.
    
    Changing a choice will change the list of operators available, and
    reset the value for the new type of field. Changing just the operator
    will retain the value unless the new or old operators had a custom value
    field.
    
    Conditions can be deleted by clicking a "-" button on the left of the
    row.
    
    The widget is designed to handle form validation and to be resilient to
    missing choices/operators (which could happen if working with conditions
    that were based on choices/operators from extensions). Errors specific
    to a condition (value validation issues, for instance) will show up in
    the row for that condition, and will be resolved once corrected and the
    form re-submitted. Missing condition choices/operators will result in a
    disabled condition row, which must be deleted before the form can be
    submitted again.
    
    Testing Done:
    Tested loading/editing existing conditions, adding new ones, and deleting
    them.
    
    Tested custom value fields on both choices and operators.
    
    Tested choices/operators that don't need a value.
    
    Tested that the value was preserved when switching operators within a choice,
    unless the old/new operator had a custom value field.
    
    Tested validation errors for value fields.
    
    Tested usage of extension-provided custom choices/operators.
    
    Tested missing choice/operators, their presentation, and inability to save
    until the conditions were removed.
    
    Unit tests pass.
    
    Reviewed at https://reviews.reviewboard.org/r/8279/
    chipx86 committed Jul 18, 2016
  3. @chipx86

    Update ExtensionInfo to be able to work with or without entrypoints.

    ExtensionInfo, the internal class for storing various bits of data about
    an extension (paths, names, metadata, etc.) previously required the use
    of a Python EntryPoint in order to retrieve the data. This made unit
    tests more annoying than they should have been.
    
    Now, ExtensionInfo's constructor takes the extension class, package
    name, and metadata. A new `create_from_entrypoint()` class method has
    been added for using an EntryPoint. The old constructor still accepts
    one as well, but will warn about deprecated usage first.
    
    Some unit tests have also been updated to make use of this, and to test
    the old behavior (modernizing some of the checks while there).
    
    Testing Done:
    Djblets and Review Board unit tests pass.
    
    Made use of this with the new, upcoming extension testing support.
    
    Reviewed at https://reviews.reviewboard.org/r/8288/
    chipx86 committed Jul 18, 2016
Commits on Jul 12, 2016
  1. @brennie
  2. @chipx86

    Fix unit test failures for WebAPITokens due to model conflicts.

    When running the entire test suite for Djblets, we'd see errors with
    certain field accesses on BaseWebAPIToken subclasses. This was due to
    the Django model metaclass machinery causing issues when two models
    shared the same name.
    
    To solve this, we're doing what all other test models do: Giving them
    their own unique names. This results in all the unit tests passing.
    
    Testing Done:
    Unit tests pass.
    
    Reviewed at https://reviews.reviewboard.org/r/8280/
    chipx86 committed Jul 11, 2016
  3. @brennie
  4. @brennie

    Change reference of form.error_dict to form.errors

    Django forms do not have an `error_dict` attribute. The correct
    attribute is the `errors` attribute. This was causing form-wide errors
    not to appear in some cases.
    
    Testing Done:
    Submitted a form with errors. Saw the error message at the top of the
    form.
    
    Reviewed at https://reviews.reviewboard.org/r/8284/
    brennie committed Jul 11, 2016
Commits on Jul 11, 2016
  1. @chipx86

    Add standard choices, operators, and value fields for conditions.

    This introduces a set of standard objects for conditions. These provide
    base choice classes for working with strings, integers, and booleans,
    along with a set of operators appropriate to each. There are also value
    fields designed to properly handle booleans, integers, and strings in a
    more convenient way.
    
    Future changes will introduce additional types, such as for dates/times.
    
    Testing Done:
    Unit tests pass.
    
    Used these operators with some changes for a Review Board extension.
    
    Reviewed at https://reviews.reviewboard.org/r/8269/
    chipx86 committed Jul 11, 2016
  2. @chipx86

    Add the foundations for user-customizable condition rules.

    This change introduces the core support for condition rules. These are a
    way to allow applications to give users a degree of flexibility for
    choosing when certain actions should take place. Users can define one or
    more "conditions," which consist of a "condition choice" (a property or
    an object, generally, that the condition is matched upon), an "operator"
    (which applies to a choice -- something like "is", "starts with",
    "greater than", etc.), and a value (depending on the type of choice and
    operator). Along with these, they can decide whether all conditions must
    match, or any of them.
    
    For example, if an application wants to post notifications to a chat
    service, it could allow the user to customize under what conditions a
    message would be sent, making it easy to have a range of per-channel
    configurations.
    
    Conditions can be serialized to a JSON-compatible form (useful for
    storage in JSONFields or elsewhere), and deserialized from them as well.
    This makes them usable just about anywhere, including in API requests.
    
    Consumers would create a set of condition choices they want to expose
    for some part of their application. Each choice has an ID (unique within
    that batch of choices), a human-readable name, a list of one or more
    operators, and an optional default value field (which handles
    representing input fields on a web UI and handling
    serialization/deserialization).
    
    Operators, similarly, have an ID and a name, and can optionally override
    the value field (allowing, for instance, some operators for a date-based
    choice to show calendar entries or numeric text fields, whichever is
    more appropriate). It also contains the logic for matching a stored
    condition value with the lookup value from the caller.
    
    Both the list of choices and list of operators are registries, which
    allows other code (such as extensions) to add additional
    choices/operators to any existing list. Through this, authors could add
    even more flexibility for conditions beyond what the application author
    intended, helping to match on specific types of metadata or state in the
    database or anything else the author wants.
    
    This is just the beginning of this support. Upcoming changes will add
    standard sets of choices, operators, and values, and will introduce
    standard UI for configuration conditions.
    
    Testing Done:
    Unit tests pass.
    
    Tested this along with the upcoming changes, adding working condition
    support in an extension.
    
    Reviewed at https://reviews.reviewboard.org/r/8268/
    chipx86 committed Jul 11, 2016
  3. @chipx86

    Update jshintrc to support ES6 and not warn about unused parameters.

    This gets jshint set up to support validating ES6, for some upcoming
    work happening in Djblets. It also tweaks the unused variable option to
    only warn about actual variables and not function parameters (which we
    often want to declare but not use, such as in a base class).
    
    Testing Done:
    Ran jshint against some upcoming code. Saw that it no longer complained
    about the unused function parameters in a base class, and that it had no
    problem with the new ES6 code.
    
    Reviewed at https://reviews.reviewboard.org/r/8277/
    chipx86 committed Jul 11, 2016
  4. @chipx86

    Add field serialization/deserialization support to KeyValueForm.

    This adds support for defining serializers/deserializers for fields in
    KeyValueForm, allowing a form field that returns a non-JSON-serializable
    object to be stored serialized, and converting it back to the object on
    load.
    
    This is most helpful when using a complex field that returns objects
    that need special serialization, such as database models.
    
    Testing Done:
    Unit tests pass.
    
    Reviewed at https://reviews.reviewboard.org/r/8261/
    chipx86 committed Jul 11, 2016
Commits on Jul 5, 2016
  1. @davidt

    Use pprint to print out webapi responses in unit tests.

    It can be annoying to menally parse the responses from unit tests when dealing
    with failures in the API tests. This change updates it to use pprint for the
    structures rather than print.
    
    Testing done:
    Used this to debug some failures.
    
    Reviewed at https://reviews.reviewboard.org/r/8266/
    davidt committed Jul 2, 2016
Commits on Jun 28, 2016
  1. @brennie

    Refactor avatar service forms to use prefixes

    The individual avatar service settings forms are now rendered with
    prefixes so that their fields do not clobber eachother. In addition, the
    rendering of forms has been drastically simplified by initializing all
    forms in `__init__()` instead of `get_extra_context()` and providing the
    form data there. The client-side JS has been updated to reference these
    new prefixed for fields.
    
    Also, some bugs were fixed relating to avatar services. Namely:
    - we were not passing the avatar settings manager from the registry to
      each avatar service; and
    - the file upload avatar service did not ever successfully validate.
    
    Testing Done:
    - Ran unit tests.
    - Able to change avatar services.
    
    Reviewed at https://reviews.reviewboard.org/r/8256/
    brennie committed Jun 27, 2016
Commits on Jun 22, 2016
  1. @brennie
  2. @gkm4d @brennie

    Fix encoding of floating point values into XML.

    The encoding functionality in `XMLEncoderAdapter` would throw an exception
    when encountering a floating point value, indicating that the value was not
    XML serializable.  This has been corrected by adding special handing for
    floating point values, analogous to how other data types are handled.
    
    Testing Done:
    Added new unit tests to exercise both the JSON and XML encoder adapters.
    Encoding is attempted on a variety of data types.  Prior to the fix, the
    XML-based test would fail due to the presence of floating point data types.
    
    Reviewed at https://reviews.reviewboard.org/r/8249/
    gkm4d committed with brennie Jun 21, 2016
Commits on Jun 21, 2016
  1. @davidt

    Merge branch 'release-0.10.x'

    davidt committed Jun 21, 2016
  2. @davidt
  3. @cafed00d4j @davidt

    Fix a typo in the datagrids docstring.

    Trivial fix.
    cafed00d4j committed with davidt Jun 21, 2016
Commits on Jun 17, 2016
  1. @brennie

    Add unit tests for AvatarServiceRegistry.for_user

    The most recent patch for avatar service registries removed the
    `get_or_default` method in favour of the `for_user` method. This patch
    removes the tests for the old method and adds tests for the new method.
    
    Testing Done:
    Ran unit tests.
    
    Reviewed at https://reviews.reviewboard.org/r/8247/
    brennie committed Jun 17, 2016
  2. @brennie

    Add customizable avatar services

    Djblets now supports avatar services that can be customized per-user via
    a configuration form. It currently includes one such avatar service, the
    `FileUploadAvatarService`, which allows users to upload an avatar of
    their choosing.
    
    The customization form uses nested configuration page forms to
    dynamically show and hide the required fields, as well as include the
    necessary CSS and JavaScript bundles for the forms.
    
    Each avatar service that is customizable requires a `SettingsManager`,
    which is set per-registry. The settings manager is responsible for
    loading and saving the per-user configuration of each avatar service.
    Djblets does not come with a default one (as it depends on the database
    schema).
    
    Testing Done:
    - Ran unit tests.
    - Changed my avatar to an uploaded avatar in Review Board.
    
    Reviewed at https://reviews.reviewboard.org/r/8205/
    brennie committed Jun 17, 2016
Commits on Jun 15, 2016
  1. @chipx86

    Remove Local Site code from Djblets WebAPITokens and sanitize arguments.

    The `WebAPIToken` code used to live in Review Board, and was moved to
    Djblets. When that happened, the `local_site` argument to the function was
    kept, unintentionally. We still need it, though, and callers will need
    to be able to set their own custom token model fields when generating a
    token, so `generate_token()` now accepts keyword arguments, passing them
    along to the model.
    
    Calling this function could still be a bit confusing, though, as some
    arguments seemed optional but would trigger strange errors when saving
    the token. These were due to the fields not working with `None` values. We
    now set sane types and normalize values when saving, helping with the
    default case of not passing all arguments.
    
    Testing Done:
    Djblets and Review Board unit tests pass.
    
    Tested manually with a new unit test in Review Board I had worked on,
    which hit the issues with the default values for optional parameters.
    
    Reviewed at https://reviews.reviewboard.org/r/8172/
    chipx86 committed Jun 14, 2016
  2. @chipx86

    Allow integration forms to use admin widgets and the current HttpRequ…

    …est.
    
    The integration configuration forms now allow the use of admin widgets,
    like the side-by-side multi-select field. The necessary JavaScript files
    are loaded onto the page to support those widgets.
    
    The configuration forms also now take a request parameter, which allows
    subclasses to provide options based on the request (such as restricting
    objects for the configuration for the owning user or organization).
    
    Testing Done:
    Made use of the request and admin widgets in an integration.
    
    Reviewed at https://reviews.reviewboard.org/r/8167/
    chipx86 committed Jun 14, 2016
  3. @chipx86

    Merge branch 'release-0.10.x'

    chipx86 committed Jun 14, 2016
  4. @chipx86

    Add support for light-weight feature checks.

    Feature checks (aka feature switches/toggles) are a way to allow new
    features to be built and tested in a codebase without exposing them to
    every user.
    
    This introduces support for light-weight feature checks. There are three
    parts: Features, Feature Checkers, and the Feature Registry.
    
    The Feature class is used to define a feature. It just requires a
    feature ID and an optional name, summary, and stability level. It may
    also contain functions for handling initialization and shutdown (for
    when the feature is registered and unregistered, respectively). Once
    instantiated, the feature is registered and ready to check.
    
    Feature checkers determine whether a feature should be enabled, based on
    the severity level and any other custom criteria. When an application
    checks if a feature should be enabled, it can pass any criteria it
    wants (user, request, etc.), and if the checker understands it, it can
    consider it. This gives applications a lot of control of how features
    and their checkers are to be used, without imposing major requirements
    on them like other frameworks.
    
    The feature registry contains all the features that have been
    instantiated, and can be used to look up or list features dynamically.
    
    There are template tags available as well for limiting bits of a
    template based on whether a feature is enabled.
    
    Documentation is provided covering how features work, and how to write
    both features and feature checkers.
    
    Testing Done:
    Unit tests pass.
    
    Checked the docs for errors and bad code references.
    
    Reviewed at https://reviews.reviewboard.org/r/8031/
    chipx86 committed Jun 14, 2016
Commits on Jun 7, 2016
  1. @brennie

    Use Beanbag, Inc.'s security patched version of Django for CI

    We now use our patched version of Django for test runs on Travis CI.
    
    Testing Done:
    Built this patch on Travis CI:
    https://travis-ci.org/brennie/djblets/builds/135073236
    
    Reviewed at https://reviews.reviewboard.org/r/8212/
    brennie committed Jun 7, 2016