Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix transaction issue #381

Merged
merged 2 commits into from
Sep 21, 2024
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
16 changes: 16 additions & 0 deletions server/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from django.http import HttpRequest, HttpResponse

from server.core.models import (
Accreditation,
Guardianship,
Player,
Team,
Expand Down Expand Up @@ -301,3 +302,18 @@ def get_name(self, obj: Guardianship) -> str:
@admin.display(description="Player", ordering="player__user__first_name")
def get_email(self, obj: Guardianship) -> str:
return obj.player.user.get_full_name()


@admin.register(Accreditation)
class AccreditationAdmin(admin.ModelAdmin[Accreditation]):
search_fields = [
"player__user__first_name",
"player__user__last_name",
"player__user__username",
]
list_display = ["get_email", "is_valid", "level"]
list_filter = ["is_valid", "level"]

@admin.display(description="Player", ordering="player__user__first_name")
def get_email(self, obj: Guardianship) -> str:
return obj.player.user.get_full_name()
16 changes: 10 additions & 6 deletions server/transaction/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from typing import Any

from django.conf import settings
from django.db import IntegrityError
from django.db.models import Model, Q, QuerySet

from server.constants import EVENT_MEMBERSHIP_AMOUNT
Expand Down Expand Up @@ -334,13 +335,16 @@ def update_transaction_player_registrations(
transaction: RazorpayTransaction,
) -> None:
for player in transaction.players.all():
registration = Registration(
event=transaction.event,
team=transaction.team,
player=player,
)
try:
registration = Registration(
event=transaction.event,
team=transaction.team,
player=player,
)

registration.save()
registration.save()
except IntegrityError:
pass


def list_transactions_by_type(
Expand Down
Loading