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
0b63aae7
Commit
0b63aae7
authored
3 months ago
by
George Katsikas
Browse files
Options
Downloads
Patches
Plain Diff
add user class var to task kind
parent
33fea425
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
scipost_django/tasks/tasks/task.py
+5
-2
5 additions, 2 deletions
scipost_django/tasks/tasks/task.py
scipost_django/tasks/tasks/task_kinds.py
+20
-8
20 additions, 8 deletions
scipost_django/tasks/tasks/task_kinds.py
scipost_django/tasks/views.py
+3
-7
3 additions, 7 deletions
scipost_django/tasks/views.py
with
28 additions
and
17 deletions
scipost_django/tasks/tasks/task.py
+
5
−
2
View file @
0b63aae7
...
@@ -19,7 +19,7 @@ if TYPE_CHECKING:
...
@@ -19,7 +19,7 @@ if TYPE_CHECKING:
@dataclass
@dataclass
class
Task
:
class
Task
:
user
:
int
user
:
"
User | None
"
kind
:
"
type[TaskKind]
"
kind
:
"
type[TaskKind]
"
data
:
dict
=
field
(
default_factory
=
dict
)
data
:
dict
=
field
(
default_factory
=
dict
)
...
@@ -46,6 +46,7 @@ class TaskKind:
...
@@ -46,6 +46,7 @@ class TaskKind:
task_title
:
str
task_title
:
str
description
:
str
=
""
description
:
str
=
""
actions
:
Collection
[
Callable
[[
Task
],
"
TaskAction
"
]]
actions
:
Collection
[
Callable
[[
Task
],
"
TaskAction
"
]]
user
:
"
User | None
"
=
None
template_name
:
str
=
"
tasks/task.html
"
template_name
:
str
=
"
tasks/task.html
"
@staticmethod
@staticmethod
...
@@ -68,7 +69,9 @@ class TaskKind:
...
@@ -68,7 +69,9 @@ class TaskKind:
@classmethod
@classmethod
def
get_tasks
(
cls
)
->
Collection
[
Task
]:
def
get_tasks
(
cls
)
->
Collection
[
Task
]:
return
[
Task
(
user
=
1
,
kind
=
cls
,
data
=
data
)
for
data
in
cls
.
get_task_data
()]
return
[
Task
(
user
=
cls
.
user
,
kind
=
cls
,
data
=
data
)
for
data
in
cls
.
get_task_data
()
]
@classmethod
@classmethod
def
get_task_data
(
cls
)
->
Collection
[
dict
]:
def
get_task_data
(
cls
)
->
Collection
[
dict
]:
...
...
This diff is collapsed.
Click to expand it.
scipost_django/tasks/tasks/task_kinds.py
+
20
−
8
View file @
0b63aae7
...
@@ -20,6 +20,26 @@ from scipost.templatetags.user_groups import is_financial_admin
...
@@ -20,6 +20,26 @@ from scipost.templatetags.user_groups import is_financial_admin
from
tasks.tasks.task
import
TaskKind
from
tasks.tasks.task
import
TaskKind
from
tasks.tasks.task_action
import
ViewAction
from
tasks.tasks.task_action
import
ViewAction
from
typing
import
TYPE_CHECKING
if
TYPE_CHECKING
:
from
django.contrib.auth.models
import
User
def
get_all_task_kinds
(
user
:
"
User | None
"
=
None
)
->
Collection
[
type
[
TaskKind
]]:
"""
Return all TaskKind classes, optionally filtered by user eligibility.
"""
classes
:
list
[
type
[
TaskKind
]]
=
[]
for
cls
in
globals
().
values
():
if
isinstance
(
cls
,
type
)
and
issubclass
(
cls
,
TaskKind
)
and
cls
!=
TaskKind
:
cls
.
user
=
user
classes
.
append
(
cls
)
# Filter the classes based on user eligibility
if
user
is
not
None
:
classes
=
[
cls
for
cls
in
classes
if
cls
.
is_user_eligible
(
user
)]
return
classes
class
ScheduleSubsidyPayments
(
TaskKind
):
class
ScheduleSubsidyPayments
(
TaskKind
):
name
=
"
Schedule Subsidy Payments
"
name
=
"
Schedule Subsidy Payments
"
...
@@ -187,11 +207,3 @@ class CheckSubsidyPaymentTask(TaskKind):
...
@@ -187,11 +207,3 @@ class CheckSubsidyPaymentTask(TaskKind):
)
)
.
filter
(
Q
(
status
=
SUBSIDY_INVOICED
))
.
filter
(
Q
(
status
=
SUBSIDY_INVOICED
))
)
)
__all__
=
[
ScheduleSubsidyPayments
,
ScheduleSubsidyCollectivePayments
,
SendSubsidyInvoiceTask
,
CheckSubsidyPaymentTask
,
]
This diff is collapsed.
Click to expand it.
scipost_django/tasks/views.py
+
3
−
7
View file @
0b63aae7
__copyright__
=
"
Copyright © Stichting SciPost (SciPost Foundation)
"
__copyright__
=
"
Copyright © Stichting SciPost (SciPost Foundation)
"
__license__
=
"
AGPL v3
"
__license__
=
"
AGPL v3
"
import
importlib
from
django.contrib.auth.decorators
import
login_required
,
user_passes_test
from
django.contrib.auth.decorators
import
login_required
,
user_passes_test
from
django.shortcuts
import
render
from
django.shortcuts
import
render
from
colleges.permissions
import
is_edadmin_or_active_fellow
from
colleges.permissions
import
is_edadmin_or_active_fellow
from
submissions.models.assignment
import
EditorialAssignment
from
submissions.models.assignment
import
EditorialAssignment
from
submissions.models.recommendation
import
EICRecommendation
from
submissions.models.recommendation
import
EICRecommendation
from
tasks.tasks.task
import
T
ask
K
ind
from
tasks.tasks.task
_kinds
import
get_all_t
ask
_k
ind
s
@login_required
@login_required
...
@@ -32,14 +31,11 @@ def tasklist(request):
...
@@ -32,14 +31,11 @@ def tasklist(request):
@user_passes_test
(
is_edadmin_or_active_fellow
)
@user_passes_test
(
is_edadmin_or_active_fellow
)
def
tasklist_new
(
request
):
def
tasklist_new
(
request
):
"""
Displays a grouped list of tasks
"""
"""
Displays a grouped list of tasks
"""
# `task_types` should be the * import of task_kinds.py
task_types
=
importlib
.
import_module
(
"
tasks.tasks.task_kinds
"
).
__all__
context
=
{
context
=
{
"
kinds_with_tasks
"
:
{
"
kinds_with_tasks
"
:
{
task_type
:
task_type
.
get_tasks
()
task_type
:
task_type
.
get_tasks
()
for
task_type
in
task_types
for
task_type
in
get_all_task_kinds
(
request
.
user
)
if
issubclass
(
task_type
,
TaskKind
)
and
task_type
.
is_user_eligible
(
request
.
user
)
}
}
}
}
return
render
(
request
,
"
tasks/tasklist_new.html
"
,
context
)
return
render
(
request
,
"
tasks/tasklist_new.html
"
,
context
)
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