Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions accounts/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ def get(self, request: Request, *args, **kwargs):
{"message": f"Account with ID {account_id} not found."}, status=404
)

donations = Donation.objects.filter(recipient=account)
donations = Donation.objects.prefetch_related('donor', 'pot', 'recipient', 'referrer', 'chef', 'token').filter(recipient=account)
results = self.paginate_queryset(donations, request, view=self)
serializer = DonationSerializer(results, many=True)
return self.get_paginated_response(serializer.data)
Expand Down Expand Up @@ -346,7 +346,7 @@ def get(self, request: Request, *args, **kwargs):
{"message": f"Account with ID {account_id} not found."}, status=404
)

donations = Donation.objects.filter(donor=account)
donations = Donation.objects.select_related('donor', 'pot', 'recipient', 'referrer', 'chef', 'token').prefetch_related('pot__admins').filter(donor=account) #TODO: this takes more time than just doing a prefetch_related for the fields.
results = self.paginate_queryset(donations, request, view=self)
serializer = DonationSerializer(results, many=True)
return self.get_paginated_response(serializer.data)
Expand Down
4 changes: 2 additions & 2 deletions lists/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,13 @@ class ListRegistrationsAPI(APIView, CustomSizePageNumberPagination):
def get(self, request: Request, *args, **kwargs):
list_id = kwargs.get("list_id")
try:
list_obj = List.objects.get(id=list_id)
list_obj = List.objects.prefetch_related('registrations').get(id=list_id)
except List.DoesNotExist:
return Response(
{"message": f"List with ID {list_id} not found."}, status=404
)

registrations = list_obj.registrations.all()
registrations = list_obj.registrations.select_related().all()
status_param = request.query_params.get("status")
category_param = request.query_params.get("category")
if status_param:
Expand Down
23 changes: 23 additions & 0 deletions pots/migrations/0013_potpayoutchallenge_tx_hash.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 5.0.6 on 2024-07-29 21:47

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("pots", "0012_alter_pot_base_currency_alter_pot_chef_and_more"),
]

operations = [
migrations.AddField(
model_name="potpayoutchallenge",
name="tx_hash",
field=models.CharField(
blank=True,
help_text="Transaction hash.",
null=True,
verbose_name="transaction hash",
),
),
]
6 changes: 6 additions & 0 deletions pots/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,12 @@ class PotPayoutChallenge(models.Model):
null=False,
help_text=_("Challenge message."),
)
tx_hash = models.CharField(
_("transaction hash"),
null=True,
blank=True,
help_text=_("Transaction hash."),
)

class Meta:
verbose_name_plural = "Payout Challenges"
Expand Down