Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
elixir
daisy
Commits
08476ef7
Commit
08476ef7
authored
Sep 20, 2021
by
Jacek Lebioda
Browse files
feat: task of sending reports
parent
94a3a551
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
3 deletions
+30
-3
core/tests/email_reporter/test_reporter.py
core/tests/email_reporter/test_reporter.py
+24
-3
notification/tasks.py
notification/tasks.py
+6
-0
No files found.
core/tests/email_reporter/test_reporter.py
View file @
08476ef7
from
core.issues
import
Issue
from
typing
import
cast
from
django.conf
import
settings
from
django.db.models.query
import
QuerySet
from
core.reporting
import
cast_to_queryset
,
cast_to_issue_list
from
core.reporting
import
ReportParameters
,
ReportParametersCollector
,
ReportRenderer
from
core.issues
import
Issue
from
core.models
import
Project
,
data_declaration
from
core.reporting
import
cast_to_queryset
,
cast_to_issue_list
,
get_users_to_receive_emails
from
core.reporting
import
ReportParameters
,
ReportParametersCollector
,
ReportRenderer
from
test
import
factories
...
...
@@ -89,3 +91,22 @@ def test_report_collector():
assert
len
(
params
.
data_declarations
)
==
1
assert
params
.
projects
[
0
].
acronym
==
PROJECT_ACRONYM
def
test_get_users_to_receive_emails
():
previous_value
=
getattr
(
settings
,
'EMAIL_REPORTS_ENABLED'
,
None
)
user1
=
factories
.
UserFactory
.
create
(
first_name
=
'Daria'
,
last_name
=
'Crayon'
,
email
=
'daria@crayon.com'
)
user1
.
save
()
user2
=
factories
.
UserFactory
.
create
(
first_name
=
'Adam'
,
last_name
=
'Crayon'
,
email
=
'adam@crayon.com'
)
user2
.
save
()
setattr
(
settings
,
'EMAIL_REPORTS_ENABLED'
,
False
)
assert
len
(
get_users_to_receive_emails
())
==
0
assert
len
(
get_users_to_receive_emails
(
True
))
>
0
setattr
(
settings
,
'EMAIL_REPORTS_ENABLED'
,
True
)
assert
len
(
get_users_to_receive_emails
())
>
0
assert
len
(
get_users_to_receive_emails
(
True
))
>
0
setattr
(
settings
,
'EMAIL_REPORTS_ENABLED'
,
previous_value
)
notification/tasks.py
View file @
08476ef7
...
...
@@ -9,6 +9,7 @@ from django.db.models import Q
from
django.utils
import
timezone
from
core.models
import
Contract
,
DataDeclaration
,
Dataset
,
Document
,
Project
,
User
from
core.reporting
import
generate_and_send_reports
from
notification.email_sender
import
send_email_from_template
from
notification.models
import
(
Notification
,
NotificationStyle
,
NotificationVerb
)
...
...
@@ -21,6 +22,11 @@ NOTIFICATION_MAPPING = {
}
@
shared_task
def
send_email_reports
():
generate_and_send_reports
()
@
shared_task
def
send_notifications_for_user_by_time
(
user_id
,
time
):
"""
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment