| author | cavaliet |
| Tue, 05 Feb 2013 17:10:18 +0100 | |
| changeset 25 | 48614929b87a |
| parent 24 | d65e05154aec |
| child 26 | a7ace38e92a4 |
--- a/src/egonomy/static/egonomy/css/egonomy.css Tue Feb 05 13:16:57 2013 +0100 +++ b/src/egonomy/static/egonomy/css/egonomy.css Tue Feb 05 17:10:18 2013 +0100 @@ -129,6 +129,10 @@ font-weight: bold; } +.right{ + float: right; +} + .main-wrap { background: #ffffff; /* Old browsers */ background: -moz-linear-gradient(top, #f0f0f0 20%, #ffffff 80%); /* FF3.6+ */ @@ -172,6 +176,9 @@ .subcol_all { float: left; margin: 2px 0 4px 10px; width: 110px; } +.subcol_all:nth-child(8n+1) { + margin-left: 0; clear: left; +} .column-third { float: left; width: 312px; @@ -205,6 +212,7 @@ margin-left: 0; clear: left; } + .column-full { margin-left: 0; width: 968px; }
--- a/src/egonomy/templates/egonomy_annotate_picture.html Tue Feb 05 13:16:57 2013 +0100 +++ b/src/egonomy/templates/egonomy_annotate_picture.html Tue Feb 05 17:10:18 2013 +0100 @@ -74,15 +74,16 @@ <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|is_portrait %} - {% thumbnail frg.image.image "x110" format="PNG" crop="center" as im %} + {% with frg.image.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 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" /> @@ -91,8 +92,9 @@ {% else %} <img src="{% static 'egonomy/img/empty.gif' %}" width=110" height="110" class="placeholder" /> {% endif %} + {% endwith %} <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>
--- a/src/egonomy/templates/egonomy_create_fragment.html Tue Feb 05 13:16:57 2013 +0100 +++ b/src/egonomy/templates/egonomy_create_fragment.html Tue Feb 05 17:10:18 2013 +0100 @@ -75,15 +75,16 @@ <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|is_portrait %} - {% thumbnail frg.image.image "x110" format="PNG" crop="center" as im %} + {% with frg.image.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 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" /> @@ -92,8 +93,9 @@ {% else %} <img src="{% static 'egonomy/img/empty.gif' %}" width=110" height="110" class="placeholder" /> {% endif %} + {% endwith %} <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>
--- a/src/egonomy/templates/egonomy_home.html Tue Feb 05 13:16:57 2013 +0100 +++ b/src/egonomy/templates/egonomy_home.html Tue Feb 05 17:10:18 2013 +0100 @@ -19,7 +19,8 @@ <!-- Liste des dernières images annotées --> <div class="column column-half"> - <h2>{% if search %}{% trans "Corresponding pictures" %}{% else %}{% trans "Last annotated pictures" %}{% endif %}</h2> + <h2>{% if search %}{% trans "Corresponding pictures" %}{% else %}{% trans "Last annotated pictures" %}{% endif %} + <span class="right"><a href="{% url 'all_pictures' %}" alt="{% trans "All pictures" %}">{% trans "All pictures" %}</a></span></h2> <ul class="fullwidth"> {% for img in img_list %} <li class="subcol subcol-half-fourth"> @@ -45,7 +46,7 @@ {% endif %} {% endwith %} </div> - <h3>{{ img.metadata.titre }}</h3></a> + <h3>{{ img.metadata.titre }} : {{img.date_modif}}</h3></a> <p>{% trans "Annotated by" %} <strong>{{ img.metadata.auteur }}</strong></p> </li> {% endfor %}
--- a/src/egonomy/templates/egonomy_view_fragment.html Tue Feb 05 13:16:57 2013 +0100 +++ b/src/egonomy/templates/egonomy_view_fragment.html Tue Feb 05 17:10:18 2013 +0100 @@ -47,6 +47,9 @@ </tr> </table> </form> + <div class="fullwidth"> + <a href="{% url 'create_fragment' image_id=fragment.image.id %}" class="big-button">{% trans "Create a fragment" %}</a> + </div> </div> </div> <div class="fullwidth"> @@ -58,15 +61,16 @@ <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|is_portrait %} - {% thumbnail frg.image.image "x110" format="PNG" crop="center" as im %} + {% with frg.image.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 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" /> @@ -75,8 +79,9 @@ {% else %} <img src="{% static 'egonomy/img/empty.gif' %}" width=110" height="110" class="placeholder" /> {% endif %} + {% endwith %} <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>
--- a/src/egonomy/templates/partial/all_pictures_pagination.html Tue Feb 05 13:16:57 2013 +0100 +++ b/src/egonomy/templates/partial/all_pictures_pagination.html Tue Feb 05 17:10:18 2013 +0100 @@ -1,7 +1,7 @@ {% if nb_pages %} {% comment %}alors ? : {{begin}} - {{middle}} - {{end}} - nb_pages = {{nb_pages}}<br/> alors ? : nb_pages = {{nb_pages}} - range = {{nb_pages}} - cur_page_nb = {{cur_page_nb}}<br/>{% endcomment %} - {% if 1 < cur_page_nb %}<a class="{{a_class}}" alt="prev"><<</a> {% endif %} + {% if 1 < cur_page_nb %}<a class="{{a_class}}" alt="prev" href="{% url 'all_pictures' %}?page={{cur_page_nb|add:'-1'}}"><<</a> {% endif %} {% for i in begin %} {% if i == cur_page_nb %}{{i}}{% else %}<a class="{{a_class}}" alt="{{i}}" href="{% url 'all_pictures' %}?page={{i}}">{{i}}</a>{% endif %} {% endfor %} @@ -17,5 +17,5 @@ {% if i == cur_page_nb %}{{i}}{% else %}<a class="{{a_class}}" alt="{{i}}" href="{% url 'all_pictures' %}?page={{i}}">{{i}}</a>{% endif %} {% endfor %} {% endif %} - {% if cur_page_nb < nb_pages %}<a class="{{a_class}}" alt="next" href="{% url 'all_pictures' %}?page={{i|add:'1'}}">>></a>{% endif %} + {% if cur_page_nb < nb_pages %}<a class="{{a_class}}" alt="next" href="{% url 'all_pictures' %}?page={{cur_page_nb|add:'1'}}">>></a>{% endif %} {% endif %} \ No newline at end of file
--- a/src/egonomy/views.py Tue Feb 05 13:16:57 2013 +0100 +++ b/src/egonomy/views.py Tue Feb 05 17:10:18 2013 +0100 @@ -3,9 +3,8 @@ from django.core.paginator import Paginator, InvalidPage, EmptyPage 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 +from django.db.models.aggregates import Max @@ -19,11 +18,9 @@ field = "all" 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] + + img_list = Image.objects.annotate(date_modif=Max('fragment__date_saved')).exclude(date_modif=None).order_by('-date_modif')[:12] frg_list = Fragment.objects.all().order_by('-date_saved')[:12] return render_to_response("egonomy_home.html", @@ -33,13 +30,8 @@ def annotate_picture(request, image_id): - img = get_object_or_404(Image, id=image_id) - - 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] + img = get_object_or_404(Image, id=image_id) + frg_list = Fragment.objects.filter(image=img) return render_to_response("egonomy_annotate_picture.html", {'img': img, 'fragment_list': frg_list, 'image_id':image_id}, @@ -49,12 +41,7 @@ def view_fragment(request, fragment_pk): frg = get_object_or_404(Fragment, pk=fragment_pk) - - 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_list = Fragment.objects.filter(image=frg.image) return render_to_response("egonomy_view_fragment.html", {'fragment': frg, 'fragment_list': frg_list}, @@ -64,13 +51,7 @@ def create_fragment(request, image_id): img = get_object_or_404(Image, id=image_id) - - 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] - + frg_list = Fragment.objects.filter(image=img) return render_to_response("egonomy_create_fragment.html", {'img': img, 'fragment_list': frg_list},