Skip to content

Commit

Permalink
Grise les boutons de comparaisons de versions si elles sont identiques
Browse files Browse the repository at this point in the history
Fix #6105
  • Loading branch information
philippemilink committed Oct 2, 2021
1 parent 01ee0fa commit 286bdcc
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 16 deletions.
57 changes: 42 additions & 15 deletions templates/tutorialv2/view/content.html
Original file line number Diff line number Diff line change
Expand Up @@ -498,27 +498,54 @@ <h2>
{# END ONLINE VERSION #}

{% if content.sha_public %}
<li>
<a href="{% url "content:diff" content.pk content.slug_repository %}?from={{ content.sha_public }}&amp;to={% if version %}{{ version }}{% else %}{{ content.sha_draft }}{% endif %}" class="ico-after history blue">
{% trans "Comparer avec la version en ligne" %}
</a>
</li>
{# interpreted as: (version and (content.sha_public != version)) or ((not version) and (content.sha_public != content.sha_draft)) #}
{% if version and content.sha_public != version or not version and content.sha_public != content.sha_draft %}
<li>
<a href="{% url "content:diff" content.pk content.slug_repository %}?from={{ content.sha_public }}&amp;to={% if version %}{{ version }}{% else %}{{ content.sha_draft }}{% endif %}" class="ico-after history blue">
{% trans "Comparer avec la version en ligne" %}
</a>
</li>
{% else %}
<li class="inactive">
<span class="ico-after history disabled">
{% trans "Comparer avec la version en ligne (identique)" %}
</a>
</li>
{% endif %}
{% endif %}

{% if content.sha_beta %}
<li>
<a href="{% url "content:diff" content.pk content.slug_repository %}?from={{ content.sha_beta }}&amp;to={% if version %}{{ version }}{% else %}{{ content.sha_draft }}{% endif %}" class="ico-after history blue">
{% trans "Comparer avec la bêta" %}
</a>
</li>
{# interpreted as: (version and (content.sha_beta != version)) or ((not version) and (content.sha_beta != content.sha_draft)) #}
{% if version and content.sha_beta != version or not version and content.sha_beta != content.sha_draft %}
<li>
<a href="{% url "content:diff" content.pk content.slug_repository %}?from={{ content.sha_beta }}&amp;to={% if version %}{{ version }}{% else %}{{ content.sha_draft }}{% endif %}" class="ico-after history blue">
{% trans "Comparer avec la bêta" %}
</a>
</li>
{% else %}
<li class="inactive">
<span class="ico-after history disabled">
{% trans "Comparer avec la bêta (identique)" %}
</a>
</li>
{% endif %}
{% endif %}

{% if content.in_validation %}
<li>
<a href="{% url "content:diff" content.pk content.slug_repository %}?from={{ validation.version }}&amp;to={% if version %}{{ version }}{% else %}{{ content.sha_draft }}{% endif %}" class="ico-after history blue">
{% trans "Comparer avec la version en validation" %}
</a>
</li>
{# interpreted as: (version and (validation.version != version)) or ((not version) and (validation.version != content.sha_draft)) #}
{% if version and validation.version != version or not version and validation.version != content.sha_draft %}
<li>
<a href="{% url "content:diff" content.pk content.slug_repository %}?from={{ validation.version }}&amp;to={% if version %}{{ version }}{% else %}{{ content.sha_draft }}{% endif %}" class="ico-after history blue">
{% trans "Comparer avec la version en validation" %}
</a>
</li>
{% else %}
<li class="inactive">
<span class="ico-after history disabled">
{% trans "Comparer avec la version en validation (identique)" %}
</a>
</li>
{% endif %}
{% endif %}

{# HISTORY #}
Expand Down
2 changes: 1 addition & 1 deletion zds/tutorialv2/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def get_context_data(self, **kwargs):

class SingleContentDetailViewMixin(SingleContentViewMixin, DetailView):
"""
This enhanced DetailView ensure,
This enhanced DetailView ensures,
- by rewriting `get()`, that:
* `self.object` contains the result of `get_object()` (as it must be if `get()` is not rewritten)
Expand Down

0 comments on commit 286bdcc

Please sign in to comment.