Fakultas Ilmu Komputer UI
Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ppl-fasilkom-ui
2020
PPL-C
Diskominfo-D'Blood
Mantan Aab-D Blood
Commits
70b94fc6
Verified
Commit
70b94fc6
authored
Jun 21, 2020
by
Giovan Isa Musthofa
Browse files
[CHORES] Add 'Lokasi' column to excel download
parent
a3de74b6
Pipeline
#50011
passed with stages
in 1 minute and 46 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
backend/donor/services.py
View file @
70b94fc6
...
...
@@ -281,11 +281,12 @@ class JadwalDonorSpreadsheetService:
worksheet
.
merge_range
(
'A1:A3'
,
'No'
,
merge_format
)
worksheet
.
merge_range
(
'B1:B3'
,
'NoTrans'
,
merge_format
)
worksheet
.
merge_range
(
'C1:C3'
,
'Tanggal'
,
merge_format
)
worksheet
.
merge_range
(
'D1:L1'
,
'Pendonor'
,
merge_format
)
worksheet
.
merge_range
(
'C1:C3'
,
'Lokasi'
,
merge_format
)
worksheet
.
merge_range
(
'D1:D3'
,
'Tanggal'
,
merge_format
)
worksheet
.
merge_range
(
'E1:M1'
,
'Pendonor'
,
merge_format
)
headers
=
'ID'
,
'Nama Lengkap'
,
'Alamat'
,
'HP'
,
'Umur'
,
'Gol (RH)'
,
'JK'
,
'Baru Ulang'
,
'Donor Ke-'
for
i
,
header
in
enumerate
(
headers
):
col
=
3
+
i
col
=
4
+
i
worksheet
.
merge_range
(
1
,
col
,
2
,
col
,
header
,
merge_format
)
@
classmethod
...
...
@@ -304,6 +305,7 @@ class JadwalDonorSpreadsheetService:
daftar_donor
=
DaftarDonor
.
download_query
(
queryset
)
fieldnames
=
[
'id'
,
'jadwal_donor__location'
,
'jadwal_donor__time_start'
,
'user__profile__id_card_no'
,
'user__first_name'
,
...
...
@@ -314,7 +316,7 @@ class JadwalDonorSpreadsheetService:
'user__profile__sex'
,
]
df
=
read_frame
(
daftar_donor
,
fieldnames
=
fieldnames
)
df
[
fieldnames
[
6
]]
=
self
.
_birthdates_to_age
(
df
[
fieldnames
[
6
]])
df
[
fieldnames
[
7
]]
=
self
.
_birthdates_to_age
(
df
[
fieldnames
[
7
]])
daftar_donor_ulang_list
=
self
.
_get_daftar_donor_ulang_list
(
daftar_donor
)
df
[
'Baru/Ulang'
]
=
[
'Ulang'
if
daftar_donor_ulang
.
exists
()
else
'Belum'
...
...
@@ -326,19 +328,20 @@ class JadwalDonorSpreadsheetService:
]
if
len
(
df
):
df
[
fieldnames
[
1
]]
=
df
[
fieldnames
[
1
]].
dt
.
tz_localize
(
None
)
df
[
fieldnames
[
2
]]
=
df
[
fieldnames
[
2
]].
dt
.
tz_localize
(
None
)
# Not actually used to write headers but still usefull to adjust column widths
df
=
df
.
rename
(
columns
=
{
fieldnames
[
0
]:
'NoTrans'
,
fieldnames
[
1
]:
'Tanggal'
,
fieldnames
[
2
]:
'ID'
,
fieldnames
[
3
]:
'Nama Lengkap'
,
fieldnames
[
4
]:
'Alamat'
,
fieldnames
[
5
]:
'HP'
,
fieldnames
[
6
]:
'Umur'
,
fieldnames
[
7
]:
'Gol (RH)'
,
fieldnames
[
8
]:
'JK'
,
fieldnames
[
1
]:
'Lokasi'
,
fieldnames
[
2
]:
'Tanggal'
,
fieldnames
[
3
]:
'ID'
,
fieldnames
[
4
]:
'Nama Lengkap'
,
fieldnames
[
5
]:
'Alamat'
,
fieldnames
[
6
]:
'HP'
,
fieldnames
[
7
]:
'Umur'
,
fieldnames
[
8
]:
'Gol (RH)'
,
fieldnames
[
9
]:
'JK'
,
})
writer
=
pd
.
ExcelWriter
(
response
,
engine
=
'xlsxwriter'
)
...
...
Write
Preview
Supports
Markdown
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