Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
I
internewshid
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
Service Desk
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
aptivate
client-projects
internewshid
Commits
1cce883b
Commit
1cce883b
authored
9 years ago
by
Martin Burchell
Browse files
Options
Downloads
Patches
Plain Diff
Made category field not required on item edit form
parent
dcc35581
No related branches found
No related tags found
1 merge request
!37
Items can be edited when form is submitted
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
django/website/hid/forms/item.py
+1
-1
1 addition, 1 deletion
django/website/hid/forms/item.py
django/website/hid/tests/add_edit_form_tests.py
+12
-0
12 additions, 0 deletions
django/website/hid/tests/add_edit_form_tests.py
with
13 additions
and
1 deletion
django/website/hid/forms/item.py
+
1
−
1
View file @
1cce883b
...
...
@@ -30,7 +30,7 @@ class AddEditItemForm(forms.Form):
choices
=
((
''
,
'
-----
'
),)
choices
+=
tuple
((
t
[
'
name
'
],
t
[
'
name
'
])
for
t
in
terms
)
self
.
fields
[
'
category
'
]
=
forms
.
ChoiceField
(
choices
=
choices
choices
=
choices
,
required
=
False
)
# The template already has support for optional fields:
# 'region' (select)
...
...
This diff is collapsed.
Click to expand it.
django/website/hid/tests/add_edit_form_tests.py
+
12
−
0
View file @
1cce883b
...
...
@@ -49,3 +49,15 @@ def test_form_category_has_expected_choices():
form
=
AddEditItemForm
(
'
some-item-type
'
)
assert
'
category
'
in
form
.
fields
assert
form
.
fields
[
'
category
'
].
choices
==
expected_choices
def
test_category_field_is_not_required
():
item_type_category
=
{
'
some-item-type
'
:
'
some-taxonomy
'
}
with
patch
.
dict
(
'
hid.forms.item.ITEM_TYPE_CATEGORY
'
,
item_type_category
):
with
patch
(
'
hid.forms.item.transport.terms.list
'
)
as
term_list
:
term_list
.
return_value
=
[]
form
=
AddEditItemForm
(
'
some-item-type
'
)
assert
not
form
.
fields
[
'
category
'
].
required
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