mirror of
https://gitlab.com/animath/si/plateforme-corres2math.git
synced 2025-07-04 12:52:15 +02:00
Upload photo authorizations
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
from django import forms
|
||||
from django.contrib.auth.forms import UserCreationForm
|
||||
from django.contrib.auth.models import User
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from .models import AdminRegistration, CoachRegistration, StudentRegistration
|
||||
@ -44,6 +45,18 @@ class StudentRegistrationForm(forms.ModelForm):
|
||||
fields = ('student_class', 'school', 'give_contact_to_animath',)
|
||||
|
||||
|
||||
class PhotoAuthorizationForm(forms.ModelForm):
|
||||
def clean_photo_authorization(self):
|
||||
file = self.files["photo_authorization"]
|
||||
if file.content_type not in ["application/pdf", "image/png", "image/jpeg"]:
|
||||
raise ValidationError(_("The uploaded file must be a PDF, PNG of JPEG file."))
|
||||
return self.cleaned_data["photo_authorization"]
|
||||
|
||||
class Meta:
|
||||
model = StudentRegistration
|
||||
fields = ('photo_authorization',)
|
||||
|
||||
|
||||
class CoachRegistrationForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = CoachRegistration
|
||||
|
Reference in New Issue
Block a user