Fakultas Ilmu Komputer UI

Verified Commit 70b94fc6 authored by Giovan Isa Musthofa's avatar 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
......@@ -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')
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment