ManageUser: Admin edit's user details
[myslice.git] / unfold / plugin.py
index de84878..229f196 100644 (file)
@@ -61,6 +61,13 @@ class Plugin:
     #                     since domid is the key for storing that data in the browser storage space
     #   .. None         : if not passed to __init__ at all, then the default_toggled() method is called
     #   ..              : anything else, defaults to True
+    # . outline_complete: whether the overall plugin (body + toggle buttons/title) needs to receive
+    #                     a border and extra space
+    # . outline_body    : same but for the plugin body only
+    #      for these 2 outline_ flags, possible values mimick the above behaviour, i.e.:
+    #   .. True:        : outline is on
+    #   .. False:       : outline is off
+    #   .. None:        : calls default_outline_complete() on the plugin object
     #
     #### internal data
     # . domid: created internally, but can be set at creation time if needed
@@ -72,7 +79,9 @@ class Plugin:
     # which will result in 'foo' being accessible to the template engine
     # 
     def __init__ (self, page, title=None, domid=None,
-                  visible=True, togglable=None, toggled=None, **settings):
+                  visible=True, togglable=None, toggled=None,
+                  outline_complete=None, outline_body=None,
+                  **settings):
         self.page = page
         # callers can provide their domid for css'ing 
         if not domid: domid=self.newdomid()
@@ -83,10 +92,14 @@ class Plugin:
         self.classname=self._py_classname()
         self.plugin_classname=self._js_classname()
         self.visible=visible
-        if togglable is None:   self.togglable=self.default_togglable()
-        else:                   self.togglable=togglable
-        if toggled is None:     self.toggled=self.default_toggled()
-        else:                   self.toggled=toggled
+        if togglable is None:           self.togglable=self.default_togglable()
+        else:                           self.togglable=togglable
+        if toggled is None:             self.toggled=self.default_toggled()
+        else:                           self.toggled=toggled
+        if outline_complete is None:    self.outline_complete=self.default_outline_complete()
+        else:                           self.outline_complete=outline_complete
+        if outline_body is None:        self.outline_body=self.default_outline_body()
+        else:                           self.outline_body=outline_body
         # what comes from subclasses
         for (k,v) in settings.iteritems():
             setattr(self,k,v)
@@ -150,10 +163,6 @@ class Plugin:
     def export_json_settings (self):
         return 'query_uuid' in self.json_settings_list()
     
-    # by default we create a timer if there's a query attached, redefine to change this behaviour
-    def start_with_spin (self):
-        return self.export_json_settings()
-
     # returns the html code for that plugin
     # in essence, wraps the results of self.render_content ()
     def render (self, request):
@@ -162,18 +171,19 @@ class Plugin:
         # shove this into plugin.html
         env = {}
         env ['plugin_content']= plugin_content
-        # need_spin is used in plugin.html
-        self.need_spin=self.start_with_spin()
         env.update(self.__dict__)
         # translate high-level 'toggled' into 4 different booleans
         self.need_toggle = False
         if self.toggled=='persistent':
             # start with everything turned off and let the js callback do its job
-            env.update({'persistent_toggle':True,'display_hide_button':False,'display_show_button':False,'display_body':False})
+            env.update({'persistent_toggle':True,'display_hide_button':False,
+                        'display_show_button':False,'display_body':False})
         elif self.toggled==False:
-            env.update({'persistent_toggle':False,'display_hide_button':False,'display_show_button':True,'display_body':False})
+            env.update({'persistent_toggle':False,'display_hide_button':False,
+                        'display_show_button':True,'display_body':False})
         else:
-            env.update({'persistent_toggle':False,'display_hide_button':True,'display_show_button':False,'display_body':True})
+            env.update({'persistent_toggle':False,'display_hide_button':True,
+                        'display_show_button':False,'display_body':True})
         if self.need_debug(): 
             print "rendering plugin.html with env keys %s"%env.keys()
             for (k,v) in env.items(): 
@@ -185,7 +195,8 @@ class Plugin:
             env ['settings_json' ] = self.settings_json()
             # compute plugin-specific initialization
             js_init = render_to_string ( 'plugin-init.js', env )
-            self.add_js_chunks (js_init)
+            # make sure this happens first in js
+            self.add_js_init_chunks (js_init)
         
         # interpret the result of requirements ()
         self.handle_requirements (request)
@@ -242,6 +253,8 @@ class Plugin:
     @to_prelude
     def add_css_files (self):pass
     @to_prelude
+    def add_js_init_chunks (self):pass
+    @to_prelude
     def add_js_chunks (self):pass
     @to_prelude
     def add_css_chunks (self):pass
@@ -262,6 +275,8 @@ class Plugin:
 
     def default_togglable (self):       return False
     def default_toggled (self):         return 'persistent'
+    def default_outline_complete (self):return False
+    def default_outline_body(self):     return False
 
 #    # tell the framework about requirements (for the document <header>)
 #    # the notion of 'Media' in django provides for medium-dependant
@@ -294,6 +309,3 @@ class Plugin:
     #
     # whether we export the json settings to js
     # def export_json_settings (self)
-    #
-    # whether we show an initial spinner
-    # def start_with_spin (self)