Self hosted FLOSS fitness/workout, nutrition and weight tracker
New License model to use for exercises, ingredients, etc.
Roland Geiderb13711d82237
diff --git a/extras/scripts/filter-fixtures.py b/extras/scripts/filter-fixtures.pyindex 3f5398004..2bf2a5ff1 100644--- a/extras/scripts/filter-fixtures.py+++ b/extras/scripts/filter-fixtures.py@@ -57,6 +57,8 @@ filter_dump(data, ('exercises.equipment', 'exercises.equipment',), 'equipment.js## Other#-filter_dump(data, ('exercises.language',), 'languages.json')+filter_dump(data, ('core.language',), 'languages.json')+filter_dump(data, ('core.license',), 'licenses.json')filter_dump(data, ('config.languageconfig',), 'language_config.json')+filter_dump(data, ('auth.group',), 'groups.json')diff --git a/wger/core/api/resources.py b/wger/core/api/resources.pyindex 371530513..3def40e84 100644--- a/wger/core/api/resources.py+++ b/wger/core/api/resources.py@@ -18,10 +18,11 @@ from tastypie.authentication import ApiKeyAuthenticationfrom tastypie.constants import ALLfrom tastypie.resources import ModelResource+from wger.utils.resources import UserObjectsOnlyAuthorizationfrom wger.core.models import UserProfilefrom wger.core.models import Languagefrom wger.core.models import DaysOfWeek-from wger.utils.resources import UserObjectsOnlyAuthorization+from wger.core.models import Licenseclass UserProfileResource(ModelResource):@@ -62,3 +63,15 @@ class DaysOfWeekResource(ModelResource):queryset = DaysOfWeek.objects.all()filtering = {'id': ALL,'day_of_week': ALL}+++class LicenseResource(ModelResource):+ '''+ Resource for licenses+ '''+ class Meta:+ queryset = License.objects.all()+ filtering = {'id': ALL,+ "full_name": ALL,+ "short_name": ALL,+ "url": ALL}diff --git a/wger/core/fixtures/test-licenses.json b/wger/core/fixtures/test-licenses.jsonnew file mode 100644index 000000000..829b29456--- /dev/null+++ b/wger/core/fixtures/test-licenses.json@@ -0,0 +1,20 @@+[+ {+ "pk": 1,+ "model": "core.license",+ "fields": {+ "url": "",+ "full_name": "A cool and free license - Germany",+ "short_name": "ACAFL - DE"+ }+ },+ {+ "pk": 2,+ "model": "core.license",+ "fields": {+ "url": "https://another-cool-license.org/acl-2.1",+ "full_name": "Another cool license 2.1",+ "short_name": "ACL 2.1"+ }+ }+]diff --git a/wger/core/migrations/0005_auto__add_license.py b/wger/core/migrations/0005_auto__add_license.pynew file mode 100644index 000000000..81babaf5b--- /dev/null+++ b/wger/core/migrations/0005_auto__add_license.py@@ -0,0 +1,109 @@+# -*- coding: utf-8 -*-+from south.utils import datetime_utils as datetime+from south.db import db+from south.v2 import SchemaMigration+from django.db import models+++class Migration(SchemaMigration):++ def forwards(self, orm):+ # Adding model 'License'+ db.create_table(u'core_license', (+ (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),+ ('short_name', self.gf('django.db.models.fields.CharField')(max_length=15)),+ ('full_name', self.gf('django.db.models.fields.CharField')(max_length=60)),+ ('url', self.gf('django.db.models.fields.URLField')(max_length=200, null=True, blank=True)),+ ))+ db.send_create_signal(u'core', ['License'])+++ def backwards(self, orm):+ # Deleting model 'License'+ db.delete_table(u'core_license')+++ models = {+ u'auth.group': {+ 'Meta': {'object_name': 'Group'},+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),+ 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),+ 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})+ },+ u'auth.permission': {+ 'Meta': {'ordering': "(u'content_type__app_label', u'content_type__model', u'codename')", 'unique_together': "((u'content_type', u'codename'),)", 'object_name': 'Permission'},+ 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),+ 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}),+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})+ },+ u'auth.user': {+ 'Meta': {'object_name': 'User'},+ 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),+ 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),+ 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),+ 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Group']"}),+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),+ 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),+ 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),+ 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),+ 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),+ 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),+ 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),+ 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Permission']"}),+ 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})+ },+ u'contenttypes.contenttype': {+ 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},+ 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),+ 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})+ },+ u'core.daysofweek': {+ 'Meta': {'ordering': "['pk']", 'object_name': 'DaysOfWeek'},+ 'day_of_week': ('django.db.models.fields.CharField', [], {'max_length': '9'}),+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'})+ },+ u'core.language': {+ 'Meta': {'ordering': "['full_name']", 'object_name': 'Language'},+ 'full_name': ('django.db.models.fields.CharField', [], {'max_length': '30'}),+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),+ 'short_name': ('django.db.models.fields.CharField', [], {'max_length': '2'})+ },+ u'core.license': {+ 'Meta': {'ordering': "['full_name']", 'object_name': 'License'},+ 'full_name': ('django.db.models.fields.CharField', [], {'max_length': '60'}),+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),+ 'short_name': ('django.db.models.fields.CharField', [], {'max_length': '15'}),+ 'url': ('django.db.models.fields.URLField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'})+ },+ u'core.userprofile': {+ 'Meta': {'object_name': 'UserProfile'},+ 'age': ('wger.utils.fields.Html5IntegerField', [], {'max_length': '2', 'null': 'True'}),+ 'calories': ('wger.utils.fields.Html5IntegerField', [], {'default': '2500', 'null': 'True'}),+ 'freetime_hours': ('wger.utils.fields.Html5IntegerField', [], {'default': '8', 'null': 'True'}),+ 'freetime_intensity': ('django.db.models.fields.CharField', [], {'default': "'1'", 'max_length': '1', 'null': 'True'}),+ 'gender': ('django.db.models.fields.CharField', [], {'default': "'1'", 'max_length': '1', 'null': 'True'}),+ 'height': ('wger.utils.fields.Html5IntegerField', [], {'max_length': '2', 'null': 'True'}),+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),+ 'is_temporary': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),+ 'last_workout_notification': ('django.db.models.fields.DateField', [], {'null': 'True'}),+ 'notification_language': ('django.db.models.fields.related.ForeignKey', [], {'default': '2', 'to': u"orm['core.Language']"}),+ 'show_comments': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),+ 'show_english_ingredients': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),+ 'sleep_hours': ('wger.utils.fields.Html5IntegerField', [], {'default': '7', 'null': 'True'}),+ 'sport_hours': ('wger.utils.fields.Html5IntegerField', [], {'default': '3', 'null': 'True'}),+ 'sport_intensity': ('django.db.models.fields.CharField', [], {'default': "'2'", 'max_length': '1', 'null': 'True'}),+ 'timer_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),+ 'timer_pause': ('wger.utils.fields.Html5IntegerField', [], {'default': '90'}),+ 'user': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['auth.User']", 'unique': 'True'}),+ 'work_hours': ('wger.utils.fields.Html5IntegerField', [], {'default': '8', 'null': 'True'}),+ 'work_intensity': ('django.db.models.fields.CharField', [], {'default': "'1'", 'max_length': '1', 'null': 'True'}),+ 'workout_duration': ('wger.utils.fields.Html5IntegerField', [], {'default': '12'}),+ 'workout_reminder': ('wger.utils.fields.Html5IntegerField', [], {'default': '14'}),+ 'workout_reminder_active': ('django.db.models.fields.BooleanField', [], {'default': 'False'})+ }+ }++ complete_apps = ['core']\ No newline at end of filediff --git a/wger/core/models.py b/wger/core/models.pyindex 4f8df774a..902ab0bd9 100644--- a/wger/core/models.py+++ b/wger/core/models.py@@ -13,13 +13,14 @@# GNU General Public License for more details.## You should have received a copy of the GNU Affero General Public License+import datetimeimport decimal-from django.core.urlresolvers import reversefrom django.db import modelsfrom django.db.models.signals import post_savefrom django.contrib.auth.models import User+from django.core.urlresolvers import reversefrom django.core.exceptions import ValidationErrorfrom django.core.validators import MinValueValidator, MaxValueValidatorfrom django.utils.translation import ugettext_lazy as _@@ -418,3 +419,47 @@ class DaysOfWeek(models.Model):Return a more human-readable representation'''return self.day_of_week+++class License(models.Model):+ '''+ License for an item (exercise, ingredient, etc.)+ '''++ full_name = models.CharField(max_length=60,+ verbose_name=_('Full name'))+ '''Full name'''++ short_name = models.CharField(max_length=15,+ verbose_name=_('Short name, e.g. CC-BY-SA 3'))+ '''Short name, e.g. CC-BY-SA 3'''++ url = models.URLField(verbose_name=_('Link'),+ help_text=_('Link to license text or other information'),+ blank=True,+ null=True)+ '''URL to full license text or other information'''++ class Meta:+ '''+ Set Meta options+ '''+ ordering = ["full_name", ]++ #+ # Django methods+ #+ def __unicode__(self):+ '''+ Return a more human-readable representation+ '''+ return u"{0} ({1})".format(self.full_name, self.short_name)++ #+ # Own methods+ #+ def get_owner_object(self):+ '''+ License has no owner information+ '''+ return Nonediff --git a/wger/core/templates/license/list.html b/wger/core/templates/license/list.htmlnew file mode 100644index 000000000..a24e9de95--- /dev/null+++ b/wger/core/templates/license/list.html@@ -0,0 +1,74 @@+{% extends "base.html" %}+{% load url from future %}+{% load i18n %}+{% load staticfiles %}+{% load wger_extras %}++{% block title %}{% trans "License list" %}{% endblock %}+++{% block content %}++<table>+<thead>+<tr>+ <th>{% trans "Actions" %}</th>+ <th>{% trans "Name" %}</th>+</tr>+</thead>+<tbody>+{% for license in license_list %}+<tr>+ <td class="no-hover">+ <a href="{% url 'core:license-delete' license.id %}"+ class="modal-dialog">+ <img src="{% static 'images/icons/trash.svg' %}"+ width="22"+ height="22"+ alt="{% trans 'Delete' %}"+ title="{% trans 'Delete' %}">+ </a>+ <a href="{% url 'core:license-edit' license.id %}"+ class="modal-dialog">+ <img src="{% static 'images/icons/edit.svg' %}"+ width="22"+ height="22"+ alt="{% trans 'Edit' %}"+ title="{% trans 'Edit' %}">+ </a>+ </td>+ <td>{{license}}</td>+</tr>+{% empty %}+<tr>+ <td colspan="2">{% trans "No licenses found" %}</td>+</tr>+{% endfor %}+</tbody>++</table>+<div style="padding-top:3em;"></div>+{% endblock %}+++++{% block sidebar %}+{% if perms.core.add_license %}+<h3>{% trans "Options" %}</h3>+<p>+ <a href="{% url 'core:license-add' %}"+ class="modal-dialog">+ <img src="{% static 'images/icons/new.svg' %}"+ width="32"+ height="32"+ alt="{% trans 'Add new license' %}"+ title="{% trans 'Add new license' %}">+ {% trans "Add new license" %}+ </a>+</p>++<p>{% blocktrans %}If a license has been localized, e.g. the Creative Commons+licenses for the different countries, add them as separate entries here.{% endblocktrans %}</p>+{% endif %}+{% endblock %}diff --git a/wger/core/tests/test_license.py b/wger/core/tests/test_license.pynew file mode 100644index 000000000..bc6028f4d--- /dev/null+++ b/wger/core/tests/test_license.py@@ -0,0 +1,90 @@+# This file is part of wger Workout Manager.+#+# wger Workout Manager is free software: you can redistribute it and/or modify+# it under the terms of the GNU Affero General Public License as published by+# the Free Software Foundation, either version 3 of the License, or+# (at your option) any later version.+#+# wger Workout Manager is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU Affero General Public License+# along with Workout Manager. If not, see <http://www.gnu.org/licenses/>.++from django.core.urlresolvers import reverse+from django.core.cache import cache++from wger.core.models import License++from wger.manager.tests.testcase import WorkoutManagerAccessTestCase+from wger.manager.tests.testcase import WorkoutManagerTestCase+from wger.manager.tests.testcase import WorkoutManagerDeleteTestCase+from wger.manager.tests.testcase import WorkoutManagerEditTestCase+from wger.manager.tests.testcase import WorkoutManagerAddTestCase+from wger.manager.tests.testcase import ApiBaseResourceTestCase+from wger.utils.cache import get_template_cache_name, cache_mapper++from wger.utils.constants import PAGINATION_OBJECTS_PER_PAGE+++class LicenseOverviewTest(WorkoutManagerAccessTestCase):+ '''+ Tests the licese overview page+ '''++ url = 'core:license-list'+ anonymous_fail = True+++class AddLicenseTestCase(WorkoutManagerAddTestCase):+ '''+ Tests adding a new license+ '''++ object_class = License+ url = 'core:license-add'+ data = {'full_name': 'Something here',+ 'short_name': 'SH'}+ pk = 3+++class DeleteLicenseTestCase(WorkoutManagerDeleteTestCase):+ '''+ Tests deleting a license+ '''++ object_class = License+ url = 'core:license-delete'+ pk = 1+++class EditLicenseTestCase(WorkoutManagerEditTestCase):+ '''+ Tests editing a license+ '''++ object_class = License+ url = 'core:license-edit'+ pk = 1+ data = {'full_name': 'Something here 1.1',+ 'short_name': 'SH 1.1'}+++class LicenseApiTestCase(ApiBaseResourceTestCase):+ '''+ Tests the license resource+ '''+ resource = 'license'+ user = None+ resource_updatable = False+++class LicenseDetailApiTestCase(ApiBaseResourceTestCase):+ '''+ Tests accessing a specific license+ '''+ resource = 'license/1'+ user = None+ resource_updatable = Falsediff --git a/wger/core/urls.py b/wger/core/urls.pyindex 4d6555921..4e390567f 100644--- a/wger/core/urls.py+++ b/wger/core/urls.py@@ -22,6 +22,7 @@ from django.core.urlresolvers import reverse_lazyfrom wger.core.views import userfrom wger.core.views import misc+from wger.core.views import licenseurlpatterns = patterns('',@@ -58,6 +59,23 @@ urlpatterns = patterns('',user.api_user_preferences,name='user-api-preferences'),+ # Licenses+ url(r'^license/list$',+ license.LicenseListView.as_view(),+ name='license-list'),+ url(r'^license/add$',+ license.LicenseAddView.as_view(),+ name='license-add'),+ url(r'^license/(?P<pk>\d+)/edit',+ license.LicenseUpdateView.as_view(),+ name='license-edit'),+ url(r'^license/(?P<pk>\d+)/delete',+ license.LicenseDeleteView.as_view(),+ name='license-delete'),++++# Othersurl(r'^about$',TemplateView.as_view(template_name="misc/about.html"),diff --git a/wger/core/views/license.py b/wger/core/views/license.pynew file mode 100644index 000000000..963647e0f--- /dev/null+++ b/wger/core/views/license.py@@ -0,0 +1,98 @@+# -*- coding: utf-8 -*-++# This file is part of wger Workout Manager.+#+# wger Workout Manager is free software: you can redistribute it and/or modify+# it under the terms of the GNU Affero General Public License as published by+# the Free Software Foundation, either version 3 of the License, or+# (at your option) any later version.+#+# wger Workout Manager is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU Affero General Public License++import logging++from django.core.urlresolvers import reverse+from django.core.urlresolvers import reverse_lazy+from django.utils.translation import ugettext as _+from django.utils.translation import ugettext_lazy+from django.views.generic import ListView+from django.views.generic import DeleteView+from django.views.generic import CreateView+from django.views.generic import UpdateView+from django.contrib import messages+from django.contrib.auth.decorators import login_required+from django.contrib.auth import login as django_login++from wger.utils.generic_views import WgerFormMixin+from wger.utils.generic_views import WgerDeleteMixin+from wger.utils.generic_views import WgerPermissionMixin++from wger.core.models import License+++logger = logging.getLogger('wger.custom')+++class LicenseListView(WgerPermissionMixin, ListView):+ '''+ Overview of all available licenses+ '''+ model = License+ permission_required = 'core.add_license'+ template_name = 'license/list.html'+++class LicenseAddView(WgerFormMixin, CreateView, WgerPermissionMixin):+ '''+ View to add a new license+ '''++ model = License+ success_url = reverse_lazy('core:license-list')+ title = ugettext_lazy('Add license')+ form_action = reverse_lazy('core:license-add')+ permission_required = 'core.add_license'+++class LicenseUpdateView(WgerFormMixin, UpdateView, WgerPermissionMixin):+ '''+ View to update an existing license+ '''++ model = License+ title = ugettext_lazy('Edit license')+ success_url = reverse_lazy('core:license-list')+ permission_required = 'core.change_license'++ def get_context_data(self, **kwargs):+ '''+ Send some additional data to the template+ '''+ context = super(LicenseUpdateView, self).get_context_data(**kwargs)+ context['form_action'] = reverse('core:license-edit', kwargs={'pk': self.object.id})+ context['title'] = _('Edit {0}'.format(self.object))+ return context+++class LicenseDeleteView(WgerDeleteMixin, DeleteView, WgerPermissionMixin):+ '''+ View to delete an existing license+ '''++ model = License+ success_url = reverse_lazy('core:license-list')+ permission_required = 'core.delete_license'++ def get_context_data(self, **kwargs):+ '''+ Send some additional data to the template+ '''+ context = super(LicenseDeleteView, self).get_context_data(**kwargs)+ context['title'] = _('Delete license {0}?'.format(self.object))+ context['form_action'] = reverse('core:license-delete', kwargs={'pk': self.kwargs['pk']})+ return contextdiff --git a/wger/exercises/templates/exercise/overview.html.orig b/wger/exercises/templates/exercise/overview.html.orignew file mode 100644index 000000000..4d0d62fa6--- /dev/null+++ b/wger/exercises/templates/exercise/overview.html.orig@@ -0,0 +1,202 @@+{% 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/");+ }+ });++ // 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 %}+<div id="tabs">+ <ul>+ {% for exercise in exercises %}+ {% ifchanged exercise.category %}+ <li id="cat-{{ exercise.category.id }}"><a href="#cat{{ exercise.category.id }}">{% trans exericse.category.name %}</a></li>+ {% endifchanged %}+ {% empty %}+ <li>{% trans "No categories." %} {% trans "Use link to create one" %}</li>+ {% endfor %}+ </ul>++ {% for exercise in exercises %}+ {% ifchanged exerice.category %}+ <div id="cat{{ category.id }}">+ <table class="narrow">+ <tbody>+ {% enfifchanged %}+ {% endfor %}+ {% for exercise in category|get_active_exercises:active_languages %}+ <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/manager/fixtures/groups.json b/wger/manager/fixtures/groups.jsonindex c7a49bec8..44ed38923 100644--- a/wger/manager/fixtures/groups.json+++ b/wger/manager/fixtures/groups.json@@ -20,6 +20,51 @@"config","languageconfig"],+ [+ "add_daysofweek",+ "core",+ "daysofweek"+ ],+ [+ "change_daysofweek",+ "core",+ "daysofweek"+ ],+ [+ "delete_daysofweek",+ "core",+ "daysofweek"+ ],+ [+ "add_language",+ "core",+ "language"+ ],+ [+ "change_language",+ "core",+ "language"+ ],+ [+ "delete_language",+ "core",+ "language"+ ],+ [+ "add_license",+ "core",+ "license"+ ],+ [+ "change_license",+ "core",+ "license"+ ],+ [+ "delete_license",+ "core",+ "license"+ ],["add_equipment","exercises",@@ -95,21 +140,6 @@"exercises","exerciseimage"],- [- "add_language",- "core",- "language"- ],- [- "change_language",- "core",- "language"- ],- [- "delete_language",- "core",- "language"- ],["add_muscle","exercises",@@ -125,21 +155,6 @@"exercises","muscle"],- [- "add_daysofweek",- "core",- "daysofweek"- ],- [- "change_daysofweek",- "core",- "daysofweek"- ],- [- "delete_daysofweek",- "core",- "daysofweek"- ],["add_ingredient","nutrition",diff --git a/wger/manager/fixtures/test-user-data.json b/wger/manager/fixtures/test-user-data.jsonindex da3d195ba..da4e1ccff 100644--- a/wger/manager/fixtures/test-user-data.json+++ b/wger/manager/fixtures/test-user-data.json@@ -20,6 +20,51 @@"config","languageconfig"],+ [+ "add_daysofweek",+ "core",+ "daysofweek"+ ],+ [+ "change_daysofweek",+ "core",+ "daysofweek"+ ],+ [+ "delete_daysofweek",+ "core",+ "daysofweek"+ ],+ [+ "add_language",+ "core",+ "language"+ ],+ [+ "change_language",+ "core",+ "language"+ ],+ [+ "delete_language",+ "core",+ "language"+ ],+ [+ "add_license",+ "core",+ "license"+ ],+ [+ "change_license",+ "core",+ "license"+ ],+ [+ "delete_license",+ "core",+ "license"+ ],["add_equipment","exercises",@@ -95,22 +140,6 @@"exercises","exerciseimage"],-- [- "add_language",- "core",- "language"- ],- [- "change_language",- "core",- "language"- ],- [- "delete_language",- "core",- "language"- ],["add_muscle","exercises",@@ -126,21 +155,6 @@"exercises","muscle"],- [- "add_daysofweek",- "core",- "daysofweek"- ],- [- "change_daysofweek",- "core",- "daysofweek"- ],- [- "delete_daysofweek",- "core",- "daysofweek"- ],["add_ingredient","nutrition",diff --git a/wger/manager/tests/testcase.py b/wger/manager/tests/testcase.pyindex b1677dd0d..8a8e6892b 100644--- a/wger/manager/tests/testcase.py+++ b/wger/manager/tests/testcase.py@@ -54,6 +54,7 @@ class BaseTestCase(object):fixtures = ('days_of_week','test-languages',+ 'test-licenses','test-user-data','test-apikeys','test-weight-data',diff --git a/wger/urls.py b/wger/urls.pyindex 4d60cd4b8..a70c2198f 100644--- a/wger/urls.py+++ b/wger/urls.py@@ -28,7 +28,7 @@ from wger.nutrition.api import resources as nutrition_apifrom wger.utils.generic_views import TextTemplateViewfrom wger.utils.generic_views import WebappManifestViewfrom wger.manager.api import resources as manager_api-from wger.core.api.resources import UserProfileResource, LanguageResource, DaysOfWeekResource+from wger.core.api import resources as core_apifrom wger.weight.api import resources as weight_api#@@ -42,7 +42,6 @@ v1_api.register(exercises_api.ExerciseCommentResource())v1_api.register(exercises_api.ExerciseImageResource())v1_api.register(exercises_api.ExerciseResource())v1_api.register(exercises_api.MuscleResource())-v1_api.register(LanguageResource())v1_api.register(exercises_api.EquipmentResource())# Nutrition app@@ -54,11 +53,9 @@ v1_api.register(nutrition_api.MealItemResource())v1_api.register(nutrition_api.IngredientToWeightUnit())# Manager app-v1_api.register(UserProfileResource())v1_api.register(manager_api.WorkoutResource())v1_api.register(manager_api.ScheduleResource())v1_api.register(manager_api.ScheduleStepResource())-v1_api.register(DaysOfWeekResource())v1_api.register(manager_api.DayResource())v1_api.register(manager_api.SetResource())v1_api.register(manager_api.SettingResource())@@ -68,6 +65,14 @@ v1_api.register(manager_api.WorkoutSessionResource())# Weight appv1_api.register(weight_api.WeightEntryResource())++# Core app+v1_api.register(core_api.LanguageResource())+v1_api.register(core_api.DaysOfWeekResource())+v1_api.register(core_api.UserProfileResource())+v1_api.register(core_api.LicenseResource())++from django.contrib import adminadmin.autodiscover()