# HG changeset patch # User Nicolas DURAND # Date 1425384278 -3600 # Node ID 353e246a8f59b01ae95b32f760465a26f5008dc2 # Parent ddba4624d66117ba8a01fac49499a249f0065f1a Added support for detailing changes on changeset pages: when a category is classified as "modified", user can show what exactly was modified for this category (added and deleted properties) diff -r ddba4624d661 -r 353e246a8f59 src/catedit/templates/social/changeset.html --- a/src/catedit/templates/social/changeset.html Mon Mar 02 14:39:22 2015 +0100 +++ b/src/catedit/templates/social/changeset.html Tue Mar 03 13:04:38 2015 +0100 @@ -12,7 +12,11 @@ $(document).ready(function(){ $(".cat-info-div").hide(); $(".cat-table").hide(); - + {% if changes_details %} + $(".changes-table").show() + $(".changes-table-toggle").toggleClass("btn-info") + $(".changes-box").toggleClass("alert-info"); + {% endif %} $(".before-cat-table-toggle").click(function(evt){ $(".before-cat-table-toggle").toggleClass("btn-info") $(".before-box").toggleClass("alert-info"); @@ -89,9 +93,12 @@ {% block navbar_items %} {{super()}}
  • >
  • -
  • Discussion: changements
  • +
  • Changements
  • +
  • >
  • +
  • Discussion
  • {% endblock navbar_items %} {% block additional_content %} +

    Changements: {{comments["title"]}}

    Avant modifications @@ -174,13 +181,78 @@

    {% for modified_category in differences["modifications"] %} -
  • +
  • {{ modified_category[0] }} {{ modified_category[1] }} - + {% if modified_category[2] != changes_details["cat_id"] %} + + {% else %} +
    +
    + {% if changes_details["only_in_first"]|length > 0 %} +

    Propriétés présentes uniquement dans la version précédente: +

    + {% for change in changes_details["only_in_first"] %} + {% if change[0] == "description" %} +
    Description
    +
    {{ change[1] }}
    + {% elif change[0] == "label" %} +
    Label
    +
    {{ change[1] }}
    + {% else %} +
    {{ config["PROPERTY_LIST"][change[0]]["descriptive_label_fr"] }}
    +
    + {% if config["PROPERTY_LIST"][change[0]]["object_type"]=="uriref-category" %} + {% for old_cat in old_cat_list %} + {% if change[1] == old_cat.cat_id %} + {{ old_cat.cat_label }} + {% endif %} + {% endfor %} + {% elif config["PROPERTY_LIST"][change[0]]["object_type"]=="uriref-link" %} + {{ change[1] }} + {% else %} + {{ change[1] }} + {% endif %} +
    + {% endif %} + {% endfor %} +
    +

    + {% endif %} + {% if changes_details["only_in_second"]|length > 0 %} +

    Propriétés présentes uniquement dans la nouvelle version: +

    + {% for change in changes_details["only_in_second"] %} + {% if change[0] == "description" %} +
    Description
    +
    {{ change[1] }}
    + {% elif change[0] == "label" %} +
    Label
    +
    {{ change[1] }}
    + {% else %} +
    {{ config["PROPERTY_LIST"][change[0]]["descriptive_label_fr"] }}
    +
    + {% if config["PROPERTY_LIST"][change[0]]["object_type"]=="uriref-category" %} + {% for new_cat in new_cat_list %} + {% if change[1] == new_cat.cat_id %} + {{ new_cat.cat_label }} + {% endif %} + {% endfor %} + {% elif config["PROPERTY_LIST"][change[0]]["object_type"]=="uriref-link" %} + {{ change[1] }} + {% else %} + {{ change[1] }} + {% endif %} +
    + {% endif %} + {% endfor %} +
    +

    + {% endif %} + {% endif %}
  • {% endfor %}
  • diff -r ddba4624d661 -r 353e246a8f59 src/catedit/templates/social/changesets_index.html --- a/src/catedit/templates/social/changesets_index.html Mon Mar 02 14:39:22 2015 +0100 +++ b/src/catedit/templates/social/changesets_index.html Tue Mar 03 13:04:38 2015 +0100 @@ -14,7 +14,7 @@
  • >
  • Atelier
  • >
  • -
  • Social
  • +
  • Changements
  • {% endif %} {% endblock navbar_items %} {% block repo_list %} diff -r ddba4624d661 -r 353e246a8f59 src/catedit/templates/social/comment_thread_layout.html --- a/src/catedit/templates/social/comment_thread_layout.html Mon Mar 02 14:39:22 2015 +0100 +++ b/src/catedit/templates/social/comment_thread_layout.html Tue Mar 03 13:04:38 2015 +0100 @@ -70,7 +70,7 @@ {{ comment_form.comment_field(class="form-control", readonly=readonly) }}
    - Retour + Retour diff -r ddba4624d661 -r 353e246a8f59 src/catedit/templates/social/discussion.html --- a/src/catedit/templates/social/discussion.html Mon Mar 02 14:39:22 2015 +0100 +++ b/src/catedit/templates/social/discussion.html Tue Mar 03 13:04:38 2015 +0100 @@ -11,6 +11,8 @@ {% block navbar_items %} {{super()}}
  • >
  • +
  • Social
  • +
  • >
  • Discussion
  • {% endblock navbar_items %} {% block comment_posting_target %}{{url_for("social.discussion", discussion_id=discussion_id, repository=current_repository)}}{% endblock %} diff -r ddba4624d661 -r 353e246a8f59 src/catedit/utils.py --- a/src/catedit/utils.py Mon Mar 02 14:39:22 2015 +0100 +++ b/src/catedit/utils.py Tue Mar 03 13:04:38 2015 +0100 @@ -87,7 +87,6 @@ compare_result["only_in_first"] = in_first compare_result["only_in_second"] = in_second compare_result["in_both"] = in_both - print(compare_result) return compare_result diff -r ddba4624d661 -r 353e246a8f59 src/catedit/views/social.py --- a/src/catedit/views/social.py Mon Mar 02 14:39:22 2015 +0100 +++ b/src/catedit/views/social.py Tue Mar 03 13:04:38 2015 +0100 @@ -7,7 +7,7 @@ from catedit.views.utils import check_user_status_and_repo_access, \ get_comments, post_comment, get_commits, \ get_issues, get_category_list_for_commit -from catedit.utils import make_differences_list +from catedit.utils import make_differences_list, compare_categories from flask import render_template, request, redirect, url_for, \ abort, Blueprint, session from flask_wtf import Form @@ -102,13 +102,22 @@ @module.route("//changesets/", methods=["GET", "POST"], - defaults={"per_page": 10, "page": 1}) + defaults={"per_page": 10, "page": 1, "details_cat_id": None}) @module.route( "//changesets/" + "/page/-per_page-", + defaults={"details_cat_id": None}, methods=["GET", "POST"] ) -def changeset(repository, changeset_id, per_page, page): +@module.route("//changesets/" + + "/details_", + methods=["GET", "POST"], + defaults={"per_page": 10, "page": 1}) +@module.route("//changesets/" + + "/page/-" + + "per_page--details_", + methods=["GET", "POST"]) +def changeset(repository, changeset_id, per_page, page, details_cat_id): """ View that displays a snapshot of the repository as it was for a given changeset, and the related discussion to this changeset. Allows @@ -146,7 +155,7 @@ category_differences_dict = { list_type: [ - (first_category.label, second_category.label) + (first_category.label, second_category.label, first_category.cat_id) for (first_category, second_category) in diff_list ] if list_type == "modifications" else [ category.label @@ -158,6 +167,31 @@ ).items() } + changes_details = None + print(str(details_cat_id)) + if details_cat_id is not None: + if ( + details_cat_id not in [category.cat_id + for category in old_category_list] + or + details_cat_id not in [category.cat_id + for category in new_category_list] + ): + abort(404) + else: + old_category = next( + category + for category in old_category_list + if category.cat_id == details_cat_id + ) + new_category = next( + category + for category in new_category_list + if category.cat_id == details_cat_id + ) + changes_details = compare_categories(old_category, new_category) + changes_details["cat_id"] = details_cat_id + old_category_list_template = [] for category in old_category_list: old_category_list_template.append({ @@ -183,6 +217,7 @@ old_cat_list=old_category_list_template, new_cat_list=new_category_list_template, differences=category_differences_dict, + changes_details=changes_details, comments=comments_list, changeset_id=changeset_id, comment_form=comment_form, @@ -201,7 +236,9 @@ "social.changeset", repository=repository, changeset_id=return_id, - per_page=per_page + page=1, + per_page=per_page, + changes_details=changes_details )) else: # Form didn't validate @@ -211,6 +248,7 @@ new_cat_list=new_category_list_template, comments=comments_list, changeset_id=changeset_id, + change_details=change_details, comment_form=comment_form, current_repository=repository, comments_pagination=pagination,