def set_user_auth(self, user_settings): """Import a user's GoogleDrive authentication and create a NodeLog. :param GoogleDriveUserSettings user_settings: The user settings to link. """ self.user_settings = user_settings nodelogger = GoogleDriveNodeLogger(node=self.owner, auth=Auth(user_settings.owner)) nodelogger.log(action="node_authorized", save=True)
def set_folder(self, folder, auth, add_log=True): self.folder_id = folder['id'] self.folder_path = folder['path'] # Add log to node if add_log: nodelogger = GoogleDriveNodeLogger(node=self.owner, auth=auth) nodelogger.log(action="folder_selected", save=True)
def deauthorize(self, auth=None, add_log=True): """Remove user authorization from this node and log the event.""" if add_log: extra = {'folder': self.folder_name} nodelogger = GoogleDriveNodeLogger(node=self.owner, auth=auth) nodelogger.log(action="node_deauthorized", extra=extra, save=True) self.folder_id = None self.folder_path = None self.user_settings = None self.save()