SciPost Code Repository
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SciPost
Manage
Activity
Members
Labels
Plan
Issues
118
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
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
Code review analytics
Issue analytics
Insights
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
SciPost
SciPost
Commits
2cad5174
Commit
2cad5174
authored
1 year ago
by
George Katsikas
Browse files
Options
Downloads
Patches
Plain Diff
add saving of production stream search options
parent
0ea12c8c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!43
Polish up new production page
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
scipost_django/production/forms.py
+47
-6
47 additions, 6 deletions
scipost_django/production/forms.py
scipost_django/production/views.py
+6
-2
6 additions, 2 deletions
scipost_django/production/views.py
with
53 additions
and
8 deletions
scipost_django/production/forms.py
+
47
−
6
View file @
2cad5174
...
...
@@ -8,6 +8,7 @@ from django import forms
from
django.contrib.auth
import
get_user_model
from
django.db.models
import
Max
from
django.db.models.functions
import
Greatest
from
django.contrib.sessions.backends.db
import
SessionStore
from
crispy_forms.helper
import
FormHelper
from
crispy_forms.layout
import
Layout
,
Div
,
Field
,
Submit
...
...
@@ -278,12 +279,16 @@ class ProductionStreamSearchForm(forms.Form):
title
=
forms
.
CharField
(
max_length
=
512
,
required
=
False
)
identifier
=
forms
.
CharField
(
max_length
=
128
,
required
=
False
)
officer
=
forms
.
ModelChoiceField
(
queryset
=
ProductionUser
.
objects
.
active
(),
queryset
=
ProductionUser
.
objects
.
active
().
filter
(
user__groups__name
=
"
Production Officers
"
),
required
=
False
,
empty_label
=
"
Any
"
,
)
supervisor
=
forms
.
ModelChoiceField
(
queryset
=
ProductionUser
.
objects
.
active
(),
queryset
=
ProductionUser
.
objects
.
active
().
filter
(
user__groups__name
=
"
Production Supervisor
"
),
required
=
False
,
empty_label
=
"
Any
"
,
)
...
...
@@ -298,10 +303,10 @@ class ProductionStreamSearchForm(forms.Form):
orderby
=
forms
.
ChoiceField
(
label
=
"
Order by
"
,
choices
=
(
(
"
submission__
editorial_decision__taken_on
"
,
"
Date accepted
"
),
(
"
submission__
acceptance_date
"
,
"
Date accepted
"
),
(
"
latest_activity_annot
"
,
"
Latest activity
"
),
(
"
status,submission__
editorial_decision__taken_on
"
,
"
status,submission__
acceptance_date
"
,
"
Status + Date accepted
"
,
),
(
"
status,latest_activity_annot
"
,
"
Status + Latest activity
"
),
...
...
@@ -320,7 +325,17 @@ class ProductionStreamSearchForm(forms.Form):
def
__init__
(
self
,
*
args
,
**
kwargs
):
self
.
user
=
kwargs
.
pop
(
"
user
"
)
self
.
session_key
=
kwargs
.
pop
(
"
session_key
"
,
None
)
super
().
__init__
(
*
args
,
**
kwargs
)
# Set the initial values of the form fields from the session data
if
self
.
session_key
:
session
=
SessionStore
(
session_key
=
self
.
session_key
)
for
field
in
self
.
fields
:
if
field
in
session
:
self
.
fields
[
field
].
initial
=
session
[
field
]
self
.
helper
=
FormHelper
()
self
.
helper
.
layout
=
Layout
(
Div
(
...
...
@@ -332,8 +347,8 @@ class ProductionStreamSearchForm(forms.Form):
Div
(
Div
(
Div
(
Div
(
Field
(
"
accepted_in
"
,
size
=
3
),
css_class
=
"
col-sm-8
"
),
Div
(
Field
(
"
proceedings
"
,
size
=
3
),
css_class
=
"
col-sm-4
"
),
Div
(
Field
(
"
accepted_in
"
,
size
=
5
),
css_class
=
"
col-sm-8
"
),
Div
(
Field
(
"
proceedings
"
,
size
=
5
),
css_class
=
"
col-sm-4
"
),
css_class
=
"
row mb-0
"
,
),
Div
(
...
...
@@ -357,6 +372,32 @@ class ProductionStreamSearchForm(forms.Form):
)
def
search_results
(
self
):
# Save the form data to the session
if
self
.
session_key
is
not
None
:
session
=
SessionStore
(
session_key
=
self
.
session_key
)
for
key
in
self
.
cleaned_data
:
session
[
key
]
=
self
.
cleaned_data
.
get
(
key
)
session
[
"
accepted_in
"
]
=
(
[
journal
.
id
for
journal
in
session
.
get
(
"
accepted_in
"
)]
if
(
session
.
get
(
"
accepted_in
"
))
else
[]
)
session
[
"
proceedings
"
]
=
(
[
proceedings
.
id
for
proceedings
in
session
.
get
(
"
proceedings
"
)]
if
(
session
.
get
(
"
proceedings
"
))
else
[]
)
session
[
"
officer
"
]
=
(
officer
.
id
if
(
officer
:
=
session
.
get
(
"
officer
"
))
else
None
)
session
[
"
supervisor
"
]
=
(
supervisor
.
id
if
(
supervisor
:
=
session
.
get
(
"
supervisor
"
))
else
None
)
session
.
save
()
streams
=
ProductionStream
.
objects
.
ongoing
()
streams
=
streams
.
annotate
(
...
...
This diff is collapsed.
Click to expand it.
scipost_django/production/views.py
+
6
−
2
View file @
2cad5174
...
...
@@ -56,7 +56,9 @@ from .utils import proofs_slug_to_id, ProductionUtils
@is_production_user
()
@permission_required
(
"
scipost.can_view_production
"
,
raise_exception
=
True
)
def
production_new
(
request
):
search_productionstreams_form
=
ProductionStreamSearchForm
(
user
=
request
.
user
)
search_productionstreams_form
=
ProductionStreamSearchForm
(
user
=
request
.
user
,
session_key
=
request
.
session
.
session_key
)
bulk_assign_officer_form
=
BulkAssignOfficersForm
()
context
=
{
"
search_productionstreams_form
"
:
search_productionstreams_form
,
...
...
@@ -68,7 +70,9 @@ def production_new(request):
@is_production_user
()
@permission_required
(
"
scipost.can_view_production
"
,
raise_exception
=
True
)
def
_hx_productionstream_list
(
request
):
form
=
ProductionStreamSearchForm
(
request
.
POST
or
None
,
user
=
request
.
user
)
form
=
ProductionStreamSearchForm
(
request
.
POST
or
None
,
user
=
request
.
user
,
session_key
=
request
.
session
.
session_key
)
if
form
.
is_valid
():
streams
=
form
.
search_results
()
else
:
...
...
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