Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add REST API service @tool-versions. #265

Merged
merged 1 commit into from
Jul 22, 2024

Conversation

mauritsvanrees
Copy link
Contributor

Sample contents if you are on a survey group with two surveys:

{
  "@id": "http://localhost:8000/tool-creator/sectors/eu/covid-19/covid-19/@tool-versions",
  "@type": "euphorie.surveygroup",
  "items": [
    {
      "@id": "http://localhost:8000/tool-creator/sectors/eu/covid-19/covid-19/oira-tool-import",
      "created": "2021-05-28T08:14:51+00:00",
      "id": "oira-tool-import",
      "modified": "2022-09-30T13:48:45+00:00",
      "published": "2021-08-30T11:57:27",
      "review_state": "published",
      "title": "OiRA Tool import"
    },
    {
      "@id": "http://localhost:8000/tool-creator/sectors/eu/covid-19/covid-19/second-version-based-on-import",
      "created": "2021-05-28T08:14:51+00:00",
      "id": "second-version-based-on-import",
      "modified": "2024-06-07T08:59:54+00:00",
      "published": "2024-07-19T18:26:05",
      "review_state": "published",
      "title": "Second version based on import"
    }
  ],
  "surveygroup": {
    "@id": "http://localhost:8000/tool-creator/sectors/eu/covid-19/covid-19",
    "title": "COVID-19"
  }
}

Sample contents when you are on a survey and it has one sibling:

{
  "@id": "http://localhost:8000/tool-creator/sectors/eu/covid-19/covid-19/second-version-based-on-import/@tool-versions",
  "@type": "euphorie.survey",
  "items": [
    {
      "@id": "http://localhost:8000/tool-creator/sectors/eu/covid-19/covid-19/oira-tool-import",
      "created": "2021-05-28T08:14:51+00:00",
      "id": "oira-tool-import",
      "modified": "2022-09-30T13:48:45+00:00",
      "published": "2021-08-30T11:57:27",
      "review_state": "published",
      "title": "OiRA Tool import"
    }
  ],
  "survey": {
    "@id": "http://localhost:8000/tool-creator/sectors/eu/covid-19/covid-19/second-version-based-on-import",
    "created": "2021-05-28T08:14:51+00:00",
    "id": "second-version-based-on-import",
    "modified": "2024-06-07T08:59:54+00:00",
    "published": "2024-07-19T18:26:05",
    "review_state": "published",
    "title": "Second version based on import"
  },
  "surveygroup": {
    "@id": "http://localhost:8000/tool-creator/sectors/eu/covid-19/covid-19",
    "title": "COVID-19"
  }
}

We probably need more info or less. But it's a nice start.

Let me paste what I have put in the docstring of this service, as explanation.

From the Quaive side we request this. Then we know if we are on a path that is within a survey group, and we can show info about the versions, if we want.

This is meant to show information about versions like on the left in the prototype: https://proto.quaivecloud.com/tools/audio-visual-productions/edit

We need this information in the sidebar. And we don't yet have a way of knowing what the "remote" portal_type is of the path we are viewing in Quaive, so we don't know if we are currently viewing a country or survey group or survey or risk. So from the Quaive side we have no idea if we should show this version information. An extra REST API service then seems a good way to me.

Sample contents if you are on a survey group with two surveys:

```
{
  "@id": "http://localhost:8000/tool-creator/sectors/eu/covid-19/covid-19/@tool-versions",
  "@type": "euphorie.surveygroup",
  "items": [
    {
      "@id": "http://localhost:8000/tool-creator/sectors/eu/covid-19/covid-19/oira-tool-import",
      "created": "2021-05-28T08:14:51+00:00",
      "id": "oira-tool-import",
      "modified": "2022-09-30T13:48:45+00:00",
      "published": "2021-08-30T11:57:27",
      "review_state": "published",
      "title": "OiRA Tool import"
    },
    {
      "@id": "http://localhost:8000/tool-creator/sectors/eu/covid-19/covid-19/second-version-based-on-import",
      "created": "2021-05-28T08:14:51+00:00",
      "id": "second-version-based-on-import",
      "modified": "2024-06-07T08:59:54+00:00",
      "published": "2024-07-19T18:26:05",
      "review_state": "published",
      "title": "Second version based on import"
    }
  ],
  "surveygroup": {
    "@id": "http://localhost:8000/tool-creator/sectors/eu/covid-19/covid-19",
    "title": "COVID-19"
  }
}
```

Sample contents when you are on a survey and it has one sibling:

```
{
  "@id": "http://localhost:8000/tool-creator/sectors/eu/covid-19/covid-19/second-version-based-on-import/@tool-versions",
  "@type": "euphorie.survey",
  "items": [
    {
      "@id": "http://localhost:8000/tool-creator/sectors/eu/covid-19/covid-19/oira-tool-import",
      "created": "2021-05-28T08:14:51+00:00",
      "id": "oira-tool-import",
      "modified": "2022-09-30T13:48:45+00:00",
      "published": "2021-08-30T11:57:27",
      "review_state": "published",
      "title": "OiRA Tool import"
    }
  ],
  "survey": {
    "@id": "http://localhost:8000/tool-creator/sectors/eu/covid-19/covid-19/second-version-based-on-import",
    "created": "2021-05-28T08:14:51+00:00",
    "id": "second-version-based-on-import",
    "modified": "2024-06-07T08:59:54+00:00",
    "published": "2024-07-19T18:26:05",
    "review_state": "published",
    "title": "Second version based on import"
  },
  "surveygroup": {
    "@id": "http://localhost:8000/tool-creator/sectors/eu/covid-19/covid-19",
    "title": "COVID-19"
  }
}
```

We probably need more info or less.  But it's a nice start.

Let me paste what I have put in the docstring of this service, as explanation.

From the Quaive side we request this.  Then we know if we are on a path that is within a survey group, and we can show info about the versions, if we want.

This is meant to show information about versions like on the left in the prototype:
https://proto.quaivecloud.com/tools/audio-visual-productions/edit

We need this information in the sidebar.  And we don't yet have a way of knowing what the "remote" portal_type is of the path we are viewing in Quaive, so we don't know if we are currently viewing a country or survey group or survey or risk.  So from the Quaive side we have no idea if we should show this version information.  An extra REST API service then seems a good way to me.
@mauritsvanrees mauritsvanrees requested a review from ale-rt July 19, 2024 18:16
else:
current_survey_id = None
items = []
# TODO Can we know which survey is the main currently published one?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the trick is to check the id of the survey under the /client path, but maybe there is already some code that does that.
We can look at this together, or, if I have time, I will check this during the week.

@ale-rt ale-rt merged commit 2abef93 into quaive-app Jul 22, 2024
2 checks passed
@ale-rt ale-rt deleted the maurits-rest-api-service-tool-versions branch July 22, 2024 12:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants