Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.32 KB | None | 0 0
  1. def form_initial(workmans, need_date):
  2.     my_initial=[]
  3.     for i in workmans:
  4.         my_initial.append({
  5.             'workshop':i.workshop.name,
  6.             'team':'' if i.team is None else i.team.name,
  7.             'username':i.__str__,
  8.             'workman':str(i.pk),
  9.             'date':need_date,
  10.             'hours':'' if i.last_date_record() is None else i.last_date_record().hours,
  11.             'hours_over_norm':'' if i.last_date_record() is None else i.last_date_record().hours_over_norm,
  12.         })
  13.  
  14.         # if i.last_date_record() or i == None:
  15.         #     my_initial.append({
  16.         #         'workshop':i.workshop.name,
  17.         #         'team':'' if i.team is None else i.team.name,
  18.         #         'username':i.__str__,
  19.         #         'workman':str(i.pk),
  20.         #         'date':need_date,
  21.         #         'hours':i.last_date_record().hours,
  22.         #         'hours_over_norm':i.last_date_record().hours_over_norm,
  23.         #     })
  24.         # else:
  25.         #     my_initial.append({
  26.         #         'workshop':i.workshop.name,
  27.         #         'team':i.team.name,
  28.         #         'username':i.__str__,
  29.         #         'workman':str(i.pk),
  30.         #         'date':need_date,
  31.         #         'hours':0,
  32.         #         'hours_over_norm':0,
  33.         #     })
  34.     return my_initial
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement