Advertisement
Mochinov

Untitled

May 23rd, 2022
292
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1.  
  2. def get_empty_item_prefilled_fields(self, context: dict) -> dict:
  3. """Возвращает список предзаполненных полей для пустого элемента."""
  4.  
  5. trunks_field = context.get('trunks_field')
  6. prefilled_fields = {
  7. 'trunks_field': trunks_field,
  8. }
  9.  
  10. return prefilled_fields
  11.  
  12. @classmethod
  13. def get_field_dict(cls, context: dict, user: User) -> dict:
  14. """Распаковывает ответ и возвращает словарь со значениями полей"""
  15.  
  16. print(context)
  17.  
  18. lv_project_id_field = TrunkLVProjectTableView.get_unpack_value(context.get('lv_project_field'))
  19.  
  20. print(
  21. context.get('trunks_field'),
  22. context.get('lv_project_field')
  23. )
  24.  
  25. lv_project_id_field = safe_to_int(lv_project_id_field, -1)
  26. lv_project = TrunkLVProject.objects.filter(id=lv_project_id_field).first()
  27.  
  28. data = {
  29. 'lv_project': lv_project,
  30. 'trunks': TrunkLVProjectTableView.get_unpack_value(context.get('trunks_field'))
  31. }
  32. print(data)
  33. return data
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement