<commit_before>{% extends "base.html" %}
{% load i18n %}
{% load staticfiles %}
{% load wger_extras %}
{% load cache %}
{% load thumbnail %}

<!--
        Title
-->
{% block title %}{% trans "Exercises" %}{% endblock %}



{% block header %}
<script src="{% static 'js/tinymce/tinymce.min.js' %}"></script>
<script>

function custom_modal_init()
{
    init_tinymce();
}

$(document).ready(function() {

    $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {


        console.log(e.target);
        var category_id = $(e.target).attr('id').match(/\d+/);
        console.log(category_id);
        $(".current-category-name").html($("#category-" + category_id).text());
        $("#current-category-edit").attr("href", "/exercise/category/" + category_id + "/edit/");
        $("#current-category-delete").attr("href", "/exercise/category/" + category_id + "/delete/");
    })


    // Prevent the form from being submited if JavaScript is enabled
    $("#exercise_search_form").submit(function() {return false;});

    // Init the autocompleter
    $("#exercise-search").catcomplete({
            source: "{% url 'wger.exercises.views.exercises.search' %}",
            minLength: 2,
            select: function(event, ui) {

                // Redirect to exercise after clicking on a result
                // Path is hard coded here, because we can't use the url-tag
                window.location.href = '/exercise/' + ui.item.id + '/view/'
            }
        });
});
</script>
{% endblock %}


<!--
        Main Content
-->
{% block content %}

{% cache cache_timeout exercise-overview language.id %}
{% regroup exercises by category as exercise_list %}
<ul class="nav nav-tabs">
    {% for item in exercise_list %}
    <li {% if forloop.first %}class="active"{% endif %}>
        <a href="#tab-{{ item.grouper.id }}" id="category-{{ item.grouper.id }}" data-toggle="tab">{% trans item.grouper.name %}</a>
    </li>
    {% empty %}
        <li>{% trans "No categories." %} {% trans "Use link to create one" %}</li>
    {% endfor %}
</ul>

<div class="tab-content">
    {% for item in exercise_list %}
    <div class="tab-pane {% if forloop.first %}active{% endif %}" id="tab-{{ item.grouper.id }}">
        <div class="list-group">
        {% for exercise in item.list %}
            <a href="{{ exercise.get_absolute_url }}" class="list-group-item">
            <div class="row">
                <div class="col-md-1">
                    {% if exercise.main_image %}
                    <span class="pull-left" style="width:60px;height:60px;">
                    <img src="{{ exercise.main_image.image|thumbnail_url:'thumbnail' }}"
                         alt=""
                         style="max-width:100%; max-height:100%;">
                    </span>
                    {% endif %}
                </div>
                <div class="col-md-10" >
                    {{ exercise.name }}
                </div>
            </div>
            </a>
        {% empty %}
            <a href="#" class="list-group-item">
                <div class="col-md-offset-1 col-md-10" >
                    {% trans "No exercises in this category. Add or edit an exercise and set its category" %}
                </div>
            </a>
        {% endfor %}
        </div>
    </div>
    {% endfor %}
</div>


{% endcache %}
<commit_msg>Sort exercises by name in the overview<commit_after>{% extends "base.html" %}
{% load i18n %}
{% load staticfiles %}
{% load wger_extras %}
{% load cache %}
{% load thumbnail %}

<!--
        Title
-->
{% block title %}{% trans "Exercises" %}{% endblock %}



{% block header %}
<script src="{% static 'js/tinymce/tinymce.min.js' %}"></script>
<script>

function custom_modal_init()
{
    init_tinymce();
}

$(document).ready(function() {

    $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {


        console.log(e.target);
        var category_id = $(e.target).attr('id').match(/\d+/);
        console.log(category_id);
        $(".current-category-name").html($("#category-" + category_id).text());
        $("#current-category-edit").attr("href", "/exercise/category/" + category_id + "/edit/");
        $("#current-category-delete").attr("href", "/exercise/category/" + category_id + "/delete/");
    })


    // Prevent the form from being submited if JavaScript is enabled
    $("#exercise_search_form").submit(function() {return false;});

    // Init the autocompleter
    $("#exercise-search").catcomplete({
            source: "{% url 'wger.exercises.views.exercises.search' %}",
            minLength: 2,
            select: function(event, ui) {

                // Redirect to exercise after clicking on a result
                // Path is hard coded here, because we can't use the url-tag
                window.location.href = '/exercise/' + ui.item.id + '/view/'
            }
        });
});
</script>
{% endblock %}


<!--
        Main Content
-->
{% block content %}

{% cache cache_timeout exercise-overview language.id %}
{% regroup exercises by category as exercise_list %}
<ul class="nav nav-tabs">
    {% for item in exercise_list %}
    <li {% if forloop.first %}class="active"{% endif %}>
        <a href="#tab-{{ item.grouper.id }}" id="category-{{ item.grouper.id }}" data-toggle="tab">{% trans item.grouper.name %}</a>
    </li>
    {% empty %}
        <li>{% trans "No categories." %} {% trans "Use link to create one" %}</li>
    {% endfor %}
</ul>

<div class="tab-content">
    {% for item in exercise_list %}
    <div class="tab-pane {% if forloop.first %}active{% endif %}" id="tab-{{ item.grouper.id }}">
        <div class="list-group">
        {% for exercise in item.list|dictsort:"name" %}
            <a href="{{ exercise.get_absolute_url }}" class="list-group-item">
            <div class="row">
                <div class="col-md-1">
                    {% if exercise.main_image %}
                    <span class="pull-left" style="width:60px;height:60px;">
                    <img src="{{ exercise.main_image.image|thumbnail_url:'thumbnail' }}"
                         alt=""
                         style="max-width:100%; max-height:100%;">
                    </span>
                    {% endif %}
                </div>
                <div class="col-md-10" >
                    {{ exercise.name }}
                </div>
            </div>
            </a>
        {% empty %}
            <a href="#" class="list-group-item">
                <div class="col-md-offset-1 col-md-10" >
                    {% trans "No exercises in this category. Add or edit an exercise and set its category" %}
                </div>
            </a>
        {% endfor %}
        </div>
    </div>
    {% endfor %}
</div>


{% endcache %}

{'fraction_non_alphanumeric': 0.18567403232982352, 'fraction_numerical': 0.005635473824707104, 'mean_word_length': 2.0093708165997324, 'pattern_counts': {'":': 0, '<': 73, '<?xml version=': 0, '>': 73, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6338003', 'n_tokens_mistral': 2201, 'n_tokens_neox': 1978, 'n_words': 460}