コード例 #1
0
 def infer_dataset(self):
     user_dataset = self.user.dataset
     collection_dataset = self.collection.dataset
     if user_dataset != collection_dataset:
         raise KolibriValidationError(
             "Collection and user for a Membership object must be in same dataset."
         )
     return user_dataset
コード例 #2
0
 def infer_dataset(self):
     user_dataset = self.user.dataset
     collection_dataset = self.collection.dataset
     if user_dataset != collection_dataset:
         raise KolibriValidationError(
             "The collection and user for a Role object must be in the same dataset."
         )
     return user_dataset
コード例 #3
0
 def ensure_dataset(self, *args, **kwargs):
     """
     If no dataset has yet been specified, try to infer it. If a dataset has already been specified, to prevent
     inconsistencies, make sure it matches the inferred dataset, otherwise raise a ``KolibriValidationError``.
     If we have no dataset and it can't be inferred, we raise a ``KolibriValidationError`` exception as well.
     """
     inferred_dataset = self.infer_dataset(*args, **kwargs)
     if self.dataset_id:
         # make sure currently stored dataset matches inferred dataset, if any
         if inferred_dataset and inferred_dataset != self.dataset:
             raise KolibriValidationError("This model is not associated with the correct FacilityDataset.")
     else:
         # use the inferred dataset, if there is one, otherwise throw an error
         if inferred_dataset:
             self.dataset = inferred_dataset
         else:
             raise KolibriValidationError("FacilityDataset ('dataset') not provided, and could not be inferred.")