def add_gdrive_file_folder(self, folder_id): """Add file to parent folder if exists""" file_id = self.source_gdrive_id from ggrc.gdrive import file_actions if folder_id: file_link = file_actions.add_gdrive_file_folder(file_id, folder_id) else: file_link = file_actions.get_gdrive_file_link(file_id) self._update_fields(file_link)
def _process_gdrive_business_logic(self): """Handles gdrive business logic If parent_obj specified => add file to parent folder If parent_obj not specified => get file link """ if self.is_with_parent_obj(): parent = self._get_parent_obj() if self.kind == Document.FILE and self.source_gdrive_id: parent_folder_id = self._get_folder(parent) self.add_gdrive_file_folder(parent_folder_id) self._build_relationship(parent) self._parent_obj = None elif (self.kind == Document.FILE and self.source_gdrive_id and not self.link): self.gdrive_id = self.source_gdrive_id from ggrc.gdrive.file_actions import get_gdrive_file_link self.link = get_gdrive_file_link(self.source_gdrive_id)
def _get_new_map(self): from ggrc.gdrive.file_actions import get_gdrive_file_link return {get_gdrive_file_link(d): d for d in self.value}