Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
hypha
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
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
ots
hypha
Commits
6c5b32e4
Commit
6c5b32e4
authored
5 years ago
by
Parbhat Puri
Committed by
Fredrik Jonsson
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add validation for archive check to parent and minor updates
parent
362c3483
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
opentech/apply/categories/migrations/0003_archive_and_other_fields_for_meta_categories.py
+3
-3
3 additions, 3 deletions
...ions/0003_archive_and_other_fields_for_meta_categories.py
opentech/apply/categories/models.py
+12
-4
12 additions, 4 deletions
opentech/apply/categories/models.py
with
15 additions
and
7 deletions
opentech/apply/categories/migrations/0003_archive_and_other_fields_meta_categories.py
→
opentech/apply/categories/migrations/0003_archive_and_other_fields_
for_
meta_categories.py
+
3
−
3
View file @
6c5b32e4
# Generated by Django 2.0.13 on 2019-07-
09 11:14
# Generated by Django 2.0.13 on 2019-07-
16 06:01
from
django.db
import
migrations
,
models
from
django.db
import
migrations
,
models
import
wagtail.core.fields
import
wagtail.core.fields
...
@@ -13,8 +13,8 @@ class Migration(migrations.Migration):
...
@@ -13,8 +13,8 @@ class Migration(migrations.Migration):
operations
=
[
operations
=
[
migrations
.
AddField
(
migrations
.
AddField
(
model_name
=
'
metacategory
'
,
model_name
=
'
metacategory
'
,
name
=
'
available_to_applica
tio
ns
'
,
name
=
'
available_to_applican
t
s
'
,
field
=
models
.
BooleanField
(
default
=
Tru
e
,
help_text
=
'
Make available
for
applica
tio
ns
'
),
field
=
models
.
BooleanField
(
default
=
Fals
e
,
help_text
=
'
Make available
to
applican
t
s
'
),
),
),
migrations
.
AddField
(
migrations
.
AddField
(
model_name
=
'
metacategory
'
,
model_name
=
'
metacategory
'
,
...
...
This diff is collapsed.
Click to expand it.
opentech/apply/categories/models.py
+
12
−
4
View file @
6c5b32e4
...
@@ -57,8 +57,8 @@ class MetaCategory(index.Indexed, MP_Node):
...
@@ -57,8 +57,8 @@ class MetaCategory(index.Indexed, MP_Node):
filter_on_dashboard
=
models
.
BooleanField
(
filter_on_dashboard
=
models
.
BooleanField
(
default
=
True
,
help_text
=
'
Make available to filter on dashboard
'
default
=
True
,
help_text
=
'
Make available to filter on dashboard
'
)
)
available_to_applica
tio
ns
=
models
.
BooleanField
(
available_to_applican
t
s
=
models
.
BooleanField
(
default
=
Tru
e
,
help_text
=
'
Make available
for
applica
tio
ns
'
default
=
Fals
e
,
help_text
=
'
Make available
to
applican
t
s
'
)
)
# node tree specific fields and attributes
# node tree specific fields and attributes
...
@@ -71,12 +71,12 @@ class MetaCategory(index.Indexed, MP_Node):
...
@@ -71,12 +71,12 @@ class MetaCategory(index.Indexed, MP_Node):
panels
=
[
panels
=
[
FieldPanel
(
'
parent
'
),
FieldPanel
(
'
parent
'
),
FieldPanel
(
'
name
'
),
FieldPanel
(
'
name
'
),
FieldPanel
(
'
is_archived
'
),
MultiFieldPanel
(
MultiFieldPanel
(
[
[
FieldPanel
(
'
is_archived
'
),
FieldPanel
(
'
help_text
'
),
FieldPanel
(
'
help_text
'
),
FieldPanel
(
'
filter_on_dashboard
'
),
FieldPanel
(
'
filter_on_dashboard
'
),
FieldPanel
(
'
available_to_applica
tio
ns
'
),
FieldPanel
(
'
available_to_applican
t
s
'
),
],
],
heading
=
"
Options
"
,
heading
=
"
Options
"
,
),
),
...
@@ -155,6 +155,14 @@ class MetaCategoryForm(WagtailAdminModelForm):
...
@@ -155,6 +155,14 @@ class MetaCategoryForm(WagtailAdminModelForm):
elif
instance
.
id
:
elif
instance
.
id
:
self
.
fields
[
'
parent
'
].
initial
=
instance
.
get_parent
()
self
.
fields
[
'
parent
'
].
initial
=
instance
.
get_parent
()
def
clean_parent
(
self
):
parent
=
self
.
cleaned_data
[
'
parent
'
]
if
parent
.
is_archived
:
raise
forms
.
ValidationError
(
'
The parent is archived therefore can not add child under it.
'
)
return
parent
def
save
(
self
,
commit
=
True
,
*
args
,
**
kwargs
):
def
save
(
self
,
commit
=
True
,
*
args
,
**
kwargs
):
instance
=
super
().
save
(
commit
=
False
,
*
args
,
**
kwargs
)
instance
=
super
().
save
(
commit
=
False
,
*
args
,
**
kwargs
)
parent
=
self
.
cleaned_data
[
'
parent
'
]
parent
=
self
.
cleaned_data
[
'
parent
'
]
...
...
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