Commits

Kai Diefenbach committed 84fcd27

Using extra tab for composing.

Comments (0)

Files changed (11)

lfc_compositor/__init__.py

     unregister_template("Composite")
 
     # Unregister resources
-    unregister_resource(type=CSS, group="manage", path="lfc_compositor/compositor_manage.css")
-    unregister_resource(type=CSS, group="lfc", path="lfc_compositor/compositor.css")
-    unregister_resource(type=JS, group="manage", path="lfc_compositor/compositor.js")
+    unregister_resource(path="lfc_compositor/compositor_manage.css")
+    unregister_resource(path="lfc_compositor/compositor.css")
+    unregister_resource(path="lfc_compositor/compositor.js")

lfc_compositor/models.py

         """
         """
         rows = self.get_rows()
-        amount = len(rows)-1
+        amount = len(rows) - 1
         content = ""
         for i, row in enumerate(self.get_rows()):
             if i == 0:
 
             content += row.render(request, edit, is_first, is_last)
 
-        return render_to_string("lfc_compositor/widgets/composite.html", RequestContext(request, {
-            "composite" : self,
-            "content" : content,
-            "edit" : edit and (amount == -1),
-        }))
+        if edit:
+            return render_to_string("lfc_compositor/widgets/composite.html", RequestContext(request, {
+                "composite" : self,
+                "content" : content,
+                "edit" : edit and (amount == -1),
+            }))
+        else:
+            self.context["composite"] = self
+            self.context["content"] = content
+            self.context["edit"] = edit and (amount == -1)
+
+            return super(Composite, self).render(request)
+            
+    def get_tabs(self, request):
+        """Returns the extra tabs of the model.
+        """
+        return [
+            {
+                "id" : "compose",
+                "name" : "Compose",
+                "content" : self.render(request, True),
+            },
+        ]
 
     def edit_form(self, **kwargs):
         """Returns the add/edit form of the page.
         model = Composite
         fields = ("title", "display_title", "slug", "tags")
 
-    def below_form(self, request):
-        return self.instance.render(request, True)
-
 class Row(models.Model):
     """A row for composite. A row can have multiple columns.
 
     parent = models.ForeignKey(Column, verbose_name=_(u"Column"), related_name="widgets")
     position = models.IntegerField(_(u"Position"), blank=True, null=True)
     content_type = models.CharField(blank=True, max_length=100)
-    
+
     class Meta:
         ordering = ("position", )
 

lfc_compositor/static/compositor.js

         var url = $(this).attr("data");
         var value = $(this).attr("value");
         $.post(url, { "width" : value }, function(data) {
-            $("#core-data-below-form").html(data);
+            $("#compose").html(data);
         });
     });
 

lfc_compositor/templates/lfc_compositor/composite.html

 {% extends "lfc/base.html" %}
-{% load compositor_tags %}
+{% load portlets_tags %}
+
+{% block section %}compositor{% endblock %}
 
 {% block content %}
     {% if lfc_context.display_title %}
     {% endif %}
     
     <div>
-        {% render %}
+        {{ content|safe }}
     </div>
-
-    <div class="overlay" id="overlay">
-        <div class="content"></div>
-    </div>
-
 {% endblock %}

lfc_compositor/templates/lfc_compositor/widgets/add_form.html

 {% load i18n %}
 <form action="{% url compositor_add_widget %}"
       method="POST"
-      enctype="multipart/form-data">
+      enctype="multipart/form-data">    
+    {% csrf_token %}
 
     <h1>{% trans "Add Widget" %}</h1>
 

lfc_compositor/templates/lfc_compositor/widgets/column.html

         <div style="clear: both">
             {% if deletable %}
                 <a class="cp-hover delete-link"
+                   is_ajax="1"                
                    id="column-{{ column.id }}"
                    href="{% url compositor_delete_column column.id %}">
                     <img src="{{ MEDIA_URL }}lfc_compositor/icons/delete_column.png" alt='{% trans "Delete Column" %}' title='{% trans "Delete Column" %}'/>

lfc_compositor/templates/lfc_compositor/widgets/composite.html

 {% load i18n %}
-<div style="max-width:1000px">
+
+<div>
     {{ content|safe }}
     {% if edit %}
+        <h1>{% trans "Compose" %}</h1>
         <div>
             <a class="ajax-link" 
                href="{% url compositor_add_row composite.id %}">

lfc_compositor/templates/lfc_compositor/widgets/form.html

 <form action="{% url compositor_edit_widget widget.id %}"
       method="POST"
       enctype="multipart/form-data">
+    {% csrf_token %}
 
     <h1>{% trans "Edit Widget22" %}</h1>
 
     {% include "lfc/manage/lfc_form.html" %}
 
-    <input class="ajax-submit" 
+    <input class="ajax-submit"
            type="submit" />
 </form>
 
 <script>
     $(function() {
         addEditor("#id_content");
-    })    
+    })
 </script>

lfc_compositor/templates/lfc_compositor/widgets/row.html

 {% load i18n %}
 {% if edit %}
+    <h1>{% trans "Compose" %}</h1>
     <div style="background-color: transparent">
 
         <a class="cp-hover delete-link"
+           is_ajax="1"
            id="row-{{ row.id }}"
            href="{% url compositor_delete_row row.id %}">
             <img src="{{ MEDIA_URL }}lfc_compositor/icons/delete_row.png" alt='{% trans "Delete Row" %}' title='{% trans "Delete Row" %}'/>
     </div>
 {% endif %}
 <table class="row-{{ row.id }} lfc-compositor-default">
-    <tr class="compositor-row row-{{ row.id }}" >{{ content|safe }}</tr>
+    <tr class="compositor-row row-{{ row.id }}">{{ content|safe }}</tr>
 </table>

lfc_compositor/templates/lfc_compositor/widgets/widget_navigation.html

 {% load i18n %}
 <div class="widget-navigation">
-    <a class="cp-hover delete-link" id="widget-{{ widget.id }}" href="{% url compositor_delete_widget widget.id %}">
+    <a class="cp-hover delete-link" is_ajax="1" id="widget-{{ widget.id }}" href="{% url compositor_delete_widget widget.id %}">
        <img src="{{ MEDIA_URL }}lfc/icons/page_delete.png" alt='{% trans "Delete Widget" %}' title='{% trans "Delete Widget" %}'/>
     </a>
     <a class="cp-hover ajax-link" id="widget-{{ widget.id }}" href="{% url compositor_edit_widget widget.id %}">

lfc_compositor/views.py

     update_columns(column.parent)
 
     html = (
-        ("#core-data-below-form", composite.render(request, edit=True)),
+        ("#compose", composite.render(request, edit=True)),
     )
 
     return HttpResponse(render_to_json(html))
     update_rows(composite)
 
     html = (
-        ("#core-data-below-form", composite.render(request, edit=True)),
+        ("#compose", composite.render(request, edit=True)),
     )
 
     return HttpResponse(render_to_json(html))
     update_widgets(widget.parent)
 
     html = (
-        ("#core-data-below-form", composite.render(request, edit=True)),
+        ("#compose", composite.render(request, edit=True)),
     )
 
     return HttpResponse(render_to_json(html))
     Column.objects.create(parent=row, position=10)
 
     html = (
-        ("#core-data-below-form", composite.render(request, edit=True)),
+        ("#compose", composite.render(request, edit=True)),
     )
 
     return HttpResponse(render_to_json(html))
     
 
     html = (
-        ("#core-data-below-form", composite.render(request, edit=True)),
+        ("#compose", composite.render(request, edit=True)),
     )
 
     return HttpResponse(render_to_json(html))
     column = Column.objects.get(pk=column_id)
 
     composite = _get_composite(column)    
-    composite.check_permission(request.user, "edit")
+    # composite.check_permission(request.user, "edit")
 
     # Get widget type's form
     type = request.REQUEST.get("type")
             update_widgets(column)
 
             html = (
-                ("#core-data-below-form", composite.render(request, edit=True)),
+                ("#compose", composite.render(request, edit=True)),
             )
 
             return HttpJsonResponse(html, close_overlay=True)
         if form.is_valid():
             form.save()
             composite = (
-                ["#core-data-below-form", composite.render(request, edit=True)],
+                ["#compose", composite.render(request, edit=True)],
             )
             return HttpJsonResponse(
                 content = composite, 
 
     update_columns(row)
 
-    html = (("#core-data-below-form", composite.render(request, edit=True)),)
+    html = (("#compose", composite.render(request, edit=True)),)
 
     json = render_to_json(
         html = html,
 
     update_rows(composite)
 
-    html = (("#core-data-below-form", composite.render(request, edit=True)),)
+    html = (("#compose", composite.render(request, edit=True)),)
 
     json = render_to_json(
         html = html,
         composite.check_permission(request.user, "edit")
         widget.delete()
 
-    html = (("#core-data-below-form", composite.render(request, edit=True)),)
+    html = (("#compose", composite.render(request, edit=True)),)
 
     json = render_to_json(
         html = html,
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.