diff MoinMoin/items/__init__.py @ 1421:9f36555901db

Automated merge with http://hg.moinmo.in/moin/2.0
author Cheer Xiao <xiaqqaix@gmail.com>
date Fri, 06 Jul 2012 18:51:24 +0800
parents ac1059572d80 100197cb69ab
children c32ff2e07e7a
line wrap: on
line diff
--- a/MoinMoin/items/__init__.py	Fri Jun 29 16:04:11 2012 +0200
+++ b/MoinMoin/items/__init__.py	Fri Jul 06 18:51:24 2012 +0800
@@ -29,7 +29,7 @@
 
 from whoosh.query import Term, And, Prefix
 
-from MoinMoin.util.forms import FileStorage
+from MoinMoin.forms import RequiredText, OptionalText, File, Submit
 
 from MoinMoin.security.textcha import TextCha, TextChaizedForm, TextChaValid
 from MoinMoin.signalling import item_modified
@@ -631,6 +631,11 @@
         return True
 
 
+class BaseChangeForm(TextChaizedForm):
+    comment = OptionalText.using(label=L_('Comment')).with_properties(placeholder=L_("Comment about your change"))
+    submit = Submit
+
+
 class Binary(Item):
     """ An arbitrary binary item, fallback class for every item mimetype. """
     modify_help = """\
@@ -659,11 +664,10 @@
         revs = flaskg.storage.search(query, sortedby=NAME_EXACT, limit=None)
         return [rev.meta[NAME] for rev in revs]
 
-    from MoinMoin.apps.frontend.views import CommentForm
-    class ModifyForm(CommentForm):
+    class ModifyForm(BaseChangeForm):
         """Base class for ModifyForm of Binary's subclasses."""
-        meta_text = String.using(optional=False).with_properties(placeholder=L_("MetaData (JSON)")).validated_by(ValidJSON())
-        data_file = FileStorage.using(optional=True, label=L_('Upload file:'))
+        meta_text = RequiredText.with_properties(placeholder=L_("MetaData (JSON)")).validated_by(ValidJSON())
+        data_file = File.using(optional=True, label=L_('Upload file:'))
 
         def _load(self, item):
             self['meta_text'] = item.meta_dict_to_text(item.prepare_meta_for_modify(item.meta))