diff --git a/rdgenerator/forms.py b/rdgenerator/forms.py index f09df56..0a24a1b 100644 --- a/rdgenerator/forms.py +++ b/rdgenerator/forms.py @@ -1,4 +1,5 @@ from django import forms +from PIL import Image class GenerateForm(forms.Form): #Platform @@ -76,4 +77,28 @@ class GenerateForm(forms.Form): xOffline = forms.BooleanField(initial=False, required=False) hidecm = forms.BooleanField(initial=False, required=False) statussort = forms.BooleanField(initial=False, required=False) - removeNewVersionNotif = forms.BooleanField(initial=False, required=False) \ No newline at end of file + removeNewVersionNotif = forms.BooleanField(initial=False, required=False) + + def clean_iconfile(self): + print("checking icon") + image = self.cleaned_data['iconfile'] + try: + # Open the image using Pillow + img = Image.open(image) + + # Check if the image is a PNG (optional, but good practice) + if img.format != 'PNG': + raise forms.ValidationError("Only PNG images are allowed.") + + # Get image dimensions + width, height = img.size + + # Check for square dimensions + if width != height: + raise forms.ValidationError("Custom App Icon dimensions must be square.") + + return image + except OSError: # Handle cases where the uploaded file is not a valid image + raise forms.ValidationError("Invalid icon file.") + except Exception as e: # Catch any other image processing errors + raise forms.ValidationError(f"Error processing icon: {e}") \ No newline at end of file diff --git a/rdgenerator/templates/generator.html b/rdgenerator/templates/generator.html index 139d4a8..7409613 100644 --- a/rdgenerator/templates/generator.html +++ b/rdgenerator/templates/generator.html @@ -122,6 +122,20 @@ .error { color: red; } + .errorlist { + color: red; + display: flex; /* Enable flexbox for centering */ + justify-content: center; /* Center horizontally */ + align-items: center; /* Center vertically (if needed) */ + list-style: none; /* Remove bullet points if it's a list */ + padding: 0; /* Remove default padding */ + margin: 10px auto; /* Center the list itself, add some top/bottom margin */ + width: fit-content; /* Make the width fit the content */ + } + + .errorlist li { + margin: 5px; /* Add some spacing between list items */ + } @@ -137,6 +151,13 @@ + {% if form.iconfile.errors %} + + {% endif %}

Select Platform