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)
--- 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()}}
<li><a class="navbar-decorative">></a></li>
- <li class="active"><a>Discussion: changements</a></li>
+ <li><a href="{{ url_for('social.changesets_index', repository=current_repository)}}">Changements</a></li>
+ <li><a class="navbar-decorative">></a></li>
+ <li class="active"><a>Discussion</a></li>
{% endblock navbar_items %}
{% block additional_content %}
+<h3><b>Changements:</b> {{comments["title"]}}</h3>
<div class="container changeset-menu">
<div class="col-md-4 before-box alert">
<h4><strong>Avant modifications </strong>
@@ -174,13 +181,78 @@
</h4>
</li>
{% for modified_category in differences["modifications"] %}
- <li class="list-group-item">
+ <li class="list-group-item {% if modified_category[2] == changes_details['cat_id'] %}list-group-item-warning{% endif %}">
{{ modified_category[0] }}
<span class="glyphicon glyphicon-chevron-right"></span>
{{ modified_category[1] }}
- <a class="btn btn-default" href="#">
+ {% if modified_category[2] != changes_details["cat_id"] %}
+ <a class="btn btn-default" href="{{url_for('social.changeset', repository=current_repository, changeset_id=changeset_id, details_cat_id=modified_category[2])}}">
<span class="glyphicon glyphicon-log-in"></span>
</a>
+ {% else %}
+ <br>
+ <br>
+ {% if changes_details["only_in_first"]|length > 0 %}
+ <p class="text-danger">Propriétés présentes uniquement dans la version précédente:
+ <dl class="dl-horizontal text-danger">
+ {% for change in changes_details["only_in_first"] %}
+ {% if change[0] == "description" %}
+ <dt>Description</dt>
+ <dd>{{ change[1] }}</dd>
+ {% elif change[0] == "label" %}
+ <dt>Label</dt>
+ <dd>{{ change[1] }}</dd>
+ {% else %}
+ <dt>{{ config["PROPERTY_LIST"][change[0]]["descriptive_label_fr"] }}</dt>
+ <dd>
+ {% 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" %}
+ <a href="{{ change[1] }}">{{ change[1] }}</a>
+ {% else %}
+ {{ change[1] }}
+ {% endif %}
+ </dd>
+ {% endif %}
+ {% endfor %}
+ </dl>
+ </p>
+ {% endif %}
+ {% if changes_details["only_in_second"]|length > 0 %}
+ <p class="text-success">Propriétés présentes uniquement dans la nouvelle version:
+ <dl class="dl-horizontal text-success">
+ {% for change in changes_details["only_in_second"] %}
+ {% if change[0] == "description" %}
+ <dt>Description</dt>
+ <dd>{{ change[1] }}</dd>
+ {% elif change[0] == "label" %}
+ <dt>Label</dt>
+ <dd>{{ change[1] }}</dd>
+ {% else %}
+ <dt>{{ config["PROPERTY_LIST"][change[0]]["descriptive_label_fr"] }}</dt>
+ <dd>
+ {% 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" %}
+ <a href="{{ change[1] }}">{{ change[1] }}</a>
+ {% else %}
+ {{ change[1] }}
+ {% endif %}
+ </dd>
+ {% endif %}
+ {% endfor %}
+ </dl>
+ </p>
+ {% endif %}
+ {% endif %}
</li>
{% endfor %}
<li class="list-group-item list-group-item-danger">
--- 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 @@
<li><a class="navbar-decorative">></a></li>
<li><a href="{{ url_for('categories.workshop', repository=current_repository) }}">Atelier</a></li>
<li><a class="navbar-decorative">></a></li>
- <li class="active"><a>Social</a></li>
+ <li class="active"><a>Changements</a></li>
{% endif %}
{% endblock navbar_items %}
{% block repo_list %}
--- 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) }}
</div>
<button type="submit" class="btn btn-default">Envoyer commentaire</button>
- <a href="{% block back_url %}{% endblock %}"class="btn btn-default">Retour</a>
+ <a href="{% block back_link %}{% endblock %}"class="btn btn-default">Retour</a>
</fieldset>
</form>
</td>
--- 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()}}
<li><a class="navbar-decorative">></a></li>
+ <li><a href="{{ url_for('social.discussions_index', repository=current_repository)}}">Social</a></li>
+ <li><a class="navbar-decorative">></a></li>
<li class="active"><a>Discussion</a></li>
{% endblock navbar_items %}
{% block comment_posting_target %}{{url_for("social.discussion", discussion_id=discussion_id, repository=current_repository)}}{% endblock %}
--- 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
--- 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("/<string:repository>/changesets/<string:changeset_id>",
methods=["GET", "POST"],
- defaults={"per_page": 10, "page": 1})
+ defaults={"per_page": 10, "page": 1, "details_cat_id": None})
@module.route(
"/<string:repository>/changesets/<string:changeset_id>"
+ "/page/<int:page>-per_page-<int:per_page>",
+ defaults={"details_cat_id": None},
methods=["GET", "POST"]
)
-def changeset(repository, changeset_id, per_page, page):
+@module.route("/<string:repository>/changesets/"
+ + "<string:changeset_id>/details_<string:details_cat_id>",
+ methods=["GET", "POST"],
+ defaults={"per_page": 10, "page": 1})
+@module.route("/<string:repository>/changesets/"
+ + "<string:changeset_id>/page/<int:page>-"
+ + "per_page-<int:per_page>-details_<string:details_cat_id>",
+ 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,