Commits

Kai Diefenbach  committed c71a3ba

Improved reference browser; Using abstract wysiwyg editor layer

  • Participants
  • Parent commits 5c074ff

Comments (0)

Files changed (6)

File lfc_compositor/fields.py

             temp = obj
             while temp is not None:
                 breadcrumbs.insert(0, temp)
-                temp = temp.parent            
-        else:    
+                temp = temp.parent
+        else:
             obj = lfc.utils.get_portal()
-        
+
+        if obj.parent:
+            children = obj.parent.get_children(self.request)
+        else:
+            children = lfc.utils.get_portal().get_children(self.request)
+
         html = """<div id="reference-input">"""
         html += render_to_string("lfc_compositor/widgets/reference_input.html", RequestContext(self.request, {
             "obj" : obj,
-            "children" : obj.get_children(),
+            "children" : children,
             "composite_id" : self.composite.id,
             "value" : value,
-            "breadcrumbs" : breadcrumbs,
+            "breadcrumbs" : breadcrumbs[:-1],
         }))
 
         html += "</div>"
-        
+
         return html

File lfc_compositor/models.py

 from lfc_compositor.config import LEFT
 from lfc_compositor.config import IMAGE_POSITIONS
 from lfc_compositor.config import COLUMN_CLASSES
+from lfc_compositor.fields import ReferenceInput
 
 class Composite(BaseContent):
     """A composite can be added to the portal. A composite has only rows.
         model = TextWithImageWidget
         fields = ("image", "size",  "image_position", "content")
 
-from lfc_compositor.fields import ReferenceInput
-
 class ReferenceWidget(Widget):
     """A widget to display existing content.
 

File lfc_compositor/templates/lfc_compositor/widgets/add_form.html

 
 <script>
     $(function() {
-        $("#id_content").cleditor();
+        addEditor("#id_content");
     })
 </script>

File lfc_compositor/templates/lfc_compositor/widgets/form.html

 
 <script>
     $(function() {
-        $("#id_content").cleditor();
+        addEditor("#id_content");
     })    
 </script>

File lfc_compositor/templates/lfc_compositor/widgets/reference_input.html

             <tr>
                 <td style="width:20px">
                     {% ifnotequal child.id composite_id %}
-                        <input type="radio" name="reference" value="{{ child.id }}"/>
+                        <input {% ifequal child.id obj.id %}checked="checked"{% endifequal %} type="radio" name="reference" value="{{ child.id }}"/>
                     {% endifnotequal %}
                 </td>
                 <td>

File lfc_compositor/views.py

     html = render_to_string(template, RequestContext(request, {
         "obj" : obj,
         "breadcrumbs" : breadcrumbs,
-        "children" : obj.get_children(),
+        "children" : obj.get_children(request),
         "composite_id" : composite_id,
     }))