# HG changeset patch # User Harris Baptiste # Date 1466072773 -7200 # Node ID 91e7f0429e4f4f5795daf7eacf11a87dd18e2d76 # Parent 13c69c2f9e5a824aba02dbf4186c872eeab412d4 editing urls.py to add new annotations views diff -r 13c69c2f9e5a -r 91e7f0429e4f src/iconolab/forms/__init__.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/iconolab/forms/__init__.py Thu Jun 16 12:26:13 2016 +0200 @@ -0,0 +1,8 @@ +from django import forms +from iconolab.models import Annotation + + +class AnnotationForm(forms.ModelForm): + class Meta: + model = Annotation + fields = ('title', 'description', 'fragment', 'tags',) \ No newline at end of file diff -r 13c69c2f9e5a -r 91e7f0429e4f src/iconolab/templates/iconolab/edit_annotation.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/iconolab/templates/iconolab/edit_annotation.html Thu Jun 16 12:26:13 2016 +0200 @@ -0,0 +1,169 @@ +{% extends 'iconolab_base.html' %} + +{% load staticfiles %} + +{% load thumbnail %} + +{% block content %} +
+ +
+
+
    +

    Type de dessin

    +
  • Rect.
  • +
  • Libre
  • +
+ +
    +

    Actions

    + +
  • Effacer
  • + +
  • Créer le fragment
  • +
+
+ +
+
+ {% thumbnail annotation.image.media "x800" crop="center" as im %} + + {% endthumbnail %} +
+
+ +
+ +
+ +
+
+ {% thumbnail annotation.image.media "x300" crop="center" as im %} + + + + + + + + + + + + + + + + + + + + + {% endthumbnail %} +
+ +
+ +
+
+ {% csrf_token %} + {{ form.as_p }} + +
+
+ +
+
+ +{% endblock %} + +{% block footer_js %} + +{% endblock %} \ No newline at end of file diff -r 13c69c2f9e5a -r 91e7f0429e4f src/iconolab/templates/iconolab/show_annotation.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/iconolab/templates/iconolab/show_annotation.html Thu Jun 16 12:26:13 2016 +0200 @@ -0,0 +1,56 @@ +{% extends 'iconolab_base.html' %} + +{% load staticfiles %} + +{% load thumbnail %} + +{% block content %} +
+ +
+ +
+
+ {% thumbnail annotation.image.media "x300" crop="center" as im %} + + + + + + + + + + + + + + + + + + + + + {% endthumbnail %} +
+ +
+ +
+ title: {{ annotation.title }} + Description: {{ annotation.description }} + Tags: {{ annotation.tags }} + + Editer + Proposer une révision +
+
+
+ +{% endblock %} diff -r 13c69c2f9e5a -r 91e7f0429e4f src/iconolab/urls.py --- a/src/iconolab/urls.py Wed Jun 15 18:43:42 2016 +0200 +++ b/src/iconolab/urls.py Thu Jun 16 12:26:13 2016 +0200 @@ -25,7 +25,7 @@ urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^home', views.index, name="home"), - url(r'^annotation/(?P[0-9]+)/$', views.detail_annotation, name='annotation_detail'), + url(r'^annotation/(?P[0-9]+)/$', views.show_annotation, name='annotation_show'), url(r'^annotation/(?P[0-9]+)/fragment', views.draw_fragment, name='annotation_fragment'), url(r'^annotation/create', views.create_annotation, name='annotation_create'), url(r'^annotation/(?P[0-9]+)/edit', views.edit_annotation, name='annotation_edit'), diff -r 13c69c2f9e5a -r 91e7f0429e4f src/iconolab/views.py --- a/src/iconolab/views.py Wed Jun 15 18:43:42 2016 +0200 +++ b/src/iconolab/views.py Thu Jun 16 12:26:13 2016 +0200 @@ -1,7 +1,8 @@ -from django.shortcuts import HttpResponse, get_object_or_404, render +from django.shortcuts import HttpResponse, get_object_or_404, render, redirect from iconolab.models import Annotation from django.http import Http404 from django.contrib.auth.decorators import login_required +from .forms import AnnotationForm @login_required def index(request): @@ -9,18 +10,38 @@ return HttpResponse("

Home

"); -def detail_annotation(request, pk): - pass - def draw_fragment(request, pk): annotation = get_object_or_404(Annotation, pk=pk) return render(request, 'iconolab/fragment_draw.html', {'annotation': annotation}) def create_annotation(request): return render(request, 'iconolab/create_annotation.html') - # reprendre les paths - # reprendre le ratio + pass + +def show_annotation(request, pk): + annotation = get_object_or_404(Annotation, pk=pk) + return render(request, 'iconolab/show_annotation.html', {'annotation': annotation}) + + +# save annotation +# handle revision +def save_annotation(request): pass def edit_annotation(request, pk): - pass \ No newline at end of file + + #enregistrer title, description, fragment:nmz + annotation = get_object_or_404(Annotation, pk=pk) + + if request.method == 'POST': + Annotation_form = AnnotationForm(request.POST, instance=annotation) + Annotation_form = AnnotationForm() + if Annotation_form.is_valid(): + + #redirect to view + pass + else: + Annotation_form = AnnotationForm(instance = annotation) + + return render(request, 'iconolab/edit_annotation.html', {'annotation': annotation, 'form': Annotation_form }) + \ No newline at end of file