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 support for publishers, creators and contributors #528

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion requirements/udata.in
Original file line number Diff line number Diff line change
@@ -1 +1 @@
udata@git+https://github.com/opendatateam/udata.git
udata@git+https://github.com/maudetes/udata.git@feat/add-roles-in-harvest-extras
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Don't forget to rollback this change

Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ const meta = {
"created_at_internal": "2018-08-24T14:38:57.262000+00:00",
"last_modified_internal": "2024-09-01T06:41:23.766000+00:00"
},
"contact_point": null
"contact_points": []
},
{
"id": "5c4ae55a634f4117716d5656",
Expand Down Expand Up @@ -301,7 +301,7 @@ const meta = {
"created_at_internal": "2019-01-25T11:30:50.573000+00:00",
"last_modified_internal": "2024-04-08T13:07:58.362000+00:00"
},
"contact_point": null
"contact_points": []
},
{
"id": "58e5924b88ee3802ca255566",
Expand Down Expand Up @@ -395,7 +395,7 @@ const meta = {
"created_at_internal": "2017-04-06T02:56:43.520000+00:00",
"last_modified_internal": "2024-07-22T16:04:24.610000+00:00"
},
"contact_point": null
"contact_points": []
},
{
"id": "5c34c4d1634f4173183a64f1",
Expand Down Expand Up @@ -515,7 +515,7 @@ const meta = {
"created_at_internal": "2019-01-08T16:42:09.929000+00:00",
"last_modified_internal": "2024-07-31T14:24:59.737000+00:00"
},
"contact_point": null
"contact_points": []
},
{
"id": "53699d0ea3a729239d205b2e",
Expand Down Expand Up @@ -617,7 +617,7 @@ const meta = {
"created_at_internal": "2013-08-23T08:43:28.560000+00:00",
"last_modified_internal": "2024-06-07T14:30:50.450000+00:00"
},
"contact_point": null
"contact_points": []
},
{
"id": "5e7e104ace2080d9162b61d8",
Expand Down Expand Up @@ -732,7 +732,7 @@ const meta = {
"created_at_internal": "2020-03-27T15:40:10.048000+00:00",
"last_modified_internal": "2023-07-04T15:11:16.551000+00:00"
},
"contact_point": null
"contact_points": []
},
{
"id": "53699fe4a3a729239d206227",
Expand Down Expand Up @@ -869,7 +869,7 @@ const meta = {
"created_at_internal": "2013-07-08T11:02:40.861000+00:00",
"last_modified_internal": "2024-08-16T13:00:07.627000+00:00"
},
"contact_point": null
"contact_points": []
},
{
"id": "53698f4ca3a729239d2036df",
Expand Down Expand Up @@ -975,7 +975,7 @@ const meta = {
"created_at_internal": "2013-07-08T15:26:21.064000+00:00",
"last_modified_internal": "2023-10-09T14:03:43.153000+00:00"
},
"contact_point": null
"contact_points": []
},
{
"id": "605d268f4661cf23272817c3",
Expand Down Expand Up @@ -1078,7 +1078,7 @@ const meta = {
"created_at_internal": "2021-03-26T01:10:55.853000+00:00",
"last_modified_internal": "2021-03-25T09:31:57+00:00"
},
"contact_point": null
"contact_points": []
},
{
"id": "5a5f4f6c88ee387da4d252a3",
Expand Down Expand Up @@ -1175,7 +1175,7 @@ const meta = {
"created_at_internal": "2018-01-17T14:28:12.305000+00:00",
"last_modified_internal": "2024-06-28T07:54:21.821000+00:00"
},
"contact_point": null
"contact_points": []
},
{
"id": "58da72bbc751df38734d8658",
Expand Down Expand Up @@ -1277,7 +1277,7 @@ const meta = {
"created_at_internal": "2017-03-28T16:27:07.231000+00:00",
"last_modified_internal": "2023-07-03T13:04:28.557000+00:00"
},
"contact_point": null
"contact_points": []
},
{
"id": "5530fbacc751df5ff937dddb",
Expand Down Expand Up @@ -1407,7 +1407,7 @@ const meta = {
"created_at_internal": "2015-04-17T14:25:16.900000+00:00",
"last_modified_internal": "2024-08-28T09:47:04.599000+00:00"
},
"contact_point": null
"contact_points": []
},
{
"id": "6010206e7aa742eb447930f7",
Expand Down Expand Up @@ -1524,7 +1524,7 @@ const meta = {
"created_at_internal": "2021-01-26T15:00:14.172000+00:00",
"last_modified_internal": "2023-07-13T13:52:25.102000+00:00"
},
"contact_point": null
"contact_points": []
},
{
"id": "61d5e2d372a52d9f9411ff88",
Expand Down Expand Up @@ -1622,7 +1622,7 @@ const meta = {
"created_at_internal": "2022-01-05T19:26:27.679000+00:00",
"last_modified_internal": "2024-08-21T13:37:41.747000+00:00"
},
"contact_point": null
"contact_points": []
},
{
"id": "548acaf2c751df1eac4120e7",
Expand Down Expand Up @@ -1720,7 +1720,7 @@ const meta = {
"created_at_internal": "2014-12-12T12:01:06.889000+00:00",
"last_modified_internal": "2024-08-20T10:49:40.579000+00:00"
},
"contact_point": null
"contact_points": []
},
{
"id": "5e74ecf52eb7514f2d3b8845",
Expand Down Expand Up @@ -1839,7 +1839,7 @@ const meta = {
"created_at_internal": "2020-03-20T17:19:01.201000+00:00",
"last_modified_internal": "2024-08-28T16:00:12.446000+00:00"
},
"contact_point": null
"contact_points": []
},
{
"id": "621df2954fa5a3b5a023e23c",
Expand Down Expand Up @@ -1939,7 +1939,7 @@ const meta = {
"created_at_internal": "2022-03-01T11:16:53.477000+00:00",
"last_modified_internal": "2024-07-18T15:41:03.686000+00:00"
},
"contact_point": null
"contact_points": []
},
{
"id": "60190d00a7273a8100dd4d38",
Expand Down Expand Up @@ -2053,7 +2053,7 @@ const meta = {
"created_at_internal": "2021-02-02T09:27:44.214000+00:00",
"last_modified_internal": "2023-09-13T15:40:16.875000+00:00"
},
"contact_point": null
"contact_points": []
},
{
"id": "53698f50a3a729239d2036f5",
Expand Down Expand Up @@ -2150,7 +2150,7 @@ const meta = {
"created_at_internal": "2013-12-12T15:48:39.611000+00:00",
"last_modified_internal": "2016-03-16T23:34:38+00:00"
},
"contact_point": null
"contact_points": []
},
{
"id": "5cd57bf68b4c4179299eb0e9",
Expand Down Expand Up @@ -2249,7 +2249,7 @@ const meta = {
"created_at_internal": "2019-05-10T15:26:14.659000+00:00",
"last_modified_internal": "2024-09-02T02:30:40.061000+00:00"
},
"contact_point": null
"contact_points": []
}
],
"page": 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const dataservice = ref<NewDataservice>({
title: "",
organization: null,
owner: user.id,
contact_point: null,
contact_points: [],
});

const savedDataservice = ref<Dataservice | null>(null);
Expand Down Expand Up @@ -101,11 +101,13 @@ async function createDataserviceAndMoveToNextStep(newDataservice: NewDataservice
try {
if (contactPoint) {
if (!isNewContact) {
newDataservice.contact_point = contactPoint.id;
newDataservice.contact_points = [contactPoint.id];
} else {
let contactData = await createContactPointOrganization(newDataservice.organization, contactPoint);
newDataservice.contact_point = contactData.id;
newDataservice.contact_points = [contactData.id];
}
} else {
newDataservice.contact_points = [];
}
savedDataservice.value = await createDataservice(newDataservice);
savedDataservice.value.datasets = []
Expand Down
1 change: 1 addition & 0 deletions udata_front/theme/gouvfr/assets/js/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ export type ContactPoint = {
name: string;
contact_form?: string;
email?: string;
role: string;
}


Expand Down
17 changes: 12 additions & 5 deletions udata_front/theme/gouvfr/datagouv-components/demo/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,14 @@ const dataset : DatasetV2 = {
name: "[TEST] Météo France",
slug: "test-meteo-france",
uri: "https://demo.data.gouv.fr/api/1/organizations/test-meteo-france/"
}
},
contact_points: [{
email: "",
id: "someId",
name: "Contact",
contact_form: "",
role: "contact",
}]
};

const license : License = {
Expand Down Expand Up @@ -324,13 +331,13 @@ const dataservice: Dataservice = {
authorization_request_url: null,
availability: 99.9,
base_api_url: null,
contact_point: {
contact_points: [{
email: "",
id: "someId",
name: "Contact",
organization: null,
owner: "John Doe",
},
contact_form: "",
role: "contact",
}],
created_at: (new Date()).toDateString(),
datasets: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,15 @@ const dataservice: Dataservice = {
authorization_request_url: null,
availability: 99.9,
base_api_url: null,
contact_point: {
email: "",
id: "someId",
name: "Contact",
organization: null,
owner: "John Doe",
},
contact_points: [
{
email: "",
id: "someId",
name: "Contact",
contact_form: "",
role: "contact",
}
],
created_at: (new Date()).toDateString(),
datasets: [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export type ContactPoint = {
id: string;
name: string;
contact_form?: string;
email?: string;
role: string;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { Harvest } from "./harvest";
import type { Owned, OwnedWithId } from "./owned";
import type { ContactPoint } from "./contact_point";

export type BaseDataservice = Owned & {
acronym: string;
Expand All @@ -23,7 +24,7 @@ export type BaseDataservice = Owned & {
private: boolean;
rate_limiting: string;
title: string;
contact_point: string | null;
contact_points: Array<ContactPoint>;
};

export type NewDataservice = Omit<BaseDataservice, keyof OwnedWithId> & OwnedWithId;
Expand All @@ -34,7 +35,7 @@ export type Dataservice = Owned & {
authorization_request_url: string | null;
availability: number | null;
base_api_url: string | null;
contact_point: string | null;
contact_points: Array<ContactPoint>;
created_at: string;
datasets: Array<{
class: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { Badges } from "./badges";
import { Harvest } from "./harvest";
import type { Owned, OwnedWithId } from "./owned";
import type { Resource } from "./resources";
import type { ContactPoint } from "./contact_point";

export type Quality = {
all_resources_available: boolean;
Expand Down Expand Up @@ -37,6 +38,7 @@ export type BaseDataset = Owned & {
zones?: Array<string>;
granularity?: string;
} | null;
contact_points: Array<ContactPoint>;
};

export type NewDataset = Omit<BaseDataset, keyof OwnedWithId> & OwnedWithId;
Expand Down
3 changes: 1 addition & 2 deletions udata_front/theme/gouvfr/templates/contact_point.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{% if contact_point and (contact_point.name or contact_point.email or contact_point.contact_form) %}
<h2 class="subtitle fr-mt-3v fr-mb-1v">{{ _('Contact point') }}</h2>
<p class="fr-text--sm fr-mt-0 fr-mb-3v">
{% if contact_point.email %}
<a
Expand All @@ -23,4 +22,4 @@ <h2 class="subtitle fr-mt-3v fr-mb-1v">{{ _('Contact point') }}</h2>
{{ contact_point.name }}
{% endif %}
</p>
{% endif %}
{% endif %}
7 changes: 5 additions & 2 deletions udata_front/theme/gouvfr/templates/dataservice/display.html
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,12 @@ <h2 id="author" class="subtitle fr-mb-1w">{{ _('Author') }}</h2>
{{author}}<br />Published on {{date}}{% endtrans %}
</p>
{% endif %}
{% with contact_point=dataservice.contact_point %}
{% for contact_point in dataservice.contact_points if contact_point.role == "contact" %}
magopian marked this conversation as resolved.
Show resolved Hide resolved
{% if loop.first %}
<h2 id="{{ contact_point.role }}" class="subtitle fr-mt-3v fr-mb-1v">{{ CONTACT_ROLES.get(contact_point.role) }}</h2>
{% endif %}
{% include theme('contact_point.html') %}
{% endwith %}
{% endfor %}
<h2 class="subtitle fr-mt-3v fr-mb-1v">{{ _('Latest update') }}</h2>
<p class="fr-text--sm fr-mt-0 fr-mb-3v">
{{ dataservice.metadata_modified_at|dateformat(format='long') }}
Expand Down
8 changes: 6 additions & 2 deletions udata_front/theme/gouvfr/templates/dataset/display.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
{% set body_class = 'dataset-display' %}
{% set community_subtitle = _('Explore with %(certifier)s', certifier=config.SITE_TITLE ) %}
{% set read_only_mode = config.READ_ONLY_MODE %}

{# Harvesting source #}

{% block extra_head %}
Expand Down Expand Up @@ -130,9 +131,12 @@ <h2 id="author" class="subtitle fr-mb-1w">{{ _('Author') }}</h2>
}}
</p>
{% endif %}
{% with contact_point=dataset.contact_point %}
{% for contact_point in dataset.contact_points if contact_point.role == "contact" %}
{% if loop.first %}
<h2 id="{{ contact_point.role }}" class="subtitle fr-mt-3v fr-mb-1v">{{ CONTACT_ROLES.get(contact_point.role) }}</h2>
{% endif %}
{% include theme('contact_point.html') %}
{% endwith %}
{% endfor %}
{% if external_source(dataset) %}
<div class="fr-my-3v fr-text--sm">
{{ banner_info(
Expand Down
2 changes: 2 additions & 0 deletions udata_front/views/dataservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from feedgenerator.django.utils.feedgenerator import Atom1Feed

from jinja2 import TemplateNotFound
from udata.core.contact_point.models import CONTACT_ROLES
from udata.core.dataservices.models import Dataservice
from udata.core.dataservices.permissions import DataserviceEditPermission
from udata.core.site.models import current_site
Expand Down Expand Up @@ -97,6 +98,7 @@ def get_context(self):
context['datasets_items'] = [dataset.fetch() for dataset in datasets.items]

context['can_edit'] = DataserviceEditPermission(self.dataservice)
context["CONTACT_ROLES"] = CONTACT_ROLES
return context


Expand Down
Loading