Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Formatting

Roland Geider069c2420d1aa
diff --git a/wger/exercises/views.py b/wger/exercises/views.py
index 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 = ExerciseComment
form_class = ExerciseCommentForm
@@ -83,9 +83,9 @@ class ExerciseCommentEditView(YamlFormMixin, UpdateView):
class ExerciseCommentAddView(YamlFormMixin, CreateView):
- """
+ '''
Generic view to add a new exercise comment
- """
+ '''
model = ExerciseComment
form_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 they
share all this settings
- """
+ '''
model = Exercise
form_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 = Exercise
success_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 search
q = request.GET.get('term', '')
@@ -336,9 +338,9 @@ class ExerciseCategoryForm(ModelForm):
class ExerciseCategoryAddView(YamlFormMixin, CreateView):
- """
+ '''
Generic view to add a new exercise category
- """
+ '''
model = ExerciseCategory
form_class = ExerciseCategoryForm
@@ -353,9 +355,9 @@ class ExerciseCategoryAddView(YamlFormMixin, CreateView):
class ExerciseCategoryUpdateView(YamlFormMixin, UpdateView):
- """
+ '''
Generic view to update an existing exercise category
- """
+ '''
model = ExerciseCategory
form_class = ExerciseCategoryForm
@@ -376,9 +378,9 @@ class ExerciseCategoryUpdateView(YamlFormMixin, UpdateView):
class ExerciseCategoryDeleteView(YamlDeleteMixin, DeleteView):
- """
+ '''
Generic view to delete an existing exercise category
- """
+ '''
model = ExerciseCategory
success_url = reverse_lazy('wger.exercises.views.exercise_overview')
diff --git a/wger/manager/pdf.py b/wger/manager/pdf.py
index 38b057fe1..ccb755685 100644
--- a/wger/manager/pdf.py
+++ b/wger/manager/pdf.py
@@ -35,19 +35,20 @@ from wger.workout_manager import get_version
logger = logging.getLogger('workout_manager.custom')
-"""
+'''
PDF functions
-"""
+'''
@login_required
def workout_log(request, id):
- """Generates a PDF with the contents of the given workout
+ '''
+ Generates a PDF with the contents of the given workout
See also
* http://www.blog.pythonlibrary.org/2010/09/21/reportlab
* http://www.reportlab.com/apis/reportlab/dev/platypus.html
- """
+ '''
#Load the workout
workout = get_object_or_404(TrainingSchedule, pk=id, user=request.user)
diff --git a/wger/manager/utils.py b/wger/manager/utils.py
index f92103292..e7f6a4be3 100644
--- a/wger/manager/utils.py
+++ b/wger/manager/utils.py
@@ -23,8 +23,9 @@ from wger.exercises.models import Language
def 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 wishes
to 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 be
presented 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.py
index 51238331b..6bfeecf6c 100644
--- a/wger/nutrition/views.py
+++ b/wger/nutrition/views.py
@@ -83,8 +83,9 @@ def overview(request):
@login_required
def 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 = NutritionPlan
success_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 = NutritionPlan
form_class = PlanForm
@@ -118,8 +119,9 @@ class PlanEditView(YamlFormMixin, UpdateView):
@login_required
def 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_required
def 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 plan
See also
* http://www.blog.pythonlibrary.org/2010/09/21/reportlab
* http://www.reportlab.com/apis/reportlab/dev/platypus.html
- """
+ '''
#Load the workout
plan = 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 = Meal
form_class = MealForm
@@ -338,9 +341,9 @@ class MealCreateView(YamlFormMixin, CreateView):
class MealEditView(YamlFormMixin, UpdateView):
- """
+ '''
Generic view to update an existing meal
- """
+ '''
model = Meal
form_class = MealForm
@@ -353,8 +356,9 @@ class MealEditView(YamlFormMixin, UpdateView):
@login_required
def delete_meal(request, id):
- """Deletes the meal with the given ID
- """
+ '''
+ Deletes the meal with the given ID
+ '''
# Load the meal
meal = get_object_or_404(Meal, pk=id)
@@ -373,8 +377,9 @@ def delete_meal(request, id):
# ************************
@login_required
def delete_meal_item(request, item_id):
- """Deletes the meal ingredient with the given ID
- """
+ '''
+ Deletes the meal ingredient with the given ID
+ '''
# Load the item
item = get_object_or_404(MealItem, pk=item_id)
@@ -390,8 +395,9 @@ def delete_meal_item(request, item_id):
@login_required
def 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 = Ingredient
template_name = 'delete.html'
@@ -517,9 +524,9 @@ class IngredientDeleteView(YamlDeleteMixin, DeleteView):
class IngredientEditView(YamlFormMixin, UpdateView):
- """
+ '''
Generic view to update an existing ingredient
- """
+ '''
model = Ingredient
form_class = IngredientForm
@@ -528,9 +535,9 @@ class IngredientEditView(YamlFormMixin, UpdateView):
class IngredientCreateView(YamlFormMixin, CreateView):
- """
+ '''
Generic view to add a new ingredient
- """
+ '''
model = Ingredient
form_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 how
the 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.py
index 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 self
diff --git a/wger/weight/views.py b/wger/weight/views.py
index 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 = WeightEntry
form_class = WeightForm
custom_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.user
return super(WeightAddView, self).form_valid(form)
class WeightUpdateView(YamlFormMixin, UpdateView):
- """
+ '''
Generic view to edit an existing weight entry
- """
+ '''
model = WeightEntry
form_class = WeightForm
custom_js = '''$(document).ready(function () {
@@ -102,8 +102,9 @@ class WeightUpdateView(YamlFormMixin, UpdateView):
@login_required
def export_csv(request):
- """Exports the saved weight data as a CSV file
- """
+ '''
+ Exports the saved weight data as a CSV file
+ '''
# Prepare the response headers
filename = "%s-%s" % (_('weightdata'), request.user.username)
@@ -125,12 +126,13 @@ def export_csv(request):
@login_required
def overview(request):
- """Shows a plot with the weight data
+ '''
+ Shows a plot with the weight data
More 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).\