Skip to content

Commit 4188497

Browse files
berinhardewdurbin
andauthored
Bugfix: sponsorship package-only benefits disappearing (#1737)
* Add level name to list display * Do not disable input if benefit was selected * Allow to filter sponsorship applications by the level name * capture all active listings, not just ones with _only_ active = was missing active + package_only labels Co-authored-by: Ernest W. Durbin III <ewdurbin@gmail.com>
1 parent 6df19e3 commit 4188497

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

sponsors/admin.py

+17-1
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,21 @@ def has_delete_permission(self, request, obj=None):
119119
return obj.open_for_editing
120120

121121

122+
class LevelNameFilter(admin.SimpleListFilter):
123+
title = "level name"
124+
parameter_name = "level"
125+
126+
def lookups(self, request, model_admin):
127+
qs = SponsorshipPackage.objects.all()
128+
return list(set([(program.name, program.name) for program in qs]))
129+
130+
def queryset(self, request, queryset):
131+
if self.value() == "all":
132+
return queryset
133+
if self.value():
134+
return queryset.filter(level_name=self.value())
135+
136+
122137
@admin.register(Sponsorship)
123138
class SponsorshipAdmin(admin.ModelAdmin):
124139
change_form_template = "sponsors/admin/sponsorship_change_form.html"
@@ -127,13 +142,14 @@ class SponsorshipAdmin(admin.ModelAdmin):
127142
list_display = [
128143
"sponsor",
129144
"status",
145+
"level_name",
130146
"applied_on",
131147
"approved_on",
132148
"start_date",
133149
"end_date",
134150
"display_sponsorship_link",
135151
]
136-
list_filter = ["status"]
152+
list_filter = ["status", LevelNameFilter]
137153
readonly_fields = [
138154
"for_modified_package",
139155
"sponsor",

static/js/sponsors/applicationForm.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ $(document).ready(function(){
2424

2525
SELECTORS.clearFormBtn().click(function(){
2626
SELECTORS.applicationForm().trigger("reset");
27-
SELECTORS.applicationForm().find("[class=active]").removeClass("active");
27+
SELECTORS.applicationForm().find(".active").removeClass("active");
2828
SELECTORS.packageInput().prop("checked", false);
2929
SELECTORS.checkboxesContainer().find(':checkbox').each(function(){
3030
$(this).prop('checked', false);

templates/sponsors/sponsorship_benefits_form.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ <h3 class="title">{{ field.label }}</h3>
5454
{% for benefit in field.field.queryset %}
5555
<li class="{% cycle '' 'highlight' %}">
5656
<label for="id_{{field.name}}_{{ forloop.counter0 }}" {% if benefit.package_only %} class='package_only'{% endif %} benefit_id="{{ benefit.id }}">
57-
<input id="id_{{field.name}}_{{ forloop.counter0 }}" name="{{ field.name }}" type="checkbox" value="{{ benefit.id }}" {% if benefit.unavailability_message %}disabled{% endif %} {% if benefit.id in field.initial %}checked{% endif %} {% if benefit.package_only %}package_only='true'{% endif %}>
57+
<input id="id_{{field.name}}_{{ forloop.counter0 }}" name="{{ field.name }}" type="checkbox" value="{{ benefit.id }}" {% if benefit.unavailability_message and benefit.id not in field.initial %}disabled{% endif %} {% if benefit.id in field.initial %}checked{% endif %} {% if benefit.package_only %}package_only='true'{% endif %}>
5858
<span>{{ benefit.name }}</span>
5959
{% if benefit.description %}<i class="fa fa-info" title="{{ benefit.description }}"></i>{% endif %}
6060
{% if benefit.package_only %}<i class="fa fa-cubes" title="{{ benefit_model.PACKAGE_ONLY_MESSAGE }}"></i>{% endif %}

0 commit comments

Comments
 (0)