Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
PyWebCooking
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
20
Issues
20
List
Boards
Labels
Milestones
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
cooking
PyWebCooking
Commits
3e20fcc8
Commit
3e20fcc8
authored
Apr 22, 2018
by
Floréal Cabanettes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix bug if category db does not exists
parent
1ddf120a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
5 deletions
+13
-5
panel/forms.py
panel/forms.py
+13
-5
No files found.
panel/forms.py
View file @
3e20fcc8
from
django
import
forms
from
django.utils.translation
import
ugettext
as
_
,
pgettext
as
__
from
django.db.utils
import
OperationalError
from
main.models.Category
import
Category
...
...
@@ -19,11 +20,18 @@ class BaseForm(forms.Form):
class
RecipeForm
(
BaseForm
):
title
=
forms
.
CharField
(
label
=
_
(
'Title'
),
max_length
=
255
,
required
=
True
)
slug
=
forms
.
CharField
(
label
=
_
(
"Slug"
),
max_length
=
255
,
required
=
True
)
categories
=
forms
.
MultipleChoiceField
(
label
=
_
(
'Categories'
),
choices
=
[(
cat
.
id
,
cat
.
name
)
for
cat
in
Category
.
objects
.
order_by
(
'order'
)],
widget
=
forms
.
CheckboxSelectMultiple
)
try
:
categories
=
forms
.
MultipleChoiceField
(
label
=
_
(
'Categories'
),
choices
=
[(
cat
.
id
,
cat
.
name
)
for
cat
in
Category
.
objects
.
order_by
(
'order'
)],
widget
=
forms
.
CheckboxSelectMultiple
)
except
OperationalError
:
categories
=
forms
.
MultipleChoiceField
(
label
=
_
(
'Categories'
),
choices
=
[],
widget
=
forms
.
CheckboxSelectMultiple
)
tps_prep_hr
=
forms
.
IntegerField
(
label
=
_
(
"hours"
),
min_value
=
0
)
tps_prep_min
=
forms
.
IntegerField
(
label
=
_
(
"minutes"
),
min_value
=
0
,
max_value
=
59
,
required
=
True
)
tps_break_j
=
forms
.
IntegerField
(
label
=
_
(
"days"
),
min_value
=
0
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment