def get_url(self): oio_path = reverse( "objectinformatieobject-detail", kwargs={ "version": "1", "uuid": self.uuid }, ) return make_absolute_uri(oio_path)
def create_from(self, relation): object_type = self.RELATIONS[type(relation)] relation_object = getattr(relation, object_type) data = { "informatieobject": relation._informatieobject_url, "object_type": f"{object_type}", f"{object_type}": make_absolute_uri(reverse(relation_object)), } return self.create(**data)
def process_filters(self, data): converted_data = {} if data.get("object_type"): object_type = data.pop("object_type") if data.get(object_type): relation_object = data.pop(object_type) else: relation_object = data.pop("object") relation_url = get_object_url(relation_object) if relation_url is None: relation_url = make_absolute_uri(reverse(relation_object)) converted_data["object_type"] = object_type converted_data[f"{object_type}"] = relation_url for key, value in data.items(): split_key = key.split("__") split_key[0] = split_key[0].strip("_") if len(split_key) > 1 and split_key[1] not in ["exact", "in"]: raise NotImplementedError( "Fields lookups other than exact are not implemented yet.") # If the value is a queryset, extract the objects if split_key[0] == "informatieobject" and isinstance( value, CMISQuerySet): list_value = [] for item in value: list_value.append(make_absolute_uri(reverse(item))) value = list_value if split_key[0] in ["besluit", "zaak"]: converted_data[split_key[0]] = make_absolute_uri( reverse(value)) elif split_key[0] in ["besluit_url", "zaak_url"]: converted_data[split_key[0].split("_")[0]] = value else: converted_data[split_key[0]] = value return converted_data
def get_object_url(informatie_obj_type: InformatieObjectType, request: Optional[Request] = None): """ Retrieves the url for the informatieobjecttypes and virtual informatieobjecttype (used for external informatieobjecttype). """ # Case in which the informatie_object_type is already a url if isinstance(informatie_obj_type, str): return informatie_obj_type elif isinstance(informatie_obj_type, ProxyMixin): return informatie_obj_type._initial_data["url"] elif isinstance(informatie_obj_type, InformatieObjectType): path = informatie_obj_type.get_absolute_api_url() return make_absolute_uri(path, request=request)
def to_representation(self, instance): ret = super().to_representation(instance) # With Alfresco, the URL of the Gebruiksrechten and EnkelvoudigInformatieObject # cannot be retrieved using the latest_version property of the canonical object if settings.CMIS_ENABLED: path = reverse("gebruiksrechten-detail", kwargs={ "version": 1, "uuid": instance.uuid }) ret["url"] = make_absolute_uri(path, request=self.context.get("request")) ret["informatieobject"] = instance.get_informatieobject_url() return ret
def to_representation(self, instance): ret = super().to_representation(instance) # With Alfresco, the URL cannot be retrieved using the # latest_version property of the canonical object if settings.CMIS_ENABLED: path = reverse( "enkelvoudiginformatieobject-detail", kwargs={ "version": "1", "uuid": instance.uuid }, ) # Following what is done in drc_cmis/client/convert.py ret["url"] = make_absolute_uri(path, request=self.context.get("request")) return ret
def to_representation(self, instance): object_type = instance.object_type self.set_object_properties(object_type) ret = super().to_representation(instance) if settings.CMIS_ENABLED: # Objects without a public key will have 'None' as the URL, so it is added manually path = reverse( "objectinformatieobject-detail", kwargs={ "version": 1, "uuid": instance.uuid }, ) ret["url"] = make_absolute_uri(path, request=self.context.get("request")) if hasattr(instance, "get_informatieobject_url"): ret["informatieobject"] = instance.get_informatieobject_url() else: ret["informatieobject"] = self.instance.get_informatieobject_url( ) return ret
def process_filters(self, data): converted_data = {} for key, value in data.items(): split_key = key.split("__") split_key[0] = split_key[0].strip("_") if len(split_key) > 1 and split_key[1] not in ["exact", "in"]: raise NotImplementedError( f"Filter on '{key}' is not implemented yet") # If the value is a queryset, extract the objects if split_key[0] == "informatieobject" and isinstance( value, CMISQuerySet): list_value = [] for item in value: list_value.append(make_absolute_uri(reverse(item))) value = list_value converted_data[split_key[0]] = value return converted_data