Skip to content
Snippets Groups Projects

Fix/import file

Merged Carlos Vega requested to merge fix/import_file into master
1 unresolved thread
1 file
+ 11
7
Compare changes
  • Side-by-side
  • Inline
  • bc8f4c6c
    Issue #268 added a worker to appointments and typelink · bc8f4c6c
    Carlos Vega authored
+ 11
7
@@ -310,7 +310,7 @@ def create_appointment_types(assessments):
@@ -310,7 +310,7 @@ def create_appointment_types(assessments):
return appointmentTypes
return appointmentTypes
def parse_row(index, row, visit_columns, appointmentTypes, voucher_types):
def parse_row(index, row, visit_columns, appointmentTypes, voucher_types, lcsb_worker):
# Languages
# Languages
if len(row['LANGUAGES']) == 0 and len(row['PREFERED WRITEN LANGUAGE']) == 0:
if len(row['LANGUAGES']) == 0 and len(row['PREFERED WRITEN LANGUAGE']) == 0:
logging.warn('No Languages available')
logging.warn('No Languages available')
@@ -473,8 +473,10 @@ def parse_row(index, row, visit_columns, appointmentTypes, voucher_types):
@@ -473,8 +473,10 @@ def parse_row(index, row, visit_columns, appointmentTypes, voucher_types):
'''
'''
If there are two Vx with the same date we put together the appointment types in the same appointment
If there are two Vx with the same date we put together the appointment types in the same appointment
'''
'''
 
starting_hour = 9
for visit_date in set(visit_dates):
for visit_date in set(visit_dates):
datetime_when = visit_date.strftime('%Y-%m-%d')
datetime_when = visit_date.replace(hour=starting_hour, minute=0, second=0, microsecond=0)
 
starting_hour+=1
# get the indices of each occurrence of the date and use them to get
# get the indices of each occurrence of the date and use them to get
# the appointment types
# the appointment types
@@ -483,17 +485,17 @@ def parse_row(index, row, visit_columns, appointmentTypes, voucher_types):
@@ -483,17 +485,17 @@ def parse_row(index, row, visit_columns, appointmentTypes, voucher_types):
# creatre appointment
# creatre appointment
appointment, _ = Appointment.objects.update_or_create(
appointment, _ = Appointment.objects.update_or_create(
visit=visit, length=sum(
visit=visit, length=sum([a.default_duration for a in appointment_types]),
[a.default_duration for a in appointment_types]),
flying_team=ft, location=location,
flying_team=ft, location=location,
status=Appointment.APPOINTMENT_STATUS_FINISHED, datetime_when=datetime_when)
status=Appointment.APPOINTMENT_STATUS_SCHEDULED, datetime_when=datetime_when,
 
worker_assigned=lcsb_worker)
date_when = visit_date.replace(
date_when = visit_date.replace(
hour=9, minute=0, second=0, microsecond=0)
hour=9, minute=0, second=0, microsecond=0)
for appointment_type in appointment_types:
for appointment_type in appointment_types:
app_type_link = AppointmentTypeLink(
app_type_link = AppointmentTypeLink(
appointment=appointment, date_when=date_when,
appointment=appointment, date_when=date_when,
appointment_type=appointment_type)
appointment_type=appointment_type, worker=lcsb_worker)
date_when += datetime.timedelta(
date_when += datetime.timedelta(
minutes=appointment_type.default_duration)
minutes=appointment_type.default_duration)
app_type_link.save()
app_type_link.save()
@@ -527,7 +529,9 @@ def createWorker(password, email='', username='admin', first_name='LCSB', last_n
@@ -527,7 +529,9 @@ def createWorker(password, email='', username='admin', first_name='LCSB', last_n
# create workerStudyRole
# create workerStudyRole
workerStudyRole, _ = WorkerStudyRole.objects.update_or_create(worker=worker,
workerStudyRole, _ = WorkerStudyRole.objects.update_or_create(worker=worker,
study_id=GLOBAL_STUDY_ID, role=ROLE_CHOICES_TECHNICIAN)
study_id=GLOBAL_STUDY_ID, role=ROLE_CHOICES_TECHNICIAN)
 
workerStudyRole.save()
logging.info('SuperUser and Worker {} created'.format(username))
logging.info('SuperUser and Worker {} created'.format(username))
 
return worker
if __name__ == '__main__':
if __name__ == '__main__':
logging.basicConfig(level=logging.DEBUG)
logging.basicConfig(level=logging.DEBUG)
Loading