changeset 2702:e893ac118592

Removed auto-computed values from the metadata edit view
author Ajitesh Gupta <ajgupta93@gmail.com>
date Sat, 09 Aug 2014 18:31:13 +0530
parents 8d8a01710ca8
children 23f66a758366
files MoinMoin/constants/keys.py MoinMoin/items/__init__.py
diffstat 2 files changed, 23 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/constants/keys.py	Thu Aug 07 21:46:46 2014 +0530
+++ b/MoinMoin/constants/keys.py	Sat Aug 09 18:31:13 2014 +0530
@@ -57,6 +57,23 @@
 DATAID = u"dataid"
 WIKINAME = u"wikiname"
 CONTENT = u"content"
+IMMUTABLE_KEYS = [
+    ACTION,
+    ADDRESS,
+    DATAID,
+    EXTERNALLINKS,
+    ITEMID,
+    ITEMLINKS,
+    ITEMTRANSCLUSIONS,
+    MTIME,
+    NAME_OLD,
+    PARENTID,
+    REVID,
+    HASH_ALGORITHM,
+    SIZE,
+    USERID,
+    WIKINAME,
+]
 
 # magic REVID for current revision:
 CURRENT = u"current"
--- a/MoinMoin/items/__init__.py	Thu Aug 07 21:46:46 2014 +0530
+++ b/MoinMoin/items/__init__.py	Sat Aug 09 18:31:13 2014 +0530
@@ -48,8 +48,8 @@
 from MoinMoin.forms import RequiredText, OptionalText, JSON, Tags, Names
 from MoinMoin.constants.keys import (
     NAME, NAME_OLD, NAME_EXACT, WIKINAME, MTIME, ITEMTYPE,
-    CONTENTTYPE, SIZE, ACTION, ADDRESS, HOSTNAME, USERID, COMMENT,
-    HASH_ALGORITHM, ITEMID, REVID, DATAID, CURRENT, PARENTID, NAMESPACE,
+    CONTENTTYPE, SIZE, ACTION, ADDRESS, HOSTNAME, USERID, COMMENT, USERGROUP,
+    HASH_ALGORITHM, ITEMID, REVID, DATAID, CURRENT, PARENTID, NAMESPACE, IMMUTABLE_KEYS,
     UFIELDS_TYPELIST, UFIELDS, TRASH,
     ACTION_SAVE, ACTION_REVERT, ACTION_TRASH, ACTION_RENAME
 )
@@ -507,7 +507,7 @@
                 meta['acl'] = "None"
 
             self['meta_form'].set(meta, policy='duck')
-            for k in self['meta_form'].field_schema_mapping.keys():
+            for k in 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)
@@ -522,7 +522,8 @@
                       suitable as arguments of the same names to pass to
                       item.modify
             """
-            meta = self['meta_form'].value.copy()
+            meta = dict(item.meta)
+            meta.update(self['meta_form'].value.copy())
             meta.update(item.meta_text_to_dict(self['extra_meta_text'].value))
             data, contenttype_guessed = self['content_form']._dump(item.content)
             comment = self['comment'].value
@@ -580,7 +581,7 @@
             elif not meta.get(ITEMID):
                 meta[NAME] = [name]
 
-        if not meta.get(NAMESPACE):
+        if meta.get(NAMESPACE) is None:
             meta[NAMESPACE] = self.fqname.namespace
 
         if comment is not None: