diff --git a/src/moin/forms.py b/src/moin/forms.py index c7a56174f..ccace17c0 100644 --- a/src/moin/forms.py +++ b/src/moin/forms.py @@ -153,6 +153,13 @@ def validate(self, element, state): # incoming request is from +usersettings#personal; # apps/frontend/views.py will validate changes to user names return True + # Make sure that the other meta is valid before validating the name. + # TODO: prove the try below is always redundant and remove it. + try: + if not element.parent.parent['extra_meta_text'].valid: + return False + except AttributeError: + pass try: validate_name(state['meta'], state[ITEMID]) except NameNotValidError as e: diff --git a/src/moin/items/__init__.py b/src/moin/items/__init__.py index 7d46ef045..eb5dfd248 100644 --- a/src/moin/items/__init__.py +++ b/src/moin/items/__init__.py @@ -48,7 +48,7 @@ from moin.utils.registry import RegistryBase from moin.utils.diff_html import diff as html_diff from moin.utils import diff3 -from moin.forms import RequiredText, OptionalText, Tags, Names, validate_name, NameNotValidError +from moin.forms import RequiredText, OptionalText, JSON, Tags, Names, validate_name, NameNotValidError from moin.constants.keys import ( NAME, NAMES, NAMENGRAM, NAME_OLD, NAME_EXACT, WIKINAME, MTIME, ITEMTYPE, CONTENTTYPE, SIZE, ACTION, ADDRESS, HOSTNAME, USERID, COMMENT, @@ -790,6 +790,7 @@ class _ModifyForm(BaseModifyForm): ModifyForm. """ meta_form = BaseMetaForm + extra_meta_text = JSON.using(label=L_("Extra MetaData (JSON)")).with_properties(rows=ROWS_META, cols=COLS) meta_template = 'modify_meta.html' def _load(self, item): @@ -808,6 +809,7 @@ def _load(self, item): self['meta_form'].set(meta, policy='duck') for k in list(self['meta_form'].field_schema_mapping.keys()) + IMMUTABLE_KEYS: meta.pop(k, None) + self['extra_meta_text'].set(item.meta_dict_to_text(meta)) self['content_form']._load(item.content) def _dump(self, item): @@ -825,6 +827,11 @@ def _dump(self, item): # e.g. we get PARENTID in here meta = item.meta_filter(item.prepare_meta_for_modify(item.meta)) meta.update(self['meta_form'].value) + try: + meta.update(item.meta_text_to_dict(self['extra_meta_text'].value)) + except TypeError: + # only items with names ending in Group or Dict have extra_meta.test + pass data, contenttype_guessed = self['content_form']._dump(item.content) comment = self['comment'].value return meta, data, contenttype_guessed, comment diff --git a/src/moin/templates/modify.html b/src/moin/templates/modify.html index ff7b00978..e5fca1ebb 100644 --- a/src/moin/templates/modify.html +++ b/src/moin/templates/modify.html @@ -68,6 +68,11 @@