Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

First version of exercise overview grouped by equipment

Roland Geiderd9c69b4b0a93
diff --git a/wger/exercises/templates/equipment/overview.html b/wger/exercises/templates/equipment/overview.html
new file mode 100644
index 000000000..ebd836607
--- /dev/null
+++ b/wger/exercises/templates/equipment/overview.html
@@ -0,0 +1,234 @@
+{% extends "base.html" %}
+{% load url from future %}
+{% 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() {
+ // Init the tabs for the exercises
+ $( "#tabs" ).tabs({
+
+ // On selecting a category, set the values to edit it
+ activate: function(event, ui) {
+ category_id = ui.newTab.attr('id').match(/\d+/);
+ $(".current-category-name").html($("#cat-" + category_id).text());
+ $("#current-category-edit").attr("href", "/exercise/category/" + category_id + "/edit/");
+ $("#current-category-delete").attr("href", "/exercise/category/" + category_id + "/delete/");
+ }
+ }).addClass( "ui-tabs-vertical ui-helper-clearfix" );
+
+ // 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>
+
+<style>
+.ui-tabs-vertical {
+ width: 100%;
+ /*width: 55em;*/
+}
+.ui-tabs-vertical .ui-tabs-nav {
+ padding: .2em .1em .2em .2em;
+ float: left;
+ width: 20%;
+ /*width: 12em;*/
+}
+
+.ui-tabs-vertical .ui-tabs-nav li {
+ clear: left;
+ width: 100%;
+ border-bottom-width: 1px !important;
+ border-right-width: 0 !important;
+ margin: 0 -1px .2em 0;
+}
+
+.ui-tabs-vertical .ui-tabs-nav li a {
+ display:block;
+}
+
+.ui-tabs-vertical .ui-tabs-nav li.ui-tabs-active {
+ padding-bottom: 0;
+ padding-right: .1em;
+ border-right-width: 1px;
+ border-right-width: 1px;
+}
+
+.ui-tabs-vertical .ui-tabs-panel {
+ padding: 1em;
+ float: right;
+ width: 70%;
+ /*width: 40em;*/
+}
+</style>
+{% endblock %}
+
+
+<!--
+ Main Content
+-->
+{% block content %}
+<div id="tabs">
+ <ul>
+ {% for equipment in equipment_list %}
+ <li id="cat-{{ equipment.id }}"><a href="#cat{{ equipment.id }}">{% trans equipment.name %}</a></li>
+ {% endfor %}
+ </ul>
+
+ {% for equipment in equipment_list %}
+ <div id="cat{{ equipment.id }}">
+ <table class="narrow">
+ <tbody>
+ {% for exercise in equipment.exercise_set.all %}
+ <tr>
+ <td style="padding-left:0px;">
+ {% if exercise.main_image %}
+ <div style="width:60px;height:60px;text-align:center;float:left;">
+ <img src="{{ exercise.main_image.image|thumbnail_url:'thumbnail' }}"
+ alt=""
+ style="vertical-align:middle;max-width:100%; max-height:100%;">
+ </div>
+ {% endif %}
+
+ <a href="{{ exercise.get_absolute_url }}">
+ {{ exercise.name }}</a>
+ </td>
+ </tr>
+ {% empty %}
+ <tr>
+ <td>
+ <p>
+ {% trans "No exercises in this category. Add or edit an exercise and set its category" %}
+ </p>
+ </td>
+ </tr>
+ {% endfor %}
+ </tbody>
+ </table>
+ </div>
+ {% endfor %}
+</div>
+{% endblock %}
+
+
+<!--
+ Side bar
+-->
+{% block sidebar %}
+<h3>{% trans "Add new exercise" %}</h3>
+<p>
+ {% if user.is_authenticated and not user.userprofile.is_temporary %}
+ <a href="{% url 'exercise-add' %}">
+ <img src="{% static 'images/icons/new.svg' %}"
+ width="32"
+ height="32"
+ alt="{% trans 'Add new exercise' %}"
+ title="{% trans 'Add new exercise' %}">
+ {% trans "Add new exercise" %}
+ </a>
+ {% else %}
+ <img src="{% static 'images/icons/new.svg' %}"
+ width="32"
+ height="32"
+ alt="{% trans 'Add new exercise' %}"
+ title="{% trans 'Add new exercise' %}">
+ <span>
+ {% trans "Only registered users can do this" %}
+ </span>
+ {% endif %}
+</p>
+
+
+{% if perms.exercises %}
+ <h3>{% trans "Options" %}</h3>
+ {% if categories %}
+ <p>
+ {% with category=categories|first %}
+ <a href="{% url 'exercisecategory-edit' category.id %}"
+ class="modal-dialog"
+ id="current-category-edit">
+ <img src="{% static 'images/icons/edit.svg' %}"
+ width="32"
+ height="32"
+ alt="{% trans 'Edit category' %}"
+ title="{% trans 'Edit category' %}">
+ {% trans "Edit category" %}:
+ <span class="current-category-name">{{category.name}}</span>
+ </a>
+ </p>
+ {% endwith %}
+ <p>
+ {% with category=categories|first %}
+ <a href="{% url 'exercisecategory-delete' category.id %}"
+ class="modal-dialog"
+ id="current-category-delete">
+ <img src="{% static 'images/icons/trash.svg' %}"
+ width="32"
+ height="32"
+ alt="{% trans 'Delete category' %}"
+ title="{% trans 'Delete category' %}">
+ {% trans "Delete category" %}:
+ <span class="current-category-name">{{category.name}}</span>
+ </a>
+ {% endwith %}
+ </p>
+ {% endif %}
+
+ <p>
+ <a href="{% url 'exercisecategory-add' %}"
+ class="modal-dialog">
+ <img src="{% static 'images/icons/folder-new.svg' %}"
+ width="32"
+ height="32"
+ alt="{% trans 'Add category' %}"
+ title="{% trans 'Add category' %}">
+ {% trans "Add category" %}
+ </a>
+ </p>
+{% endif %}
+
+ <h3>{% trans "Search" %}</h3>
+
+ <div class="ui-widget">
+ <form action="{% url 'wger.exercises.views.exercises.search' %}"
+ method="get"
+ id="exercise_search_form">
+ {% csrf_token %}
+ <input name="term"
+ type="search"
+ id="exercise-search"
+ class="ajax-form-element"
+ placeholder="{% trans 'exercise name' %}"
+ style="width:100%;">
+ </form>
+ </div>
+{% endblock %}
diff --git a/wger/exercises/templates/mobile/exercise/overview.html b/wger/exercises/templates/mobile/exercise/overview.html
new file mode 100644
index 000000000..56bb2dc69
--- /dev/null
+++ b/wger/exercises/templates/mobile/exercise/overview.html
@@ -0,0 +1,139 @@
+{% extends "base.html" %}
+{% load i18n %}
+{% load staticfiles %}
+{% load wger_extras %}
+{% load thumbnail %}
+
+<!--
+ Title
+-->
+{% block title %}{% trans "Exercises" %}{% endblock %}
+
+
+<!--
+ Main Content
+-->
+{% block content %}
+
+<div data-role="collapsible-set" data-theme="c" data-content-theme="c">
+{% for category in categories %}
+ <div data-role="collapsible">
+ <h3>{% trans category.name %}</h3>
+
+ <ul data-role="listview">
+ {% for exercise in category|get_active_exercises:active_languages %}
+ <li>
+ <a href="{{ exercise.get_absolute_url }}" data-ajax="false">
+ {% if exercise.main_image.image %}
+ <img src="{{ exercise.main_image.image|thumbnail_url:'small' }}">
+ {% endif %}
+ {{ exercise.name }}</a>
+ </li>
+ {% endfor %}
+ </ul>
+ </div>
+{% endfor %}
+</div>
+{% endblock %}
+
+
+<!--
+ Side bar
+-->
+{% block sidebar %}
+<h3>{% trans "Search" %}</h3>
+<br>
+
+<ul data-role="listview"
+ data-theme="c"
+ data-filter="true"
+ data-filter-reveal="true"
+ data-inset="true"
+ data-filter-placeholder="{% trans 'exercise name' %}"
+ id="exercise_search_form">
+ {% for category in categories %}
+ {% for exercise in category|get_active_exercises:active_languages %}
+ <li>
+ <a href="{{ exercise.get_absolute_url }}" data-ajax="false">
+ {% if exercise.main_image.image %}
+ <img src="{{ exercise.main_image.image|thumbnail_url:'small' }}">
+ {% endif %}
+ {{ exercise.name }}</a>
+ </li>
+ {% endfor %}
+ {% endfor %}
+</ul>
+
+
+<h3>{% trans "Add new exercise" %}</h3>
+<p>
+ {% if user.is_authenticated and not user.userprofile.is_temporary %}
+ <a href="{% url 'exercise-add' %}" data-role="button">
+ <img src="{% static 'images/icons/new.svg' %}"
+ width="32"
+ height="32"
+ alt="{% trans 'Add new exercise' %}"
+ title="{% trans 'Add new exercise' %}">
+ {% trans "Add new exercise" %}
+ </a>
+ {% else %}
+ <span data-role="button" class="ui-disabled">
+ <img src="{% static 'images/icons/new.svg' %}"
+ width="32"
+ height="32"
+ alt="{% trans 'Add new exercise' %}"
+ title="{% trans 'Add new exercise' %}">
+ {% trans "Only registered users can do this" %}
+ </span>
+ {% endif %}
+</p>
+
+
+{% if perms.exercises %}
+ <h3>{% trans "Options" %}</h3>
+ {% if categories %}
+ <p>
+ {% with category=categories|first %}
+ <a href="{% url 'exercisecategory-edit' category.id %}"
+ data-role="button"
+ id="current-category-edit">
+ <img src="{% static 'images/icons/edit.svg' %}"
+ width="32"
+ height="32"
+ alt="{% trans 'Edit category' %}"
+ title="{% trans 'Edit category' %}">
+ {% trans "Edit category" %}:
+ <span class="current-category-name">{{category.name}}</span>
+ </a>
+ </p>
+ {% endwith %}
+ <p>
+ {% with category=categories|first %}
+ <a href="{% url 'exercisecategory-delete' category.id %}"
+ data-role="button"
+ id="current-category-delete">
+ <img src="{% static 'images/icons/trash.svg' %}"
+ width="32"
+ height="32"
+ alt="{% trans 'Delete category' %}"
+ title="{% trans 'Delete category' %}">
+ {% trans "Delete category" %}:
+ <span class="current-category-name">{{category.name}}</span>
+ </a>
+ {% endwith %}
+ </p>
+ {% endif %}
+
+ <p>
+ <a href="{% url 'exercisecategory-add' %}"
+ data-role="button">
+ <img src="{% static 'images/icons/folder-new.svg' %}"
+ width="32"
+ height="32"
+ alt="{% trans 'Add category' %}"
+ title="{% trans 'Add category' %}">
+ {% trans "Add category" %}
+ </a>
+ </p>
+{% endif %}
+{% endblock %}
diff --git a/wger/exercises/urls.py b/wger/exercises/urls.py
index 8c45c9f07..8f58fd892 100644
--- a/wger/exercises/urls.py
+++ b/wger/exercises/urls.py
@@ -102,5 +102,8 @@ urlpatterns = patterns('wger.exercises.views',
url(r'^equipment/(?P<pk>\d+)/delete$',
equipment.EquipmentDeleteView.as_view(),
name='equipment-delete'),
+ url(r'^equipment/overview$',
+ equipment.EquipmentOverviewView.as_view(),
+ name='equipment-overview'),
)
diff --git a/wger/exercises/views/equipment.py b/wger/exercises/views/equipment.py
index 1216c4e28..3be4d2c35 100644
--- a/wger/exercises/views/equipment.py
+++ b/wger/exercises/views/equipment.py
@@ -113,3 +113,13 @@ class EquipmentDeleteView(WgerDeleteMixin, DeleteView, WgerPermissionMixin):
kwargs={'pk': pk})
return context
+
+
+class EquipmentOverviewView(WgerPermissionMixin, ListView):
+ '''
+ Overview with all exercises, group by equipment
+ '''
+
+ model = Equipment
+ template_name = 'equipment/overview.html'
+ context_object_name = 'equipment_list'
diff --git a/wger/manager/templates/navigation.html b/wger/manager/templates/navigation.html
index 53c5ed067..5839d1b7e 100644
--- a/wger/manager/templates/navigation.html
+++ b/wger/manager/templates/navigation.html
@@ -43,6 +43,7 @@
<ul class="dropdown-menu">
<li><a href="{% url 'exercise-overview' %}">{% trans "Exercises" %}</a></li>
<li><a href="{% url 'muscle-overview' %}">{% trans "Muscle overview" %}</a></li>
+ <li><a href="{% url 'equipment-overview' %}">{% trans "Equipment overview" %}</a></li>
{% if user.is_authenticated and not user.userprofile.is_temporary %}
<li><a href="{% url 'exercise-add' %}">{% trans "Add new exercise" %}</a><li>
{% endif %}