# HG changeset patch # User durandn # Date 1467902071 -7200 # Node ID 8702ab13783eceaeff95064e30539d10c87c6daa # Parent 22c88b2c325f6836c19f7e5dda1c61c0b957319d design work on templates, redirect to home on /, implemented accept and reject revisions shortcuts when applicable diff -r 22c88b2c325f -r 8702ab13783e src/iconolab/auth/views.py --- a/src/iconolab/auth/views.py Fri Jul 22 16:48:08 2016 +0200 +++ b/src/iconolab/auth/views.py Thu Jul 07 16:34:31 2016 +0200 @@ -37,7 +37,6 @@ return super(LoginView, self).get(request, *args, **kwargs) def form_valid(self, form): - print(self.request.POST) login(self.request, form.get_user()) return HttpResponseRedirect(self.get_success_url()) diff -r 22c88b2c325f -r 8702ab13783e src/iconolab/models.py --- a/src/iconolab/models.py Fri Jul 22 16:48:08 2016 +0200 +++ b/src/iconolab/models.py Thu Jul 07 16:34:31 2016 +0200 @@ -119,8 +119,12 @@ tag_count = models.IntegerField(blank=True, null=True, default=0) def contributors(self): - # returns users that submitted an accepted revision - return + contributors = [] + for revision in self.annotation.revisions.filter(state__in=[AnnotationRevision.ACCEPTED, AnnotationRevision.STUDIED]): + if revision.author not in contributors: + contributors.append(revision.author) + print(contributors) + return contributors class Annotation(models.Model): @@ -164,18 +168,27 @@ # Call when we're validating an awaiting revision whose parent is the current revision AS IT WAS CREATED @transaction.atomic def validate_existing_revision(self, revision_to_validate): - if revision_to_validate.parent_revision == current_revision: + if revision_to_validate.parent_revision == self.current_revision and revision_to_validate.state == AnnotationRevision.AWAITING: self.current_revision = revision_to_validate revision_to_validate.state = AnnotationRevision.ACCEPTED revision_to_validate.save() self.save() - + + # Call to reject a + @transaction.atomic + def reject_existing_revision(self, revision_to_reject): + if revision_to_reject.state == AnnotationRevision.AWAITING: + revision_to_reject.state = AnnotationRevision.REJECTED + revision_to_reject.save() + # Call when we're validating an awaiting revision whose parent isn't the current revision OR IF IT WAS CHANGED BY THE ANNOTATION AUTHOR @transaction.atomic def merge_existing_revision(self, title, description, fragment, tags, revision_to_merge): merged_revision = self.make_new_revision(author=self.author, title=title, description=description, fragment=fragment, tags=tags) merged_revision.merge_parent_revision = revision_to_merge merged_revision.save() + revision_to_merge.state = AnnotationRevision.STUDIED + revision_to_merge.save() self.current_revision=merged_revision self.save() @@ -185,11 +198,13 @@ AWAITING = 0 ACCEPTED = 1 REJECTED = 2 + STUDIED = 3 REVISION_STATES = ( (AWAITING, 'awaiting'), (ACCEPTED, 'accepted'), - (REJECTED, 'rejected') + (REJECTED, 'rejected'), + (STUDIED, 'studied'), ) revision_guid = models.UUIDField(default=uuid.uuid4) diff -r 22c88b2c325f -r 8702ab13783e src/iconolab/settings/__init__.py --- a/src/iconolab/settings/__init__.py Fri Jul 22 16:48:08 2016 +0200 +++ b/src/iconolab/settings/__init__.py Thu Jul 07 16:34:31 2016 +0200 @@ -94,6 +94,7 @@ 'django.contrib.messages.context_processors.messages', 'django.core.context_processors.media', 'django.core.context_processors.static', + 'django.core.context_processors.i18n', 'iconolab.utils.context_processors.notifications', ], }, @@ -136,8 +137,6 @@ # Internationalization # https://docs.djangoproject.com/en/1.9/topics/i18n/ -LANGUAGE_CODE = 'en-us' - TIME_ZONE = 'UTC' USE_I18N = True diff -r 22c88b2c325f -r 8702ab13783e src/iconolab/static/iconolab/css/iconolab.css --- a/src/iconolab/static/iconolab/css/iconolab.css Fri Jul 22 16:48:08 2016 +0200 +++ b/src/iconolab/static/iconolab/css/iconolab.css Thu Jul 07 16:34:31 2016 +0200 @@ -6,3 +6,47 @@ .form-drawing-wrapper .selected {border: 1px solid orange; color: white; background-color: orange} .showPointer {cursor: pointer;} + +.annotation-content{ + margin-top: 15px; + margin-bottom: 15px; +} + +.collection-home-btn{ + margin-top: 5px; +} + +.revision-link:hover{ + text-decoration: underline; +} + +.item-image-thumbnail:hover{ + cursor: pointer; +} + +ul.annotation-comments{ + background-color: #ededed; +} +li.list-group-item{ + border: 1px solid #bbb +} + +.comment-reply-link{ + cursor: pointer; +} +.comment-subtext{ + font-size:0.9em; + display:inline; +} +.comment-metacategories{ + font-size:0.9em; + display:inline; +} +.comment-separator{ + margin-top: 10px; + margin-bottom: 5px; +} + +.pagination-shortcut{ + cursor: pointer; +} \ No newline at end of file diff -r 22c88b2c325f -r 8702ab13783e src/iconolab/templates/iconolab/change_annotation.html --- a/src/iconolab/templates/iconolab/change_annotation.html Fri Jul 22 16:48:08 2016 +0200 +++ b/src/iconolab/templates/iconolab/change_annotation.html Thu Jul 07 16:34:31 2016 +0200 @@ -31,7 +31,7 @@
- {% thumbnail image.media "x800" crop="center" as im %} + {% thumbnail image.media "835x835" crop=False as im %} @@ -50,12 +50,9 @@
- {% thumbnail image.media "x300" crop="center" as im %} - - - + {% thumbnail image.media "500x360" crop=False as im %} + - @@ -149,9 +146,10 @@ id="id_{{ form.comment.name }}" > - - Retour - + + Retour +

+
diff -r 22c88b2c325f -r 8702ab13783e src/iconolab/templates/iconolab/detail_annotation.html --- a/src/iconolab/templates/iconolab/detail_annotation.html Fri Jul 22 16:48:08 2016 +0200 +++ b/src/iconolab/templates/iconolab/detail_annotation.html Thu Jul 07 16:34:31 2016 +0200 @@ -14,7 +14,7 @@
- {% thumbnail annotation.image.media "x300" crop="center" as im %} + {% thumbnail annotation.image.media "300x300" crop=False as im %} @@ -27,24 +27,31 @@ {% endthumbnail %}
-

+

-
-

Annotation créée par {{ annotation.author.username }}

- -

Title: {{ annotation.current_revision.title }}

-

Description: {{ annotation.current_revision.description }}

-

Tags:

- - {% if user == annotation.author %}Editer{% else %}Proposer une révision{% endif %} - -
+
+

Annotation créée par {{ annotation.author.username }}

+

Titre: {{ annotation.current_revision.title }}

+

Description: {{ annotation.current_revision.description }}

+

Tags:

+ + {% if user.is_authenticated %} +
+ + {% if user == annotation.author %} + Editer l'annotation + {% else %} + Proposer une révision + {% endif %} + + {% endif %} +
+ +   + {% if comments.has_previous or comments.has_next %} +
    + {% if comments.has_previous %} +
  • + + + +
  • + {% endif %} + + {% for page in comments.paginator.page_range %} + + + + + + {% endfor %} + + {% if comments.has_next %} +
  • + + + +
  • + {% endif %} +
+ {% endif %} +
+ +
{% if user.is_authenticated %} {% if not comment_form %} @@ -103,11 +183,21 @@ {{ comment_form.object_pk }} {{ comment_form.timestamp }} {{ comment_form.security_hash }} - {{ comment_form.reply_to }} +

Commenter en tant que {{user.username}}

+
+ +
+

+
+
+
+
+ Annuler et répondre sur le fil principal

+
- + {% if comment_form.comment.errors %} {% endblock %} @@ -166,5 +256,27 @@ 'Zoomview': iconolab.VueComponents.Zoomview } }); + + $(".reply-to-container").hide() + $(".reply-to-btn").click(function(event){ + $(".reply-to-container").hide() + var commentID = /reply\-to\-([0-9]+)/.exec($(this).attr("id"))[1]; + var comment_content = $("#c"+commentID+"-content").html(); + var comment_subtext = $("#c"+commentID+"-subtext").html(); + var comment_labels = $("#c"+commentID+"-label-list").html(); + $(".reply-to-alert .reply-to-content").html(comment_content); + $(".reply-to-alert .reply-to-subtext").html(comment_subtext); + $(".reply-to-alert .reply-to-label-list").html(comment_labels); + $(".reply-to-container").slideDown(); + $("#form-reply-to-label").get(0).scrollIntoView(); + $("#reply-to-field").val(commentID); + }) + $(".reply-to-cancel").click(function(event){ + $(".reply-to-container").hide() + $(".reply-to-alert .reply-to-content").html(""); + $(".reply-to-alert .reply-to-subtext").html(""); + $(".reply-to-alert .reply-to-label-list").html(""); + $("#reply-to-field").val("0"); + }) {% endblock %} \ No newline at end of file diff -r 22c88b2c325f -r 8702ab13783e src/iconolab/templates/iconolab/detail_revision.html --- a/src/iconolab/templates/iconolab/detail_revision.html Fri Jul 22 16:48:08 2016 +0200 +++ b/src/iconolab/templates/iconolab/detail_revision.html Thu Jul 07 16:34:31 2016 +0200 @@ -8,25 +8,26 @@ {% load iconolab_tags %} {% block content %} - Revoir l'image
- -
+ {% if not user.is_authenticated and revision.state != 1 %} +

Connectez vous pour voir cette proposition de révision.

+ {% else %} +
{% thumbnail image.media "x300" crop="center" as im %} - - - - {% endthumbnail %}
+
+ Revoir l'image
+ Retour sur l'annotation
+ {% if revision.parent_revision %} Voir révision précédente
{% endif %}

Annotation révisée par {{ revision.author.username}}

@@ -34,16 +35,39 @@

Description: {{ revision.description }}

Tags:

+
- Retour sur l'annotation - {% if revision.parent_revision %} | Voir révision précédente{% endif %} -
+ {% if revision.state == 0 and user == annotation.author %} +
+
+ {% if revision.parent_revision == annotation.current_revision %} + + {% endif %} + + +


+ + {% if revision.parent_revision == annotation.current_revision %} +
Si vous acceptez cette proposition, elle deviendra automatiquement la version courante de l'annotation.

+ Valider +
+ {% endif %} +
Attention: l'action de rejeter une proposition est irréversible.

+ Valider +
+
En étudiant la révision, vous accédez à une interface qui vous permet notamment de comparer la proposition avec la version courante de l'annotation avant d'en accepter tout ou partie.

+ Valider +
+ {% endif %} + +
+ {% endif %} {% endblock %} {% block footer_js %} @@ -53,5 +77,24 @@ components: {'Typeahead': iconolab.VueComponents.Typeahead }, methods: { yo: function(){alert(1);} } }); + $(".alert-merge").hide(); + $("#accept-revision").click(function(){ + if($("#accept-info").is(":hidden")){ + $(".alert-merge").hide(); + $("#accept-info").slideDown(); + } + }); + $("#merge-revision").click(function(){ + if($("#merge-info").is(":hidden")){ + $(".alert-merge").hide(); + $("#merge-info").slideDown(); + } + }); + $("#reject-revision").click(function(){ + if($("#reject-info").is(":hidden")){ + $(".alert-merge").hide(); + $("#reject-info").slideDown(); + } + }) {% endblock %} diff -r 22c88b2c325f -r 8702ab13783e src/iconolab/templates/iconolab/home.html --- a/src/iconolab/templates/iconolab/home.html Fri Jul 22 16:48:08 2016 +0200 +++ b/src/iconolab/templates/iconolab/home.html Thu Jul 07 16:34:31 2016 +0200 @@ -1,11 +1,15 @@ {% extends 'iconolab_base.html' %} +{% load i18n %} {% load staticfiles %} - {% load thumbnail %} - {% load iconolab_tags %} {% block content %}

Fond Ingres

+ +{% get_current_language as LANGUAGE_CODE %} +{% get_available_languages as LANGUAGES %} +{% get_current_language_bidi as LANGUAGE_BIDI %} +the current language is {{ LANGUAGE_CODE }} {% endblock %} \ No newline at end of file diff -r 22c88b2c325f -r 8702ab13783e src/iconolab/templates/iconolab_base.html --- a/src/iconolab/templates/iconolab_base.html Fri Jul 22 16:48:08 2016 +0200 +++ b/src/iconolab/templates/iconolab_base.html Thu Jul 07 16:34:31 2016 +0200 @@ -9,6 +9,7 @@ {% block main_js %} + {% endblock %} {% block page_js %} {% endblock %} diff -r 22c88b2c325f -r 8702ab13783e src/iconolab/templates/partials/image_annotations_list.html --- a/src/iconolab/templates/partials/image_annotations_list.html Fri Jul 22 16:48:08 2016 +0200 +++ b/src/iconolab/templates/partials/image_annotations_list.html Thu Jul 07 16:34:31 2016 +0200 @@ -23,9 +23,14 @@ {% endthumbnail %}
Voir -

Créee par {{ annotation.author }}

-

Révisée par {{ annotation.current_revision.author }} - le {{ annotation.current_revision.created|date:'d-m-Y' }} +

Créee par {{ annotation.author }}, dernière révision le {{ annotation.current_revision.created|date:'d-m-Y' }}

+

Contributeurs: + {% for contributor in annotation.stats.contributors %} + {% if not forloop.last %} + + {% endif %} + {{ contributor }}{% if not forloop.last %}, {% endif %} + {% endfor %}

diff -r 22c88b2c325f -r 8702ab13783e src/iconolab/urls.py --- a/src/iconolab/urls.py Fri Jul 22 16:48:08 2016 +0200 +++ b/src/iconolab/urls.py Thu Jul 07 16:34:31 2016 +0200 @@ -13,6 +13,7 @@ 1. Import the include() function: from django.conf.urls import url, include 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls')) """ +from django.core.urlresolvers import reverse_lazy from django.conf.urls import url, include from django.contrib import admin from . import views @@ -23,6 +24,7 @@ from django.contrib.staticfiles.urls import staticfiles_urlpatterns urlpatterns = [ + url(r'^$', views.RedirectView.as_view(url=reverse_lazy("home"))), url(r'^admin/', admin.site.urls), url(r'^home$', views.GlobalHomepageView.as_view(), name="home"), url(r'^collections/(?P[a-z]+)$', views.CollectionHomepageView.as_view(), name='collection_home'), # Home fond diff -r 22c88b2c325f -r 8702ab13783e src/iconolab/views.py --- a/src/iconolab/views.py Fri Jul 22 16:48:08 2016 +0200 +++ b/src/iconolab/views.py Thu Jul 07 16:34:31 2016 +0200 @@ -341,7 +341,33 @@ 'revision_guid': revision.revision_guid } ) - ) + )(request) + # Auto-accepts the revision only if the proper query arg is set and only if the revision parent is the current revision + if "auto_accept" in request.GET and request.GET["auto_accept"] in ["True", "true", "1", "yes"] and revision.parent_revision == annotation.current_revision: + annotation.validate_existing_revision(revision) + return RedirectView.as_view( + url=reverse('annotation_detail', + kwargs={ + 'collection_name': collection.name, + 'image_guid': image.image_guid, + 'annotation_guid': annotation.annotation_guid + } + ) + )(request) + # Auto-reject the revision only if the proper query arg is set + print(request.GET) + if "auto_reject" in request.GET and request.GET["auto_reject"] in ["True", "true", "1", "yes"]: + annotation.reject_existing_revision(revision) + return RedirectView.as_view( + url=reverse('annotation_detail', + kwargs={ + 'collection_name': collection.name, + 'image_guid': image.image_guid, + 'annotation_guid': annotation.annotation_guid + } + ) + )(request) + context = self.get_context_data(**kwargs) context['collection'] = collection context['image'] = image