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
7a28d1e4
Commit
7a28d1e4
authored
6 years ago
by
Todd Dembrey
Committed by
Fredrik Jonsson
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Allow redirects post determination - fixes an error case but safe to keep
parent
7e497db6
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
opentech/apply/determinations/views.py
+24
-1
24 additions, 1 deletion
opentech/apply/determinations/views.py
opentech/apply/funds/tests/test_views.py
+21
-0
21 additions, 0 deletions
opentech/apply/funds/tests/test_views.py
opentech/apply/funds/views.py
+4
-5
4 additions, 5 deletions
opentech/apply/funds/views.py
with
49 additions
and
6 deletions
opentech/apply/determinations/views.py
+
24
−
1
View file @
7a28d1e4
...
...
@@ -11,11 +11,12 @@ from django.views.generic import DetailView
from
opentech.apply.activity.models
import
Activity
from
opentech.apply.activity.messaging
import
messenger
,
MESSAGES
from
opentech.apply.funds.models
import
ApplicationSubmission
from
opentech.apply.funds.workflow
import
DETERMINATION_OUTCOMES
from
opentech.apply.utils.views
import
CreateOrUpdateView
,
ViewDispatcher
from
opentech.apply.users.decorators
import
staff_required
from
.forms
import
ConceptDeterminationForm
,
ProposalDeterminationForm
from
.models
import
Determination
,
DeterminationMessageSettings
,
NEEDS_MORE_INFO
from
.models
import
Determination
,
DeterminationMessageSettings
,
NEEDS_MORE_INFO
,
TRANSITION_DETERMINATION
from
.utils
import
can_create_determination
,
can_edit_determination
,
has_final_determination
,
transition_from_outcome
...
...
@@ -109,6 +110,28 @@ class DeterminationCreateOrUpdateView(CreateOrUpdateView):
return
HttpResponseRedirect
(
self
.
submission
.
get_absolute_url
())
@classmethod
def
should_redirect
(
cls
,
request
,
submission
,
action
):
if
has_final_determination
(
submission
):
determination
=
submission
.
determinations
.
final
().
first
()
if
determination
.
outcome
==
TRANSITION_DETERMINATION
[
action
]:
# We want to progress as normal so don't redirect through form
return
False
else
:
# Add a helpful message to prompt them to select the correct option
messages
.
warning
(
request
,
_
(
'
A determination of
"
{current}
"
exists but you tried to progress as
"
{target}
"'
).
format
(
current
=
determination
.
get_outcome_display
(),
target
=
action
,
)
)
if
action
in
DETERMINATION_OUTCOMES
:
return
HttpResponseRedirect
(
reverse_lazy
(
'
apply:submissions:determinations:form
'
,
args
=
(
submission
.
id
,))
+
"
?action=
"
+
action
)
@method_decorator
(
staff_required
,
name
=
'
dispatch
'
)
class
AdminDeterminationDetailView
(
DetailView
):
...
...
This diff is collapsed.
Click to expand it.
opentech/apply/funds/tests/test_views.py
+
21
−
0
View file @
7a28d1e4
...
...
@@ -2,6 +2,7 @@ from datetime import datetime, timedelta
import
json
from
opentech.apply.activity.models
import
Activity
from
opentech.apply.determinations.tests.factories
import
DeterminationFactory
from
opentech.apply.funds.tests.factories
import
(
ApplicationSubmissionFactory
,
ApplicationRevisionFactory
,
...
...
@@ -100,6 +101,26 @@ class TestStaffSubmissionView(BaseSubmissionViewTestCase):
self
.
assertEqual
(
submission
.
status
,
'
concept_review_discussion
'
)
self
.
assertIsNone
(
submission
.
next
)
def
test_not_redirected_if_determination_submitted
(
self
):
submission
=
ApplicationSubmissionFactory
(
lead
=
self
.
user
)
DeterminationFactory
(
submission
=
submission
,
rejected
=
True
,
submitted
=
True
)
self
.
post_page
(
submission
,
{
'
form-submitted-progress_form
'
:
''
,
'
action
'
:
'
rejected
'
})
submission
=
self
.
refresh
(
submission
)
self
.
assertEqual
(
submission
.
status
,
'
rejected
'
)
def
test_not_redirected_if_wrong_determination_selected
(
self
):
submission
=
ApplicationSubmissionFactory
(
lead
=
self
.
user
)
DeterminationFactory
(
submission
=
submission
,
accepted
=
True
,
submitted
=
True
)
response
=
self
.
post_page
(
submission
,
{
'
form-submitted-progress_form
'
:
''
,
'
action
'
:
'
rejected
'
})
self
.
assertContains
(
response
,
'
you tried to progress
'
)
submission
=
self
.
refresh
(
submission
)
self
.
assertNotEqual
(
submission
.
status
,
'
accepted
'
)
self
.
assertNotEqual
(
submission
.
status
,
'
rejected
'
)
def
test_cant_access_edit_button_when_applicant_editing
(
self
):
submission
=
ApplicationSubmissionFactory
(
status
=
'
more_info
'
)
response
=
self
.
get_page
(
submission
)
...
...
This diff is collapsed.
Click to expand it.
opentech/apply/funds/views.py
+
4
−
5
View file @
7a28d1e4
...
...
@@ -21,7 +21,7 @@ from opentech.apply.activity.views import (
DelegatedViewMixin
,
)
from
opentech.apply.activity.messaging
import
messenger
,
MESSAGES
from
opentech.apply.
funds.workflow
import
DETERMINATION_OUTCOMES
from
opentech.apply.
determinations.views
import
DeterminationCreateOrUpdateView
from
opentech.apply.review.views
import
ReviewContextMixin
from
opentech.apply.users.decorators
import
staff_required
from
opentech.apply.utils.views
import
DelegateableView
,
ViewDispatcher
...
...
@@ -80,10 +80,9 @@ class ProgressSubmissionView(DelegatedViewMixin, UpdateView):
def
form_valid
(
self
,
form
):
action
=
form
.
cleaned_data
.
get
(
'
action
'
)
# Defer to the determination form for any of the determination transitions
if
action
in
DETERMINATION_OUTCOMES
:
return
HttpResponseRedirect
(
reverse_lazy
(
'
apply:submissions:determinations:form
'
,
args
=
(
form
.
instance
.
id
,))
+
"
?action=
"
+
action
)
redirect
=
DeterminationCreateOrUpdateView
.
should_redirect
(
self
.
request
,
self
.
object
,
action
)
if
redirect
:
return
redirect
self
.
object
.
perform_transition
(
action
,
self
.
request
.
user
,
request
=
self
.
request
)
return
super
().
form_valid
(
form
)
...
...
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