Skip to content

Commit

Permalink
Rename workout model attributes
Browse files Browse the repository at this point in the history
'comment' is renamed to 'name' and a new field 'description' is now available
for actual longer descriptions if needed

Closes wger-project#666
  • Loading branch information
rolandgeider committed May 10, 2021
1 parent 4220348 commit b0ec10a
Show file tree
Hide file tree
Showing 17 changed files with 502 additions and 382 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ For a live system, refer to the project's site: <https://wger.de/>

![Workout plan](https://raw.githubusercontent.com/wger-project/wger/master/wger/software/static/images/workout.png)


## Installation

These are the basic steps to install and run the application locally on a Linux
Expand Down
13 changes: 11 additions & 2 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,16 @@ Upgrade steps from 2.0:

🧰 Maintenance:

*
* Changes to the REST API:
+ /exerciseimage/
- ``exercise`` was renamed to ``exercise_base`` (was pointing there anyway)
+ /workout/
- ``comment`` was renamed to name
- field ``description`` was added, for longer descriptions
* `#666`_,

.. _#666: https://github.com/wger-project/wger/issues/666



2.0
Expand Down Expand Up @@ -108,7 +117,7 @@ Upgrade steps from 1.9:
.. _@jeevikaghosh: https://github.com/jeevikaghosh
.. _@bradsk88: https://github.com/bradsk88
.. _@Sidrah-Madiha: https://github.com/Sidrah-Madiha
.. _@calvinrw : https://github.com/calvinrw
.. _@calvinrw: https://github.com/calvinrw


.. _#246: https://github.com/wger-project/wger/issues/246
Expand Down
8 changes: 4 additions & 4 deletions wger/core/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def create_demo_entries(user):
#
setting_list = []
weight_log = []
workout = Workout(user=user, comment=_('Sample workout'))
workout = Workout(user=user, name=_('Sample workout'))
workout.save()
monday = DaysOfWeek.objects.get(pk=1)
wednesday = DaysOfWeek.objects.get(pk=3)
Expand Down Expand Up @@ -338,11 +338,11 @@ def create_demo_entries(user):
#

# create some empty workouts to fill the list
workout2 = Workout(user=user, comment=_('Placeholder workout nr {0} for schedule').format(1))
workout2 = Workout(user=user, name=_('Placeholder workout nr {0} for schedule').format(1))
workout2.save()
workout3 = Workout(user=user, comment=_('Placeholder workout nr {0} for schedule').format(2))
workout3 = Workout(user=user, name=_('Placeholder workout nr {0} for schedule').format(2))
workout3.save()
workout4 = Workout(user=user, comment=_('Placeholder workout nr {0} for schedule').format(3))
workout4 = Workout(user=user, name=_('Placeholder workout nr {0} for schedule').format(3))
workout4.save()

schedule = Schedule()
Expand Down
188 changes: 101 additions & 87 deletions wger/core/templates/tags/render_day.html
Original file line number Diff line number Diff line change
@@ -1,77 +1,91 @@
{% load i18n static wger_extras thumbnail %}

<script>
$(document).ready(function() {
$(document).ready(function () {

// Call the setup function to allow the sets to be sortable again after loading this
// view via AJAX
wgerSetupSortable();
// Call the setup function to allow the sets to be sortable again after loading this
// view via AJAX
wgerSetupSortable();

// Init the modal dialog to edit the exercise
wgerFormModalDialog();
// Init the modal dialog to edit the exercise
wgerFormModalDialog();

})
})
</script>

<table class="table table-bordered workout-table" id="table-day-{{ day.obj.id }}" data-id="{{ day.obj.id }}">
<thead class="thead-light">
<table class="table table-bordered workout-table" id="table-day-{{ day.obj.id }}"
data-id="{{ day.obj.id }}">
<thead class="thead-light">
<tr id="day-{{ day.obj.id }}">
<th colspan="2">
{{ day.days_of_week.text }} – {{ day.obj.description }}


{% if editable %}
<div class="float-right">
<div class="dropdown">
<button class="btn btn-sm dropdown-toggle " type="button" id="dropdownMenuDay{{day.obj.id}}" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="{% fa_class 'cog' %}"></span>
</button>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdownMenuDay{{day.obj.id}}">
<a href="{% url 'manager:day:log' day.obj.id %}" class="dropdown-item">
<span class="{% fa_class 'chart-line' %}"></span>
{% translate 'Add weight log' %}
</a>
<a href="{% url 'manager:day:edit' day.obj.id %}" class="wger-modal-dialog dropdown-item">
<span class="{% fa_class 'edit' %}"></span>
{% translate 'Edit' %}
</a>
<div class="dropdown-divider"></div>
<a href="{% url 'manager:day:delete' day.obj.id %}" class="dropdown-item">
<span class="{% fa_class 'trash' %}"></span>
{% translate 'Delete' %}
</a>
<div class="float-right">
<div class="dropdown">
<button class="btn btn-sm dropdown-toggle " type="button"
id="dropdownMenuDay{{ day.obj.id }}" data-toggle="dropdown"
aria-haspopup="true" aria-expanded="false">
<span class="{% fa_class 'cog' %}"></span>
</button>
<div class="dropdown-menu dropdown-menu-right"
aria-labelledby="dropdownMenuDay{{ day.obj.id }}">
<a href="{% url 'manager:day:log' day.obj.id %}" class="dropdown-item">
<span class="{% fa_class 'chart-line' %}"></span>
{% translate 'Add weight log' %}
</a>
<a href="{% url 'manager:day:edit' day.obj.id %}"
class="wger-modal-dialog dropdown-item">
<span class="{% fa_class 'edit' %}"></span>
{% translate 'Edit' %}
</a>
<div class="dropdown-divider"></div>
<a href="{% url 'manager:day:delete' day.obj.id %}"
class="dropdown-item">
<span class="{% fa_class 'trash' %}"></span>
{% translate 'Delete' %}
</a>

</div>
</div>
</div>
</div>
</div>
{% endif %}

<h4>{{ day.obj.description }}</h4>
{{ day.days_of_week.text }}
</th>
</tr>
</thead>
<tbody>
{% for set in day.set_list %}
{% for set in day.set_list %}
<tr data-id="{{ set.obj.id }}" id="set-{{ set.obj.id }}">
<td style="width: 15%;border-right-width: 0px;">
<td style="width: 15%;border-right-width: 0;">
<span>#{{ forloop.counter }}</span>

{% if editable %}
<div class="dropdown float-right">
<button class="btn btn-link btn-sm btn-block dropdown-toggle " type="button" id="dropdownMenuSet{{set.obj.id}}" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<button class="btn btn-link btn-sm btn-block dropdown-toggle " type="button"
id="dropdownMenuSet{{ set.obj.id }}" data-toggle="dropdown"
aria-haspopup="true" aria-expanded="false">
</button>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdownMenuSet{{set.obj.id}}">
<a href="{% url 'manager:set:edit' set.obj.id %}" class="wger-modal-dialog dropdown-item">
<span class="{% fa_class 'edit' %}"></span>
{% translate 'Edit' %}
<div class="dropdown-menu dropdown-menu-right"
aria-labelledby="dropdownMenuSet{{ set.obj.id }}">
<a href="{% url 'manager:set:edit' set.obj.id %}"
class="wger-modal-dialog dropdown-item">
<span class="{% fa_class 'edit' %}"></span>
{% translate 'Edit' %}
</a>
<div class="dropdown-divider"></div>
<a href="{% url 'manager:set:delete' set.obj.id %}" class="dropdown-item">
<a href="{% url 'manager:set:delete' set.obj.id %}"
class="dropdown-item">
<span class="{% fa_class 'trash' %}"></span>
{% translate 'Delete' %}
</a>
</div>
</div>

{% if false and day.set_list|length > 1 %}
<span class="editoptions">
<span class="editoptions">
<span class="{% fa_class 'bars' %} dragndrop-handle"></span>
<br>
</span>
Expand All @@ -81,67 +95,67 @@
<td style="border-left-width: 0px;">
<div class="exercise-list">
{% for exercise in set.exercise_list %}
<div id="exercise-{{ exercise.obj.id }}" class="ajax-set-edit-target">
<div class="media">

<div style="width: 64px; height: 64px;">
<a href="{{exercise.obj.get_absolute_url}}" >
{% if exercise.obj.main_image %}
<img class="img-fluid"
src="{{ exercise.obj.main_image.image|thumbnail_url:'small' }}"
alt="{{exercise.obj}}"
style="max-width: 100%; max-height: 100%;">
{% else %}
<img class="img-fluid"
src="{% static 'images/icons/image-placeholder.svg' %}"
alt="{% translate 'Placeholder image for exercise' %}"
style="opacity: 0.4;">
{% endif %}
</a>
</div>

<div class="media-body ml-2">
<p class="media-heading h5">
{{ exercise.obj.name }}
</p>
<p>{{exercise.setting_text}}</p>

{% if editable %}
{% if not exercise.setting_obj_list %}
<p>
{% translate "This exercise has no repetitions." %}<br>
<a href="{% url 'manager:set:edit' set.obj.id %}" class="wger-modal-dialog">
{% translate "Edit them now."%}
<div id="exercise-{{ exercise.obj.id }}" class="ajax-set-edit-target">
<div class="media">

<div style="width: 64px; height: 64px;">
<a href="{{ exercise.obj.get_absolute_url }}">
{% if exercise.obj.main_image %}
<img class="img-fluid"
src="{{ exercise.obj.main_image.image|thumbnail_url:'small' }}"
alt="{{ exercise.obj }}"
style="max-width: 100%; max-height: 100%;">
{% else %}
<img class="img-fluid"
src="{% static 'images/icons/image-placeholder.svg' %}"
alt="{% translate 'Placeholder image for exercise' %}"
style="opacity: 0.4;">
{% endif %}
</a>
</p>
{% endif %}

{% if exercise.comment_list %}
<p class="text-muted exercise-comments">
{% for comment in exercise.comment_list %}
{{comment}}<br>
{% endfor %}
</p>
{% endif %}
{% endif %}
</div>

<div class="media-body ml-2">
<p class="media-heading h5">
{{ exercise.obj.name }}
</p>
<p>{{ exercise.setting_text }}</p>

{% if editable %}
{% if not exercise.setting_obj_list %}
<p>
{% translate "This exercise has no repetitions." %}<br>
<a href="{% url 'manager:set:edit' set.obj.id %}"
class="wger-modal-dialog">
{% translate "Edit them now." %}
</a>
</p>
{% endif %}

{% if exercise.comment_list %}
<p class="text-muted exercise-comments">
{% for comment in exercise.comment_list %}
{{ comment }}<br>
{% endfor %}
</p>
{% endif %}
{% endif %}
</div>
</div>
</div>
</div>
{% endfor %} <!--for exercise in set-->
</div>
</td>
</tr>
{% endfor %} <!--for set in day-->
{% if editable %}
{% endfor %} <!--for set in day-->
{% if editable %}
<tr>
<td colspan="2" class="py-0">
<a href="{% url 'manager:set:add' day.obj.id %}"
class="wger-modal-dialog btn btn-link btn-block">{% translate "Add exercises to this workout day" %}</a>
</td>
</tr>
{% endif %}
{% endif %}
</tbody>



</table>
2 changes: 1 addition & 1 deletion wger/exercises/tests/test_exercise_comments.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def exercise_delete_comment(self, fail=True):

# Comments are loaded
comments = exercise_1.exercisecomment_set.all()
comment_1 = comments[0]
comment_1: ExerciseComment = comments[0]
self.assertEqual(comment_1.id, 1)
self.assertEqual(comment_1.comment, "test 123")
self.assertEqual(len(comments), 1)
Expand Down
3 changes: 2 additions & 1 deletion wger/manager/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ class WorkoutViewSet(viewsets.ModelViewSet):
serializer_class = WorkoutSerializer
is_private = True
ordering_fields = '__all__'
filterset_fields = ('comment',
filterset_fields = ('name',
'description',
'creation_date')

def get_queryset(self):
Expand Down
15 changes: 9 additions & 6 deletions wger/manager/fixtures/test-workout-data.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,30 @@
"pk": 1,
"model": "manager.workout",
"fields": {
"comment": "A test workout",
"name": "A test workout",
"user": 1,
"creation_date": "2012-11-01"
"creation_date": "2012-11-01",
"description": "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna"
}
},
{
"pk": 2,
"model": "manager.workout",
"fields": {
"comment": "Another test workout",
"name": "Another test workout",
"user": 1,
"creation_date": "2012-11-10"
"creation_date": "2012-11-10",
"description": "The wild boar (Sus scrofa), also known as the \"wild swine\", \"common wild pig\", or simply \"wild pig\", is a suid native to much of Eurasia and North Africa"
}
},
{
"pk": 3,
"model": "manager.workout",
"fields": {
"comment": "My test workout",
"name": "My test workout",
"user": 2,
"creation_date": "2012-11-20"
"creation_date": "2012-11-20",
"description": ""
}
},

Expand Down
13 changes: 9 additions & 4 deletions wger/manager/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,14 @@ class Meta:


class WorkoutCopyForm(Form):
comment = CharField(max_length=100,
help_text=_('The goal or description of the new workout.'),
required=False)
name = CharField(max_length=100,
help_text=_('The name of the workout'),
required=False)
description = CharField(max_length=1000,
help_text=_("A short description or goal of the workout. For "
"example 'Focus on back' or 'Week 1 of program xy'."),
widget=widgets.Textarea,
required=False)


class DayForm(ModelForm):
Expand Down Expand Up @@ -111,7 +116,7 @@ class Meta:
class SettingForm(ModelForm):
class Meta:
model = Setting
exclude = ('set', 'exercise', 'order', 'comment')
exclude = ('set', 'exercise', 'order', 'name')


class WorkoutLogForm(ModelForm):
Expand Down
Loading

0 comments on commit b0ec10a

Please sign in to comment.