Problem with metadata lookup options

222 views
Skip to first unread message

LeVon Smoker

unread,
Feb 1, 2016, 1:44:15 PM2/1/16
to Mayan EDMS
I'm having trouble getting optional metadata types to work when the type has a list of lookup options. When I try to upload a document that has optional metadata and I don't choose from the dropdown boxes, I get an error message - "Value is not one of the provided options." See the attachment. For the "Meeting Type" metadata I have 'Board', 'Management Team', 'Supervisors' entered as options in the Lookup field. I could add a value of None to the list but I think that defeats the purpose of allowing for optional vs required metadata based on document type.

Or am I missing something?

Thanks,
LeVon Smoker
mayan.png

LeVon Smoker

unread,
Feb 2, 2016, 11:54:58 AM2/2/16
to Mayan EDMS
I fixed the problem by changing line 129 in mayan/apps/metadata/models.py from:

        if self.lookup:
            lookup_options
= self.get_lookup_values()
           
if value not in lookup_options:
               
raise ValidationError(
                    _
('Value is not one of the provided options.')
               
)

to:
        if self.lookup:
            lookup_options
= self.get_lookup_values()
           
if value and value not in lookup_options:
               
raise ValidationError(
                    _
('Value is not one of the provided options.')
               
)

Adding the 'value and' to the if statement allows empty values. Of course if the metadata type is required, that will be caught by the preceding code and raise the appropriate error.

Thoughts?

LeVon S.

Roberto Rosario

unread,
Feb 5, 2016, 7:07:46 AM2/5/16
to mayan...@googlegroups.com

Looks like a bug. I'll write the view tests for each case and add a ticket for the 2.1 milestone or add a 2.0.2 milestone if it is to critical. Thanks for the finding this.

--

---
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 mayan-edms+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Chris H

unread,
Feb 9, 2016, 5:10:26 PM2/9/16
to Mayan EDMS
LeVon

I applied your patch and it resolved the error but what I noticed is that if a metadata field has no value selected, the metadata is still applied to document, albeit with no value. I believe it should not be applied to the document at all. So I think there needs to be a second part to this patch that checks if a value has been defined before applying the metadata to the document. I had a look at the code but it is way beyond my coding abilities :(

Thank you for this patch which helped me move forward in my testing.

Chris

Roberto Rosario

unread,
Feb 9, 2016, 6:46:24 PM2/9/16
to Mayan EDMS
Working on it (https://gitlab.com/mayan-edms/mayan-edms/commit/f1b090f8d6b89d826ee9bf623d5c7291fd5a57f9). Found a good solution, if the checkbox is not selected the metadata entry is ignored completely. If the checkbox is selected the metadata is created with an empty value if the metadata type allows it. If the update checkbox is not selected, validation is also turned off to avoid invalid values stopping the wizard moving forward for metadata that is not even going to be stored.  Commit is part of the 2.0.2 milestone to be release in a day or two.

LeVon Smoker

unread,
Feb 10, 2016, 8:33:47 AM2/10/16
to Mayan EDMS
Thanks! I think that's an intuitive way of handling it.

Chris, I also realized that my "fix" was incomplete but couldn't figure out how to test the update checkbox control. Obviously, Roberto knows the codebase best...

LeVon

Chris H

unread,
Feb 10, 2016, 8:42:01 AM2/10/16
to Mayan EDMS
I appreciate the fix very much and hope I can contribute to some testing of the new release with official resolution.

As I mentioned I am a newbie to Mayan. My next step is to set up a Docker environment so I can test and learn without destroying what I hope will become a production instance :)


On Monday, February 1, 2016 at 1:44:15 PM UTC-5, LeVon Smoker wrote:

Roberto Rosario

unread,
Feb 12, 2016, 11:13:09 PM2/12/16
to Mayan EDMS
When I was designing the metadata entry behavior it was very hard to foresee all possible interactions so I'm very grateful for all the testing and feedback, it is allowing the feature to be fine tuned to actual use cases.

https://gitlab.com/mayan-edms/mayan-edms/commit/59624d75cb99219c726f10e73bda2bbcae1b3301

Roberto Rosario

unread,
Feb 12, 2016, 11:17:48 PM2/12/16
to Mayan EDMS
If you want to build your own Docker images this is the repository to use: https://gitlab.com/mayan-edms/mayan-edms-docker

You can also use the pre-built image at Docker Hub (https://hub.docker.com/r/mayanedms/monolithic/) but those have not been updated and are based on 2.0.0 (http://mayan.readthedocs.org/en/latest/topics/deploying.html#docker). Once 2.0.2 is out I will update the official Docker images.

Chris H

unread,
Feb 13, 2016, 8:34:31 AM2/13/16
to mayan...@googlegroups.com

When i am back in town next week i'll update my docker instance and do some testing. Thanks for the fix!

> --
>
> ---
> You received this message because you are subscribed to a topic in the Google Groups "Mayan EDMS" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/mayan-edms/VUGRl4xX-1c/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to mayan-edms+...@googlegroups.com.

Reply all
Reply to author
Forward
0 new messages