Skip to content

Commit

Permalink
Merge branch 'master' into 945-feature-email-ifm-invitation-skal-være…
Browse files Browse the repository at this point in the history
…-flexibel-ligesom-ved-sletning-fra-venteliste
  • Loading branch information
rasmusselsmark authored Sep 24, 2023
2 parents 645d44a + e068013 commit 85d1838
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
4 changes: 2 additions & 2 deletions members/admin/activity_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ class ActivityParticipantInline(admin.TabularInline):
"person",
"note",
"photo_permission",
"payment_info_text",
"payment_info_html",
)
readonly_fields = fields
can_delete = False

def get_queryset(self, request):
return ActivityParticipant.objects.all()
return ActivityParticipant.objects.all().order_by("person")


class ActivityUnionListFilter(admin.SimpleListFilter):
Expand Down
10 changes: 10 additions & 0 deletions members/admin/activityinvite_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ def get_form(self, request, obj=None, change=False, **kwargs):
"invite_dtm",
"expire_dtm",
"rejected_at",
"participating",
)
list_filter = (
ActivityInviteUnionListFilter,
Expand Down Expand Up @@ -244,3 +245,12 @@ def person_link(self, item):

person_link.short_description = "Person"
person_link.admin_order_field = "person__name"

def participating(self, item):
return (
item.person.activityparticipant_set.filter(activity=item.activity).count()
> 0
)

participating.short_description = "Deltager"
participating.boolean = True
11 changes: 10 additions & 1 deletion members/models/activityparticipant.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ def payment_info_text(self):

payment_info_text.short_description = "Betalingsinfo"

def payment_info_html(self):
return self.payment_info(True)

payment_info_html.short_description = "Betalingsinfo"

def payment_info(self, format_as_html: bool):
if format_as_html:
html_error_pre = "<span style='color:red'><b>"
Expand All @@ -77,7 +82,11 @@ def payment_info(self, format_as_html: bool):

# Checking for price = 0 before checking for payment
if self.activity.price_in_dkk == 0:
return f"{html_good_pre}Gratis.{html_post} "
result_string = f"{html_good_pre}Gratis.{html_post} "
if format_as_html:
return format_html(result_string)
else:
return result_string

try:
payment = members.models.payment.Payment.objects.get(
Expand Down

0 comments on commit 85d1838

Please sign in to comment.