CDLUC3 / dmptool

DMPTool version of the DMPRoadmap codebase
https://dmptool.org
MIT License
58 stars 13 forks source link

Template API Endpoint #424

Closed miggall closed 1 year ago

miggall commented 1 year ago

Please complete the following fields as applicable:

What version of the DMPRoadmap code are you running? (e.g. v2.2.0) v4.0.4

Expected behavior: When I query the template endpoint via the API I would expect the json to return the latest version of the template if it has been customized

Actual behaviour: Template is returned but any customization to the example answers or guidelines is missing

Steps to reproduce: Query the API for a list of templates. Pick one of those, edit the guidelines and add example answers and publish a new version. Query the API endpoint once more to see if the annotations are present.

This maybe something I introduced when adding the option to show_phases to the end point or perhaps this is by design.

briri commented 1 year ago

Interesting. The templates are loaded in the Api::V2::TemplatesPolicy class and it references the .published scope on the Template model

That should theoretically be grabbing the latest version of your template.

When you say 'customization' do you mean the owner of the template has changed something on their own template or that they have 'customized' a funder template? For example, is the admin for DOE changing their own template or is an admin from Sandia customizing a template owned and created by the DOE admin?

miggall commented 1 year ago

That's precisely what I mean. An org admin went to the "customizable templates" section and customized a DOE Generic Template and added some annotations. I could not see the latest customizations.

briri commented 1 year ago

Ok. Make sure that they've published their customizations and that the 'customized' template has not changed. There is an icon that appears if they've made changes and not yet published them. We admit that the icon is not intuitive and should likely be updated. There's also a scenario where they've made customizations but the 'customized' template has a new version out. That new version would essentially invalidate the old customizations until the org admin resolves them and republishes against the new template. Here is a screenshot showing both scenarios:

Screen Shot 2023-01-17 at 2 44 33 PM
miggall commented 1 year ago

Alright. Let me ensure they have properly published all their changes and then I will close this out.

briri commented 1 year ago

👍🏻 cool. If it is in fact published let me know and I'll see if I can duplicate the issue and narrow it down.

miggall commented 1 year ago

So the template is published. I can see in the data it actually comes in the form of "with additional questions for Org.name".

It looks like this is intentional behavior. What I had incorrectly assumed was the template data would be delivered in original form with a version update and the updates to the annotations, questions, etc.

So basically, I get two forms of the template. The original and the customized version with the title of "Template name with additional questions for Org.name"

briri commented 1 year ago

Yeah, the customization is essentially a copy of the original funder template.

miggall commented 1 year ago

A copy of the original funder template but with an org change. Understood now. I will have to figure out how to work around this but my question has been answered and there is not a bug. Thank you for clarifying!