Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
scheduling-system
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
SMASCH
scheduling-system
Commits
ef63ec45
There was a problem fetching the pipeline mini graph.
Commit
ef63ec45
authored
7 years ago
by
Piotr Gawron
Browse files
Options
Downloads
Patches
Plain Diff
set of notification types is configurable via db
parent
fbb9c70f
No related branches found
No related tags found
1 merge request
!104
Resolve "Notifications should be customized by study"
Pipeline
#
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
smash/web/tests/functions.py
+19
-19
19 additions, 19 deletions
smash/web/tests/functions.py
smash/web/tests/view/test_notifications.py
+15
-4
15 additions, 4 deletions
smash/web/tests/view/test_notifications.py
smash/web/views/notifications.py
+24
-11
24 additions, 11 deletions
smash/web/views/notifications.py
with
58 additions
and
34 deletions
smash/web/tests/functions.py
+
19
−
19
View file @
ef63ec45
...
@@ -52,27 +52,27 @@ def create_study(name="test"):
...
@@ -52,27 +52,27 @@ def create_study(name="test"):
return
Study
.
objects
.
create
(
name
=
name
,
columns
=
study_columns
,
notification_parameters
=
notification_parameters
)
return
Study
.
objects
.
create
(
name
=
name
,
columns
=
study_columns
,
notification_parameters
=
notification_parameters
)
def
create_empty_study
(
name
=
"
test
"
):
def
create_empty_notification_parametres
():
study_columns
=
StudyColumns
.
objects
.
create
(
return
StudyNotificationParameters
.
objects
.
create
(
postponed
=
False
,
exceeded_visits_visible
=
False
,
datetime_contact_reminder
=
False
,
unfinished_visits_visible
=
False
,
type
=
False
,
approaching_visits_without_appointments_visible
=
False
,
default_location
=
False
,
unfinished_appointments_visible
=
False
,
flying_team
=
False
,
visits_with_missing_appointments_visible
=
False
,
screening_number
=
False
,
subject_no_visits_visible
=
False
,
nd_number
=
False
,
approaching_visits_for_mail_contact_visible
=
False
,
mpower_id
=
False
,
subject_require_contact_visible
=
False
,
comments
=
False
,
missing_redcap_subject_visible
=
False
,
referral
=
False
,
inconsistent_redcap_subject_visible
=
False
,
diagnosis
=
False
,
year_of_diagnosis
=
False
,
information_sent
=
False
,
pd_in_family
=
False
,
resigned
=
False
,
resign_reason
=
False
)
)
result
=
create_study
()
def
create_empty_study
(
name
=
"
test
"
):
study_columns
=
create_empty_study_columns
()
notification_parameters
=
create_empty_notification_parametres
()
result
=
create_study
(
name
)
result
.
columns
=
study_columns
result
.
columns
=
study_columns
result
.
notification_parameters
=
notification_parameters
result
.
save
()
result
.
save
()
return
result
return
result
...
...
This diff is collapsed.
Click to expand it.
smash/web/tests/view/test_notifications.py
+
15
−
4
View file @
ef63ec45
...
@@ -2,11 +2,11 @@ import datetime
...
@@ -2,11 +2,11 @@ import datetime
from
django.contrib.auth.models
import
AnonymousUser
from
django.contrib.auth.models
import
AnonymousUser
from
web.models
import
Appointment
,
Location
,
AppointmentTypeLink
from
web.models
import
Appointment
,
Location
,
AppointmentTypeLink
,
Study
from
web.models.constants
import
GLOBAL_STUDY_ID
from
web.tests
import
LoggedInTestCase
from
web.tests
import
LoggedInTestCase
from
web.tests.functions
import
create_appointment
,
create_location
,
create_worker
,
create_appointment_type
from
web.tests.functions
import
create_appointment
,
create_location
,
create_worker
,
create_appointment_type
,
\
from
web.tests.functions
import
create_study_subject
create_empty_notification_parametres
,
create_study_subject
,
create_visit
from
web.tests.functions
import
create_visit
from
web.views.notifications
import
\
from
web.views.notifications
import
\
get_approaching_visits_for_mail_contact
,
\
get_approaching_visits_for_mail_contact
,
\
get_approaching_visits_for_mail_contact_count
,
\
get_approaching_visits_for_mail_contact_count
,
\
...
@@ -94,6 +94,17 @@ class NotificationViewTests(LoggedInTestCase):
...
@@ -94,6 +94,17 @@ class NotificationViewTests(LoggedInTestCase):
self
.
assertTrue
(
isinstance
(
result
[
1
],
list
))
self
.
assertTrue
(
isinstance
(
result
[
1
],
list
))
self
.
assertTrue
(
len
(
result
[
1
])
>
0
)
self
.
assertTrue
(
len
(
result
[
1
])
>
0
)
def
test_get_notifications_with_empty_study_notification
(
self
):
study
=
Study
.
objects
.
filter
(
id
=
GLOBAL_STUDY_ID
)[
0
]
study
.
notification_parameters
=
create_empty_notification_parametres
()
study
.
save
()
create_worker
(
self
.
user
)
result
=
get_notifications
(
self
.
user
)
self
.
assertEquals
(
0
,
result
[
0
])
self
.
assertEquals
(
0
,
len
(
result
[
1
]))
def
test_get_visits_without_appointments_count_2
(
self
):
def
test_get_visits_without_appointments_count_2
(
self
):
appointment_type
=
create_appointment_type
()
appointment_type
=
create_appointment_type
()
original_notification
=
get_visits_without_appointments_count
(
self
.
user
)
original_notification
=
get_visits_without_appointments_count
(
self
.
user
)
...
...
This diff is collapsed.
Click to expand it.
smash/web/views/notifications.py
+
24
−
11
View file @
ef63ec45
# coding=utf-8
# coding=utf-8
import
datetime
import
datetime
from
django.utils
import
timezone
from
django.contrib.auth.models
import
User
,
AnonymousUser
from
django.contrib.auth.models
import
User
,
AnonymousUser
from
django.db.models
import
Count
,
Case
,
When
from
django.db.models
import
Count
,
Case
,
When
from
django.utils
import
timezone
from
web.models
import
Study
from
web.models.constants
import
GLOBAL_STUDY_ID
from
..models
import
Worker
,
StudySubject
,
Visit
,
Appointment
,
Location
,
MissingSubject
,
InconsistentSubject
from
..models
import
Worker
,
StudySubject
,
Visit
,
Appointment
,
Location
,
MissingSubject
,
InconsistentSubject
...
@@ -115,16 +117,27 @@ def get_notifications(the_user):
...
@@ -115,16 +117,27 @@ def get_notifications(the_user):
notifications
=
[]
notifications
=
[]
count
=
0
count
=
0
if
worker
is
not
None
:
if
worker
is
not
None
:
notifications
.
append
(
get_exceeded_visit_notifications_count
(
worker
))
study
=
Study
.
objects
.
filter
(
id
=
GLOBAL_STUDY_ID
)[
0
]
notifications
.
append
(
get_visits_without_appointments_count
(
worker
))
if
study
.
notification_parameters
.
exceeded_visits_visible
:
notifications
.
append
(
get_approaching_visits_without_appointments_count
(
worker
))
notifications
.
append
(
get_exceeded_visit_notifications_count
(
worker
))
notifications
.
append
(
get_unfinished_appointments_count
(
worker
))
if
study
.
notification_parameters
.
unfinished_visits_visible
:
notifications
.
append
(
get_visits_with_missing_appointments_count
(
worker
))
notifications
.
append
(
get_visits_without_appointments_count
(
worker
))
notifications
.
append
(
get_subject_with_no_visit_notifications_count
(
worker
))
if
study
.
notification_parameters
.
approaching_visits_without_appointments_visible
:
notifications
.
append
(
get_approaching_visits_for_mail_contact_count
(
worker
))
notifications
.
append
(
get_approaching_visits_without_appointments_count
(
worker
))
notifications
.
append
(
get_subjects_with_reminder_count
(
worker
))
if
study
.
notification_parameters
.
unfinished_appointments_visible
:
notifications
.
append
(
get_missing_redcap_subject_notification_count
(
worker
))
notifications
.
append
(
get_unfinished_appointments_count
(
worker
))
notifications
.
append
(
get_inconsistent_redcap_subject_notification_count
(
worker
))
if
study
.
notification_parameters
.
visits_with_missing_appointments_visible
:
notifications
.
append
(
get_visits_with_missing_appointments_count
(
worker
))
if
study
.
notification_parameters
.
subject_no_visits_visible
:
notifications
.
append
(
get_subject_with_no_visit_notifications_count
(
worker
))
if
study
.
notification_parameters
.
approaching_visits_for_mail_contact_visible
:
notifications
.
append
(
get_approaching_visits_for_mail_contact_count
(
worker
))
if
study
.
notification_parameters
.
subject_require_contact_visible
:
notifications
.
append
(
get_subjects_with_reminder_count
(
worker
))
if
study
.
notification_parameters
.
missing_redcap_subject_visible
:
notifications
.
append
(
get_missing_redcap_subject_notification_count
(
worker
))
if
study
.
notification_parameters
.
inconsistent_redcap_subject_visible
:
notifications
.
append
(
get_inconsistent_redcap_subject_notification_count
(
worker
))
for
notification
in
notifications
:
for
notification
in
notifications
:
count
+=
notification
.
count
count
+=
notification
.
count
...
...
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