first step user login/logout. Create fragment works. Views and templates adapted with real data model.
authorcavaliet
Tue, 05 Feb 2013 11:56:59 +0100
changeset 23 bb7819c8d7c2
parent 22 101723fc7ec6
child 24 d65e05154aec
first step user login/logout. Create fragment works. Views and templates adapted with real data model.
src/egonomy/migrations/0002_update_site.py
src/egonomy/templates/egonomy_annotate_picture.html
src/egonomy/templates/egonomy_base.html
src/egonomy/templates/egonomy_create_fragment.html
src/egonomy/templates/egonomy_home.html
src/egonomy/templates/egonomy_view_fragment.html
src/egonomy/templates/registration/login.html
src/egonomy/urls.py
src/egonomy/views.py
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/egonomy/migrations/0002_update_site.py	Tue Feb 05 11:56:59 2013 +0100
@@ -0,0 +1,134 @@
+# -*- coding: utf-8 -*-
+import datetime
+from south.db import db
+from south.v2 import DataMigration
+from django.conf import settings
+from django.db import models
+
+class Migration(DataMigration):
+
+    def forwards(self, orm):
+        Sites = orm['sites.Site']
+        site = Sites()
+        site.id = settings.SITE_ID
+        web_url = settings.WEB_URL
+        if(web_url.startswith("http://")):
+            domain_area = web_url.split("//",1)
+            domain = domain_area[1]
+        else :
+            domain=web_url
+        if domain.endswith("/"):
+            domain = domain[:-1]
+        site.domain = domain
+        site.name=domain
+        site.save()
+
+    def backwards(self, orm):
+        "Write your backwards methods here."
+        Sites = orm['sites.Site']
+        site = Sites.objects.get(id=settings.SITE_ID)
+        if site:
+            site.delete()
+
+    models = {
+        u'auth.group': {
+            'Meta': {'object_name': 'Group'},
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
+            'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
+        },
+        u'auth.permission': {
+            'Meta': {'ordering': "(u'content_type__app_label', u'content_type__model', u'codename')", 'unique_together': "((u'content_type', u'codename'),)", 'object_name': 'Permission'},
+            'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}),
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
+        },
+        u'auth.user': {
+            'Meta': {'object_name': 'User'},
+            'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+            'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
+            'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+            'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+            'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+            'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+            'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
+            'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
+            'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
+        },
+        u'contenttypes.contenttype': {
+            'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
+            'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
+        },
+        u'egonomy.fragment': {
+            'Meta': {'object_name': 'Fragment'},
+            'author': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['auth.User']"}),
+            'coordinates': ('django.db.models.fields.TextField', [], {}),
+            'date_created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+            'date_saved': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
+            'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'image': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['egonomy.Image']"}),
+            'tags': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
+            'title': ('django.db.models.fields.CharField', [], {'max_length': '2048', 'null': 'True', 'blank': 'True'})
+        },
+        u'egonomy.image': {
+            'Meta': {'object_name': 'Image'},
+            'id': ('django.db.models.fields.CharField', [], {'max_length': '15', 'primary_key': 'True'}),
+            'info': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['egonomy.ImageInfo']", 'null': 'True', 'blank': 'True'}),
+            'metadata': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['egonomy.ImageMetadata']"})
+        },
+        u'egonomy.imageinfo': {
+            'Meta': {'object_name': 'ImageInfo'},
+            'exif': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
+            'height': ('django.db.models.fields.IntegerField', [], {}),
+            'id': ('django.db.models.fields.CharField', [], {'max_length': '15', 'primary_key': 'True'}),
+            'image_file': ('django.db.models.fields.files.ImageField', [], {'max_length': '2048'}),
+            'mimetype': ('django.db.models.fields.CharField', [], {'max_length': '1024', 'null': 'True', 'blank': 'True'}),
+            'width': ('django.db.models.fields.IntegerField', [], {})
+        },
+        u'egonomy.imagemetadata': {
+            'Meta': {'object_name': 'ImageMetadata'},
+            'auteur': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
+            'cliche': ('django.db.models.fields.CharField', [], {'max_length': '15'}),
+            'date': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}),
+            'date_inserted': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+            'date_modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
+            'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
+            'description_pertimm': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
+            'diametre': ('django.db.models.fields.DecimalField', [], {'null': 'True', 'max_digits': '20', 'decimal_places': '15', 'blank': 'True'}),
+            'droits': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
+            'hauteur': ('django.db.models.fields.DecimalField', [], {'null': 'True', 'max_digits': '20', 'decimal_places': '15', 'blank': 'True'}),
+            'id': ('django.db.models.fields.CharField', [], {'max_length': '15', 'primary_key': 'True'}),
+            'inventaire': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
+            'lieu': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
+            'localisation': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
+            'longueur': ('django.db.models.fields.DecimalField', [], {'null': 'True', 'max_digits': '20', 'decimal_places': '15', 'blank': 'True'}),
+            'mentions': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
+            'mots_cles': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
+            'periode': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
+            'photographe': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
+            'profondeur': ('django.db.models.fields.DecimalField', [], {'null': 'True', 'max_digits': '20', 'decimal_places': '15', 'blank': 'True'}),
+            'site': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
+            'technique': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
+            'thesaurus_pertimm': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
+            'titre': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
+            'titre_pertimm': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'})
+        },
+        'sites.site': {
+            'Meta': {'ordering': "('domain',)", 'object_name': 'Site', 'db_table': "'django_site'"},
+            'domain': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
+        }
+    }
+
+    complete_apps = ['egonomy']
+    symmetrical = True
--- a/src/egonomy/templates/egonomy_annotate_picture.html	Mon Feb 04 15:25:30 2013 +0100
+++ b/src/egonomy/templates/egonomy_annotate_picture.html	Tue Feb 05 11:56:59 2013 +0100
@@ -8,13 +8,15 @@
 {% block content %}
                 <div class="fullwidth">
                     <div class="column column-half">
-                        <h2>Titre de l'image</h2>
+                        <h2>{{ img.metadata.titre }}</h2>
                         <div class="fullphoto">
-                          {% thumbnail image.image "476" format="PNG" crop="center" as im %}
+                          {% with img.info.image_file as image %}
+                          {% thumbnail 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 %}
+                          {% endwith %}
                         </div>
                     </div>
                     <div class="column column-half">
@@ -22,31 +24,31 @@
                         <table class="image-metadata">
                             <tr>
                                 <th>{% trans "Description" %}&nbsp;:</th>
-                                <td>{{ image.description }}</td>
+                                <td>{{ img.metadata.description }}</td>
                             </tr>
                             <tr>
                                 <th>{% trans "Author" %}&nbsp;:</th>
-                                <td>{{ image.author }}</td>
+                                <td>{{ img.metadata.auteur }}</td>
                             </tr>
                             <tr>
                                 <th>{% trans "Period" %}&nbsp;:</th>
-                                <td>{{ image.period }}</td>
+                                <td>{{ img.metadata.periode }}</td>
                             </tr>
                             <tr>
                                 <th>{% trans "Production site" %}&nbsp;:</th>
-                                <td>{{ image.production_site }}</td>
+                                <td>{{ img.metadata.site }}</td>
                             </tr>
                             <tr>
                                 <th>{% trans "Localization" %}&nbsp;:</th>
-                                <td>{{ image.localization }}</td>
+                                <td>{{ img.metadata.lieu }}</td>
                             </tr>
                             <tr>
                                 <th>{% trans "RMN keywords" %}&nbsp;:</th>
-                                <td>{{ image.rmn_keywords }}</td>
+                                <td>{{ img.metadata.mots_cles }}</td>
                             </tr>
                             <tr>
                                 <th>{% trans "Users keywords" %}</th>
-                                <td><textarea class="user-keywords">{{ image.users_keywords }}</textarea></td>
+                                <td><textarea class="user-keywords">{{ img.metadata.users_keywords }}</textarea></td>
                             </tr>
                             <tr>
                                 <th> </th>
@@ -59,7 +61,7 @@
                         </table>
                         </form>
                         <div class="fullwidth">
-                            <a href="{% url 'create_fragment' %}" class="big-button">{% trans "Create a fragment" %}</a>
+                            <a href="{% url 'create_fragment' image_id=img.id %}" class="big-button">{% trans "Create a fragment" %}</a>
                         </div>
                     </div>
                 </div>
@@ -69,10 +71,10 @@
                         <ul class="fullwidth">
                           {% for frg in fragment_list %}
                             <li class="subcol subcol-eighth">
-                                <a href="{% url 'view_fragment' %}">
+                                <a href="{% url 'view_fragment' fragment_pk='1' %}">
                                 <div class="center-image">
                                     <div class="image-and-fragment">
-                                        {% if frg.image.image %}
+                                     {% 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 }}"/>
--- a/src/egonomy/templates/egonomy_base.html	Mon Feb 04 15:25:30 2013 +0100
+++ b/src/egonomy/templates/egonomy_base.html	Tue Feb 05 11:56:59 2013 +0100
@@ -25,7 +25,11 @@
                     <input type="hidden" value="all" name="field">
                 </form>
                 <nav class="column column-third">
-                    <a href="#">{% trans "Login" %}</a>
+                  {% if user.is_authenticated %}
+		            {{ user.username }} : <a href="{% url 'logout' %}?next={% url 'home' %}">{% trans "Log out" %}</a>
+		          {% else %}
+		            <a href="{% url 'login' %}">{% trans "Log in" %}</a>
+		          {% endif %}
                 </nav>
             </header>
         </div>
--- a/src/egonomy/templates/egonomy_create_fragment.html	Mon Feb 04 15:25:30 2013 +0100
+++ b/src/egonomy/templates/egonomy_create_fragment.html	Tue Feb 05 11:56:59 2013 +0100
@@ -20,21 +20,24 @@
                             <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">
-                              {% thumbnail image.image "476" format="PNG" crop="center" as im %}
+                              {% with img.info.image_file as image %}
+                              {% thumbnail 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 %}
+	                          {% endwith %}
                                 <div class="cutout-canvas"></div>
                             </div>
                             <input name="fragment_path" id="fragment_path" type="text" class="fragment-path column-half" value="M 0 .5 L .5 0 L 1 .5 L .5 1 Z" />
+                            <input name="image_id" id="image_id" type="hidden" value="{{ img.id }}" />
                         {% csrf_token %}
                         </div>
                         <div class="column column-half">
                             <table class="image-metadata">
                                 <tr>
                                     <th>{% trans 'Source picture' %}&nbsp;:</th>
-                                    <td><a href="{% url 'annotate_picture' %}">{{ image.title }}</a></td>
+                                    <td><a href="{% url 'annotate_picture' image_id=img.id %}">{{ img.metadata.titre }}</a></td>
                                 </tr>
                                 <tr>
                                     <th>{% trans "Fragment's title" %}&nbsp;:</th>
@@ -69,10 +72,10 @@
                         <ul class="fullwidth">
                           {% for frg in fragment_list %}
                             <li class="subcol subcol-eighth">
-                                <a href="{% url 'view_fragment' %}">
+                                <a href="{% url 'view_fragment' fragment_pk=1 %}">
                                 <div class="center-image">
                                     <div class="image-and-fragment">
-                                        {% if frg.image.image %}
+                                     {% 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 }}"/>
--- a/src/egonomy/templates/egonomy_home.html	Mon Feb 04 15:25:30 2013 +0100
+++ b/src/egonomy/templates/egonomy_home.html	Tue Feb 05 11:56:59 2013 +0100
@@ -23,17 +23,18 @@
                         <ul class="fullwidth">
                           {% for img in img_list %}
                             <li class="subcol subcol-half-fourth">
-                                <a href="{% url 'annotate_picture' %}">
+                                <a href="{% url 'annotate_picture' image_id=img.id %}">
                                 <div class="center-image">
-                                 {% if img.image %}
-                                  {% if img.image|is_portrait %}
-							 	    {% thumbnail img.image "x110" format="PNG" crop="center" as im %}
+                                 {% with img.info.image_file as image %}
+                                 {% if image %}
+                                  {% if image|is_portrait %}
+							 	    {% thumbnail 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.image "110" format="PNG" crop="center" as im %}
+                                    {% thumbnail 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" />
@@ -42,9 +43,10 @@
 	                             {% else %}
 	                                  <img src="{% static 'egonomy/img/empty.gif' %}" width=110" height="110" class="placeholder" />
 	                             {% endif %}
+	                             {% endwith %}
                                 </div>
-                                <h3>{{ img.title|safe }}</h3></a>
-                                <p>{% trans "Annotated by" %} <strong>{{ img.author }}</strong></p>
+                                <h3>{{ img.metadata.titre }}</h3></a>
+                                <p>{% trans "Annotated by" %} <strong>{{ img.metadata.auteur }}</strong></p>
                             </li>
                           {% endfor %}
                         </ul>
@@ -56,33 +58,35 @@
                         <ul class="fullwidth">
                           {% for frg in fragment_list %}
                             <li class="subcol subcol-half-fourth">
-                                <a href="{% url 'view_fragment' %}">
+                                <a href="{% url 'view_fragment' fragment_pk=frg.pk %}">
                                 <div class="center-image">
                                     <div class="image-and-fragment">
-                                     {% if frg.image.image %}
-		                              {% if frg.image.image|is_portrait %}
-		                               {% thumbnail frg.image.image "x110" format="PNG" crop="center" as im %}
+                                     {% if frg.image %}
+                                      {% with frg.image.info.image_file as image %}
+		                              {% if image|is_portrait %}
+		                               {% thumbnail 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 %}
+		                               {% thumbnail 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 %}
+		                              {% endwith %}
 		                             {% 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="{{ frg.path }}" stroke="red" stroke-width=".02" fill="red" fill-opacity=".3" />
+                                            <path d="{{ frg.coordinates }}" stroke="red" stroke-width=".02" fill="red" fill-opacity=".3" />
                                         </svg>
                                     </div>
                                 </div>
-                                <h3>{{ frg.title|safe }}</h3></a>
-                                <h4>{% trans "Fragment from" %} <a href="{% url 'annotate_picture' %}">{{ frg.image.title|safe }}</a></h4>
+                                <h3>{{ frg.title }}</h3></a>
+                                <h4>{% trans "Fragment from" %} <a href="{% url 'annotate_picture' image_id='01-013015' %}">{{ frg.image.metadata.titre }}</a></h4>
                                 <p>{% trans "Annotated by" %} <strong>{{ frg.author }}</strong></p>
                             </li>
                           {% endfor %}
--- a/src/egonomy/templates/egonomy_view_fragment.html	Mon Feb 04 15:25:30 2013 +0100
+++ b/src/egonomy/templates/egonomy_view_fragment.html	Tue Feb 05 11:56:59 2013 +0100
@@ -10,13 +10,15 @@
                     <div class="column column-half">
                         <h2>{{ fragment.title }}</h2>
                         <div class="image-and-fragment">
-                          {% thumbnail fragment.image.image "476" format="PNG" crop="center" as im %}
+                          {% with fragment.image.info.image_file as image %}
+                          {% thumbnail 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 %}
+                          {% endwith %}
                             <svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewbox="0 0 1 1" preserveAspectRatio="none">
-                                <path d="{{ fragment.path }}" stroke="red" stroke-width=".002" fill="red" fill-opacity=".3" />
+                                <path d="{{ fragment.coordinates }}" stroke="red" stroke-width=".002" fill="red" fill-opacity=".3" />
                             </svg>
                         </div>
                     </div>
@@ -25,7 +27,7 @@
                             <table class="image-metadata">
                                 <tr>
                                     <th>{% trans "Source picture" %}&nbsp;:</th>
-                                    <td><a href="{% url 'annotate_picture' %}">{{ fragment.image.title }}</a></td>
+                                    <td><a href="{% url 'annotate_picture' image_id=fragment.image.id %}">{{ fragment.image.metadata.titre }}</a></td>
                                 </tr>
                                 <tr>
                                     <th>{% trans "Fragment's description" %}&nbsp;:</th>
@@ -33,7 +35,7 @@
                                 </tr>
                                 <tr>
                                     <th>{% trans "Users keywords" %}</th>
-                                    <td><textarea class="user-keywords">{{ fragment.users_keywords }}</textarea></td>
+                                    <td><textarea class="user-keywords">{{ fragment.tags }}</textarea></td>
                                 </tr>
                                 <tr>
                                     <th> </th>
@@ -53,7 +55,7 @@
                         <ul class="fullwidth">
                           {% for frg in fragment_list %}
                             <li class="subcol subcol-eighth">
-                                <a href="{% url 'view_fragment' %}">
+                                <a href="{% url 'view_fragment' fragment_pk='1'  %}">
                                 <div class="center-image">
                                     <div class="image-and-fragment">
                                         {% if frg.image.image %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/egonomy/templates/registration/login.html	Tue Feb 05 11:56:59 2013 +0100
@@ -0,0 +1,32 @@
+{% extends "egonomy_base.html" %}
+{% load static %}
+{% load i18n %}
+
+{% block title %}{% trans "Login" %}{% endblock %}
+
+{% block content %}
+    {% if form.errors %}
+    <p class="error">{% trans "Sorry, that's not a valid username or password." %}</p>
+   {% endif %}
+    <div class="span-24 last">
+        <form action="" method='post' id="login-form">
+            <div id="loginform_div" class="span-12">
+            {% csrf_token %}
+            <input type="hidden" name="next" value="{% url 'home' %}" />
+            <ul id="login_fields_list">
+            {{form.as_ul}}
+            </ul>
+            <!--ul>
+                <li><a href="" >{% trans "Forget password?" %}</a></li>
+            </ul-->
+            <div id="submitcontent-buttons-login" class="span-24 last">
+                <button class="button"type="submit" value="login">{% trans "login" %}</button>
+            </div>
+            </div>
+        </form>
+    </div> 
+
+{% endblock %}
+
+
+
--- a/src/egonomy/urls.py	Mon Feb 04 15:25:30 2013 +0100
+++ b/src/egonomy/urls.py	Tue Feb 05 11:56:59 2013 +0100
@@ -9,15 +9,18 @@
 
 urlpatterns = patterns('',
     url(r'^$', 'egonomy.views.home', name='home'),
-    url(r'^annotate/$', 'egonomy.views.annotate_picture', name='annotate_picture'),
-    url(r'^viewfragment/$', 'egonomy.views.view_fragment', name='view_fragment'),
-    url(r'^createfragment/$', 'egonomy.views.create_fragment', name='create_fragment'),
+    url(r'^annotate/(?P<image_id>.*)/$', 'egonomy.views.annotate_picture', name='annotate_picture'),
+    url(r'^viewfragment/(?P<fragment_pk>.*)/$', 'egonomy.views.view_fragment', name='view_fragment'),
+    url(r'^createfragment/(?P<image_id>.*)/$', 'egonomy.views.create_fragment', name='create_fragment'),
     url(r'^savefragment/$', 'egonomy.views.save_fragment', name='save_fragment'),
 
     # Uncomment the admin/doc line below to enable admin documentation:
     url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
     # Uncomment the next line to enable the admin:
     url(r'^admin/', include(admin.site.urls)),
+    # login logout view
+    url(r'^login/', 'django.contrib.auth.views.login', name='login'),
+    url(r'^logout/', 'django.contrib.auth.views.logout', name='logout'),
 )
 urlpatterns += staticfiles_urlpatterns()
 urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
\ No newline at end of file
--- a/src/egonomy/views.py	Mon Feb 04 15:25:30 2013 +0100
+++ b/src/egonomy/views.py	Tue Feb 05 11:56:59 2013 +0100
@@ -3,9 +3,11 @@
 #from django.contrib.auth.models import Group, User
 from django.core.files.storage import FileSystemStorage
 #from django.core.paginator import Paginator, InvalidPage, EmptyPage
-from django.shortcuts import render_to_response, redirect
+from django.shortcuts import get_object_or_404, render_to_response, redirect
 from django.template import RequestContext
 from sorl.thumbnail.images import ImageFile
+from models import Image, Fragment
+from random import randint
 
 
 
@@ -20,113 +22,60 @@
         if "field" in request.GET:
             field = request.GET["field"]
         
+    #i =  randint(0, 200000)
+    #img_list = Image.objects.all()[i:i+12]
+    img_list = Image.objects.all()[:12]
     
-    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":"<span class=\"highlight\">title</span> 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"}
-    if search:
-        img_list = [im1,im2,im3,im4]
-    else:
-        img_list = [im1,im2,im3,im4,im3,im4,im1,im2]
-    
-    frg1 = {"image": im2, "path":"M 0 .5 L .5 0 L 1 .5 L .5 1 Z", "title":"<span class=\"highlight\">Fragment</span> 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"}
-    if search:
-        frg_list = [frg1,frg2,frg3,frg4]
-    else:
-        frg_list = [frg1,frg2,frg3,frg4,frg3,frg4,frg1,frg2]
+    frg_list = Fragment.objects.all()[:12]
     
     return render_to_response("egonomy_home.html",
                               {'img_list':img_list, 'fragment_list':frg_list, "search":search, "nb_results":nb_results},
                               context_instance=RequestContext(request))
 
 
-def annotate_picture(request):
+def annotate_picture(request, image_id):
 
-    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"})
+    img = get_object_or_404(Image, id=image_id) 
     
-    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"}
+    frg1 = {"image": img, "path":"M 0 .5 L .5 0 L 1 .5 L .5 1 Z", "title":"Fragment X", "author":"juju"}
+    frg2 = {"image": img, "path":"M .1 .3 L .5 .1 L .8 .7 Z", "title":"Fragment Y", "author":"loulou"}
+    frg3 = {"image": img, "path":"M 0 .5 L .5 0 L 1 .5 L .5 1 Z", "title":"Fragment Z", "author":"juju"}
+    frg4 = {"image": img, "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",
-                              {'image': im, 'fragment_list': frg_list},
+                              {'img': img, 'fragment_list': frg_list, 'image_id':image_id},
                               context_instance=RequestContext(request))
 
 
-def view_fragment(request):
+def view_fragment(request, fragment_pk):
+    
+    frg = get_object_or_404(Fragment, pk=fragment_pk)
     
-    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"}
+    frg1 = {"image": frg.image, "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": frg.image, "path":"M .1 .3 L .5 .1 L .8 .7 Z", "title":"Fragment Y", "author":"loulou", "users_keywords":"Modernite, Ready-made"}
+    frg3 = {"image": frg.image, "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": frg.image, "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",
                               {'fragment': frg, 'fragment_list': frg_list},
                               context_instance=RequestContext(request))
 
 #@login_required
-def create_fragment(request):
+def create_fragment(request, image_id):
+    
+    img = get_object_or_404(Image, id=image_id)
     
-    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"}
+    frg1 = {"image": img, "path":"M 0 .5 L .5 0 L 1 .5 L .5 1 Z", "title":"Fragment X", "author":"juju"}
+    frg2 = {"image": img, "path":"M .1 .3 L .5 .1 L .8 .7 Z", "title":"Fragment Y", "author":"loulou"}
+    frg3 = {"image": img, "path":"M 0 .5 L .5 0 L 1 .5 L .5 1 Z", "title":"Fragment Z", "author":"juju"}
+    frg4 = {"image": img, "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",
-                              {'image': im, 'fragment_list': frg_list},
+                              {'img': img, 'fragment_list': frg_list},
                               context_instance=RequestContext(request))
 
 #@login_required
@@ -136,8 +85,20 @@
     frg_desc = request.POST["fragment_description"]
     frg_kw = request.POST["users_keywords"]
     frg_path = request.POST["fragment_path"]
+    frg_image_id = request.POST["image_id"]
+    img = get_object_or_404(Image, id=frg_image_id)
     
-    return redirect("view_fragment")
+    frg = Fragment()
+    frg.image = img
+    frg.coordinates = frg_path
+    frg.title = frg_title
+    frg.description = frg_desc
+    frg.tags = frg_kw
+    frg.author = request.user
+    
+    frg.save()
+    
+    return redirect("view_fragment", fragment_pk=frg.pk)