Self hosted FLOSS fitness/workout, nutrition and weight tracker
Fix formatting errors checked with new version of pep8
Roland Geider017eb25f14cf
diff --git a/wger/core/models.py b/wger/core/models.pyindex 902ab0bd9..5a951c1da 100644--- a/wger/core/models.py+++ b/wger/core/models.py@@ -37,11 +37,11 @@ class Language(models.Model):Language of an item (exercise, workout, etc.)'''- #e.g. 'de'+ # e.g. 'de'short_name = models.CharField(max_length=2,verbose_name=_('Language short name'))- #e.g. 'Deutsch'+ # e.g. 'Deutsch'full_name = models.CharField(max_length=30,verbose_name=_('Language full name'))@@ -318,8 +318,8 @@ by the US Department of Agriculture. It is extremely complete, with around+ (6.25 * self.height) # in cm- (5 * self.age) # in years+ factor)- except TypeError:# Any of the entries is missing+ except TypeError:rate = 0return decimal.Decimal(str(rate)).quantize(TWOPLACES)diff --git a/wger/exercises/admin.py b/wger/exercises/admin.pyindex 7e64c74e2..92071fa1a 100644--- a/wger/exercises/admin.py+++ b/wger/exercises/admin.py@@ -27,7 +27,6 @@ class ExerciseCommentInline(admin.TabularInline): # admin.StackedInlineclass ExerciseAdmin(admin.ModelAdmin):- #fields = ['name',]inlines = [ExerciseCommentInline]diff --git a/wger/exercises/tests/test_exercise_images.py b/wger/exercises/tests/test_exercise_images.pyindex 3d43af19d..e5de23c91 100644--- a/wger/exercises/tests/test_exercise_images.py+++ b/wger/exercises/tests/test_exercise_images.py@@ -136,22 +136,22 @@ class DeleteExerciseImageTestCase(WorkoutManagerDeleteTestCase):pk = 1-#class ExerciseImagesApiTestCase(ApiBaseResourceTestCase):- #'''- #Tests the exercise image overview resource- #'''- #resource = 'exerciseimage'- #user = None- #resource_updatable = False- #data = {"is_main": "true",- #"exercise": "/api/v1/exercise/1/",- #"id": 1}---#class ExerciseImageDetailApiTestCase(ApiBaseResourceTestCase):- #'''- #Tests accessing a specific exercise image- #'''- #resource = 'exerciseimage/1'- #user = None- #resource_updatable = False+# class ExerciseImagesApiTestCase(ApiBaseResourceTestCase):+ # '''+ # Tests the exercise image overview resource+ # '''+ # resource = 'exerciseimage'+ # user = None+ # resource_updatable = False+ # data = {"is_main": "true",+ # "exercise": "/api/v1/exercise/1/",+ # "id": 1}+++# class ExerciseImageDetailApiTestCase(ApiBaseResourceTestCase):+ # '''+ # Tests accessing a specific exercise image+ # '''+ # resource = 'exerciseimage/1'+ # user = None+ # resource_updatable = Falsediff --git a/wger/main.py b/wger/main.pyindex 34c37168d..bc1b03166 100755--- a/wger/main.py+++ b/wger/main.py@@ -391,7 +391,7 @@ def load_fixtures():call_command("loaddata", path + "language_config.json")# Manager- #path = os.path.join(current_dir, 'manager', 'fixtures/')+ # path = os.path.join(current_dir, 'manager', 'fixtures/')# Exercisespath = os.path.join(current_dir, 'exercises', 'fixtures/')diff --git a/wger/manager/models.py b/wger/manager/models.pyindex 67a32ed5b..037638371 100644--- a/wger/manager/models.py+++ b/wger/manager/models.py@@ -311,12 +311,6 @@ class ScheduleStep(models.Model):default=1,editable=False)- #comment = models.CharField(verbose_name=_('Comment'),- # max_length=100,- # help_text=_("A short comment or description"),- # blank=True)- #'''Short comment about the step'''-def get_owner_object(self):'''Returns the object that has owner informationdiff --git a/wger/manager/pdf.py b/wger/manager/pdf.pyindex d8c572848..b6979b209 100644--- a/wger/manager/pdf.py+++ b/wger/manager/pdf.py@@ -48,13 +48,13 @@ def workout_log(request, id):# Create the HttpResponse object with the appropriate PDF headers.response = HttpResponse(content_type='application/pdf')- #Load the workout+ # Load the workoutworkout = get_object_or_404(Workout, pk=id, user=request.user)# Create the PDF object, using the response object as its "file."doc = SimpleDocTemplate(response,pagesize=A4,- #pagesize = landscape(A4),+ # pagesize = landscape(A4),leftMargin=cm,rightMargin=cm,topMargin=0.5 * cm,@@ -116,7 +116,6 @@ def workout_log(request, id):data.append([_('Nr.'), _('Exercise'), _('Reps')] + [_('Weight')] * nr_of_weeks)# Sets- #for set_obj in day.set_set.select_related():for set in day['set_list']:group_exercise_marker[set['obj'].id] = {'start': len(data), 'end': len(data)}@@ -124,7 +123,7 @@ def workout_log(request, id):for exercise in set['exercise_list']:group_exercise_marker[set['obj'].id]['end'] = len(data)- # Note: '+1' here because there's an emtpy cell between days+ # Note: '+1' here because there's an emtpy cell between daysexercise_markers[day['obj'].id].append(len(data) + 1)data.append([set_count,@@ -133,11 +132,6 @@ def workout_log(request, id):+ [''] * nr_of_weeks)set_count += 1- # Note: as above with _('Date'), the _('Impression') has to be here on- # the 1st cell so it is shown after adding a span- #data.append([_('Impression'), '', ''])-- set_count += 1data.append([''])group_day_marker[day['obj'].id]['end'] = len(data)@@ -148,8 +142,6 @@ def workout_log(request, id):rowheights = [None] * len(data)# Set general table styles- #('INNERGRID', (0,0), (-1,-1), 0.25, colors.black),- #('BOX', (0,0), (-1,-1), 1.25, colors.black),table_style = [('FONT', (0, 0), (-1, -1), 'OpenSans'),('FONTSIZE', (0, 0), (-1, -1), 8),('VALIGN', (0, 0), (-1, -1), 'MIDDLE'),@@ -201,8 +193,6 @@ def workout_log(request, id):start_marker = group_day_marker[marker]['start']end_marker = group_day_marker[marker]['end']- #table_style.append(('ALIGN', (0, end_marker - 2), (2, end_marker - 2), 'RIGHT'))-# There is an empty cell between the day blocks, set a border around themtable_style.append(('INNERGRID',(0, start_marker),@@ -288,13 +278,13 @@ def workout_view(request, id):# Create the HttpResponse object with the appropriate PDF headers.response = HttpResponse(content_type='application/pdf')- #Load the workout+ # Load the workoutworkout = get_object_or_404(Workout, pk=id, user=request.user)# Create the PDF object, using the response object as its "file."doc = SimpleDocTemplate(response,pagesize=A4,- #pagesize = landscape(A4),+ # pagesize = landscape(A4),leftMargin=cm,rightMargin=cm,topMargin=0.5 * cm,@@ -344,7 +334,6 @@ def workout_view(request, id):data.append([p])# Sets- #for set_obj in day.set_set.select_related():for set in day['set_list']:group_exercise_marker[set['obj'].id] = {'start': len(data), 'end': len(data)}@@ -352,7 +341,7 @@ def workout_view(request, id):for exercise in set['exercise_list']:group_exercise_marker[set['obj'].id]['end'] = len(data)- # Note: '+1' here because there's an emtpy cell between days+ # Note: '+1' here because there's an emtpy cell between daysexercise_markers[day['obj'].id].append(len(data) + 1)data.append([set_count,Paragraph(exercise['obj'].name, styleSheet["Small"]),diff --git a/wger/manager/tests/test_copy_workout.py b/wger/manager/tests/test_copy_workout.pyindex 6c18511c8..4cbecbac3 100644--- a/wger/manager/tests/test_copy_workout.py+++ b/wger/manager/tests/test_copy_workout.py@@ -78,8 +78,6 @@ class CopyWorkoutTestCase(WorkoutManagerTestCase):sets_copy = days_copy[i].set_set.all()for j in range(days_original[i].set_set.count()):- #sets_original_id = sets_original[j].id- #sets_copy_id = sets_copy[j].idself.assertEqual(sets_original[j].sets, sets_copy[j].sets)self.assertEqual(sets_original[j].order, sets_copy[j].order)diff --git a/wger/manager/tests/test_workout_canonical.py b/wger/manager/tests/test_workout_canonical.pyindex eff140c41..2d9f3ad42 100644--- a/wger/manager/tests/test_workout_canonical.py+++ b/wger/manager/tests/test_workout_canonical.py@@ -97,10 +97,10 @@ class WorkoutCanonicalFormTestCase(WorkoutManagerTestCase):'setting_list': [10, 10, 10, 10],'setting_obj_list': [Setting.objects.get(pk=3)],'setting_text': u'4 \xd7 10'}],- 'is_superset': False,- 'has_settings': True,- 'muscles': {'back': [2], 'front': []},- 'obj': Set.objects.get(pk=3)}]+ 'is_superset': False,+ 'has_settings': True,+ 'muscles': {'back': [2], 'front': []},+ 'obj': Set.objects.get(pk=3)}]self.assertEqual(day.canonical_representation['set_list'], canonical_form)diff --git a/wger/manager/tests/testcase.py b/wger/manager/tests/testcase.pyindex 8a8e6892b..ac00f7084 100644--- a/wger/manager/tests/testcase.py+++ b/wger/manager/tests/testcase.py@@ -346,7 +346,6 @@ class WorkoutManagerAddTestCase(WorkoutManagerTestCase):if fail:self.assertIn(response.status_code, STATUS_CODES_FAIL)- #self.assertTemplateUsed('login.html')else:self.assertEqual(response.status_code, 200)diff --git a/wger/manager/views/log.py b/wger/manager/views/log.pyindex 7d59ac893..06967305b 100644--- a/wger/manager/views/log.py+++ b/wger/manager/views/log.py@@ -223,7 +223,6 @@ def add(request, pk):formset = WorkoutLogFormSet(queryset=WorkoutLog.objects.none())dateform = HelperDateForm(initial={'date': datetime.date.today()})- #session_form = HelperWorkoutSessionForm()# Depending on whether there is already a workout session for today, update# the current one or create a new one (this will be the most usual case)if WorkoutSession.objects.filter(user=request.user, date=datetime.date.today()).exists():@@ -380,7 +379,7 @@ def calendar(request, year=None, month=None):# Process the logs, 'overview' list for the calendarfor log in logs:- if not log.date in temp_date_list:+ if log.date not in temp_date_list:temp_date_list.append(log.date)logs_filtered.append(log)diff --git a/wger/manager/views/workout.py b/wger/manager/views/workout.pyindex 0756603f6..a08d8cc28 100644--- a/wger/manager/views/workout.py+++ b/wger/manager/views/workout.py@@ -78,10 +78,10 @@ def view(request, id):muscles_front = []muscles_back = []for i in canonical['muscles']['front']:- if not i in muscles_front:+ if i not in muscles_front:muscles_front.append('images/muscles/main/muscle-{0}.svg'.format(i))for i in canonical['muscles']['back']:- if not i in muscles_back:+ if i not in muscles_back:muscles_back.append('images/muscles/main/muscle-{0}.svg'.format(i))# Append the silhouette of the human body as the last entry so the browserdiff --git a/wger/nutrition/tests/test_ingredient.py b/wger/nutrition/tests/test_ingredient.pyindex 7434ec19a..f38a1f23d 100644--- a/wger/nutrition/tests/test_ingredient.py+++ b/wger/nutrition/tests/test_ingredient.py@@ -95,7 +95,6 @@ class AddIngredientTestCase(WorkoutManagerAddTestCase):'''Test that the creation date and the status are correctly set'''- #print self.current_userif self.current_user == 'admin':ingredient = Ingredient.objects.get(pk=self.pk)self.assertEqual(ingredient.creation_date, datetime.date.today())diff --git a/wger/nutrition/views/plan.py b/wger/nutrition/views/plan.pyindex 3807dd9ca..792abba2f 100644--- a/wger/nutrition/views/plan.py+++ b/wger/nutrition/views/plan.py@@ -164,7 +164,7 @@ def export_pdf(request, id):* http://www.reportlab.com/apis/reportlab/dev/platypus.html'''- #Load the workout+ # Load the workoutplan = get_object_or_404(NutritionPlan, pk=id, user=request.user)plan_data = plan.get_nutritional_values()diff --git a/wger/nutrition/views/unit_ingredient.py b/wger/nutrition/views/unit_ingredient.pyindex ed48a30d0..0e04a2aae 100644--- a/wger/nutrition/views/unit_ingredient.py+++ b/wger/nutrition/views/unit_ingredient.py@@ -52,7 +52,7 @@ class WeightUnitIngredientCreateView(WgerFormMixin, CreateView, WgerPermissionMititle = ugettext_lazy('Add a new weight unit')permission_required = 'nutrition.add_ingredientweightunit'- # Send some additional data to the template+ # Send some additional data to the templatedef get_context_data(self, **kwargs):context = super(WeightUnitIngredientCreateView, self).get_context_data(**kwargs)context['form_action'] = reverse('weight-unit-ingredient-add',diff --git a/wger/settings_global.py b/wger/settings_global.pyindex cc737ca16..35bfaf017 100644--- a/wger/settings_global.py+++ b/wger/settings_global.py@@ -27,7 +27,7 @@ For a full list of options, visit:SITE_ROOT = os.path.realpath(os.path.dirname(__file__))ADMINS = (- #('Your name', '[email protected]'),+ # ('Your name', '[email protected]'),)MANAGERS = ADMINS@@ -131,7 +131,7 @@ STATICFILES_DIRS = (STATICFILES_FINDERS = ('django.contrib.staticfiles.finders.FileSystemFinder','django.contrib.staticfiles.finders.AppDirectoriesFinder',- #'django.contrib.staticfiles.finders.DefaultStorageFinder',+ # 'django.contrib.staticfiles.finders.DefaultStorageFinder','compressor.finders.CompressorFinder',)@@ -142,14 +142,14 @@ TEMPLATE_LOADERS = ('django.template.loaders.filesystem.Loader','django.template.loaders.app_directories.Loader',- #'django.template.loaders.eggs.Loader',+ # 'django.template.loaders.eggs.Loader',)MIDDLEWARE_CLASSES = ('django.middleware.common.CommonMiddleware','django.contrib.sessions.middleware.SessionMiddleware','django.middleware.csrf.CsrfViewMiddleware',- #'django.contrib.auth.middleware.AuthenticationMiddleware',+ # 'django.contrib.auth.middleware.AuthenticationMiddleware',# Custom authentication middleware. Creates users on-the-fly for certain# paths'wger.utils.middleware.WgerAuthenticationMiddleware',@@ -177,7 +177,7 @@ TEMPLATE_DIRS = (# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".# Always use forward slashes, even on Windows.# Don't forget to use absolute paths, not relative paths.- #'',+ # '',)INSTALLED_APPS = (@@ -328,5 +328,5 @@ THUMBNAIL_ALIASES = {## The default is not DEBUG, override if needed-#COMPRESS_ENABLED = True+# COMPRESS_ENABLED = TrueCOMPRESS_ROOT = STATIC_ROOTdiff --git a/wger/utils/helpers.py b/wger/utils/helpers.pyindex 53ff02ad4..b6e49014c 100644--- a/wger/utils/helpers.py+++ b/wger/utils/helpers.py@@ -36,7 +36,6 @@ class DecimalJsonEncoder(json.JSONEncoder):def default(self, obj):if isinstance(obj, decimal.Decimal):return str(obj)- #return "%.2f" % objreturn json.JSONEncoder.default(self, obj)@@ -49,7 +48,7 @@ def disable_for_loaddata(signal_handler):@wraps(signal_handler)def wrapper(*args, **kwargs):if kwargs['raw']:- #print "Skipping signal for {0} {1}".format(args, kwargs)+ # print "Skipping signal for {0} {1}".format(args, kwargs)returnsignal_handler(*args, **kwargs)return wrapperdiff --git a/wger/utils/language.py b/wger/utils/language.pyindex 414067bc1..19d485e7d 100644--- a/wger/utils/language.py+++ b/wger/utils/language.py@@ -65,8 +65,6 @@ def load_item_languages(item):# Load the configurations we are interested in and return the languagesif not languages:-- #LanguageConfig.SHOW_ITEM_LISTlanguages = []config = LanguageConfig.objects.filter(language=language, item=item, show=True)diff --git a/wger/weight/api/resources.py b/wger/weight/api/resources.pyindex da8af9169..02284fad5 100644--- a/wger/weight/api/resources.py+++ b/wger/weight/api/resources.py@@ -27,8 +27,6 @@ class WeightEntryResource(ModelResource):Resource for weight entries'''- #meals = fields.ToManyField('wger.nutrition.api.resources.MealResource', 'meal_set')-def authorized_read_list(self, object_list, bundle):'''Filter to own objectsdiff --git a/wger/weight/helpers.py b/wger/weight/helpers.pyindex d36ffaba9..b52634c4e 100644--- a/wger/weight/helpers.py+++ b/wger/weight/helpers.py@@ -33,7 +33,6 @@ def parse_weight_csv(request, cleaned_data):try:dialect = csv.Sniffer().sniff(cleaned_data['csv_input'])except csv.Error:- #logger.debug('Error while sniffing CSV format')dialect = 'excel'# csv.reader expects a file-like object, so use StringIO@@ -53,8 +52,6 @@ def parse_weight_csv(request, cleaned_data):except (ValueError, IndexError, decimal.InvalidOperation):error_list.append(row)- #logger.debug(row)- #logger.debug(e)return (weight_list, error_list)diff --git a/wger/weight/views.py b/wger/weight/views.pyindex 98845c754..1a43d2cdb 100644--- a/wger/weight/views.py+++ b/wger/weight/views.py@@ -57,7 +57,6 @@ class WeightForm(ModelForm):model = WeightEntrywidgets = {'user': widgets.HiddenInput(),- #'weight': Html5NumberInput()}@@ -193,11 +192,11 @@ def get_weight_data(request):CSV_DATE_FORMAT = (('%d.%m.%Y', 'DD.MM.YYYY (30.01.2012)'),- ('%d.%m.%y', 'DD.MM.YY (30.01.12)'),- ('%Y-%m-%d', 'YYYY-MM-DD (2012-01-30)'),- ('%y-%m-%d', 'YY-MM-DD (12-01-30)'),- ('%m/%d/%Y', 'MM/DD/YYYY (01/30/2012)'),- ('%m/%d/%y', 'MM/DD/YY (01/30/12)'),)+ ('%d.%m.%y', 'DD.MM.YY (30.01.12)'),+ ('%Y-%m-%d', 'YYYY-MM-DD (2012-01-30)'),+ ('%y-%m-%d', 'YY-MM-DD (12-01-30)'),+ ('%m/%d/%Y', 'MM/DD/YYYY (01/30/2012)'),+ ('%m/%d/%y', 'MM/DD/YY (01/30/12)'),)class WeightCsvImportForm(Form):