Skip to content

Commit

Permalink
changing imagefield to file field on sponsorupdateform and sponsorshi…
Browse files Browse the repository at this point in the history
…papplicationform. adding django file validator to these two and the sponsor model
  • Loading branch information
jessiebelle committed Dec 24, 2023
1 parent cbc6c14 commit 3c59256
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
7 changes: 5 additions & 2 deletions sponsors/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from django import forms
from django.conf import settings
from django.contrib.admin.widgets import AdminDateWidget
from django.core.validators import FileExtensionValidator
from django.db.models import Q
from django.utils import timezone
from django.utils.functional import cached_property
Expand Down Expand Up @@ -225,10 +226,11 @@ class SponsorshipApplicationForm(forms.Form):
help_text="For display on our sponsor webpage. High resolution PNG or JPG, smallest dimension no less than 256px",
required=False,
)
print_logo = forms.ImageField(
print_logo = forms.FileField(
label="Sponsor print logo",
help_text="For printed materials, signage, and projection. SVG or EPS",
required=False,
validators=[FileExtensionValidator(['eps', 'epsf' 'epsi', 'svg'])],
)

primary_phone = forms.CharField(
Expand Down Expand Up @@ -557,10 +559,11 @@ class SponsorUpdateForm(forms.ModelForm):
help_text="For display on our sponsor webpage. High resolution PNG or JPG, smallest dimension no less than 256px",
required=False,
)
print_logo = forms.ImageField(
print_logo = forms.FileField(
widget=forms.widgets.FileInput,
help_text="For printed materials, signage, and projection. SVG or EPS",
required=False,
validators=[FileExtensionValidator(['eps', 'epsf' 'epsi', 'svg'])],
)

def __init__(self, *args, **kwargs):
Expand Down
19 changes: 19 additions & 0 deletions sponsors/migrations/0099_auto_20231224_1829.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 2.2.24 on 2023-12-24 18:29

import django.core.validators
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('sponsors', '0098_auto_20231219_1910'),
]

operations = [
migrations.AlterField(
model_name='sponsor',
name='print_logo',
field=models.FileField(blank=True, help_text='For printed materials, signage, and projection. SVG or EPS', null=True, upload_to='sponsor_print_logos', validators=[django.core.validators.FileExtensionValidator(['eps', 'epsfepsi', 'svg'])], verbose_name='Print logo'),
),
]
2 changes: 2 additions & 0 deletions sponsors/models/sponsors.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""
from allauth.account.models import EmailAddress
from django.conf import settings
from django.core.validators import FileExtensionValidator
from django.db import models
from django.core.exceptions import ObjectDoesNotExist
from django.template.defaultfilters import slugify
Expand Down Expand Up @@ -51,6 +52,7 @@ class Sponsor(ContentManageable):
)
print_logo = models.FileField(
upload_to="sponsor_print_logos",
validators=[FileExtensionValidator(['eps', 'epsf' 'epsi', 'svg'])],
blank=True,
null=True,
verbose_name="Print logo",
Expand Down

0 comments on commit 3c59256

Please sign in to comment.