Skip to content
Draft
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
12 changes: 0 additions & 12 deletions backend/conferences/admin/conference.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,18 +184,6 @@ class ConferenceAdmin(
)
},
),
(
"Grants",
{
"fields": (
"grants_default_ticket_amount",
"grants_default_accommodation_amount",
"grants_default_travel_from_italy_amount",
"grants_default_travel_from_europe_amount",
"grants_default_travel_from_extra_eu_amount",
)
},
),
("YouTube", {"fields": ("video_title_template", "video_description_template")}),
)
inlines = [DeadlineInline, DurationInline, SponsorLevelInline, IncludedEventInline]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Generated by Django 5.1.4 on 2025-07-27 14:30

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('conferences', '0054_conference_frontend_revalidate_secret_and_more'),
]

operations = [
migrations.RemoveField(
model_name='conference',
name='grants_default_accommodation_amount',
),
migrations.RemoveField(
model_name='conference',
name='grants_default_ticket_amount',
),
migrations.RemoveField(
model_name='conference',
name='grants_default_travel_from_europe_amount',
),
migrations.RemoveField(
model_name='conference',
name='grants_default_travel_from_extra_eu_amount',
),
migrations.RemoveField(
model_name='conference',
name='grants_default_travel_from_italy_amount',
),
]
41 changes: 0 additions & 41 deletions backend/conferences/models/conference.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,47 +93,6 @@ class Conference(GeoLocalizedModel, TimeFramedModel, TimeStampedModel):
default="",
)

grants_default_ticket_amount = models.DecimalField(
verbose_name=_("grants default ticket amount"),
null=True,
blank=True,
max_digits=6,
decimal_places=2,
default=None,
)
grants_default_accommodation_amount = models.DecimalField(
verbose_name=_("grants default accommodation amount"),
null=True,
blank=True,
max_digits=6,
decimal_places=2,
default=None,
)
grants_default_travel_from_italy_amount = models.DecimalField(
verbose_name=_("grants default travel from Italy amount"),
null=True,
blank=True,
max_digits=6,
decimal_places=2,
default=None,
)
grants_default_travel_from_europe_amount = models.DecimalField(
verbose_name=_("grants default travel from Europe amount"),
null=True,
blank=True,
max_digits=6,
decimal_places=2,
default=None,
)
grants_default_travel_from_extra_eu_amount = models.DecimalField(
verbose_name=_("grants default travel from Extra EU amount"),
null=True,
blank=True,
max_digits=6,
decimal_places=2,
default=None,
)

video_title_template = models.TextField(
default="",
blank=True,
Expand Down
67 changes: 55 additions & 12 deletions backend/grants/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
create_addition_admin_log_entry,
create_change_admin_log_entry,
)
from django.db.models import Value, IntegerField

from django.db.models import Sum
from django.db.models.functions import Coalesce
from conferences.models.conference_voucher import ConferenceVoucher
from pycon.constants import UTC
from custom_admin.admin import (
Expand All @@ -30,7 +34,12 @@
)
from schedule.models import ScheduleItem
from submissions.models import Submission
from .models import Grant, GrantConfirmPendingStatusProxy
from .models import (
Grant,
GrantConfirmPendingStatusProxy,
GrantReimbursementCategory,
GrantReimbursement,
)
from django.db.models import Exists, OuterRef, F
from pretix import user_has_admission_ticket

Expand Down Expand Up @@ -393,6 +402,32 @@ def queryset(self, request, queryset):
return queryset


@admin.register(GrantReimbursementCategory)
class GrantReimbursementCategoryAdmin(ConferencePermissionMixin, admin.ModelAdmin):
list_display = ("__str__", "max_amount", "category", "included_by_default")
list_filter = ("conference", "category", "included_by_default")
search_fields = ("category", "name")


@admin.register(GrantReimbursement)
class GrantReimbursementAdmin(ConferencePermissionMixin, admin.ModelAdmin):
list_display = (
"grant",
"category",
"granted_amount",
)
list_filter = ("grant__conference", "category")
search_fields = ("grant__full_name", "grant__email")
autocomplete_fields = ("grant",)


class GrantReimbursementInline(admin.TabularInline):
model = GrantReimbursement
extra = 0
autocomplete_fields = ["category"]
fields = ["category", "granted_amount"]


@admin.register(Grant)
class GrantAdmin(ExportMixin, ConferencePermissionMixin, admin.ModelAdmin):
change_list_template = "admin/grants/grant/change_list.html"
Expand All @@ -405,11 +440,7 @@ class GrantAdmin(ExportMixin, ConferencePermissionMixin, admin.ModelAdmin):
"emoji_gender",
"conference",
"status",
"approved_type",
"ticket_amount",
"travel_amount",
"accommodation_amount",
"total_amount",
"total_amount_display",
"country_type",
"user_has_ticket",
"has_voucher",
Expand All @@ -423,7 +454,6 @@ class GrantAdmin(ExportMixin, ConferencePermissionMixin, admin.ModelAdmin):
"pending_status",
"country_type",
"occupation",
"approved_type",
"needs_funds_for_travel",
"need_visa",
"need_accommodation",
Expand All @@ -449,6 +479,7 @@ class GrantAdmin(ExportMixin, ConferencePermissionMixin, admin.ModelAdmin):
"delete_selected",
]
autocomplete_fields = ("user",)
inlines = [GrantReimbursementInline]

fieldsets = (
(
Expand All @@ -457,12 +488,7 @@ class GrantAdmin(ExportMixin, ConferencePermissionMixin, admin.ModelAdmin):
"fields": (
"status",
"pending_status",
"approved_type",
"country_type",
"ticket_amount",
"travel_amount",
"accommodation_amount",
"total_amount",
"applicant_reply_sent_at",
"applicant_reply_deadline",
"internal_notes",
Expand Down Expand Up @@ -584,10 +610,22 @@ def user_has_ticket(self, obj: Grant) -> bool:
def has_voucher(self, obj: Grant) -> bool:
return obj.has_voucher

@admin.display(description="Total")
def total_amount_display(self, obj):
return f"{obj.total_allocated:.2f}"

@admin.display(description="Approved Reimbursements")
def approved_amounts_display(self, obj):
return ", ".join(
f"{r.category.name}: {r.granted_amount}" for r in obj.reimbursements.all()
)

def get_queryset(self, request):
qs = (
super()
.get_queryset(request)
.select_related("user")
.prefetch_related("reimbursements__category")
.annotate(
is_proposed_speaker=Exists(
Submission.objects.non_cancelled().filter(
Expand All @@ -608,6 +646,11 @@ def get_queryset(self, request):
user_id=OuterRef("user_id"),
)
),
total_allocated=Coalesce(
Sum("reimbursements__granted_amount"),
Value(0),
output_field=IntegerField(),
),
)
)

Expand Down
Loading