Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exercise comments are now editable #1480

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion wger/manager/templates/set/edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@
{% for formset in formsets %}
{% include 'set/formset.html' with base=formset.base formset=formset.formset helper=helper %}
{% endfor %}

<div class="form-group">
<label for="id_comment" class="control-label">{% translate "Comment" %}:</label>
<input id="id_comment" name="comment" class="form-control" type="text" value="{{ comment }}">
</div>
<br>
<input type="submit" class="btn btn-primary btn-success btn-block" value="{% translate 'Update' %}">
</form>
{% endblock %}
5 changes: 4 additions & 1 deletion wger/manager/views/set.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,9 @@ def edit(request, pk):
formsets.append({'base': base, 'formset': formset})

if request.method == "POST":
set_obj.comment = request.POST.get('comment',"") # Update the comment value for the Set object
set_obj.save() # Save the changes to the Set object

formsets = []
for base in set_obj.exercise_bases:
formset = SettingFormsetEdit(request.POST, prefix='exercise{0}'.format(base.id))
Expand All @@ -218,5 +221,5 @@ def edit(request, pk):
)

# Other context we need
context = {'formsets': formsets, 'helper': WorkoutLogFormHelper()}
context = {'formsets': formsets, 'helper': WorkoutLogFormHelper(),'comment': set_obj.comment }
return render(request, 'set/edit.html', context)