Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
steering
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AURA
steering
Commits
0d43cf48
Commit
0d43cf48
authored
12 years ago
by
Ernesto Rico Schmidt
Browse files
Options
Downloads
Patches
Plain Diff
added forms.py
parent
4ccc96c6
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
program/forms.py
+42
-0
42 additions, 0 deletions
program/forms.py
with
42 additions
and
0 deletions
program/forms.py
0 → 100644
+
42
−
0
View file @
0d43cf48
from
django
import
forms
from
django.core.files.images
import
get_image_dimensions
from
program.models
import
MusicFocus
,
ShowInformation
,
ShowTopic
class
FormWithButton
(
forms
.
ModelForm
):
def
clean_button
(
self
):
button
=
self
.
cleaned_data
.
get
(
'
button
'
)
if
button
:
width
,
height
=
get_image_dimensions
(
button
)
if
width
!=
11
or
height
!=
11
:
raise
forms
.
ValidationError
(
"
width or height is not 11, (11x11)
"
)
return
button
def
clean_button_hover
(
self
):
button_hover
=
self
.
cleaned_data
.
get
(
'
button_hover
'
)
if
button_hover
:
width
,
height
=
get_image_dimensions
(
button_hover
)
if
width
!=
11
or
height
!=
11
:
raise
forms
.
ValidationError
(
"
width or height is not 11, (11x11)
"
)
return
button_hover
def
clean_big_button
(
self
):
big_button
=
self
.
cleaned_data
.
get
(
'
big_button
'
)
if
big_button
:
width
,
height
=
get_image_dimensions
(
big_button
)
if
width
!=
17
or
height
!=
17
:
raise
forms
.
ValidationError
(
"
width or height is not 17, (17x17)
"
)
return
big_button
class
MusicFocusForm
(
FormWithButton
):
class
Meta
:
model
=
MusicFocus
class
ShowInformationForm
(
FormWithButton
):
class
Meta
:
model
=
ShowInformation
class
ShowTopicForm
(
FormWithButton
):
class
Meta
:
model
=
ShowTopic
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment