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
1e9ae5c6
Commit
1e9ae5c6
authored
4 years ago
by
sks444
Browse files
Options
Downloads
Patches
Plain Diff
When default screening status changes replace submission with new default
parent
ed6504e0
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
hypha/apply/funds/admin_forms.py
+16
-10
16 additions, 10 deletions
hypha/apply/funds/admin_forms.py
with
16 additions
and
10 deletions
hypha/apply/funds/admin_forms.py
+
16
−
10
View file @
1e9ae5c6
...
@@ -4,6 +4,7 @@ from django.apps import apps
...
@@ -4,6 +4,7 @@ from django.apps import apps
from
wagtail.admin.forms
import
WagtailAdminModelForm
,
WagtailAdminPageForm
from
wagtail.admin.forms
import
WagtailAdminModelForm
,
WagtailAdminPageForm
from
.workflow
import
WORKFLOWS
from
.workflow
import
WORKFLOWS
from
.models.submissions
import
ApplicationSubmission
class
WorkflowFormAdminForm
(
WagtailAdminPageForm
):
class
WorkflowFormAdminForm
(
WagtailAdminPageForm
):
...
@@ -87,20 +88,25 @@ class RoundBasePageAdminForm(WagtailAdminPageForm):
...
@@ -87,20 +88,25 @@ class RoundBasePageAdminForm(WagtailAdminPageForm):
class
ScreeningStatusAdminForm
(
WagtailAdminModelForm
):
class
ScreeningStatusAdminForm
(
WagtailAdminModelForm
):
def
clean
(
self
):
def
save
(
self
,
commit
=
True
):
cleaned_data
=
super
().
clean
()
default
=
self
.
cleaned_data
[
'
default
'
]
default
=
cleaned_data
[
'
default
'
]
yes
=
self
.
cleaned_data
[
'
yes
'
]
yes
=
cleaned_data
[
'
yes
'
]
ScreeningStatus
=
apps
.
get_model
(
'
funds
'
,
'
ScreeningStatus
'
)
ScreeningStatus
=
apps
.
get_model
(
'
funds
'
,
'
ScreeningStatus
'
)
if
default
:
if
default
:
try
:
try
:
default_
yes
=
ScreeningStatus
.
objects
.
get
(
default_
screening
=
ScreeningStatus
.
objects
.
get
(
default
=
True
,
yes
=
yes
default
=
default
,
yes
=
yes
)
)
except
ScreeningStatus
.
DoesNotExist
:
except
ScreeningStatus
.
DoesNotExist
:
pass
pass
else
:
else
:
if
default_yes
.
id
!=
self
.
instance
.
id
:
screening
=
super
().
save
(
commit
)
yes_or_no
=
'
yes
'
if
yes
else
'
no
'
if
default_screening
.
id
!=
screening
.
id
:
self
.
add_error
(
'
default
'
,
f
'
Can not set two ScreeningStatus as default
{
yes_or_no
}
'
)
submissions
=
ApplicationSubmission
.
objects
.
filter
(
screening_statuses__id
=
default_screening
.
id
)
return
cleaned_data
for
submission
in
submissions
:
submission
.
screening_statuses
.
remove
(
default_screening
)
submission
.
screening_statuses
.
add
(
screening
)
default_screening
.
default
=
False
default_screening
.
save
()
return
screening
return
super
().
save
(
commit
)
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