Skip to content

Commit

Permalink
Merge branch 'master' into Replace-CkEditor-with-TinyMCE
Browse files Browse the repository at this point in the history
  • Loading branch information
0einstein0 authored Nov 10, 2023
2 parents f7effd7 + 6c9669d commit 00bb988
Show file tree
Hide file tree
Showing 9 changed files with 249 additions and 198 deletions.
9 changes: 9 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@
Changes
=======

Version 7.17.0 (released 2023-11-10)

- assets: add overridable id to profile form
- assets: increase the char limit on community page description

Version 7.16.5 (released 2023-11-07)

- views: always show add community menu

Version 7.16.4 (released 2023-11-01)

- schema: avoid loading None value in custom fields
Expand Down
2 changes: 1 addition & 1 deletion invenio_communities/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
from .ext import InvenioCommunities
from .proxies import current_communities

__version__ = "7.16.4"
__version__ = "7.17.0"

__all__ = ("InvenioCommunities", "current_communities")
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import * as Yup from "yup";

const COMMUNITY_PAGES_VALIDATION_SCHEMA = Yup.object({
metadata: Yup.object({
curation_policy: Yup.string().max(5000, "Maximum number of characters is 5000"),
page: Yup.string().max(5000, "Maximum number of characters is 5000"),
curation_policy: Yup.string().max(50000, "Maximum number of characters is 50000"),
page: Yup.string().max(50000, "Maximum number of characters is 50000"),
}),
});

Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import React from "react";
import ReactDOM from "react-dom";
import { default as CommunityProfileForm } from "./CommunityProfileForm";
import { OverridableContext, overrideStore } from "react-overridable";

const domContainer = document.getElementById("app");
const community = JSON.parse(domContainer.dataset.community);
Expand All @@ -18,16 +19,19 @@ const types = JSON.parse(domContainer.dataset.types);
const logoMaxSize = JSON.parse(domContainer.dataset.logoMaxSize);
const customFields = JSON.parse(domContainer.dataset.customFields);
const permissions = JSON.parse(domContainer.dataset.permissions);
const overriddenComponents = overrideStore.getAll();

ReactDOM.render(
<CommunityProfileForm
community={community}
hasLogo={hasLogo}
defaultLogo="/static/images/square-placeholder.png"
types={types}
logoMaxSize={logoMaxSize}
customFields={customFields}
permissions={permissions}
/>,
<OverridableContext.Provider value={overriddenComponents}>
<CommunityProfileForm
community={community}
hasLogo={hasLogo}
defaultLogo="/static/images/square-placeholder.png"
types={types}
logoMaxSize={logoMaxSize}
customFields={customFields}
permissions={permissions}
/>
</OverridableContext.Provider>,
domContainer
);
4 changes: 2 additions & 2 deletions invenio_communities/communities/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ class CommunityMetadataSchema(Schema):
title = SanitizedUnicode(required=True, validate=_not_blank(max=250))
description = SanitizedUnicode(validate=_not_blank(max=250))

curation_policy = SanitizedHTML(validate=no_longer_than(max=5000))
page = SanitizedHTML(validate=no_longer_than(max=5000))
curation_policy = SanitizedHTML(validate=no_longer_than(max=50000))
page = SanitizedHTML(validate=no_longer_than(max=50000))

type = fields.Nested(VocabularySchema, metadata={"type": "communitytypes"})
website = URL(validate=_not_blank())
Expand Down
4 changes: 2 additions & 2 deletions invenio_communities/fixtures/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ def create_fake_community(faker):
"type": {
"id": random.choice(["organization", "event", "topic", "project"])
},
"curation_policy": faker.text(max_nb_chars=5000),
"page": faker.text(max_nb_chars=5000),
"curation_policy": faker.text(max_nb_chars=50000),
"page": faker.text(max_nb_chars=50000),
"website": "https://" + faker.domain_name(), # fake.url()
"organizations": [{"name": "CERN"}],
},
Expand Down
1 change: 0 additions & 1 deletion invenio_communities/views/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ def register_menus():
"invenio_communities.communities_new",
_("New community"),
order=3,
visible_when=_can_create_community,
)

communities = current_menu.submenu("communities")
Expand Down
12 changes: 6 additions & 6 deletions tests/communities/test_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,27 +221,27 @@ def test_post_metadata_schema_validation(
assert res.json["errors"][0]["field"] == "metadata.title"
# assert res.json["errors"][0]['messages'] == ['Title is too long.']

# Description max 5000
# Description max 250
data["metadata"]["title"] = "New Title"
data["metadata"]["description"] = "x" * 5001
data["metadata"]["description"] = "x" * 251
res = client.post("/communities", headers=headers, json=data)
assert res.status_code == 400
assert res.json["message"] == "A validation error occurred."
assert res.json["errors"][0]["field"] == "metadata.description"
# assert res.json["errors"][0]['messages'] == ['Description is too long.']

# Curation policy max 5000
# Curation policy max 50000
data["metadata"]["description"] = "basic description"
data["metadata"]["curation_policy"] = "x" * 5001
data["metadata"]["curation_policy"] = "x" * 50001
res = client.post("/communities", headers=headers, json=data)
assert res.status_code == 400
assert res.json["message"] == "A validation error occurred."
assert res.json["errors"][0]["field"] == "metadata.curation_policy"
# assert res.json["errors"][0]['messages'] == ['Curation policy is too long.']

# Curation policy max 5000
# Curation policy max 50000
data["metadata"]["curation_policy"] = "no policy"
data["metadata"]["page"] = "".join([str(i) for i in range(5001)])
data["metadata"]["page"] = "".join([str(i) for i in range(50001)])
res = client.post("/communities", headers=headers, json=data)
assert res.status_code == 400
assert res.json["message"] == "A validation error occurred."
Expand Down

0 comments on commit 00bb988

Please sign in to comment.