Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Do store the value of the comment visibility in the user profile

Roland Geider81d1078be802
diff --git a/manager/templates/workout/view.html b/manager/templates/workout/view.html
index 5ed20b97f..f59acecf0 100644
--- a/manager/templates/workout/view.html
+++ b/manager/templates/workout/view.html
@@ -50,17 +50,32 @@ $(document).ready(function() {
});
// Show/Hide the comments to the exercises
- $("#exercise-comments-toggle").click(function(e) {
- e.preventDefault();
-
- $(".exercise-comments").toggle();
- $("#ajax-info").load("/workout/api/user-preferences?do=set_show-comments&show=" + true);
- });
{% if user.userprofile.show_comments %}
+ showComment = 1;
$(".exercise-comments").show();
{% else %}
+ showComment = 0;
$(".exercise-comments").hide();
{% endif %}
+
+ $("#exercise-comments-toggle").click(function(e) {
+ e.preventDefault();
+
+
+ if ( showComment == 0 )
+ {
+ $('.exercise-comments').show();
+ showComment = 1;
+ }
+ else if ( showComment == 1 )
+ {
+ $('.exercise-comments').hide();
+ showComment = 0;
+ }
+
+ $("#ajax-info").load("/workout/api/user-preferences?do=set_show-comments&show=" + showComment);
+ });
+
});
</script>
diff --git a/manager/views.py b/manager/views.py
index 33445d7a4..9ba6bfa32 100644
--- a/manager/views.py
+++ b/manager/views.py
@@ -270,7 +270,7 @@ def api_user_preferences(request):
# Show comments on workout view
if request.GET.get('do') == 'set_show-comments':
- new_value = request.GET.get('show')
+ new_value = int(request.GET.get('show'))
profile = request.user.get_profile()
profile.show_comments = new_value