Skip to content

Commit bd837b6

Browse files
committed
Merge branch 'main' into release
2 parents 95f98c7 + 0d5432a commit bd837b6

File tree

15 files changed

+241
-47
lines changed

15 files changed

+241
-47
lines changed

downloads/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class Meta(GenericResource.Meta):
6969
'creator', 'last_modified_by',
7070
'os', 'release', 'description', 'is_source', 'url', 'gpg_signature_file',
7171
'md5_sum', 'filesize', 'download_button', 'sigstore_signature_file',
72-
'sigstore_cert_file', 'sigstore_bundle_file',
72+
'sigstore_cert_file', 'sigstore_bundle_file', 'sbom_spdx2_file',
7373
]
7474
filtering = {
7575
'name': ('exact',),
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Generated by Django 2.2.24 on 2024-01-12 21:04
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('downloads', '0009_releasefile_sigstore_bundle_file'),
10+
]
11+
12+
operations = [
13+
migrations.AddField(
14+
model_name='releasefile',
15+
name='sbom_spdx2_file',
16+
field=models.URLField(blank=True, help_text='SPDX-2 SBOM URL', verbose_name='SPDX-2 SBOM URL'),
17+
),
18+
]

downloads/models.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,9 @@ class ReleaseFile(ContentManageable, NameSlugModel):
332332
sigstore_bundle_file = models.URLField(
333333
"Sigstore Bundle URL", blank=True, help_text="Sigstore Bundle URL"
334334
)
335+
sbom_spdx2_file = models.URLField(
336+
"SPDX-2 SBOM URL", blank=True, help_text="SPDX-2 SBOM URL"
337+
)
335338
md5_sum = models.CharField('MD5 Sum', max_length=200, blank=True)
336339
filesize = models.IntegerField(default=0)
337340
download_button = models.BooleanField(default=False, help_text="Use for the supernav download button for this OS")

downloads/serializers.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,5 @@ class Meta:
4949
'sigstore_signature_file',
5050
'sigstore_cert_file',
5151
'sigstore_bundle_file',
52+
'sbom_spdx2_file',
5253
)

downloads/templatetags/download_tags.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,8 @@ def has_sigstore_materials(files):
1414
f.sigstore_bundle_file or f.sigstore_cert_file or f.sigstore_signature_file
1515
for f in files
1616
)
17+
18+
19+
@register.filter
20+
def has_sbom(files):
21+
return any(f.sbom_spdx2_file for f in files)

sponsors/admin.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,9 +246,13 @@ def has_delete_permission(self, request, obj=None):
246246
return True
247247
return obj.open_for_editing
248248

249-
def get_queryset(self, *args, **kwargs):
250-
qs = super().get_queryset(*args, **kwargs)
251-
return qs.select_related("sponsorship_benefit__program", "program")
249+
def get_queryset(self, request):
250+
#filters the available benefits by the benefits for the year of the sponsorship
251+
match = request.resolver_match
252+
sponsorship = self.parent_model.objects.get(pk=match.kwargs["object_id"])
253+
year = sponsorship.year
254+
255+
return super().get_queryset(request).filter(sponsorship_benefit__year=year)
252256

253257

254258
class TargetableEmailBenefitsFilter(admin.SimpleListFilter):

sponsors/forms.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,10 +253,17 @@ class SponsorshipApplicationForm(forms.Form):
253253
state = forms.CharField(
254254
label="State/Province/Region", max_length=64, required=False
255255
)
256+
state_of_incorporation = forms.CharField(
257+
label="State of incorporation", help_text="US only, If different than mailing address", max_length=64, required=False
258+
)
256259
postal_code = forms.CharField(
257260
label="Zip/Postal Code", max_length=64, required=False
258261
)
259-
country = CountryField().formfield(required=False)
262+
country = CountryField().formfield(required=False, help_text="For mailing/contact purposes")
263+
264+
country_of_incorporation = CountryField().formfield(
265+
label="Country of incorporation", help_text="For contractual purposes", required=False
266+
)
260267

261268
def __init__(self, *args, **kwargs):
262269
self.user = kwargs.pop("user", None)
@@ -373,6 +380,8 @@ def save(self):
373380
landing_page_url=self.cleaned_data.get("landing_page_url", ""),
374381
twitter_handle=self.cleaned_data["twitter_handle"],
375382
print_logo=self.cleaned_data.get("print_logo"),
383+
country_of_incorporation=self.cleaned_data.get("country_of_incorporation", ""),
384+
state_of_incorporation=self.cleaned_data.get("state_of_incorporation", ""),
376385
)
377386
contacts = [f.save(commit=False) for f in self.contacts_formset.forms]
378387
for contact in contacts:
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Generated by Django 2.2.24 on 2024-01-07 10:54
2+
3+
from django.db import migrations, models
4+
import django_countries.fields
5+
6+
7+
class Migration(migrations.Migration):
8+
9+
dependencies = [
10+
('sponsors', '0099_auto_20231224_1854'),
11+
]
12+
13+
operations = [
14+
migrations.AddField(
15+
model_name='sponsor',
16+
name='country_of_incorporation',
17+
field=django_countries.fields.CountryField(blank=True, help_text='For contractual purposes', max_length=2, null=True, verbose_name='Country of incorporation (If different)'),
18+
),
19+
migrations.AddField(
20+
model_name='sponsor',
21+
name='state_of_incorporation',
22+
field=models.CharField(blank=True, default='', max_length=64, null=True, verbose_name='US only: State of incorporation (If different)'),
23+
),
24+
migrations.AlterField(
25+
model_name='sponsor',
26+
name='country',
27+
field=django_countries.fields.CountryField(default='', help_text='For mailing/contact purposes', max_length=2),
28+
),
29+
]

sponsors/models/sponsors.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,15 @@ class Sponsor(ContentManageable):
7373
postal_code = models.CharField(
7474
verbose_name="Zip/Postal Code", max_length=64, default=""
7575
)
76-
country = CountryField(default="")
76+
country = CountryField(default="", help_text="For mailing/contact purposes")
7777
assets = GenericRelation(GenericAsset)
78+
country_of_incorporation = CountryField(
79+
verbose_name="Country of incorporation (If different)", help_text="For contractual purposes", blank=True, null=True
80+
)
81+
state_of_incorporation = models.CharField(
82+
verbose_name="US only: State of incorporation (If different)",
83+
max_length=64, blank=True, null=True, default=""
84+
)
7885

7986
class Meta:
8087
verbose_name = "sponsor"

sponsors/tests/test_forms.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,14 +423,18 @@ def test_create_sponsor_with_valid_data(self):
423423
def test_create_sponsor_with_valid_data_for_non_required_inputs(
424424
self,
425425
):
426+
user = baker.make(settings.AUTH_USER_MODEL)
427+
426428
self.data["description"] = "Important company"
427429
self.data["landing_page_url"] = "https://companyx.com"
428430
self.data["twitter_handle"] = "@companyx"
431+
self.data["country_of_incorporation"] = "US"
432+
self.data["state_of_incorporation"] = "NY"
429433
self.files["print_logo"] = get_static_image_file_as_upload(
430434
"psf-logo_print.png", "logo_print.png"
431435
)
432436

433-
form = SponsorshipApplicationForm(self.data, self.files)
437+
form = SponsorshipApplicationForm(self.data, self.files, user=user)
434438
self.assertTrue(form.is_valid(), form.errors)
435439

436440
sponsor = form.save()
@@ -440,6 +444,8 @@ def test_create_sponsor_with_valid_data_for_non_required_inputs(
440444
self.assertFalse(form.user_with_previous_sponsors)
441445
self.assertEqual(sponsor.landing_page_url, "https://companyx.com")
442446
self.assertEqual(sponsor.twitter_handle, "@companyx")
447+
self.assertEqual(sponsor.country_of_incorporation, "US")
448+
self.assertEqual(sponsor.state_of_incorporation, "NY")
443449

444450
def test_create_sponsor_with_svg_for_print_logo(
445451
self,

0 commit comments

Comments
 (0)