Skip to content

Sort corporate donors by donation amount within each bracket #1867

Open
@jacobian

Description

@jacobian

I'm looking at the corporate donors on https://www.djangoproject.com/fundraising/. The intent there is that, within each donation bracket, donors are meant to be sorted by donation amount, then alphabetically (e.g. so if a Silver donor donated $7,000, the'd be sorted above one who donated $5,000, even though both are in the Silver bracket).

However, responding to a question from a donor, I think I've discovered two problems:

  1. The code actually sorts by total amount donated all time, not the current donation level:
    class CorporateMemberManager(models.Manager):
    def for_public_display(self):
    objs = (
    self.get_queryset()
    .filter(
    invoice__expiration_date__gte=timezone_today(),
    )
    .annotate(donated_amount=models.Sum("invoice__amount"))
    )
    return objs.order_by("-donated_amount", "display_name")
    def by_membership_level(self):
    members_by_type = defaultdict(list)
    members = self.for_public_display()
    for member in members:
    key = MEMBERSHIP_TO_KEY[member.membership_level]
    members_by_type[key].append(member)
    return members_by_type
  2. And it doesn't appear to be working. I don't want to publish donation amounts, but anyone with access to the live site data should check out Bronze sponsors. The sort there appears purely alphabetical, but there are large differences in donation amounts there. (If whoever ends up debugging this doesn't have access to live donation data, feel free to contact me privately and I'll get you that access to debug.)

(1) is arguably by design and not a bug, so I'm gonna discuss this with the board and the fundraising team to double check that my understanding of the intent (sort by current donation amount, not total amount) is correct.

But (2) is definitely a bug -- the code clear intends to sort by donation amount, but the sort seems to be lost somewhere somehow.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions