Skip to content

Commit

Permalink
Merge branch 'master' into elasticsearch
Browse files Browse the repository at this point in the history
  • Loading branch information
magopian committed Sep 11, 2024
1 parent 0214671 commit 53b122c
Show file tree
Hide file tree
Showing 47 changed files with 1,101 additions and 172 deletions.
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,29 @@

## Current (in progress)

- Allow OAuth clients without secrets [#3138](https://github.com/opendatateam/udata/pull/3138)
- Add a `archived` button for datasets and reuses on frontend admin [#3104](https://github.com/opendatateam/udata/pull/3104)
- **breaking change** Return all the reuses available to a user on the /reuses endpoint, including the private and deleted ones they own [#3140](https://github.com/opendatateam/udata/pull/3140).
- Fix undelete reuse and dataservices [#3141](https://github.com/opendatateam/udata/pull/3141)
- Add a minimal publiccode.yml [#3144](https://github.com/opendatateam/udata/pull/3144)
- Fix the boolean filters in the API for the "new system" endpoints [#3139](https://github.com/opendatateam/udata/pull/3139)
- Update authlib dependency from 0.14.3 to 1.3.1 [#3135](https://github.com/opendatateam/udata/pull/3135)
- Add CORS on resource redirect [#3145](https://github.com/opendatateam/udata/pull/3145)

## 9.1.4 (2024-08-26)

- Fix many linting issues reported by ruff [#3118](https://github.com/opendatateam/udata/pull/3118)
- Import the dataservice's organization from the fixtures [#3121](https://github.com/opendatateam/udata/pull/3121)
- Convert reuse to new API system [#3066](https://github.com/opendatateam/udata/pull/3066)
- Fix circular import error [#3128](https://github.com/opendatateam/udata/pull/3128)
- Add an option to specify the port when using `inv serve` [#3123](https://github.com/opendatateam/udata/pull/3123)
- Add a new `related_to` filter parameter to the activities API endpoint [#3127](https://github.com/opendatateam/udata/pull/3127)
- Properly import the `Discussion.closed_by` from the fixtures [#3125](https://github.com/opendatateam/udata/pull/3125)
- Send an API token to Hydra when publishing resource events [#3130](https://github.com/opendatateam/udata/pull/3130)
- Add `last_login_at` to org members API [#3133](https://github.com/opendatateam/udata/pull/3133)
- Always add Vary even for non CORS requests [#3132](https://github.com/opendatateam/udata/pull/3132)
- Add acronym in organization csv catalog [#3134](https://github.com/opendatateam/udata/pull/3134)
- Limit the number of user suggestions [#3131](https://github.com/opendatateam/udata/pull/3131)

## 9.1.3 (2024-08-01)

Expand All @@ -16,6 +34,7 @@
- Update to the version v2.0.0 of udata-fixtures (with the dataservices)
- Add type hints [#3111](https://github.com/opendatateam/udata/pull/3111)
- Make sure requests v2.32.3 is used everywhere consistently [#3116](https://github.com/opendatateam/udata/pull/3116)
- Expose a dataservice in its organization's catalog, and expose a dataservice's catalog [#3122](https://github.com/opendatateam/udata/pull/3122)

## 9.1.2 (2024-07-29)

Expand Down
24 changes: 24 additions & 0 deletions docs/adapting-settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -641,3 +641,27 @@ FS_ROOT = '/srv/http/www.data.dev/fs'
[flask-mongoengine-doc]: https://flask-mongoengine.readthedocs.org/
[authlib-doc]: https://docs.authlib.org/en/latest/flask/2/authorization-server.html#server
[udata-search-service]: https://github.com/opendatateam/udata-search-service

## Resources modifications publishing

udata may notify external services (ex: [hydra](https://github.com/datagouv/hydra)) about resources modification on the platform.
install, or any other service.


### PUBLISH_ON_RESOURCE_EVENTS

**default**: `False`

Publish resource events to an external service.

### RESOURCES_ANALYSER_URI

**default**: `http://localhost:8000`

URI of the external service receiving the resource events.

### RESOURCES_ANALYSER_API_KEY

**default**: `api_key_to_change`

API key sent in the headers of the endpoint requests as a Bearer token.
4 changes: 2 additions & 2 deletions docs/harvesting.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def inner_harvest():
def inner_process_dataset(item: HarvestItem, args1, args2, args3):
dataset = self.get_dataset(item.remote_id)
update_dataset(dataset, args1, args2)
update_dataset(dataset, args1, args2)
return dataset
```
Expand Down Expand Up @@ -207,7 +207,7 @@ class RandomBackend(BaseBackend):

dataset.title = faker.sentence()
dataset.description = faker.text()
dataset.tags = list(set(faker.words(nb=faker.pyint())))
dataset.tags = list(set(faker.tags(nb=faker.pyint())))

# Resources
for i in range(faker.pyint()):
Expand Down
31 changes: 30 additions & 1 deletion js/views/dataset.vue
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,19 @@ export default {
icon: 'send',
method: this.transfer_request
});
if (!this.dataset.archived) {
actions.push({
label: this._('Archive'),
icon: 'archive',
method: this.archive
})
} else {
actions.push({
label: this._('Unarchive'),
icon: 'undo',
method: this.unarchive
});
}
if(!this.dataset.deleted) {
actions.push({
label: this._('Delete'),
Expand Down Expand Up @@ -169,6 +182,22 @@ export default {
edit() {
this.$go({name: 'dataset-edit', params: {oid: this.dataset.id}});
},
archive() {
this.dataset.archived = new Date().toISOString();
API.datasets.update_dataset({dataset: this.dataset.id, payload: this.dataset},
(response) => {
this.dataset.on_fetched(response);
}
);
},
unarchive() {
this.dataset.archived = null;
API.datasets.update_dataset({dataset: this.dataset.id, payload: this.dataset},
(response) => {
this.dataset.on_fetched(response);
}
);
},
confirm_delete() {
this.$root.$modal(
require('components/dataset/delete-modal.vue'),
Expand Down Expand Up @@ -201,7 +230,7 @@ export default {
class: _class,
label
});
} else if (existing) {
} else if (!value && existing) {
this.badges.splice(this.badges.indexOf(existing), 1);
}
}
Expand Down
26 changes: 16 additions & 10 deletions js/views/reuse.vue
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,18 @@ export default {
this.$root.$modal(require('components/badges/modal.vue'), {
subject: this.reuse
})
},
addOrRemoveBadge(id, value, _class, label) {
const existing = this.badges.find(b => b.id === id);
if (value && !existing) {
this.badges.push({
id,
class: _class,
label
});
} else if (!value && existing) {
this.badges.splice(this.badges.indexOf(existing), 1);
}
}
},
route: {
Expand All @@ -258,16 +270,10 @@ export default {
}
},
'reuse.deleted': function (deleted) {
if (deleted) {
this.badges = [
{
class: 'danger',
label: this._('Deleted')
}
]
} else {
this.badges = []
}
this.addOrRemoveBadge('deleted', deleted, 'danger', this._('Deleted'));
},
'reuse.archived': function(archived) {
this.addOrRemoveBadge('archived', archived, 'warning', this._('Archived'));
}
}
}
Expand Down
26 changes: 26 additions & 0 deletions publiccode.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
publiccodeYmlVersion: "0.2"
name: udata
url: https://github.com/opendatateam/udata
landingURL: http://udata.readthedocs.org
creationDate: 2014-04-25
latestRelease:
date: ""
version: ""
logo: https://github.com/opendatateam.png
usedBy: []
fundedBy:
- name: Direction interministérielle du numérique
url: https://lannuaire.service-public.fr/gouvernement/d1a97841-b4bf-46df-a089-1003e4e266b4
softwareType: ""
description:
en:
shortDescription: Customizable and skinnable social platform dedicated to open data.
documentation: ""
legal:
license: agpl-3.0
authorsFile: ""
maintenance:
type: community
contacts:
- name: ""
email: ""
11 changes: 3 additions & 8 deletions requirements/develop.pip
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ attrs==23.2.0
# -c requirements/test.pip
# jsonschema
# referencing
authlib==0.14.3
authlib==1.3.1
# via
# -c requirements/install.pip
# -c requirements/test.pip
Expand Down Expand Up @@ -155,7 +155,6 @@ cryptography==2.8
# -c requirements/test.pip
# -r requirements/install.in
# authlib
# secretstorage
decorator==5.1.1
# via ipython
distlib==0.3.8
Expand All @@ -170,11 +169,13 @@ docutils==0.20.1
# via readme-renderer
elasticsearch==7.15.0
# via
# -c requirements/install.pip
# -c requirements/test.pip
# -r requirements/install.in
# elasticsearch-dsl
elasticsearch-dsl==7.4.0
# via
# -c requirements/install.pip
# -c requirements/test.pip
# -r requirements/install.in
email-validator==2.2.0
Expand Down Expand Up @@ -350,10 +351,6 @@ jaraco-classes==3.3.1
# via keyring
jedi==0.19.1
# via ipython
jeepney==0.8.0
# via
# keyring
# secretstorage
jinja2==3.1.2
# via
# -c requirements/install.pip
Expand Down Expand Up @@ -606,8 +603,6 @@ s3transfer==0.6.2
# -c requirements/install.pip
# -c requirements/test.pip
# boto3
secretstorage==3.3.3
# via keyring
sentry-sdk[flask]==2.9.0
# via
# -c requirements/install.pip
Expand Down
4 changes: 3 additions & 1 deletion requirements/doc.pip
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ attrs==23.2.0
# -c requirements/test.pip
# jsonschema
# referencing
authlib==0.14.3
authlib==1.3.1
# via
# -c requirements/install.pip
# -c requirements/test.pip
Expand Down Expand Up @@ -154,11 +154,13 @@ dnspython==2.6.1
# pymongo
elasticsearch==7.15.0
# via
# -c requirements/install.pip
# -c requirements/test.pip
# -r requirements/install.in
# elasticsearch-dsl
elasticsearch-dsl==7.4.0
# via
# -c requirements/install.pip
# -c requirements/test.pip
# -r requirements/install.in
email-validator==2.2.0
Expand Down
2 changes: 1 addition & 1 deletion requirements/install.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
authlib==0.14.3
authlib==1.3.1
awesome-slugify==1.6.5
Babel==2.12.1
bcrypt==3.1.7
Expand Down
2 changes: 1 addition & 1 deletion requirements/install.pip
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ attrs==23.2.0
# via
# jsonschema
# referencing
authlib==0.14.3
authlib==1.3.1
# via -r requirements/install.in
awesome-slugify==1.6.5
# via -r requirements/install.in
Expand Down
4 changes: 3 additions & 1 deletion requirements/report.pip
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ attrs==23.2.0
# -c requirements/test.pip
# jsonschema
# referencing
authlib==0.14.3
authlib==1.3.1
# via
# -c requirements/install.pip
# -c requirements/test.pip
Expand Down Expand Up @@ -157,11 +157,13 @@ dnspython==2.6.1
# pymongo
elasticsearch==7.15.0
# via
# -c requirements/install.pip
# -c requirements/test.pip
# -r requirements/install.in
# elasticsearch-dsl
elasticsearch-dsl==7.4.0
# via
# -c requirements/install.pip
# -c requirements/test.pip
# -r requirements/install.in
email-validator==2.2.0
Expand Down
7 changes: 5 additions & 2 deletions requirements/test.pip
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ attrs==23.2.0
# -c requirements/install.pip
# jsonschema
# referencing
authlib==0.14.3
authlib==1.3.1
# via
# -c requirements/install.pip
# -r requirements/install.in
Expand Down Expand Up @@ -128,10 +128,13 @@ dnspython==2.6.1
# pymongo
elasticsearch==7.15.0
# via
# -c requirements/install.pip
# -r requirements/install.in
# elasticsearch-dsl
elasticsearch-dsl==7.4.0
# via -r requirements/install.in
# via
# -c requirements/install.pip
# -r requirements/install.in
email-validator==2.2.0
# via
# -c requirements/install.pip
Expand Down
2 changes: 1 addition & 1 deletion tasks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def qa(ctx):
def serve(ctx, host="localhost", port="7000"):
"""Run a development server"""
with ctx.cd(ROOT):
ctx.run(f"python manage.py serve -d -r -h {host} -p {port}")
ctx.run(f"python manage.py serve -d -r -h {host} -p {port}", pty=True)


@task
Expand Down
2 changes: 1 addition & 1 deletion udata/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
udata
"""

__version__ = "9.1.4.dev"
__version__ = "9.1.5.dev"
__description__ = "Open data portal"
12 changes: 10 additions & 2 deletions udata/api/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import click
from flask import current_app, json
from flask_restx import schemas
from werkzeug.security import gen_salt

from udata.api import api
from udata.api.oauth2 import OAuth2Client
Expand Down Expand Up @@ -77,24 +78,31 @@ def validate():
@click.option(
"-r", "--response-types", multiple=True, default=["code"], help="Client's response types"
)
def create_oauth_client(client_name, user_email, uri, grant_types, scope, response_types):
@click.option("-p", "--public", is_flag=True, help="Public client (SPA)")
def create_oauth_client(client_name, user_email, uri, grant_types, scope, response_types, public):
"""Creates an OAuth2Client instance in DB"""
user = User.objects(email=user_email).first()
if user is None:
exit_with_error("No matching user to email")

client_secret = gen_salt(50) if not public else None

client = OAuth2Client.objects.create(
name=client_name,
owner=user,
grant_types=grant_types,
scope=scope,
response_types=response_types,
redirect_uris=uri,
secret=client_secret,
)

click.echo(f"New OAuth client: {client.name}")
click.echo(f"Client's ID {client.id}")
click.echo(f"Client's secret {client.secret}")
if public:
click.echo("Client is public and has no secret.")
else:
click.echo(f"Client's secret {client.secret}")
click.echo(f"Client's grant_types {client.grant_types}")
click.echo(f"Client's response_types {client.response_types}")
click.echo(f"Client's URI {client.redirect_uris}")
Loading

0 comments on commit 53b122c

Please sign in to comment.