Commits

Dries Desmet committed 28f7bff

Represent problem

Comments (0)

Files changed (4)

 *DS_Store
 *.egg-info
 .project
-example/public/
+example/public/
+*.sublime-workspace

ibpcatalog.sublime-project

+{
+	"folders":
+	[
+		{
+			"path": "/Users/dries/src/ibpcatalog"
+		}
+	]
+}

ibpcatalog/templates/ibpcatalog/feed_detail.html

 {% extends "base.html" %}
 
 {% block content %}
+{{ source }}
+
 <ul>
-{% for entry in feed.entries.all %}
-<li>
-	<h1>{{ entry.companyname }}</h1>
-	<table>
-		<tr>
-			<td>Product</td>
-			<td>Titel</td>
-			<td>Link</td>
-		</tr>
-		<tr>
-			<td>{{ entry.productname }}</td>
-			<td>{{ entry.title }}</td>
-			<td><a href="{{ entry.calculatedurl }}">PDF</a></td>
-	</table>
+{{ target|unordered_list }}
+</ul>
+
+<p>{{ test }}</p>
 
-</li>
-{% endfor %}
+<ul>
+	{% for entry in entries %}
+	<li>
+		{{ entry.companyname }}
+	</li>
+	{% endfor %}
 </ul>
+
 {% endblock %}

ibpcatalog/views.py

     model = Feed
 
 class FeedDetail(DetailView):
+    """
+    I want to get this:
+    <ul>
+        <li>
+            company1
+            <ul>
+                <li>
+                    productname1
+                    <ul>
+                        <li>document1</li>
+                        <li>document2</li>
+                    </ul>
+                </li>
+                <li>
+                    productname2
+                    <ul>
+                        <li>document1</li>
+                    </ul>
+                </li>
+            </ul>
+        </li>
+
+
+        <li>
+            company2
+        </li>
+    </ul>
+
+    """
     model = Feed
-    context_object_name = 'feed'
+    context_object_name = 'feed'
+    
+    source=[
+        {
+            'companyname': 'Allianz',
+            'lang': 'nl',
+            'productname': 'product1',
+            'title': 'document1'
+        },
+        {
+            'companyname': 'Allianz',
+            'lang': 'nl',
+            'productname': 'product1',
+            'title': 'document2'
+        }
+    ]
+
+    for entry in source:
+        pass
+
+
+    target = [
+        'Allianz', 
+        [
+            'product1',
+            ['document1', 'document2'],
+            'product2',
+            ['document3', 'document4'],
+            'product3',
+            ['document5', 'document6'],
+        ],
+        'Axa',
+        [
+            'product4',
+            ['document7', 'document8'],
+            'product5',
+            ['document9', 'document10'],
+        ]
+]    
+        
+    def get_context_data(self, **kwargs):
+        # Call the base implementation first to get a context
+        context = super(FeedDetail, self).get_context_data(**kwargs)
+        # Add in extra context
+        # import ipdb;ipdb.set_trace()
+        context['source'] = self.source
+        context['target'] = self.target
+        
+        return context