I'm going to look into this, but what I ended up doing between posting this 
question and now is editing api_views.py's APIDocumentMetadataView class 
and change the 'put' function to:

def put(self, *args, **kwargs):
>         """
>         Edit the selected document metadata type and value.
>         """
>         try:
>             partial = kwargs.pop('partial', False)
>             instance = self.get_object()
>             serializer = self.get_serializer(instance, 
> data=self.request.data, partial=partial)
>             serializer.is_valid(raise_exception=True)
>             instance.user = self.request.user
>             serializer.save()
>             return Response(serializer.data)
>         except Exception as exception:
>             return Response(
>                 status=status.HTTP_400_BAD_REQUEST, data={
>                     'non_fields_errors': unicode(exception)
>                 }
>             )
>

This gave me a user variable available in class DocumentMetadata to use in 
the save method:

>     def save(self, *args, **kwargs):
>         if self.metadata_type.pk not in 
> self.document.document_type.metadata.values_list('metadata_type', 
> flat=True):
>             raise ValidationError(
>                 _('Metadata type is not valid for this document type.')
>             )
>
>         #compare metadata values; if different, log the change
>         
>         valueList = self.document.metadata.filter(id=self.id).values()
>         if len(valueList) > 0:
>             old_metadata_value = valueList[0]['value']
>             if old_metadata_value != self.value:
>                 event_metadata_properties_edit.commit(
>                     actor=self.user,
>                     target=self._document_cache,
>                     description='Changed value from 
> "'+str(old_metadata_value or '')+'" to "'+str(self.value or '')+'"',
>                     action_object=self._metadata_type_cache
>                 )
>             
>         return super(DocumentMetadata, self).save(*args, **kwargs)
>

This is what I've used internally for my implementation.
I'm still getting up to speed on the whole 'django-mvc-layers-on-layers' 
thing; This is my first project using python in a web environment, using 
classes in python, and very near to my first time implementing classes 
myself... so forgive me if things aren't 'good enough' or 'pythonic enough' 
code wise.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"Mayan EDMS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to