Prepare template for real datas. Some fake datas temporary generated in views.
authorcavaliet
Wed, 30 Jan 2013 17:13:19 +0100
changeset 18 ffd106d9b8e1
parent 17 38611b2c2782
child 19 e00c68158187
Prepare template for real datas. Some fake datas temporary generated in views.
src/egonomy/templates/egonomy_annotate_picture.html
src/egonomy/templates/egonomy_create_fragment.html
src/egonomy/templates/egonomy_home.html
src/egonomy/templates/egonomy_view_fragment.html
src/egonomy/views.py
--- a/src/egonomy/templates/egonomy_annotate_picture.html	Tue Jan 29 18:42:24 2013 +0100
+++ b/src/egonomy/templates/egonomy_annotate_picture.html	Wed Jan 30 17:13:19 2013 +0100
@@ -1,6 +1,7 @@
 {% extends "egonomy_base.html" %}
 {% load static %}
 {% load i18n %}
+{% load thumbnail %}
 
 {% block title %}{% trans "Annotate a picture" %}{% endblock %}
 
@@ -8,8 +9,12 @@
                 <div class="fullwidth">
                     <div class="column column-half">
                         <h2>Titre de l'image</h2>
-                        <div class="fullphoto placeholder">
-                            Photo à annoter
+                        <div class="fullphoto">
+                          {% thumbnail image.image "476" format="PNG" crop="center" as im %}
+                            <img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}"/>
+                          {% empty %}
+                            <img src="{% static 'egonomy/img/empty.gif' %}" width="476" height="476" class="placeholder" />
+                          {% endthumbnail %}
                         </div>
                     </div>
                     <div class="column column-half">
@@ -17,31 +22,31 @@
                         <table class="image-metadata">
                             <tr>
                                 <th>{% trans "Description" %}&nbsp;:</th>
-                                <td>Lorem Ipsum, Ceci est la description de l'&oelig;uvre représentée dans l'image.</td>
+                                <td>{{ image.description }}</td>
                             </tr>
                             <tr>
                                 <th>{% trans "Author" %}&nbsp;:</th>
-                                <td>Marcel Duchamp</td>
+                                <td>{{ image.author }}</td>
                             </tr>
                             <tr>
                                 <th>{% trans "Period" %}&nbsp;:</th>
-                                <td>XXème siècle</td>
+                                <td>{{ image.period }}</td>
                             </tr>
                             <tr>
                                 <th>{% trans "Production site" %}&nbsp;:</th>
-                                <td>Paris, France</td>
+                                <td>{{ image.production_site }}</td>
                             </tr>
                             <tr>
                                 <th>{% trans "Localization" %}&nbsp;:</th>
-                                <td>Musée du Louvre, Paris.</td>
+                                <td>{{ image.localization }}</td>
                             </tr>
                             <tr>
                                 <th>{% trans "RMN keywords" %}&nbsp;:</th>
-                                <td>Art contemporain, Art conceptuel, Cyclisme</td>
+                                <td>{{ image.rmn_keywords }}</td>
                             </tr>
                             <tr>
                                 <th>{% trans "Users keywords" %}</th>
-                                <td><textarea class="user-keywords">Modernité, Ready-made</textarea></td>
+                                <td><textarea class="user-keywords">{{ image.users_keywords }}</textarea></td>
                             </tr>
                             <tr>
                                 <th> </th>
@@ -62,71 +67,37 @@
                     <div class="column column-full">
                         <h2>{% trans "Fragments from this picture" %}</h2>
                         <ul class="fullwidth">
-                            <li class="subcol subcol-eighth">
-                                <a href="{% url 'view_fragment' %}">
-                                <div class="center-image">
-                                    <div class="image-and-fragment">
-                                        <img src="{% static 'egonomy/img/empty.gif' %}" width="110" height="82" class="placeholder" />
-                                        <svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewbox="0 0 1 1" preserveAspectRatio="none">
-                                            <path d="M 0 .5 L .5 0 L 1 .5 L .5 1 Z" stroke="red" stroke-width=".02" fill="red" fill-opacity=".3" />
-                                        </svg>
-                                    </div>
-                                </div>
-                                <h3>Titre du fragment</h3></a>
-                                <p>{% trans "Annotated by" %} <strong>Julien75</strong></p>
-                            </li>
-                            <li class="subcol subcol-eighth">
-                                <a href="{% url 'view_fragment' %}">
-                                <div class="center-image">
-                                    <div class="image-and-fragment">
-                                        <img src="{% static 'egonomy/img/empty.gif' %}" width="110" height="82" class="placeholder" />
-                                        <svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewbox="0 0 1 1" preserveAspectRatio="none">
-                                            <path d="M .2 .5 L .7 .2 L .8 .7 Z" stroke="red" stroke-width=".02" fill="red" fill-opacity=".3" />
-                                        </svg>
-                                    </div>
-                                </div>
-                                <h3>Titre du fragment</h3></a>
-                                <p>{% trans "Annotated by" %} <strong>Julien75</strong></p>
-                            </li>
+                          {% for frg in fragment_list %}
                             <li class="subcol subcol-eighth">
                                 <a href="{% url 'view_fragment' %}">
                                 <div class="center-image">
                                     <div class="image-and-fragment">
-                                        <img src="{% static 'egonomy/img/empty.gif' %}" width="110" height="82" class="placeholder" />
+                                        {% if frg.image.image %}
+                                      {% if frg.image.image|is_portrait %}
+                                       {% thumbnail frg.image.image "x110" format="PNG" crop="center" as im %}
+                                        <img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}"/>
+                                       {% empty %}
+                                        <img src="{% static 'egonomy/img/empty.gif' %}" width="110" height="110" class="placeholder" />
+                                       {% endthumbnail %}
+                                      {% else %}
+                                       {% thumbnail frg.image.image "110" format="PNG" crop="center" as im %}
+                                        <img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}"/>
+                                       {% empty %}
+                                        <img src="{% static 'egonomy/img/empty.gif' %}" width=110" height="110" class="placeholder" />
+                                       {% endthumbnail %}
+                                      {% endif %}
+                                     {% else %}
+                                        <img src="{% static 'egonomy/img/empty.gif' %}" width=110" height="110" class="placeholder" />
+                                     {% endif %}
                                         <svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewbox="0 0 1 1" preserveAspectRatio="none">
-                                            <path d="M .3 .1 L .55 .15 L .6 .6 Z" stroke="red" stroke-width=".02" fill="red" fill-opacity=".3" />
+                                            <path d="{{ frg.path }}" stroke="red" stroke-width=".02" fill="red" fill-opacity=".3" />
                                         </svg>
                                     </div>
                                 </div>
-                                <h3>Titre du fragment</h3></a>
-                                <p>{% trans "Annotated by" %} <strong>Julien75</strong></p>
+                                <h3>{{ frg.title }}</h3></a>
+                                <p>{% trans "Annotated by" %} <strong>{{ frg.author }}</strong></p>
                             </li>
-                            <li class="subcol subcol-eighth">
-                                <a href="{% url 'view_fragment' %}">
-                                <div class="center-image">
-                                    <div class="image-and-fragment">
-                                        <img src="{% static 'egonomy/img/empty.gif' %}" width="110" height="82" class="placeholder" />
-                                        <svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewbox="0 0 1 1" preserveAspectRatio="none">
-                                            <path d="M .2 .5 L .7 .2 L .8 .7 Z" stroke="red" stroke-width=".02" fill="red" fill-opacity=".3" />
-                                        </svg>
-                                    </div>
-                                </div>
-                                <h3>Titre du fragment</h3></a>
-                                <p>{% trans "Annotated by" %} <strong>Julien75</strong></p>
-                            </li>
-                            <li class="subcol subcol-eighth">
-                                <a href="{% url 'view_fragment' %}">
-                                <div class="center-image">
-                                    <div class="image-and-fragment">
-                                        <img src="{% static 'egonomy/img/empty.gif' %}" width="110" height="82" class="placeholder" />
-                                        <svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewbox="0 0 1 1" preserveAspectRatio="none">
-                                            <path d="M .2 .5 L .7 .2 L .8 .7 Z" stroke="red" stroke-width=".02" fill="red" fill-opacity=".3" />
-                                        </svg>
-                                    </div>
-                                </div>
-                                <h3>Titre du fragment</h3></a>
-                                <p>{% trans "Annotated by" %} <strong>Julien75</strong></p>
-                            </li>
+                          {% endfor %}
                         </ul>
                     </div>
                 </div>
--- a/src/egonomy/templates/egonomy_create_fragment.html	Tue Jan 29 18:42:24 2013 +0100
+++ b/src/egonomy/templates/egonomy_create_fragment.html	Wed Jan 30 17:13:19 2013 +0100
@@ -1,6 +1,7 @@
 {% extends "egonomy_base.html" %}
 {% load static %}
 {% load i18n %}
+{% load thumbnail %}
 
 {% block title %}{% trans "Create or edit a fragment" %}{% endblock %}
 
@@ -19,28 +20,32 @@
                             <a href="#" class="head-button reset-fragment" title="{% trans 'Back to the original drawing' %}">&#8634;</a>
                             <h2>{% trans 'New fragment' %}&nbsp;:</h2>
                             <div class="image-and-fragment">
-                                <img src="{% static 'egonomy/img/empty.gif' %}" width="476" height="350" class="placeholder" />
+                              {% thumbnail image.image "476" format="PNG" crop="center" as im %}
+	                            <img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}"/>
+	                          {% empty %}
+	                            <img src="{% static 'egonomy/img/empty.gif' %}" width="476" height="476" class="placeholder" />
+	                          {% endthumbnail %}
                                 <div class="cutout-canvas"></div>
                             </div>
-                            <input id="fragment-path" type="text" class="fragment-path" value="M 0 .5 L .5 0 L 1 .5 L .5 1 Z" />
+                            <input id="fragment-path" type="text" class="fragment-path column-half" value="M 0 .5 L .5 0 L 1 .5 L .5 1 Z" />
                         </div>
                         <div class="column column-half">
                             <table class="image-metadata">
                                 <tr>
                                     <th>{% trans 'Source picture' %}&nbsp;:</th>
-                                    <td><a href="{% url 'annotate_picture' %}">Titre de l'image source</a></td>
+                                    <td><a href="{% url 'annotate_picture' %}">{{ image.title }}</a></td>
                                 </tr>
                                 <tr>
-                                    <th>{% trans 'Title' %}&nbsp;:</th>
-                                    <td><input type="text" class="fragment-title" placeholder="Titre du fragment" /></td>
+                                    <th>{% trans "Fragment's title" %}&nbsp;:</th>
+                                    <td><input type="text" class="fragment-title" placeholder="{% trans "Fragment's title" %}" /></td>
                                 </tr>
                                 <tr>
-                                    <th>{% trans 'Description' %}&nbsp;:</th>
-                                    <td><textarea class="fragment-description">Lorem Ipsum description du fragment</textarea></td>
+                                    <th>{% trans "Fragment's description" %}&nbsp;:</th>
+                                    <td><textarea class="fragment-description"></textarea></td>
                                 </tr>
                                 <tr>
-                                    <th>{% trans 'Users keywords' %}</th>
-                                    <td><textarea class="user-keywords">Modernité, Ready-made</textarea></td>
+                                    <th>{% trans 'Users keywords' %}&nbsp;:</th>
+                                    <td><textarea class="user-keywords"></textarea></td>
                                 </tr>
                                 <tr>
                                     <th> </th>
@@ -61,71 +66,37 @@
                     <div class="column column-full">
                         <h2>{% trans 'Fragments from this picture' %}</h2>
                         <ul class="fullwidth">
-                            <li class="subcol subcol-eighth">
-                                <a href="{% url 'view_fragment' %}">
-                                <div class="center-image">
-                                    <div class="image-and-fragment">
-                                        <img src="{% static 'egonomy/img/empty.gif' %}" width="110" height="82" class="placeholder" />
-                                        <svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewbox="0 0 1 1" preserveAspectRatio="none">
-                                            <path d="M 0 .5 L .5 0 L 1 .5 L .5 1 Z" stroke="red" stroke-width=".02" fill="red" fill-opacity=".3" />
-                                        </svg>
-                                    </div>
-                                </div>
-                                <h3>Titre du fragment</h3></a>
-                                <p>{% trans "Annotated by" %} <strong>Julien75</strong></p>
-                            </li>
-                            <li class="subcol subcol-eighth">
-                                <a href="{% url 'view_fragment' %}">
-                                <div class="center-image">
-                                    <div class="image-and-fragment">
-                                        <img src="{% static 'egonomy/img/empty.gif' %}" width="110" height="82" class="placeholder" />
-                                        <svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewbox="0 0 1 1" preserveAspectRatio="none">
-                                            <path d="M .2 .5 L .7 .2 L .8 .7 Z" stroke="red" stroke-width=".02" fill="red" fill-opacity=".3" />
-                                        </svg>
-                                    </div>
-                                </div>
-                                <h3>Titre du fragment</h3></a>
-                                <p>{% trans "Annotated by" %} <strong>Julien75</strong></p>
-                            </li>
+                          {% for frg in fragment_list %}
                             <li class="subcol subcol-eighth">
                                 <a href="{% url 'view_fragment' %}">
                                 <div class="center-image">
                                     <div class="image-and-fragment">
-                                        <img src="{% static 'egonomy/img/empty.gif' %}" width="110" height="82" class="placeholder" />
+                                        {% if frg.image.image %}
+                                      {% if frg.image.image|is_portrait %}
+                                       {% thumbnail frg.image.image "x110" format="PNG" crop="center" as im %}
+                                        <img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}"/>
+                                       {% empty %}
+                                        <img src="{% static 'egonomy/img/empty.gif' %}" width="110" height="110" class="placeholder" />
+                                       {% endthumbnail %}
+                                      {% else %}
+                                       {% thumbnail frg.image.image "110" format="PNG" crop="center" as im %}
+                                        <img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}"/>
+                                       {% empty %}
+                                        <img src="{% static 'egonomy/img/empty.gif' %}" width=110" height="110" class="placeholder" />
+                                       {% endthumbnail %}
+                                      {% endif %}
+                                     {% else %}
+                                        <img src="{% static 'egonomy/img/empty.gif' %}" width=110" height="110" class="placeholder" />
+                                     {% endif %}
                                         <svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewbox="0 0 1 1" preserveAspectRatio="none">
-                                            <path d="M .3 .1 L .55 .15 L .6 .6 Z" stroke="red" stroke-width=".02" fill="red" fill-opacity=".3" />
+                                            <path d="{{ frg.path }}" stroke="red" stroke-width=".02" fill="red" fill-opacity=".3" />
                                         </svg>
                                     </div>
                                 </div>
-                                <h3>Titre du fragment</h3></a>
-                                <p>{% trans "Annotated by" %} <strong>Julien75</strong></p>
+                                <h3>{{ frg.title }}</h3></a>
+                                <p>{% trans "Annotated by" %} <strong>{{ frg.author }}</strong></p>
                             </li>
-                            <li class="subcol subcol-eighth">
-                                <a href="{% url 'view_fragment' %}">
-                                <div class="center-image">
-                                    <div class="image-and-fragment">
-                                        <img src="{% static 'egonomy/img/empty.gif' %}" width="110" height="82" class="placeholder" />
-                                        <svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewbox="0 0 1 1" preserveAspectRatio="none">
-                                            <path d="M .2 .5 L .7 .2 L .8 .7 Z" stroke="red" stroke-width=".02" fill="red" fill-opacity=".3" />
-                                        </svg>
-                                    </div>
-                                </div>
-                                <h3>Titre du fragment</h3></a>
-                                <p>{% trans "Annotated by" %} <strong>Julien75</strong></p>
-                            </li>
-                            <li class="subcol subcol-eighth">
-                                <a href="{% url 'view_fragment' %}">
-                                <div class="center-image">
-                                    <div class="image-and-fragment">
-                                        <img src="{% static 'egonomy/img/empty.gif' %}" width="110" height="82" class="placeholder" />
-                                        <svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewbox="0 0 1 1" preserveAspectRatio="none">
-                                            <path d="M .2 .5 L .7 .2 L .8 .7 Z" stroke="red" stroke-width=".02" fill="red" fill-opacity=".3" />
-                                        </svg>
-                                    </div>
-                                </div>
-                                <h3>Titre du fragment</h3></a>
-                                <p>{% trans "Annotated by" %} <strong>Julien75</strong></p>
-                            </li>
+                          {% endfor %}
                         </ul>
                     </div>
                 </div>
--- a/src/egonomy/templates/egonomy_home.html	Tue Jan 29 18:42:24 2013 +0100
+++ b/src/egonomy/templates/egonomy_home.html	Wed Jan 30 17:13:19 2013 +0100
@@ -16,26 +16,26 @@
                             <li class="subcol subcol-half-fourth">
                                 <a href="{% url 'annotate_picture' %}">
                                 <div class="center-image">
-                                 {% if img %}
-                                  {% if img|is_portrait %}
-							 	    {% thumbnail img "x110" format="PNG" crop="center" as im %}
+                                 {% if img.image %}
+                                  {% if img.image|is_portrait %}
+							 	    {% thumbnail img.image "x110" format="PNG" crop="center" as im %}
 	                                  <img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}"/>
 	                                {% empty %}
 	                                  <img src="{% static 'egonomy/img/empty.gif' %}" width="110" height="110" class="placeholder" />
 	                                {% endthumbnail %}
 	                              {% else %}
-                                    {% thumbnail img "110" format="PNG" crop="center" as im %}
+                                    {% thumbnail img.image "110" format="PNG" crop="center" as im %}
                                       <img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}"/>
                                     {% empty %}
                                       <img src="{% static 'egonomy/img/empty.gif' %}" width=110" height="110" class="placeholder" />
                                     {% endthumbnail %}
 	                              {% endif %}
-	                              {% else %}
+	                             {% else %}
 	                                  <img src="{% static 'egonomy/img/empty.gif' %}" width=110" height="110" class="placeholder" />
 	                             {% endif %}
                                 </div>
-                                <h3>Titre de l'image</h3></a>
-                                <p>{% trans "Annotated by" %} <strong>Julien75</strong></p>
+                                <h3>{{ img.title }}</h3></a>
+                                <p>{% trans "Annotated by" %} <strong>{{ img.author }}</strong></p>
                             </li>
                           {% endfor %}
                         </ul>
@@ -45,62 +45,38 @@
                     <div class="column column-half">
                         <h2>{% trans "Last created fragments" %}</h2>
                         <ul class="fullwidth">
-                            <li class="subcol subcol-half-fourth">
-                                <a href="{% url 'view_fragment' %}">
-                                <div class="center-image">
-                                    <div class="image-and-fragment">
-                                        <img src="{% static 'egonomy/img/empty.gif' %}" width="110" height="82" class="placeholder" />
-                                        <svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewbox="0 0 1 1" preserveAspectRatio="none">
-                                            <path d="M 0 .5 L .5 0 L 1 .5 L .5 1 Z" stroke="red" stroke-width=".02" fill="red" fill-opacity=".3" />
-                                        </svg>
-                                    </div>
-                                </div>
-                                <h3>Titre du fragment</h3></a>
-                                <h4>{% trans "Fragment from" %} <a href="{% url 'annotate_picture' %}">Titre de l'image</a></h4>
-                                <p>{% trans "Annotated by" %} <strong>Julien75</strong></p>
-                            </li>
+                          {% for frg in fragment_list %}
                             <li class="subcol subcol-half-fourth">
                                 <a href="{% url 'view_fragment' %}">
                                 <div class="center-image">
                                     <div class="image-and-fragment">
-                                        <img src="{% static 'egonomy/img/empty.gif' %}" width="82" height="110" class="placeholder" />
+                                     {% if frg.image.image %}
+		                              {% if frg.image.image|is_portrait %}
+		                               {% thumbnail frg.image.image "x110" format="PNG" crop="center" as im %}
+		                                <img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}"/>
+		                               {% empty %}
+		                                <img src="{% static 'egonomy/img/empty.gif' %}" width="110" height="110" class="placeholder" />
+		                               {% endthumbnail %}
+		                              {% else %}
+		                               {% thumbnail frg.image.image "110" format="PNG" crop="center" as im %}
+		                                <img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}"/>
+		                               {% empty %}
+		                                <img src="{% static 'egonomy/img/empty.gif' %}" width=110" height="110" class="placeholder" />
+		                               {% endthumbnail %}
+		                              {% endif %}
+		                             {% else %}
+		                                <img src="{% static 'egonomy/img/empty.gif' %}" width=110" height="110" class="placeholder" />
+		                             {% endif %}
                                         <svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewbox="0 0 1 1" preserveAspectRatio="none">
-                                            <path d="M .2 .5 L .7 .2 L .8 .7 Z" stroke="red" stroke-width=".02" fill="red" fill-opacity=".3" />
+                                            <path d="{{ frg.path }}" stroke="red" stroke-width=".02" fill="red" fill-opacity=".3" />
                                         </svg>
                                     </div>
                                 </div>
-                                <h3>Titre du fragment</h3></a>
-                                <h4>{% trans "Fragment from" %} <a href="{% url 'annotate_picture' %}">Titre de l'image</a></h4>
-                                <p>{% trans "Annotated by" %} <strong>Julien75</strong></p>
+                                <h3>{{ frg.title }}</h3></a>
+                                <h4>{% trans "Fragment from" %} <a href="{% url 'annotate_picture' %}">{{ frg.image.title }}</a></h4>
+                                <p>{% trans "Annotated by" %} <strong>{{ frg.author }}</strong></p>
                             </li>
-                            <li class="subcol subcol-half-fourth">
-                                <a href="{% url 'view_fragment' %}">
-                                <div class="center-image">
-                                    <div class="image-and-fragment">
-                                        <img src="{% static 'egonomy/img/empty.gif' %}" width="110" height="82" class="placeholder" />
-                                        <svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewbox="0 0 1 1" preserveAspectRatio="none">
-                                            <path d="M .2 .5 L .7 .2 L .8 .7 Z" stroke="red" stroke-width=".02" fill="red" fill-opacity=".3" />
-                                        </svg>
-                                    </div>
-                                </div>
-                                <h3>Titre du fragment</h3></a>
-                                <h4>{% trans "Fragment from" %} <a href="{% url 'annotate_picture' %}">Titre de l'image</a></h4>
-                                <p>{% trans "Annotated by" %} <strong>Julien75</strong></p>
-                            </li>
-                            <li class="subcol subcol-half-fourth">
-                                <a href="{% url 'view_fragment' %}">
-                                <div class="center-image">
-                                    <div class="image-and-fragment">
-                                        <img src="{% static 'egonomy/img/empty.gif' %}" width="110" height="110" class="placeholder" />
-                                        <svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewbox="0 0 1 1" preserveAspectRatio="none">
-                                            <path d="M 0 .5 L .5 0 L 1 .5 L .5 1 Z" stroke="red" stroke-width=".02" fill="red" fill-opacity=".3" />
-                                        </svg>
-                                    </div>
-                                </div>
-                                <h3>Titre du fragment</h3></a>
-                                <h4>{% trans "Fragment from" %} <a href="{% url 'annotate_picture' %}">Titre de l'image</a></h4>
-                                <p>{% trans "Annotated by" %} <strong>Julien75</strong></p>
-                            </li>
+                          {% endfor %}
                         </ul>
                     </div>
                 </div>
--- a/src/egonomy/templates/egonomy_view_fragment.html	Tue Jan 29 18:42:24 2013 +0100
+++ b/src/egonomy/templates/egonomy_view_fragment.html	Wed Jan 30 17:13:19 2013 +0100
@@ -1,17 +1,22 @@
 {% extends "egonomy_base.html" %}
 {% load static %}
 {% load i18n %}
+{% load thumbnail %}
 
 {% block title %}{% trans "View a fragment" %}{% endblock %}
 
 {% block content %}
                 <div class="fullwidth">
                     <div class="column column-half">
-                        <h2>Titre du fragment</h2>
+                        <h2>{{ fragment.title }}</h2>
                         <div class="image-and-fragment">
-                            <img src="{% static 'egonomy/img/empty.gif' %}" width="476" height="350" class="placeholder" />
+                          {% thumbnail fragment.image.image "476" format="PNG" crop="center" as im %}
+                            <img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}"/>
+                          {% empty %}
+                            <img src="{% static 'egonomy/img/empty.gif' %}" width="476" height="476" class="placeholder" />
+                          {% endthumbnail %}
                             <svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewbox="0 0 1 1" preserveAspectRatio="none">
-                                <path d="M 0 .5 L .5 0 L 1 .5 L .5 1 Z" stroke="red" stroke-width=".002" fill="red" fill-opacity=".3" />
+                                <path d="{{ fragment.path }}" stroke="red" stroke-width=".002" fill="red" fill-opacity=".3" />
                             </svg>
                         </div>
                     </div>
@@ -20,15 +25,15 @@
                             <table class="image-metadata">
                                 <tr>
                                     <th>{% trans "Source picture" %}&nbsp;:</th>
-                                    <td><a href="{% url 'annotate_picture' %}">Titre de l'image source</a></td>
+                                    <td><a href="{% url 'annotate_picture' %}">{{ fragment.image.title }}</a></td>
                                 </tr>
                                 <tr>
-                                    <th>{% trans "Description" %}&nbsp;:</th>
-                                    <td>Lorem Ipsum Description du fragment</td>
+                                    <th>{% trans "Fragment's description" %}&nbsp;:</th>
+                                    <td>{{ fragment.description }}</td>
                                 </tr>
                                 <tr>
                                     <th>{% trans "Users keywords" %}</th>
-                                    <td><textarea class="user-keywords">Modernité, Ready-made</textarea></td>
+                                    <td><textarea class="user-keywords">{{ fragment.users_keywords }}</textarea></td>
                                 </tr>
                                 <tr>
                                     <th> </th>
@@ -46,71 +51,37 @@
                     <div class="column column-full">
                         <h2>{% trans "Fragments from this picture" %}</h2>
                         <ul class="fullwidth">
-                            <li class="subcol subcol-eighth">
-                                <a href="{% url 'view_fragment' %}">
-                                <div class="center-image">
-                                    <div class="image-and-fragment">
-                                        <img src="{% static 'egonomy/img/empty.gif' %}" width="110" height="82" class="placeholder" />
-                                        <svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewbox="0 0 1 1" preserveAspectRatio="none">
-                                            <path d="M 0 .5 L .5 0 L 1 .5 L .5 1 Z" stroke="red" stroke-width=".02" fill="red" fill-opacity=".3" />
-                                        </svg>
-                                    </div>
-                                </div>
-                                <h3>Titre du fragment</h3></a>
-                                <p>{% trans "Annotated by" %} <strong>Julien75</strong></p>
-                            </li>
-                            <li class="subcol subcol-eighth">
-                                <a href="{% url 'view_fragment' %}">
-                                <div class="center-image">
-                                    <div class="image-and-fragment">
-                                        <img src="{% static 'egonomy/img/empty.gif' %}" width="110" height="82" class="placeholder" />
-                                        <svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewbox="0 0 1 1" preserveAspectRatio="none">
-                                            <path d="M .2 .5 L .7 .2 L .8 .7 Z" stroke="red" stroke-width=".02" fill="red" fill-opacity=".3" />
-                                        </svg>
-                                    </div>
-                                </div>
-                                <h3>Titre du fragment</h3></a>
-                                <p>{% trans "Annotated by" %} <strong>Julien75</strong></p>
-                            </li>
+                          {% for frg in fragment_list %}
                             <li class="subcol subcol-eighth">
                                 <a href="{% url 'view_fragment' %}">
                                 <div class="center-image">
                                     <div class="image-and-fragment">
-                                        <img src="{% static 'egonomy/img/empty.gif' %}" width="110" height="82" class="placeholder" />
+                                        {% if frg.image.image %}
+                                      {% if frg.image.image|is_portrait %}
+                                       {% thumbnail frg.image.image "x110" format="PNG" crop="center" as im %}
+                                        <img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}"/>
+                                       {% empty %}
+                                        <img src="{% static 'egonomy/img/empty.gif' %}" width="110" height="110" class="placeholder" />
+                                       {% endthumbnail %}
+                                      {% else %}
+                                       {% thumbnail frg.image.image "110" format="PNG" crop="center" as im %}
+                                        <img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}"/>
+                                       {% empty %}
+                                        <img src="{% static 'egonomy/img/empty.gif' %}" width=110" height="110" class="placeholder" />
+                                       {% endthumbnail %}
+                                      {% endif %}
+                                     {% else %}
+                                        <img src="{% static 'egonomy/img/empty.gif' %}" width=110" height="110" class="placeholder" />
+                                     {% endif %}
                                         <svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewbox="0 0 1 1" preserveAspectRatio="none">
-                                            <path d="M .3 .1 L .55 .15 L .6 .6 Z" stroke="red" stroke-width=".02" fill="red" fill-opacity=".3" />
+                                            <path d="{{ frg.path }}" stroke="red" stroke-width=".02" fill="red" fill-opacity=".3" />
                                         </svg>
                                     </div>
                                 </div>
-                                <h3>Titre du fragment</h3></a>
-                                <p>{% trans "Annotated by" %} <strong>Julien75</strong></p>
+                                <h3>{{ frg.title }}</h3></a>
+                                <p>{% trans "Annotated by" %} <strong>{{ frg.author }}</strong></p>
                             </li>
-                            <li class="subcol subcol-eighth">
-                                <a href="{% url 'view_fragment' %}">
-                                <div class="center-image">
-                                    <div class="image-and-fragment">
-                                        <img src="{% static 'egonomy/img/empty.gif' %}" width="110" height="82" class="placeholder" />
-                                        <svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewbox="0 0 1 1" preserveAspectRatio="none">
-                                            <path d="M .2 .5 L .7 .2 L .8 .7 Z" stroke="red" stroke-width=".02" fill="red" fill-opacity=".3" />
-                                        </svg>
-                                    </div>
-                                </div>
-                                <h3>Titre du fragment</h3></a>
-                                <p>{% trans "Annotated by" %} <strong>Julien75</strong></p>
-                            </li>
-                            <li class="subcol subcol-eighth">
-                                <a href="{% url 'view_fragment' %}">
-                                <div class="center-image">
-                                    <div class="image-and-fragment">
-                                        <img src="{% static 'egonomy/img/empty.gif' %}" width="110" height="82" class="placeholder" />
-                                        <svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewbox="0 0 1 1" preserveAspectRatio="none">
-                                            <path d="M .2 .5 L .7 .2 L .8 .7 Z" stroke="red" stroke-width=".02" fill="red" fill-opacity=".3" />
-                                        </svg>
-                                    </div>
-                                </div>
-                                <h3>Titre du fragment</h3></a>
-                                <p>{% trans "Annotated by" %} <strong>Julien75</strong></p>
-                            </li>
+                          {% endfor %}
                         </ul>
                     </div>
                 </div>
--- a/src/egonomy/views.py	Tue Jan 29 18:42:24 2013 +0100
+++ b/src/egonomy/views.py	Wed Jan 30 17:13:19 2013 +0100
@@ -10,36 +10,106 @@
 
 def home(request):
     
+    im1 = {"image": ImageFile(open(settings.RMN_PICT_ROOT+"0/00-004125.jpg", 'r'),FileSystemStorage(location=settings.RMN_PICT_ROOT)), "title":"title im 1", "author":"juju"}
+    im2 = {"image": ImageFile(open(settings.RMN_PICT_ROOT+"0/00-004543.jpg", 'r'),FileSystemStorage(location=settings.RMN_PICT_ROOT)), "title":"title im 2", "author":"loulou"}
+    im3 = {"image": ImageFile(open(settings.RMN_PICT_ROOT+"0/01-017513.jpg", 'r'),FileSystemStorage(location=settings.RMN_PICT_ROOT)), "title":"title im 3", "author":"juju"}
+    im4 = {"image": ImageFile(open(settings.RMN_PICT_ROOT+"0/02-009258.jpg", 'r'),FileSystemStorage(location=settings.RMN_PICT_ROOT)), "title":"title im 4", "author":"loulou"}
+    img_list = [im1,im2,im3,im4,im3,im4,im1,im2]
     
-    im1 = ImageFile(open(settings.RMN_PICT_ROOT+"0/00-004125.jpg", 'r'), FileSystemStorage(location=settings.RMN_PICT_ROOT))
-    im2 = ImageFile(open(settings.RMN_PICT_ROOT+"1/00-007590.jpg", 'r'), FileSystemStorage(location=settings.RMN_PICT_ROOT))
-    im3 = ImageFile(open(settings.RMN_PICT_ROOT+"2/00-001283.jpg", 'r'), FileSystemStorage(location=settings.RMN_PICT_ROOT))
-    im4 = ImageFile(open(settings.RMN_PICT_ROOT+"3/00-000023.jpg", 'r'), FileSystemStorage(location=settings.RMN_PICT_ROOT))
-    img_list = [im1,im2,im3,im4]
+    frg1 = {"image": im2, "path":"M 0 .5 L .5 0 L 1 .5 L .5 1 Z", "title":"Fragment X", "author":"juju"}
+    frg2 = {"image": im3, "path":"M .1 .3 L .5 .1 L .8 .7 Z", "title":"Fragment Y", "author":"loulou"}
+    frg3 = {"image": im4, "path":"M 0 .5 L .5 0 L 1 .5 L .5 1 Z", "title":"Fragment Z", "author":"juju"}
+    frg4 = {"image": im1, "path":"M .2 .5 L .7 .2 L .8 .7 Z", "title":"Fragment W", "author":"loulou"}
+    frg_list = [frg1,frg2,frg3,frg4,frg3,frg4,frg1,frg2]
     
     return render_to_response("egonomy_home.html",
-                              {'img_list': img_list},
+                              {'img_list': img_list, 'fragment_list': frg_list},
                               context_instance=RequestContext(request))
 
 
 def annotate_picture(request):
+
+    im1 = {"image": ImageFile(open(settings.RMN_PICT_ROOT+"0/03-007695.jpg", 'r'),FileSystemStorage(location=settings.RMN_PICT_ROOT)), "title":"title im 1", "author":"juju"}
+    im2 = {"image": ImageFile(open(settings.RMN_PICT_ROOT+"0/03-007696.jpg", 'r'),FileSystemStorage(location=settings.RMN_PICT_ROOT)), "title":"title im 2", "author":"loulou"}
+    im3 = {"image": ImageFile(open(settings.RMN_PICT_ROOT+"0/03-007697.jpg", 'r'),FileSystemStorage(location=settings.RMN_PICT_ROOT)), "title":"title im 3", "author":"juju"}
+    im4 = {"image": ImageFile(open(settings.RMN_PICT_ROOT+"0/03-007698.jpg", 'r'),FileSystemStorage(location=settings.RMN_PICT_ROOT)), "title":"title im 4", "author":"loulou"}
+    img_list = [im1,im2,im3,im4]
+    from random import choice
+    im = choice(img_list)
+    im.update({"description":"Ceci est la description de l'oeuvre representee dans l'image",
+               "author":"Marcel Duchamp",
+               "period":"XXeme siecle",
+               "production_site":"Paris, France",
+               "localization":"Musee du Louvre, Paris",
+               "rmn_keywords":"Art contemporain, Art conceptuel, Cyclisme",
+               "users_keywords":"Modernite, Ready-made"})
+    
+    frg1 = {"image": im, "path":"M 0 .5 L .5 0 L 1 .5 L .5 1 Z", "title":"Fragment X", "author":"juju"}
+    frg2 = {"image": im, "path":"M .1 .3 L .5 .1 L .8 .7 Z", "title":"Fragment Y", "author":"loulou"}
+    frg3 = {"image": im, "path":"M 0 .5 L .5 0 L 1 .5 L .5 1 Z", "title":"Fragment Z", "author":"juju"}
+    frg4 = {"image": im, "path":"M .2 .5 L .7 .2 L .8 .7 Z", "title":"Fragment W", "author":"loulou"}
+    frg_list = [frg1,frg2,frg3,frg4,frg3,frg4,frg1,frg4,frg3,frg4,frg1,frg2]
     
     return render_to_response("egonomy_annotate_picture.html",
-                              {'any_var': "coucou"},
+                              {'image': im, 'fragment_list': frg_list},
                               context_instance=RequestContext(request))
 
 
 def view_fragment(request):
     
+    im1 = {"image": ImageFile(open(settings.RMN_PICT_ROOT+"0/04-000035.jpg", 'r'),FileSystemStorage(location=settings.RMN_PICT_ROOT)), "title":"title im 1", "author":"juju"}
+    im2 = {"image": ImageFile(open(settings.RMN_PICT_ROOT+"0/04-000038.jpg", 'r'),FileSystemStorage(location=settings.RMN_PICT_ROOT)), "title":"title im 2", "author":"loulou"}
+    im3 = {"image": ImageFile(open(settings.RMN_PICT_ROOT+"0/05-513007.jpg", 'r'),FileSystemStorage(location=settings.RMN_PICT_ROOT)), "title":"title im 3", "author":"juju"}
+    im4 = {"image": ImageFile(open(settings.RMN_PICT_ROOT+"0/05-513027.jpg", 'r'),FileSystemStorage(location=settings.RMN_PICT_ROOT)), "title":"title im 4", "author":"loulou"}
+    img_list = [im1,im2,im3,im4]
+    from random import choice
+    im = choice(img_list)
+    im.update({"description":"Ceci est la description de l'oeuvre representee dans l'image",
+               "author":"Marcel Duchamp",
+               "period":"XXeme siecle",
+               "production_site":"Paris, France",
+               "localization":"Musee du Louvre, Paris",
+               "rmn_keywords":"Art contemporain, Art conceptuel, Cyclisme",
+               "users_keywords":"Modernite, Ready-made"})
+    
+    frg1 = {"image": im, "path":"M 0 .5 L .5 0 L 1 .5 L .5 1 Z", "title":"Fragment X", "author":"juju", "users_keywords":"Modernite, Ready-made"}
+    frg2 = {"image": im, "path":"M .1 .3 L .5 .1 L .8 .7 Z", "title":"Fragment Y", "author":"loulou", "users_keywords":"Modernite, Ready-made"}
+    frg3 = {"image": im, "path":"M 0 .5 L .5 0 L 1 .5 L .5 1 Z", "title":"Fragment Z", "author":"juju", "users_keywords":"Modernite, Ready-made"}
+    frg4 = {"image": im, "path":"M .2 .5 L .7 .2 L .8 .7 Z", "title":"Fragment W", "author":"loulou", "users_keywords":"Modernite, Ready-made"}
+    frg_list = [frg1,frg2,frg3,frg3,frg4,frg4,frg3,frg4,frg1,frg4,frg1]
+    frg = choice(frg_list)
+    
     return render_to_response("egonomy_view_fragment.html",
-                              {'any_var': "coucou"},
+                              {'fragment': frg, 'fragment_list': frg_list},
                               context_instance=RequestContext(request))
 
 
 def create_fragment(request):
     
+    im1 = {"image": ImageFile(open(settings.RMN_PICT_ROOT+"0/08-551797.jpg", 'r'),FileSystemStorage(location=settings.RMN_PICT_ROOT)), "title":"title im 1", "author":"juju"}
+    im2 = {"image": ImageFile(open(settings.RMN_PICT_ROOT+"0/09-508948.jpg", 'r'),FileSystemStorage(location=settings.RMN_PICT_ROOT)), "title":"title im 2", "author":"loulou"}
+    im3 = {"image": ImageFile(open(settings.RMN_PICT_ROOT+"0/09-509002.jpg", 'r'),FileSystemStorage(location=settings.RMN_PICT_ROOT)), "title":"title im 3", "author":"juju"}
+    im4 = {"image": ImageFile(open(settings.RMN_PICT_ROOT+"0/09-510583.jpg", 'r'),FileSystemStorage(location=settings.RMN_PICT_ROOT)), "title":"title im 4", "author":"loulou"}
+    img_list = [im1,im2,im3,im4]
+    from random import choice
+    im = choice(img_list)
+    im.update({"description":"Ceci est la description de l'oeuvre representee dans l'image",
+               "author":"Marcel Duchamp",
+               "period":"XXeme siecle",
+               "production_site":"Paris, France",
+               "localization":"Musee du Louvre, Paris",
+               "rmn_keywords":"Art contemporain, Art conceptuel, Cyclisme",
+               "users_keywords":"Modernite, Ready-made"})
+    
+    frg1 = {"image": im, "path":"M 0 .5 L .5 0 L 1 .5 L .5 1 Z", "title":"Fragment X", "author":"juju"}
+    frg2 = {"image": im, "path":"M .1 .3 L .5 .1 L .8 .7 Z", "title":"Fragment Y", "author":"loulou"}
+    frg3 = {"image": im, "path":"M 0 .5 L .5 0 L 1 .5 L .5 1 Z", "title":"Fragment Z", "author":"juju"}
+    frg4 = {"image": im, "path":"M .2 .5 L .7 .2 L .8 .7 Z", "title":"Fragment W", "author":"loulou"}
+    frg_list = [frg1,frg2,frg3,frg4,frg3,frg4,frg1,frg4,frg3,frg4,frg1,frg2]
+    
+    
     return render_to_response("egonomy_create_fragment.html",
-                              {'any_var': "coucou"},
+                              {'image': im, 'fragment_list': frg_list},
                               context_instance=RequestContext(request))