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
cb53c211
Commit
cb53c211
authored
7 years ago
by
Piotr Gawron
Browse files
Options
Downloads
Patches
Plain Diff
visits and status api use common bool_to_str function
parent
05e189b6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!107
Resolve "exceeded visits list & unfinished visits list"
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
smash/web/api_views/serialization_utils.py
+10
-0
10 additions, 0 deletions
smash/web/api_views/serialization_utils.py
smash/web/api_views/subject.py
+6
-12
6 additions, 12 deletions
smash/web/api_views/subject.py
smash/web/api_views/visit.py
+3
-2
3 additions, 2 deletions
smash/web/api_views/visit.py
with
19 additions
and
14 deletions
smash/web/api_views/serialization_utils.py
0 → 100644
+
10
−
0
View file @
cb53c211
import
logging
logger
=
logging
.
getLogger
(
__name__
)
def
bool_to_yes_no
(
val
):
if
val
:
return
"
YES
"
else
:
return
"
NO
"
This diff is collapsed.
Click to expand it.
smash/web/api_views/subject.py
+
6
−
12
View file @
cb53c211
...
@@ -5,6 +5,7 @@ from django.db.models import Count, Case, When, Min, Max
...
@@ -5,6 +5,7 @@ from django.db.models import Count, Case, When, Min, Max
from
django.db.models
import
Q
from
django.db.models
import
Q
from
django.http
import
JsonResponse
from
django.http
import
JsonResponse
from
web.api_views.serialization_utils
import
bool_to_yes_no
from
web.models
import
StudySubject
,
Visit
,
Appointment
,
Subject
,
SubjectColumns
,
StudyColumns
,
Study
,
ContactAttempt
from
web.models
import
StudySubject
,
Visit
,
Appointment
,
Subject
,
SubjectColumns
,
StudyColumns
,
Study
,
ContactAttempt
from
web.models.constants
import
SUBJECT_TYPE_CHOICES
,
GLOBAL_STUDY_ID
from
web.models.constants
import
SUBJECT_TYPE_CHOICES
,
GLOBAL_STUDY_ID
from
web.models.study_subject_list
import
SUBJECT_LIST_GENERIC
,
SUBJECT_LIST_NO_VISIT
,
SUBJECT_LIST_REQUIRE_CONTACT
,
\
from
web.models.study_subject_list
import
SUBJECT_LIST_GENERIC
,
SUBJECT_LIST_NO_VISIT
,
SUBJECT_LIST_REQUIRE_CONTACT
,
\
...
@@ -321,13 +322,6 @@ def types(request):
...
@@ -321,13 +322,6 @@ def types(request):
})
})
def
get_yes_no
(
val
):
if
val
:
return
"
YES
"
else
:
return
"
NO
"
def
serialize_subject
(
study_subject
):
def
serialize_subject
(
study_subject
):
location
=
""
location
=
""
if
study_subject
.
default_location
is
not
None
:
if
study_subject
.
default_location
is
not
None
:
...
@@ -369,7 +363,7 @@ def serialize_subject(study_subject):
...
@@ -369,7 +363,7 @@ def serialize_subject(study_subject):
if
len
(
contact_attempts
)
>
0
:
if
len
(
contact_attempts
)
>
0
:
last_contact_attempt
=
contact_attempts
[
0
]
last_contact_attempt
=
contact_attempts
[
0
]
last_contact_attempt_string
=
last_contact_attempt
.
datetime_when
.
strftime
(
last_contact_attempt_string
=
last_contact_attempt
.
datetime_when
.
strftime
(
'
%Y-%m-%d %H:%M
'
)
+
"
<br/>
"
+
str
(
last_contact_attempt
.
worker
)
+
"
<br/> Success:
"
+
get
_yes_no
(
'
%Y-%m-%d %H:%M
'
)
+
"
<br/>
"
+
str
(
last_contact_attempt
.
worker
)
+
"
<br/> Success:
"
+
bool_to
_yes_no
(
last_contact_attempt
.
success
)
+
"
<br/>
"
+
last_contact_attempt
.
comment
last_contact_attempt
.
success
)
+
"
<br/>
"
+
last_contact_attempt
.
comment
else
:
else
:
...
@@ -385,10 +379,10 @@ def serialize_subject(study_subject):
...
@@ -385,10 +379,10 @@ def serialize_subject(study_subject):
"
referral
"
:
study_subject
.
referral
,
"
referral
"
:
study_subject
.
referral
,
"
default_location
"
:
location
,
"
default_location
"
:
location
,
"
flying_team
"
:
flying_team
,
"
flying_team
"
:
flying_team
,
"
dead
"
:
get
_yes_no
(
study_subject
.
subject
.
dead
),
"
dead
"
:
bool_to
_yes_no
(
study_subject
.
subject
.
dead
),
"
resigned
"
:
get
_yes_no
(
study_subject
.
resigned
),
"
resigned
"
:
bool_to
_yes_no
(
study_subject
.
resigned
),
"
postponed
"
:
get
_yes_no
(
study_subject
.
postponed
),
"
postponed
"
:
bool_to
_yes_no
(
study_subject
.
postponed
),
"
information_sent
"
:
get
_yes_no
(
study_subject
.
information_sent
),
"
information_sent
"
:
bool_to
_yes_no
(
study_subject
.
information_sent
),
"
type
"
:
study_subject
.
get_type_display
(),
"
type
"
:
study_subject
.
get_type_display
(),
"
id
"
:
study_subject
.
id
,
"
id
"
:
study_subject
.
id
,
"
visits
"
:
serialized_visits
,
"
visits
"
:
serialized_visits
,
...
...
This diff is collapsed.
Click to expand it.
smash/web/api_views/visit.py
+
3
−
2
View file @
cb53c211
...
@@ -3,6 +3,7 @@ import logging
...
@@ -3,6 +3,7 @@ import logging
from
django.contrib.auth.decorators
import
login_required
from
django.contrib.auth.decorators
import
login_required
from
django.http
import
JsonResponse
from
django.http
import
JsonResponse
from
web.api_views.serialization_utils
import
bool_to_yes_no
from
web.models
import
SubjectColumns
from
web.models
import
SubjectColumns
from
web.models
import
Visit
,
Study
,
VisitColumns
,
StudyVisitList
from
web.models
import
Visit
,
Study
,
VisitColumns
,
StudyVisitList
from
web.models.constants
import
GLOBAL_STUDY_ID
from
web.models.constants
import
GLOBAL_STUDY_ID
...
@@ -183,8 +184,8 @@ def serialize_visit(visit):
...
@@ -183,8 +184,8 @@ def serialize_visit(visit):
"
last_name
"
:
visit
.
subject
.
subject
.
last_name
,
"
last_name
"
:
visit
.
subject
.
subject
.
last_name
,
"
datetime_begin
"
:
datetime_begin
,
"
datetime_begin
"
:
datetime_begin
,
"
datetime_end
"
:
datetime_end
,
"
datetime_end
"
:
datetime_end
,
"
is_finished
"
:
visit
.
is_finished
,
"
is_finished
"
:
bool_to_yes_no
(
visit
.
is_finished
)
,
"
post_mail_sent
"
:
visit
.
post_mail_sent
,
"
post_mail_sent
"
:
bool_to_yes_no
(
visit
.
post_mail_sent
)
,
"
visit_number
"
:
visit
.
visit_number
,
"
visit_number
"
:
visit
.
visit_number
,
"
id
"
:
visit
.
id
,
"
id
"
:
visit
.
id
,
}
}
...
...
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