Skip to content
Snippets Groups Projects
  1. Mar 28, 2022
    • Konrad Mohrfeldt's avatar
      feat: add new syntaxes for filtering by choices · edf2cf78
      Konrad Mohrfeldt authored
      In addition to the
      
      	?foo=1,2,3
      
      filter syntax we now also support
      
      	?foo=1&foo=2&foo=3
      	?foo[]=1&foo[]=2&foo[]=3
      edf2cf78
    • Konrad Mohrfeldt's avatar
      feat: return schedule dry-runs with a separate status code · b82b0435
      Konrad Mohrfeldt authored
      Schedule dry-runs returned a 201 response before, because the only check
      for a 201 return code was, that the payload must not contain the
      "projected" keyword.
      
      As dry-runs don’t create any data 201 is not an appropriate status code.
      b82b0435
    • Konrad Mohrfeldt's avatar
      fix: don’t restrict timeslot queryset on detail views · 3c38698a
      Konrad Mohrfeldt authored
      The filter defaults caused the queryset to always yield results filtered
      for the coming 60 days. We should only apply filter defaults when
      listing timeslots, not when querying individual items.
      3c38698a
    • Konrad Mohrfeldt's avatar
      fix: remove superfluous retrieve/update actions for APIUserViewSet · 5bc1f22b
      Konrad Mohrfeldt authored
      The retrieve and update actions can be removed because the get_queryset
      method already ensures that the user has only access to their own user
      object (or all user objects in case of superusers).
      
      Sending 401 responses for unauthorized requests may also be considered
      leaky, because it exposes that these objects exist instead of returning
      a 404 that simply states that no object with that primary key can be
      found.
      5bc1f22b
    • Konrad Mohrfeldt's avatar
      fix: always include API fields · 78168ae2
      Konrad Mohrfeldt authored
      Simply omitting properties in the API in certain edge cases makes API
      client implementations brittle and documentation a lot harder.
      78168ae2
    • Konrad Mohrfeldt's avatar
      fix: raise ValidationError on invalid data · e2cc7bb9
      Konrad Mohrfeldt authored
      This gives the calling code better control over the handling of such
      errors and makes it easy to differentiate between errors and valid
      return types.
      e2cc7bb9
    • Konrad Mohrfeldt's avatar
      feat: API errors now come with an optional code · 59219ebf
      Konrad Mohrfeldt authored
      This change allows clients to identify specific errors by an optional
      code provided as part of any APIException instances raised in our code.
      
      This code:
      
      ```py
      raise ValidationError(
          "Please provide a correct date and time",
          code="time-invalid",
      )
      ```
      
      now returns an error object via the API with a message and a code
      property making error processing on the client side easy for both humans
      and machines and looks like this:
      
      ```json
      {
          "message": "Please provide a correct date and time",
          "code": "time-invalid"
      }
      ```
      59219ebf
    • Konrad Mohrfeldt's avatar
      refactor: move subroute filtering into viewset mixin · a0e800d9
      Konrad Mohrfeldt authored
      Most of the queryset filtering for subroutes formerly implemented
      through custom get_queryset methods can happen semi-automated through a
      mixin, making the behaviour re-usable and allowing us strip a lot of
      additional logic for retrieving objects.
      
      The use of the viewset get_object method also allows us to implement
      object access with permission classes in the future, and should make a
      whole lot of other code obselete.
      
      This change is primarily motivated by the fact that documentation of the
      API will become a lot easier if the subroutes don’t impose arbitrary
      restrictions on the specific subpath under which an operation is
      allowed. For instance updating a schedule should be possible through
      either /schedules/<pk>/ or
      /shows/<show_pk>/schedules/<schedule_pk>/ as long as all the necessary
      data is present in the request body.
      a0e800d9
    • Konrad Mohrfeldt's avatar
      refactor: implement consistent pk/slug retrieval for shows · c650f609
      Konrad Mohrfeldt authored
      The show retrieve method allowed shows to be identified through the slug
      or the id. This is handy, but was restricted to the retrieve and did not
      apply to the update nor delete methods. The proper way to implement this
      kind of behaviour is through overriding get_object so that route
      identifiers are handled consistently.
      c650f609
    • Konrad Mohrfeldt's avatar
      fix: cba_id should be part of the serialized representation · 0d695cf1
      Konrad Mohrfeldt authored
      cba_id was always part of the serialized note representation through the
      use of `fields = "__all__"``and shouldn’t be write-only.
      0d695cf1
  2. Mar 25, 2022
  3. Mar 22, 2022
  4. Mar 21, 2022
  5. Mar 18, 2022
  6. Mar 17, 2022
    • Ernesto Rico Schmidt's avatar
      Merge branch 'refactor-filters' into 'master' · 47d90bcc
      Ernesto Rico Schmidt authored
      refactor collection filters with django_filters
      
      See merge request !20
      47d90bcc
    • Konrad Mohrfeldt's avatar
      refactor: use django_filters FilterSet for APINoteViewSet · 7eaa0a49
      Konrad Mohrfeldt authored
      This change re-implements all existing collection filters for the
      APINoteViewSet with a FilterSet. No breaking changes are expected.
      7eaa0a49
    • Konrad Mohrfeldt's avatar
      refactor: tidy up APIScheduleViewSet · 29837872
      Konrad Mohrfeldt authored
      * TODOs are no longer part of the method description
      * normalized queryset handling
      * consistent formatting of method descriptions.
      29837872
    • Konrad Mohrfeldt's avatar
      refactor: pre-fill show and timeslot data on note creation · b3247ab5
      Konrad Mohrfeldt authored
      If notes are created through subroutes some of the data necessary to
      create a note is already available through the route data and doesn’t
      need to be passed as part of the request body anymore.
      b3247ab5
    • Konrad Mohrfeldt's avatar
      fix: fix typo causing note creations to fail · 0dc2903b
      Konrad Mohrfeldt authored
      Notes will only be created if called through a timeslot subroute. The
      typo prohibited the note creation, because timeslot_pk was always None
      and caused the view to error early.
      0dc2903b
    • Konrad Mohrfeldt's avatar
      feat: add string representations for models · 3bfec8a5
      Konrad Mohrfeldt authored
      This adds a string representation for all program models except the
      schedule so that it is easier to identify objects in DRF’s filter,
      create, and update forms.
      3bfec8a5
    • Konrad Mohrfeldt's avatar
      fix: fix audio_url generation for notes · 24f6f06d
      Konrad Mohrfeldt authored
      There were some problems during audio_url generation for notes:
      
      1. the cba_id was never part of the Note serializer so getting
         values from the validated data needed to fail.
      2. the get_audio_url utililty function returned None if
         no cba_id was provided if a the CBA_API_KEY was missing,
         but None but the respective model field is not nullable on the note.
      3. Request or JSON decoder errors would bubble unhandled, even though
         audio_url generation seems to be optional and should not necessarily
         interfere with note creation.
      24f6f06d
    • Konrad Mohrfeldt's avatar
      refactor: implement active filter for various viewsets · 2d9fd804
      Konrad Mohrfeldt authored
      APICategoryViewSet, APITypeViewSet, APITopicViewSet,
      APIMusicFocusViewSet, APIFundingCategoryViewSet, APILanguageViewSet, and
      APIHostViewSet all used the same base class implementing get_queryset
      for filtering by their active state. This is now handled by a generic
      FilterSet.
      2d9fd804
    • Konrad Mohrfeldt's avatar
      refactor: tidy up APIUserViewSet · cf82526d
      Konrad Mohrfeldt authored
      * normalized queryset handling
      * consistent formatting of method descriptions.
      cf82526d
    • Konrad Mohrfeldt's avatar
      fix: don’t advertise prohibited API methods · 60a791ae
      Konrad Mohrfeldt authored
      There is no point in advertising the methods by inheriting from
      the default CRUD viewset, if we don’t actually intend to implement them.
      60a791ae
    • Konrad Mohrfeldt's avatar
      refactor: use django_filters FilterSet for APITimeSlotViewSet · 6c8236d2
      Konrad Mohrfeldt authored
      This change re-implements all existing collection filters for the
      APITimeSlotViewSet with a FilterSet. No breaking changes are expected,
      though there are some changes in semantics:
      
      * The start and end query parameters no longer need to be specified
        together. If users only want to modify the start or end date they
        can now do that.
        If start is specified and end is not, end will be start + 60 days.
      * If end was not set it would default to start + 60 days at 00:00.
        This is now fixed and end will be start + 60 days at 23:59:59.
      * end now uses time.max, which selects the latest possible time on
        the specified date.
      * The surrounding-filter now accepts a datetime value and will be set
        to the current time if only the query parameter but no value
        has been set.
      * All filters are now applied in series. This wasn’t the case for
        every filter, e.g. the surrounding-filter would return early.
      6c8236d2
    • Konrad Mohrfeldt's avatar
      refactor: use django_filters FilterSet for APIShowViewSet · 0fed711d
      Konrad Mohrfeldt authored
      This change re-implements all existing collection filters for the
      APIShowViewSet with a FilterSet. No breaking changes are expected,
      though there are some changes in semantics:
      
      * The owner, host, musicfocus, language, category, and topic
        filters now accept multiple values (i.e. ?category=2,3)
      * The owner, host, musicfocus, language, category, topic, and type
        filter values are now validated and may be rejected as invalid if
        the referenced object does not exist.
      0fed711d
    • Roman Brendler's avatar
      Feat(release-management): Add CHANGELOG · 70f30f94
      Roman Brendler authored
      70f30f94
  7. Mar 16, 2022
  8. Mar 15, 2022
  9. Mar 14, 2022
  10. Mar 11, 2022
Loading