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
420b948b
Commit
420b948b
authored
2 years ago
by
Piotr Gawron
Browse files
Options
Downloads
Patches
Plain Diff
allow to export languages of subjects
parent
549a7b37
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!422
Resolve "allow to export subject languages"
Pipeline
#54415
failed
2 years ago
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
CHANGELOG
+6
-0
6 additions, 0 deletions
CHANGELOG
smash/web/tests/functions.py
+1
-1
1 addition, 1 deletion
smash/web/tests/functions.py
smash/web/tests/view/test_export.py
+13
-1
13 additions, 1 deletion
smash/web/tests/view/test_export.py
smash/web/views/export.py
+9
-1
9 additions, 1 deletion
smash/web/views/export.py
with
29 additions
and
3 deletions
CHANGELOG
+
6
−
0
View file @
420b948b
smasch (1.2.0-1) untable; urgency=low
* small improvement: export of subjects contains languages field (#507)
-- Piotr Gawron <piotr.gawron@uni.lu> Wed, 31 Mar 2022 12:00:00 +0200
smasch (1.1.1-1) stable; urgency=medium
* bug fix: smasch installation failed when subject did not contain type
...
...
This diff is collapsed.
Click to expand it.
smash/web/tests/functions.py
+
1
−
1
View file @
420b948b
...
...
@@ -385,7 +385,7 @@ def create_room(owner='Test owner', city='Test city',
return
room
def
create_language
(
name
=
"
French
"
,
locale
=
DEFAULT_LOCALE_NAME
):
def
create_language
(
name
=
"
French
"
,
locale
=
DEFAULT_LOCALE_NAME
)
->
Language
:
language
=
Language
(
name
=
name
,
locale
=
locale
)
language
.
save
()
return
language
...
...
This diff is collapsed.
Click to expand it.
smash/web/tests/view/test_export.py
+
13
−
1
View file @
420b948b
# coding=utf-8
from
django.db.models.manager
import
BaseManager
from
django.urls
import
reverse
from
web.models
import
Appointment
,
AppointmentTypeLink
...
...
@@ -7,7 +8,7 @@ from web.models.custom_data import CustomStudySubjectField
from
web.models.custom_data.custom_study_subject_field
import
get_study_subject_field_id
from
web.tests
import
LoggedInTestCase
from
web.tests.functions
import
create_study_subject
,
create_appointment
,
create_visit
,
create_appointment_type
,
\
get_test_study
get_test_study
,
create_language
from
web.views.export
import
subject_to_row_for_fields
,
DROP_OUT_FIELD
,
get_subjects_as_array
...
...
@@ -114,3 +115,14 @@ class TestExportView(LoggedInTestCase):
)
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertEqual
(
response
.
content
.
decode
(
"
UTF-8
"
).
count
(
"
\n
"
),
2
)
def
test_export_subjects_to_csv_with_languages
(
self
):
self
.
login_as_admin
()
study_subject
=
create_study_subject
()
language
=
create_language
()
study_subject
.
subject
.
languages
.
set
([
language
])
study_subject
.
subject
.
save
()
response
=
self
.
client
.
get
(
reverse
(
'
web.views.export_to_csv
'
,
kwargs
=
{
'
study_id
'
:
get_test_study
().
id
,
'
data_type
'
:
"
subjects
"
}))
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertTrue
(
language
.
name
in
response
.
content
.
decode
(
"
UTF-8
"
))
This diff is collapsed.
Click to expand it.
smash/web/views/export.py
+
9
−
1
View file @
420b948b
...
...
@@ -2,6 +2,7 @@
import
csv
import
django_excel
as
excel
from
django.db.models.manager
import
BaseManager
from
django.http
import
HttpResponse
from
django.shortcuts
import
get_object_or_404
...
...
@@ -9,8 +10,8 @@ from web.decorators import PermissionDecorator
from
web.models
import
Subject
,
StudySubject
,
Appointment
,
Study
,
Worker
,
Provenance
from
web.models.custom_data
import
CustomStudySubjectField
from
web.models.custom_data.custom_study_subject_field
import
get_study_subject_field_id
from
.view_utils
import
wrap_response
,
e500_error
from
.notifications
import
get_today_midnight_date
from
.view_utils
import
wrap_response
,
e500_error
from
..utils
import
get_client_ip
...
...
@@ -118,6 +119,8 @@ def get_default_subject_fields(study: Study):
for
field
in
Subject
.
_meta
.
fields
:
if
field
.
name
.
upper
()
!=
"
ID
"
:
subject_fields
.
append
(
field
)
for
field
in
Subject
.
_meta
.
many_to_many
:
subject_fields
.
append
(
field
)
for
field
in
StudySubject
.
_meta
.
fields
:
if
field
.
name
.
upper
()
!=
"
ID
"
and
field
.
name
.
upper
()
!=
"
SUBJECT
"
:
subject_fields
.
append
(
field
)
...
...
@@ -172,6 +175,11 @@ def subject_to_row_for_fields(study_subject: StudySubject, subject_fields):
cell
=
getattr
(
study_subject
.
subject
,
field
.
name
)
if
cell
is
None
:
cell
=
""
if
isinstance
(
cell
,
BaseManager
):
collection_value
=
""
for
value
in
cell
.
all
():
collection_value
+=
str
(
value
)
+
"
,
"
cell
=
collection_value
row
.
append
(
cell
)
return
row
...
...
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