Self hosted FLOSS fitness/workout, nutrition and weight tracker
Formatting
Roland Geider069c2420d1aa
diff --git a/wger/exercises/views.py b/wger/exercises/views.pyindex 0e7645e2f..2b1839b73 100644--- a/wger/exercises/views.py+++ b/wger/exercises/views.py@@ -62,9 +62,9 @@ class ExerciseCommentForm(ModelForm):class ExerciseCommentEditView(YamlFormMixin, UpdateView):- """+ '''Generic view to update an existing exercise comment- """+ '''model = ExerciseCommentform_class = ExerciseCommentForm@@ -83,9 +83,9 @@ class ExerciseCommentEditView(YamlFormMixin, UpdateView):class ExerciseCommentAddView(YamlFormMixin, CreateView):- """+ '''Generic view to add a new exercise comment- """+ '''model = ExerciseCommentform_class = ExerciseCommentForm@@ -125,8 +125,9 @@ def exercisecomment_delete(request, id):# Exercises# ************************def exercise_overview(request):- """Overview with all exercises- """+ '''+ Overview with all exercises+ '''language = load_language()template_data = {}@@ -211,10 +212,10 @@ def exercise_view(request, id, slug=None):class ExercisesEditAddView(YamlFormMixin):- """+ '''Generic view to subclass from for exercise adding and editing, since theyshare all this settings- """+ '''model = Exerciseform_fields = ['name',@@ -247,9 +248,9 @@ class ExercisesEditAddView(YamlFormMixin):class ExerciseUpdateView(ExercisesEditAddView, UpdateView):- """+ '''Generic view to update an existing exercise- """+ '''def get_context_data(self, **kwargs):context = super(ExerciseUpdateView, self).get_context_data(**kwargs)@@ -260,17 +261,17 @@ class ExerciseUpdateView(ExercisesEditAddView, UpdateView):class ExerciseAddView(ExercisesEditAddView, CreateView):- """+ '''Generic view to add a new exercise- """+ '''form_action = reverse_lazy('exercise-add')class ExerciseDeleteView(YamlDeleteMixin, DeleteView):- """+ '''Generic view to delete an existing exercise- """+ '''model = Exercisesuccess_url = reverse_lazy('wger.exercises.views.exercise_overview')@@ -287,8 +288,9 @@ class ExerciseDeleteView(YamlDeleteMixin, DeleteView):def exercise_search(request):- """Search an exercise, return the result as a JSON list- """+ '''+ Search an exercise, return the result as a JSON list+ '''# Perform the searchq = request.GET.get('term', '')@@ -336,9 +338,9 @@ class ExerciseCategoryForm(ModelForm):class ExerciseCategoryAddView(YamlFormMixin, CreateView):- """+ '''Generic view to add a new exercise category- """+ '''model = ExerciseCategoryform_class = ExerciseCategoryForm@@ -353,9 +355,9 @@ class ExerciseCategoryAddView(YamlFormMixin, CreateView):class ExerciseCategoryUpdateView(YamlFormMixin, UpdateView):- """+ '''Generic view to update an existing exercise category- """+ '''model = ExerciseCategoryform_class = ExerciseCategoryForm@@ -376,9 +378,9 @@ class ExerciseCategoryUpdateView(YamlFormMixin, UpdateView):class ExerciseCategoryDeleteView(YamlDeleteMixin, DeleteView):- """+ '''Generic view to delete an existing exercise category- """+ '''model = ExerciseCategorysuccess_url = reverse_lazy('wger.exercises.views.exercise_overview')diff --git a/wger/manager/pdf.py b/wger/manager/pdf.pyindex 38b057fe1..ccb755685 100644--- a/wger/manager/pdf.py+++ b/wger/manager/pdf.py@@ -35,19 +35,20 @@ from wger.workout_manager import get_versionlogger = logging.getLogger('workout_manager.custom')-"""+'''PDF functions-"""+'''@login_requireddef workout_log(request, id):- """Generates a PDF with the contents of the given workout+ '''+ Generates a PDF with the contents of the given workoutSee also* http://www.blog.pythonlibrary.org/2010/09/21/reportlab* http://www.reportlab.com/apis/reportlab/dev/platypus.html- """+ '''#Load the workoutworkout = get_object_or_404(TrainingSchedule, pk=id, user=request.user)diff --git a/wger/manager/utils.py b/wger/manager/utils.pyindex f92103292..e7f6a4be3 100644--- a/wger/manager/utils.py+++ b/wger/manager/utils.py@@ -23,8 +23,9 @@ from wger.exercises.models import Languagedef load_language():- """Returns the currently used language, e.g. to load appropriate exercises- """+ '''+ Returns the currently used language, e.g. to load appropriate exercises+ '''# TODO: perhaps store a language preference in the user's profile?# Read the first part of a composite language, e.g. 'de-at'@@ -41,7 +42,8 @@ def load_language():def load_ingredient_languages(request):- """ Filter the ingredients the user will see by its language.+ '''+ Filter the ingredients the user will see by its language.Additionally, if the user has selected on his preference page that he wishesto also see the ingredients in English (from the US Department of Agriculture),@@ -49,7 +51,7 @@ def load_ingredient_languages(request):This only makes sense if the user's language isn't English, as he will bepresented those in that case anyway, so also do a check for this.- """+ '''language = load_language()languages = (language.id,)diff --git a/wger/nutrition/views.py b/wger/nutrition/views.pyindex 51238331b..6bfeecf6c 100644--- a/wger/nutrition/views.py+++ b/wger/nutrition/views.py@@ -83,8 +83,9 @@ def overview(request):@login_requireddef add(request):- """Add a new nutrition plan and redirect to its page- """+ '''+ Add a new nutrition plan and redirect to its page+ '''plan = NutritionPlan()plan.user = request.user@@ -95,9 +96,9 @@ def add(request):class PlanDeleteView(YamlDeleteMixin, DeleteView):- """+ '''Generic view to delete a nutritional plan- """+ '''model = NutritionPlansuccess_url = reverse_lazy('wger.nutrition.views.overview')@@ -106,9 +107,9 @@ class PlanDeleteView(YamlDeleteMixin, DeleteView):class PlanEditView(YamlFormMixin, UpdateView):- """+ '''Generic view to update an existing nutritional plan- """+ '''model = NutritionPlanform_class = PlanForm@@ -118,8 +119,9 @@ class PlanEditView(YamlFormMixin, UpdateView):@login_requireddef view(request, id):- """Show the nutrition plan with the given ID- """+ '''+ Show the nutrition plan with the given ID+ '''template_data = {}plan = get_object_or_404(NutritionPlan, pk=id, user=request.user)@@ -140,9 +142,9 @@ def view(request, id):@login_requireddef copy(request, pk):- """+ '''Copy the nutrition plan- """+ '''plan = get_object_or_404(NutritionPlan, pk=pk, user=request.user)@@ -174,12 +176,13 @@ def copy(request, pk):def export_pdf(request, id):- """Generates a PDF with the contents of a nutrition plan+ '''+ Generates a PDF with the contents of a nutrition planSee also* http://www.blog.pythonlibrary.org/2010/09/21/reportlab* http://www.reportlab.com/apis/reportlab/dev/platypus.html- """+ '''#Load the workoutplan = get_object_or_404(NutritionPlan, pk=id, user=request.user)@@ -310,9 +313,9 @@ class MealItemForm(ModelForm):class MealCreateView(YamlFormMixin, CreateView):- """+ '''Generic view to add a new meal to a nutrition plan- """+ '''model = Mealform_class = MealForm@@ -338,9 +341,9 @@ class MealCreateView(YamlFormMixin, CreateView):class MealEditView(YamlFormMixin, UpdateView):- """+ '''Generic view to update an existing meal- """+ '''model = Mealform_class = MealForm@@ -353,8 +356,9 @@ class MealEditView(YamlFormMixin, UpdateView):@login_requireddef delete_meal(request, id):- """Deletes the meal with the given ID- """+ '''+ Deletes the meal with the given ID+ '''# Load the mealmeal = get_object_or_404(Meal, pk=id)@@ -373,8 +377,9 @@ def delete_meal(request, id):# ************************@login_requireddef delete_meal_item(request, item_id):- """Deletes the meal ingredient with the given ID- """+ '''+ Deletes the meal ingredient with the given ID+ '''# Load the itemitem = get_object_or_404(MealItem, pk=item_id)@@ -390,8 +395,9 @@ def delete_meal_item(request, item_id):@login_requireddef edit_meal_item(request, id, meal_id, item_id=None):- """Form to add a meal to a plan- """+ '''+ Form to add a meal to a plan+ '''template_data = {}# Load the plan@@ -459,8 +465,9 @@ def edit_meal_item(request, id, meal_id, item_id=None):# Ingredient functions# ************************def ingredient_overview(request):- """Show an overview of all ingredients- """+ '''+ Show an overview of all ingredients+ '''template_data = {}@@ -498,9 +505,9 @@ class IngredientForm(ModelForm):class IngredientDeleteView(YamlDeleteMixin, DeleteView):- """+ '''Generic view to delete an existing ingredient- """+ '''model = Ingredienttemplate_name = 'delete.html'@@ -517,9 +524,9 @@ class IngredientDeleteView(YamlDeleteMixin, DeleteView):class IngredientEditView(YamlFormMixin, UpdateView):- """+ '''Generic view to update an existing ingredient- """+ '''model = Ingredientform_class = IngredientForm@@ -528,9 +535,9 @@ class IngredientEditView(YamlFormMixin, UpdateView):class IngredientCreateView(YamlFormMixin, CreateView):- """+ '''Generic view to add a new ingredient- """+ '''model = Ingredientform_class = IngredientForm@@ -543,9 +550,11 @@ class IngredientCreateView(YamlFormMixin, CreateView):def ingredient_search(request):- """Search for an exercise, return the result as a JSON list or as HTML page, depending on how+ '''+ Search for an exercise, return the result as a JSON list or as HTML page, depending on howthe function was invoked- """+ '''+# Filter the ingredients the user will see by its language# (the user can also want to see ingredients in English, see load_ingredient_languages)languages = load_ingredient_languages(request)diff --git a/wger/weight/models.py b/wger/weight/models.pyindex 0cd7d1df2..aea7f5564 100644--- a/wger/weight/models.py+++ b/wger/weight/models.py@@ -22,8 +22,9 @@ from django.utils.translation import ugettext_lazy as _class WeightEntry(models.Model):- """Model for a weight point- """+ '''+ Model for a weight point+ '''creation_date = models.DateField(verbose_name=_('Date'))weight = models.FloatField(verbose_name=_('Weight'))user = models.ForeignKey(User, verbose_name=_('User'))@@ -35,12 +36,13 @@ class WeightEntry(models.Model):ordering = ["creation_date", ]def __unicode__(self):- """Return a more human-readable representation- """+ '''+ Return a more human-readable representation+ '''return "%s: %s kg" % (self.creation_date, self.weight)def get_owner_object(self):- """+ '''Returns the object that has owner information- """+ '''return selfdiff --git a/wger/weight/views.py b/wger/weight/views.pyindex 2e0346b60..284a2cfb4 100644--- a/wger/weight/views.py+++ b/wger/weight/views.py@@ -60,9 +60,9 @@ class WeightForm(ModelForm):class WeightAddView(YamlFormMixin, CreateView):- """+ '''Generic view to add a new weight entry- """+ '''model = WeightEntryform_class = WeightFormcustom_js = '''$(document).ready(function () {@@ -73,18 +73,18 @@ class WeightAddView(YamlFormMixin, CreateView):success_url = reverse_lazy('wger.weight.views.overview')def form_valid(self, form):- """+ '''Set the owner of the entry here- """+ '''form.instance.user = self.request.userreturn super(WeightAddView, self).form_valid(form)class WeightUpdateView(YamlFormMixin, UpdateView):- """+ '''Generic view to edit an existing weight entry- """+ '''model = WeightEntryform_class = WeightFormcustom_js = '''$(document).ready(function () {@@ -102,8 +102,9 @@ class WeightUpdateView(YamlFormMixin, UpdateView):@login_requireddef export_csv(request):- """Exports the saved weight data as a CSV file- """+ '''+ Exports the saved weight data as a CSV file+ '''# Prepare the response headersfilename = "%s-%s" % (_('weightdata'), request.user.username)@@ -125,12 +126,13 @@ def export_csv(request):@login_requireddef overview(request):- """Shows a plot with the weight data+ '''+ Shows a plot with the weight dataMore info about the D3 library can be found here:* https://github.com/mbostock/d3* http://d3js.org/- """+ '''template_data = {}min_date = WeightEntry.objects.filter(user=request.user).\