Skip to content
Snippets Groups Projects
  1. Aug 05, 2023
  2. Aug 04, 2023
    • Anselm Lingnau's avatar
      refactor: Use `Collection.objects.visible()` instead of `Collection.get_visible()`. · 565c4a50
      Anselm Lingnau authored
      This is somewhat simpler than the `VisibleManager` for dance lists and
      volumes because there are no public collections.
      565c4a50
    • Anselm Lingnau's avatar
      refactor: Use `DanceListVolume.objects.visible()` instead of `DanceListVolume.get_visible()`. · e1f28569
      Anselm Lingnau authored
      It also turns out that `DanceList` and `DanceListVolume` can share a
      `VisibleManager`, which simplifies the code somewhat.
      e1f28569
    • Anselm Lingnau's avatar
      refactor: Use `DanceList.objects.visible()` instead of `DanceList.get_visible()`. · f2ab7d6c
      Anselm Lingnau authored
      This is after we upgrade `DanceList.objects.visible()` to include the
      patch from the previous changeset that fixes the weird multiplication
      of lists in the result.
      f2ab7d6c
    • Anselm Lingnau's avatar
      fix: Don't multiply public dance lists in the list view if they have a group attached. · 4ee88367
      Anselm Lingnau authored
      The base queryset for the dance list “list view” looked like
      ```
      DanceList.objects.filter(
          Q(visibility=LV_PUBLIC)
          | (Q(visibility=LV_GROUP) & Q(group__user=self.request.user))
          | (Q(visibility=LV_PRIVATE) & Q(owner=self.request.user))
      )
      ```
      This resulted in a very weird error where a public dance list that
      still had a group attached appeared in the list display several times,
      because the Django ORM translated this into something like
      ```
      SELECT …
      FROM "db_dancelist"
        LEFT OUTER JOIN "auth_group" ON ("db_dancelist"."group_id" = "auth_group"."id")
        LEFT OUTER JOIN "auth_user_groups" ON ("auth_group"."id" = "auth_user_groups"."group_id")
      WHERE ("db_dancelist"."visibility" = 3
        OR ("db_dancelist"."visibility" = 2 AND "auth_user_groups"."user_id" = 1)
      )
      ```
      i.e., the second `LEFT OUTER JOIN` resulted in as many rows as there
      were members in the associated group, and all of them were picked for
      the result because the list visibility was `LV_PUBLIC` (3) and they
      matched the first `WHERE` clause.
      
      We're changing this to
      ```
      DanceList.objects.filter(
          Q(visibility=LV_PUBLIC)
          | Q(visibility=LV_GROUP,
              group__in=Subquery(self.request.user.groups.values("id")))
          | Q(visibility=LV_PRIVATE, owner=self.request.user)
      )
      ```
      which doesn't do a `JOIN` on the `auth_user_groups` table. (The
      `Subquery()` doesn't depend on the content of the row being considered
      but PostgreSQL is smart enough to lift it out of the loop.)
      23.216.1
      4ee88367
  3. Aug 02, 2023
  4. Aug 01, 2023
  5. Jul 30, 2023
  6. Jul 29, 2023
  7. Jul 28, 2023
    • Anselm Lingnau's avatar
      feature: Add (optional) collection references to dance list crib sheets. · b97409ad
      Anselm Lingnau authored
      If a collection is active when you're generating a crib sheet, then
      optionally references to relevant publications in that collection will
      be added to dance/extra/alternative items.
      
      This is mainly interesting for the shelf codes so it becomes easier to
      pull the original publications in preparation for a class.
      b97409ad
  8. Jul 27, 2023
  9. Jul 26, 2023
  10. Jul 25, 2023
Loading