Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Remove the number related own HTML5 input fields

Roland Geider15e48beb3fe0
diff --git a/wger/core/migrations/0006_auto__chg_field_userprofile_workout_reminder__chg_field_userprofile_ti.py b/wger/core/migrations/0006_auto__chg_field_userprofile_workout_reminder__chg_field_userprofile_ti.py
new file mode 100644
index 000000000..428da58ff
--- /dev/null
+++ b/wger/core/migrations/0006_auto__chg_field_userprofile_workout_reminder__chg_field_userprofile_ti.py
@@ -0,0 +1,157 @@
+# -*- coding: utf-8 -*-
+from south.utils import datetime_utils as datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+
+class Migration(SchemaMigration):
+
+ def forwards(self, orm):
+
+ # Changing field 'UserProfile.workout_reminder'
+ db.alter_column(u'core_userprofile', 'workout_reminder', self.gf('django.db.models.fields.IntegerField')())
+
+ # Changing field 'UserProfile.timer_pause'
+ db.alter_column(u'core_userprofile', 'timer_pause', self.gf('django.db.models.fields.IntegerField')())
+
+ # Changing field 'UserProfile.workout_duration'
+ db.alter_column(u'core_userprofile', 'workout_duration', self.gf('django.db.models.fields.IntegerField')())
+
+ # Changing field 'UserProfile.sleep_hours'
+ db.alter_column(u'core_userprofile', 'sleep_hours', self.gf('django.db.models.fields.IntegerField')(null=True))
+
+ # Changing field 'UserProfile.sport_hours'
+ db.alter_column(u'core_userprofile', 'sport_hours', self.gf('django.db.models.fields.IntegerField')(null=True))
+
+ # Changing field 'UserProfile.freetime_hours'
+ db.alter_column(u'core_userprofile', 'freetime_hours', self.gf('django.db.models.fields.IntegerField')(null=True))
+
+ # Changing field 'UserProfile.height'
+ db.alter_column(u'core_userprofile', 'height', self.gf('django.db.models.fields.IntegerField')(max_length=2, null=True))
+
+ # Changing field 'UserProfile.work_hours'
+ db.alter_column(u'core_userprofile', 'work_hours', self.gf('django.db.models.fields.IntegerField')(null=True))
+
+ # Changing field 'UserProfile.age'
+ db.alter_column(u'core_userprofile', 'age', self.gf('django.db.models.fields.IntegerField')(max_length=2, null=True))
+
+ # Changing field 'UserProfile.calories'
+ db.alter_column(u'core_userprofile', 'calories', self.gf('django.db.models.fields.IntegerField')(null=True))
+
+ def backwards(self, orm):
+
+ # Changing field 'UserProfile.workout_reminder'
+ db.alter_column(u'core_userprofile', 'workout_reminder', self.gf('wger.utils.fields.Html5IntegerField')())
+
+ # Changing field 'UserProfile.timer_pause'
+ db.alter_column(u'core_userprofile', 'timer_pause', self.gf('wger.utils.fields.Html5IntegerField')())
+
+ # Changing field 'UserProfile.workout_duration'
+ db.alter_column(u'core_userprofile', 'workout_duration', self.gf('wger.utils.fields.Html5IntegerField')())
+
+ # Changing field 'UserProfile.sleep_hours'
+ db.alter_column(u'core_userprofile', 'sleep_hours', self.gf('wger.utils.fields.Html5IntegerField')(null=True))
+
+ # Changing field 'UserProfile.sport_hours'
+ db.alter_column(u'core_userprofile', 'sport_hours', self.gf('wger.utils.fields.Html5IntegerField')(null=True))
+
+ # Changing field 'UserProfile.freetime_hours'
+ db.alter_column(u'core_userprofile', 'freetime_hours', self.gf('wger.utils.fields.Html5IntegerField')(null=True))
+
+ # Changing field 'UserProfile.height'
+ db.alter_column(u'core_userprofile', 'height', self.gf('wger.utils.fields.Html5IntegerField')(max_length=2, null=True))
+
+ # Changing field 'UserProfile.work_hours'
+ db.alter_column(u'core_userprofile', 'work_hours', self.gf('wger.utils.fields.Html5IntegerField')(null=True))
+
+ # Changing field 'UserProfile.age'
+ db.alter_column(u'core_userprofile', 'age', self.gf('wger.utils.fields.Html5IntegerField')(max_length=2, null=True))
+
+ # Changing field 'UserProfile.calories'
+ db.alter_column(u'core_userprofile', 'calories', self.gf('wger.utils.fields.Html5IntegerField')(null=True))
+
+ models = {
+ u'auth.group': {
+ 'Meta': {'object_name': 'Group'},
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
+ 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
+ },
+ u'auth.permission': {
+ 'Meta': {'ordering': "(u'content_type__app_label', u'content_type__model', u'codename')", 'unique_together': "((u'content_type', u'codename'),)", 'object_name': 'Permission'},
+ 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
+ },
+ u'auth.user': {
+ 'Meta': {'object_name': 'User'},
+ 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
+ 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+ 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Group']"}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+ 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+ 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
+ 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Permission']"}),
+ 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
+ },
+ u'contenttypes.contenttype': {
+ 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
+ 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
+ },
+ u'core.daysofweek': {
+ 'Meta': {'ordering': "['pk']", 'object_name': 'DaysOfWeek'},
+ 'day_of_week': ('django.db.models.fields.CharField', [], {'max_length': '9'}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'})
+ },
+ u'core.language': {
+ 'Meta': {'ordering': "['full_name']", 'object_name': 'Language'},
+ 'full_name': ('django.db.models.fields.CharField', [], {'max_length': '30'}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'short_name': ('django.db.models.fields.CharField', [], {'max_length': '2'})
+ },
+ u'core.license': {
+ 'Meta': {'ordering': "['full_name']", 'object_name': 'License'},
+ 'full_name': ('django.db.models.fields.CharField', [], {'max_length': '60'}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'short_name': ('django.db.models.fields.CharField', [], {'max_length': '15'}),
+ 'url': ('django.db.models.fields.URLField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'})
+ },
+ u'core.userprofile': {
+ 'Meta': {'object_name': 'UserProfile'},
+ 'age': ('django.db.models.fields.IntegerField', [], {'max_length': '2', 'null': 'True'}),
+ 'calories': ('django.db.models.fields.IntegerField', [], {'default': '2500', 'null': 'True'}),
+ 'freetime_hours': ('django.db.models.fields.IntegerField', [], {'default': '8', 'null': 'True'}),
+ 'freetime_intensity': ('django.db.models.fields.CharField', [], {'default': "'1'", 'max_length': '1', 'null': 'True'}),
+ 'gender': ('django.db.models.fields.CharField', [], {'default': "'1'", 'max_length': '1', 'null': 'True'}),
+ 'height': ('django.db.models.fields.IntegerField', [], {'max_length': '2', 'null': 'True'}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'is_temporary': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'last_workout_notification': ('django.db.models.fields.DateField', [], {'null': 'True'}),
+ 'notification_language': ('django.db.models.fields.related.ForeignKey', [], {'default': '2', 'to': u"orm['core.Language']"}),
+ 'show_comments': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+ 'show_english_ingredients': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+ 'sleep_hours': ('django.db.models.fields.IntegerField', [], {'default': '7', 'null': 'True'}),
+ 'sport_hours': ('django.db.models.fields.IntegerField', [], {'default': '3', 'null': 'True'}),
+ 'sport_intensity': ('django.db.models.fields.CharField', [], {'default': "'2'", 'max_length': '1', 'null': 'True'}),
+ 'timer_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+ 'timer_pause': ('django.db.models.fields.IntegerField', [], {'default': '90'}),
+ 'user': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['auth.User']", 'unique': 'True'}),
+ 'work_hours': ('django.db.models.fields.IntegerField', [], {'default': '8', 'null': 'True'}),
+ 'work_intensity': ('django.db.models.fields.CharField', [], {'default': "'1'", 'max_length': '1', 'null': 'True'}),
+ 'workout_duration': ('django.db.models.fields.IntegerField', [], {'default': '12'}),
+ 'workout_reminder': ('django.db.models.fields.IntegerField', [], {'default': '14'}),
+ 'workout_reminder_active': ('django.db.models.fields.BooleanField', [], {'default': 'False'})
+ }
+ }
+
+ complete_apps = ['core']
\ No newline at end of file
diff --git a/wger/core/models.py b/wger/core/models.py
index 29786246e..fd95b2e6a 100644
--- a/wger/core/models.py
+++ b/wger/core/models.py
@@ -18,6 +18,7 @@ import datetime
import decimal
from django.db import models
+from django.db.models import IntegerField
from django.db.models.signals import post_save
from django.contrib.auth.models import User
from django.core.urlresolvers import reverse
@@ -27,7 +28,6 @@ from django.utils.translation import ugettext_lazy as _
from wger.utils.helpers import disable_for_loaddata
from wger.utils.constants import TWOPLACES
-from wger.utils.fields import Html5IntegerField
from wger.weight.models import WeightEntry
@@ -128,17 +128,17 @@ by the US Department of Agriculture. It is extremely complete, with around
'to work.'),
default=False)
- workout_reminder = Html5IntegerField(verbose_name=_('Remind before expiration'),
- help_text=_('The number of days you want to be reminded '
- 'before a workout expires.'),
- default=14,
- validators=[MinValueValidator(1), MaxValueValidator(30)])
- workout_duration = Html5IntegerField(verbose_name=_('Default duration of workouts'),
- help_text=_('Default duration in weeks of workouts not '
- 'in a schedule. Used for email workout '
- 'reminders.'),
- default=12,
- validators=[MinValueValidator(1), MaxValueValidator(30)])
+ workout_reminder = IntegerField(verbose_name=_('Remind before expiration'),
+ help_text=_('The number of days you want to be reminded '
+ 'before a workout expires.'),
+ default=14,
+ validators=[MinValueValidator(1), MaxValueValidator(30)])
+ workout_duration = IntegerField(verbose_name=_('Default duration of workouts'),
+ help_text=_('Default duration in weeks of workouts not '
+ 'in a schedule. Used for email workout '
+ 'reminders.'),
+ default=12,
+ validators=[MinValueValidator(1), MaxValueValidator(30)])
last_workout_notification = models.DateField(editable=False,
blank=False,
null=True)
@@ -165,11 +165,11 @@ by the US Department of Agriculture. It is extremely complete, with around
Switch to activate pauses in the gym view
'''
- timer_pause = Html5IntegerField(verbose_name=_('Default duration of workout pauses'),
- help_text=_('Default duration in seconds of pauses used by '
- 'the timer in the gym mode.'),
- default=90,
- validators=[MinValueValidator(10), MaxValueValidator(400)])
+ timer_pause = IntegerField(verbose_name=_('Default duration of workout pauses'),
+ help_text=_('Default duration in seconds of pauses used by '
+ 'the timer in the gym mode.'),
+ default=90,
+ validators=[MinValueValidator(10), MaxValueValidator(400)])
'''
Default duration of workout pauses in the gym view
'''
@@ -177,18 +177,18 @@ by the US Department of Agriculture. It is extremely complete, with around
#
# User statistics
#
- age = Html5IntegerField(max_length=2,
- verbose_name=_('Age'),
- blank=False,
- null=True,
- validators=[MinValueValidator(10), MaxValueValidator(100)])
+ age = IntegerField(max_length=2,
+ verbose_name=_('Age'),
+ blank=False,
+ null=True,
+ validators=[MinValueValidator(10), MaxValueValidator(100)])
'''The user's age'''
- height = Html5IntegerField(max_length=2,
- verbose_name=_('Height (cm)'),
- blank=False,
- validators=[MinValueValidator(140), MaxValueValidator(230)],
- null=True)
+ height = IntegerField(max_length=2,
+ verbose_name=_('Height (cm)'),
+ blank=False,
+ validators=[MinValueValidator(140), MaxValueValidator(230)],
+ null=True)
'''The user's height'''
gender = models.CharField(max_length=1,
@@ -198,20 +198,20 @@ by the US Department of Agriculture. It is extremely complete, with around
null=True)
'''Gender'''
- sleep_hours = Html5IntegerField(verbose_name=_('Hours of sleep'),
- help_text=_('The average hours of sleep per day'),
- default=7,
- blank=False,
- null=True,
- validators=[MinValueValidator(4), MaxValueValidator(10)])
+ sleep_hours = IntegerField(verbose_name=_('Hours of sleep'),
+ help_text=_('The average hours of sleep per day'),
+ default=7,
+ blank=False,
+ null=True,
+ validators=[MinValueValidator(4), MaxValueValidator(10)])
'''The average hours of sleep per day'''
- work_hours = Html5IntegerField(verbose_name=_('Work'),
- help_text=_('Average hours per day'),
- default=8,
- blank=False,
- null=True,
- validators=[MinValueValidator(1), MaxValueValidator(15)])
+ work_hours = IntegerField(verbose_name=_('Work'),
+ help_text=_('Average hours per day'),
+ default=8,
+ blank=False,
+ null=True,
+ validators=[MinValueValidator(1), MaxValueValidator(15)])
'''The average hours at work per day'''
work_intensity = models.CharField(verbose_name=_('Physical intensity'),
@@ -223,12 +223,12 @@ by the US Department of Agriculture. It is extremely complete, with around
null=True)
'''Physical intensity of work'''
- sport_hours = Html5IntegerField(verbose_name=_('Sport'),
- help_text=_('Average hours per week'),
- default=3,
- blank=False,
- null=True,
- validators=[MinValueValidator(1), MaxValueValidator(30)])
+ sport_hours = IntegerField(verbose_name=_('Sport'),
+ help_text=_('Average hours per week'),
+ default=3,
+ blank=False,
+ null=True,
+ validators=[MinValueValidator(1), MaxValueValidator(30)])
'''The average hours performing sports per week'''
sport_intensity = models.CharField(verbose_name=_('Physical intensity'),
@@ -240,12 +240,12 @@ by the US Department of Agriculture. It is extremely complete, with around
null=True)
'''Physical intensity of sport activities'''
- freetime_hours = Html5IntegerField(verbose_name=_('Free time'),
- help_text=_('Average hours per day'),
- default=8,
- blank=False,
- null=True,
- validators=[MinValueValidator(1), MaxValueValidator(15)])
+ freetime_hours = IntegerField(verbose_name=_('Free time'),
+ help_text=_('Average hours per day'),
+ default=8,
+ blank=False,
+ null=True,
+ validators=[MinValueValidator(1), MaxValueValidator(15)])
'''The average hours of free time per day'''
freetime_intensity = models.CharField(verbose_name=_('Physical intensity'),
@@ -257,12 +257,12 @@ by the US Department of Agriculture. It is extremely complete, with around
null=True)
'''Physical intensity during free time'''
- calories = Html5IntegerField(verbose_name=_('Total daily calories'),
- help_text=_('Total caloric intake, including e.g. any surplus'),
- default=2500,
- blank=False,
- null=True,
- validators=[MinValueValidator(1500), MaxValueValidator(5000)])
+ calories = IntegerField(verbose_name=_('Total daily calories'),
+ help_text=_('Total caloric intake, including e.g. any surplus'),
+ default=2500,
+ blank=False,
+ null=True,
+ validators=[MinValueValidator(1500), MaxValueValidator(5000)])
'''Basic caloric intake based on physical activity'''
@property
@@ -299,7 +299,8 @@ by the US Department of Agriculture. It is extremely complete, with around
- weight in kg
- height in m
'''
- return self.weight / (self.height / 100.0 * self.height / 100.0)
+ return self.weight / (self.height / decimal.Decimal(100) *
+ self.height / decimal.Decimal(100.0))
def calculate_basal_metabolic_rate(self, formula=1):
'''
@@ -307,15 +308,11 @@ by the US Department of Agriculture. It is extremely complete, with around
Currently only the Mifflin-St.Jeor formula is supported
'''
-
- if self.gender == self.GENDER_MALE:
- factor = 5
- else:
- factor = -161
+ factor = 5 if self.gender == self.GENDER_MALE else -161
try:
rate = ((10 * self.weight) # in kg
- + (6.25 * self.height) # in cm
+ + (decimal.Decimal(6.25) * self.height) # in cm
- (5 * self.age) # in years
+ factor)
# Any of the entries is missing
diff --git a/wger/core/tests/test_preferences.py b/wger/core/tests/test_preferences.py
index 2ee2986c1..e9f7061bf 100644
--- a/wger/core/tests/test_preferences.py
+++ b/wger/core/tests/test_preferences.py
@@ -206,7 +206,9 @@ class PreferencesCalculationsTestCase(WorkoutManagerTestCase):
user = User.objects.get(pk=2)
bmi = user.userprofile.calculate_bmi()
- self.assertEqual(bmi, user.userprofile.weight / (1.80 * 1.80))
+ self.assertEqual(bmi,
+ user.userprofile.weight.quantize(TWOPLACES)
+ / decimal.Decimal(1.80 * 1.80).quantize(TWOPLACES))
def test_basal_metabolic_rate(self):
'''
diff --git a/wger/manager/forms.py b/wger/manager/forms.py
index 4c233d60e..d96ccf789 100644
--- a/wger/manager/forms.py
+++ b/wger/manager/forms.py
@@ -22,7 +22,6 @@ from django.forms import Form
from django.forms import ModelForm
from django.forms import DateField
from django.forms import CharField
-from django.forms import DecimalField
from django.forms import widgets
from django.forms import ModelChoiceField
from django.utils.translation import ugettext as _
@@ -40,7 +39,6 @@ from wger.utils.widgets import TranslatedSelectMultiple
from wger.utils.widgets import ExerciseAjaxSelect
from wger.utils.constants import DATE_FORMATS
from wger.utils.widgets import Html5DateInput
-from wger.utils.widgets import Html5NumberInput
class DemoUserForm(Form):
@@ -118,14 +116,7 @@ class HelperDateForm(Form):
class WorkoutLogForm(ModelForm):
'''
Helper form for a WorkoutLog.
-
- The field for the weight is overwritten here, activating localization (so a
- German user can use ',' as the separator)
'''
- weight = DecimalField(decimal_places=2,
- max_digits=5,
- localize=True,
- widget=Html5NumberInput())
class Meta:
model = WorkoutLog
diff --git a/wger/manager/migrations/0019_auto__chg_field_setting_reps__chg_field_setting_order__chg_field_set_o.py b/wger/manager/migrations/0019_auto__chg_field_setting_reps__chg_field_setting_order__chg_field_set_o.py
new file mode 100644
index 000000000..fd88972b9
--- /dev/null
+++ b/wger/manager/migrations/0019_auto__chg_field_setting_reps__chg_field_setting_order__chg_field_set_o.py
@@ -0,0 +1,213 @@
+# -*- coding: utf-8 -*-
+from south.utils import datetime_utils as datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+
+class Migration(SchemaMigration):
+
+ def forwards(self, orm):
+
+ # Changing field 'Setting.reps'
+ db.alter_column(u'manager_setting', 'reps', self.gf('django.db.models.fields.IntegerField')())
+
+ # Changing field 'Setting.order'
+ db.alter_column(u'manager_setting', 'order', self.gf('django.db.models.fields.IntegerField')())
+
+ # Changing field 'Set.order'
+ db.alter_column(u'manager_set', 'order', self.gf('django.db.models.fields.IntegerField')(null=True))
+
+ # Changing field 'Set.sets'
+ db.alter_column(u'manager_set', 'sets', self.gf('django.db.models.fields.IntegerField')())
+
+ # Changing field 'WorkoutLog.weight'
+ db.alter_column(u'manager_workoutlog', 'weight', self.gf('django.db.models.fields.DecimalField')(max_digits=5, decimal_places=2))
+
+ # Changing field 'WorkoutLog.reps'
+ db.alter_column(u'manager_workoutlog', 'reps', self.gf('django.db.models.fields.IntegerField')())
+
+ # Changing field 'ScheduleStep.duration'
+ db.alter_column(u'manager_schedulestep', 'duration', self.gf('django.db.models.fields.IntegerField')())
+
+ def backwards(self, orm):
+
+ # Changing field 'Setting.reps'
+ db.alter_column(u'manager_setting', 'reps', self.gf('wger.utils.fields.Html5IntegerField')())
+
+ # Changing field 'Setting.order'
+ db.alter_column(u'manager_setting', 'order', self.gf('wger.utils.fields.Html5IntegerField')())
+
+ # Changing field 'Set.order'
+ db.alter_column(u'manager_set', 'order', self.gf('wger.utils.fields.Html5IntegerField')(null=True))
+
+ # Changing field 'Set.sets'
+ db.alter_column(u'manager_set', 'sets', self.gf('wger.utils.fields.Html5IntegerField')())
+
+ # Changing field 'WorkoutLog.weight'
+ db.alter_column(u'manager_workoutlog', 'weight', self.gf('wger.utils.fields.Html5DecimalField')(max_digits=5, decimal_places=2))
+
+ # Changing field 'WorkoutLog.reps'
+ db.alter_column(u'manager_workoutlog', 'reps', self.gf('wger.utils.fields.Html5IntegerField')())
+
+ # Changing field 'ScheduleStep.duration'
+ db.alter_column(u'manager_schedulestep', 'duration', self.gf('wger.utils.fields.Html5IntegerField')())
+
+ models = {
+ u'auth.group': {
+ 'Meta': {'object_name': 'Group'},
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
+ 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
+ },
+ u'auth.permission': {
+ 'Meta': {'ordering': "(u'content_type__app_label', u'content_type__model', u'codename')", 'unique_together': "((u'content_type', u'codename'),)", 'object_name': 'Permission'},
+ 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
+ },
+ u'auth.user': {
+ 'Meta': {'object_name': 'User'},
+ 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
+ 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+ 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Group']"}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+ 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+ 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
+ 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Permission']"}),
+ 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
+ },
+ u'contenttypes.contenttype': {
+ 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
+ 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
+ },
+ u'core.daysofweek': {
+ 'Meta': {'ordering': "['pk']", 'object_name': 'DaysOfWeek'},
+ 'day_of_week': ('django.db.models.fields.CharField', [], {'max_length': '9'}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'})
+ },
+ u'core.language': {
+ 'Meta': {'ordering': "['full_name']", 'object_name': 'Language'},
+ 'full_name': ('django.db.models.fields.CharField', [], {'max_length': '30'}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'short_name': ('django.db.models.fields.CharField', [], {'max_length': '2'})
+ },
+ u'core.license': {
+ 'Meta': {'ordering': "['full_name']", 'object_name': 'License'},
+ 'full_name': ('django.db.models.fields.CharField', [], {'max_length': '60'}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'short_name': ('django.db.models.fields.CharField', [], {'max_length': '15'}),
+ 'url': ('django.db.models.fields.URLField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'})
+ },
+ u'exercises.equipment': {
+ 'Meta': {'ordering': "['name']", 'object_name': 'Equipment'},
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
+ },
+ u'exercises.exercise': {
+ 'Meta': {'ordering': "['name']", 'object_name': 'Exercise'},
+ 'category': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['exercises.ExerciseCategory']"}),
+ 'creation_date': ('django.db.models.fields.DateField', [], {'auto_now_add': 'True', 'null': 'True', 'blank': 'True'}),
+ 'description': ('django.db.models.fields.TextField', [], {'max_length': '2000'}),
+ 'equipment': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'to': u"orm['exercises.Equipment']", 'null': 'True', 'blank': 'True'}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'language': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['core.Language']"}),
+ 'license': ('django.db.models.fields.related.ForeignKey', [], {'default': '1', 'to': u"orm['core.License']"}),
+ 'license_author': ('django.db.models.fields.CharField', [], {'max_length': '50', 'null': 'True', 'blank': 'True'}),
+ 'muscles': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'to': u"orm['exercises.Muscle']", 'null': 'True', 'blank': 'True'}),
+ 'muscles_secondary': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "'secondary_muscles'", 'null': 'True', 'symmetrical': 'False', 'to': u"orm['exercises.Muscle']"}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '200'}),
+ 'status': ('django.db.models.fields.CharField', [], {'default': "'1'", 'max_length': '2'})
+ },
+ u'exercises.exercisecategory': {
+ 'Meta': {'ordering': "['name']", 'object_name': 'ExerciseCategory'},
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
+ },
+ u'exercises.muscle': {
+ 'Meta': {'ordering': "['name']", 'object_name': 'Muscle'},
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'is_front': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
+ },
+ u'manager.day': {
+ 'Meta': {'object_name': 'Day'},
+ 'day': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['core.DaysOfWeek']", 'symmetrical': 'False'}),
+ 'description': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'training': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['manager.Workout']"})
+ },
+ u'manager.schedule': {
+ 'Meta': {'object_name': 'Schedule'},
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+ 'is_loop': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'start_date': ('wger.utils.fields.Html5DateField', [], {'default': 'datetime.date.today'}),
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['auth.User']"})
+ },
+ u'manager.schedulestep': {
+ 'Meta': {'ordering': "['order']", 'object_name': 'ScheduleStep'},
+ 'duration': ('django.db.models.fields.IntegerField', [], {'default': '4'}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'order': ('django.db.models.fields.IntegerField', [], {'default': '1', 'max_length': '1'}),
+ 'schedule': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['manager.Schedule']"}),
+ 'workout': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['manager.Workout']"})
+ },
+ u'manager.set': {
+ 'Meta': {'ordering': "['order']", 'object_name': 'Set'},
+ 'exerciseday': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['manager.Day']"}),
+ 'exercises': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['exercises.Exercise']", 'symmetrical': 'False'}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'order': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}),
+ 'sets': ('django.db.models.fields.IntegerField', [], {'default': '4'})
+ },
+ u'manager.setting': {
+ 'Meta': {'ordering': "['order', 'id']", 'object_name': 'Setting'},
+ 'comment': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}),
+ 'exercise': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['exercises.Exercise']"}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'order': ('django.db.models.fields.IntegerField', [], {'blank': 'True'}),
+ 'reps': ('django.db.models.fields.IntegerField', [], {}),
+ 'set': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['manager.Set']"})
+ },
+ u'manager.workout': {
+ 'Meta': {'ordering': "['-creation_date']", 'object_name': 'Workout'},
+ 'comment': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}),
+ 'creation_date': ('django.db.models.fields.DateField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['auth.User']"})
+ },
+ u'manager.workoutlog': {
+ 'Meta': {'ordering': "['date', 'reps']", 'object_name': 'WorkoutLog'},
+ 'date': ('wger.utils.fields.Html5DateField', [], {}),
+ 'exercise': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['exercises.Exercise']"}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'reps': ('django.db.models.fields.IntegerField', [], {}),
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['auth.User']"}),
+ 'weight': ('django.db.models.fields.DecimalField', [], {'max_digits': '5', 'decimal_places': '2'}),
+ 'workout': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['manager.Workout']"})
+ },
+ u'manager.workoutsession': {
+ 'Meta': {'ordering': "['date']", 'unique_together': "(('date', 'user'),)", 'object_name': 'WorkoutSession'},
+ 'date': ('wger.utils.fields.Html5DateField', [], {}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'impression': ('django.db.models.fields.CharField', [], {'default': "'2'", 'max_length': '2'}),
+ 'notes': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
+ 'time_end': ('django.db.models.fields.TimeField', [], {'null': 'True', 'blank': 'True'}),
+ 'time_start': ('django.db.models.fields.TimeField', [], {'null': 'True', 'blank': 'True'}),
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['auth.User']"}),
+ 'workout': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['manager.Workout']"})
+ }
+ }
+
+ complete_apps = ['manager']
\ No newline at end of file
diff --git a/wger/manager/models.py b/wger/manager/models.py
index 1370dc356..ce1a3acc3 100644
--- a/wger/manager/models.py
+++ b/wger/manager/models.py
@@ -32,8 +32,6 @@ from wger.core.models import DaysOfWeek
from wger.exercises.models import Exercise
from wger.utils.cache import cache_mapper, reset_workout_canonical_form
from wger.utils.fields import Html5DateField
-from wger.utils.fields import Html5DecimalField
-from wger.utils.fields import Html5IntegerField
logger = logging.getLogger('wger.custom')
@@ -298,10 +296,10 @@ class ScheduleStep(models.Model):
workout = models.ForeignKey(Workout)
'''The workout this step manages'''
- duration = Html5IntegerField(verbose_name=_('Duration'),
- help_text=_('The duration in weeks'),
- default=4,
- validators=[MinValueValidator(1), MaxValueValidator(25)])
+ duration = models.IntegerField(verbose_name=_('Duration'),
+ help_text=_('The duration in weeks'),
+ default=4,
+ validators=[MinValueValidator(1), MaxValueValidator(25)])
'''The duration in weeks'''
order = models.IntegerField(verbose_name=_('Order'),
@@ -479,12 +477,12 @@ class Set(models.Model):
verbose_name=_('Exercise day'))
exercises = models.ManyToManyField(Exercise,
verbose_name=_('Exercises'))
- order = Html5IntegerField(blank=True,
- null=True,
- verbose_name=_('Order'))
- sets = Html5IntegerField(validators=[MinValueValidator(0), MaxValueValidator(MAX_SETS)],
- verbose_name=_('Number of sets'),
- default=DEFAULT_SETS)
+ order = models.IntegerField(blank=True,
+ null=True,
+ verbose_name=_('Order'))
+ sets = models.IntegerField(validators=[MinValueValidator(0), MaxValueValidator(MAX_SETS)],
+ verbose_name=_('Number of sets'),
+ default=DEFAULT_SETS)
# Metaclass to set some other properties
class Meta:
@@ -527,10 +525,10 @@ class Setting(models.Model):
set = models.ForeignKey(Set, verbose_name=_('Sets'))
exercise = models.ForeignKey(Exercise,
verbose_name=_('Exercises'))
- reps = Html5IntegerField(validators=[MinValueValidator(0), MaxValueValidator(100)],
- verbose_name=_('Repetitions'))
- order = Html5IntegerField(blank=True,
- verbose_name=_('Order'))
+ reps = models.IntegerField(validators=[MinValueValidator(0), MaxValueValidator(100)],
+ verbose_name=_('Repetitions'))
+ order = models.IntegerField(blank=True,
+ verbose_name=_('Order'))
comment = models.CharField(max_length=100,
blank=True,
verbose_name=_('Comment'))
@@ -581,13 +579,13 @@ class WorkoutLog(models.Model):
workout = models.ForeignKey(Workout,
verbose_name=_('Workout'))
- reps = Html5IntegerField(verbose_name=_('Repetitions'),
- validators=[MinValueValidator(0)])
-
- weight = Html5DecimalField(decimal_places=2,
- max_digits=5,
- verbose_name=_('Weight'),
+ reps = models.IntegerField(verbose_name=_('Repetitions'),
validators=[MinValueValidator(0)])
+
+ weight = models.DecimalField(decimal_places=2,
+ max_digits=5,
+ verbose_name=_('Weight'),
+ validators=[MinValueValidator(0)])
date = Html5DateField(verbose_name=_('Date'))
# Metaclass to set some other properties
diff --git a/wger/nutrition/migrations/0012_auto__chg_field_mealitem_amount__chg_field_ingredient_sodium__chg_fiel.py b/wger/nutrition/migrations/0012_auto__chg_field_mealitem_amount__chg_field_ingredient_sodium__chg_fiel.py
new file mode 100644
index 000000000..5a4359e19
--- /dev/null
+++ b/wger/nutrition/migrations/0012_auto__chg_field_mealitem_amount__chg_field_ingredient_sodium__chg_fiel.py
@@ -0,0 +1,179 @@
+# -*- coding: utf-8 -*-
+from south.utils import datetime_utils as datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+
+class Migration(SchemaMigration):
+
+ def forwards(self, orm):
+
+ # Changing field 'MealItem.amount'
+ db.alter_column(u'nutrition_mealitem', 'amount', self.gf('django.db.models.fields.DecimalField')(max_digits=6, decimal_places=2))
+
+ # Changing field 'Ingredient.sodium'
+ db.alter_column(u'nutrition_ingredient', 'sodium', self.gf('django.db.models.fields.DecimalField')(null=True, max_digits=6, decimal_places=3))
+
+ # Changing field 'Ingredient.carbohydrates'
+ db.alter_column(u'nutrition_ingredient', 'carbohydrates', self.gf('django.db.models.fields.DecimalField')(max_digits=6, decimal_places=3))
+
+ # Changing field 'Ingredient.fat'
+ db.alter_column(u'nutrition_ingredient', 'fat', self.gf('django.db.models.fields.DecimalField')(max_digits=6, decimal_places=3))
+
+ # Changing field 'Ingredient.carbohydrates_sugar'
+ db.alter_column(u'nutrition_ingredient', 'carbohydrates_sugar', self.gf('django.db.models.fields.DecimalField')(null=True, max_digits=6, decimal_places=3))
+
+ # Changing field 'Ingredient.fat_saturated'
+ db.alter_column(u'nutrition_ingredient', 'fat_saturated', self.gf('django.db.models.fields.DecimalField')(null=True, max_digits=6, decimal_places=3))
+
+ # Changing field 'Ingredient.fibres'
+ db.alter_column(u'nutrition_ingredient', 'fibres', self.gf('django.db.models.fields.DecimalField')(null=True, max_digits=6, decimal_places=3))
+
+ # Changing field 'Ingredient.protein'
+ db.alter_column(u'nutrition_ingredient', 'protein', self.gf('django.db.models.fields.DecimalField')(max_digits=6, decimal_places=3))
+
+ # Changing field 'Ingredient.energy'
+ db.alter_column(u'nutrition_ingredient', 'energy', self.gf('django.db.models.fields.IntegerField')())
+
+ def backwards(self, orm):
+
+ # Changing field 'MealItem.amount'
+ db.alter_column(u'nutrition_mealitem', 'amount', self.gf('wger.utils.fields.Html5DecimalField')(max_digits=6, decimal_places=2))
+
+ # Changing field 'Ingredient.sodium'
+ db.alter_column(u'nutrition_ingredient', 'sodium', self.gf('wger.utils.fields.Html5DecimalField')(null=True, max_digits=6, decimal_places=3))
+
+ # Changing field 'Ingredient.carbohydrates'
+ db.alter_column(u'nutrition_ingredient', 'carbohydrates', self.gf('wger.utils.fields.Html5DecimalField')(max_digits=6, decimal_places=3))
+
+ # Changing field 'Ingredient.fat'
+ db.alter_column(u'nutrition_ingredient', 'fat', self.gf('wger.utils.fields.Html5DecimalField')(max_digits=6, decimal_places=3))
+
+ # Changing field 'Ingredient.carbohydrates_sugar'
+ db.alter_column(u'nutrition_ingredient', 'carbohydrates_sugar', self.gf('wger.utils.fields.Html5DecimalField')(null=True, max_digits=6, decimal_places=3))
+
+ # Changing field 'Ingredient.fat_saturated'
+ db.alter_column(u'nutrition_ingredient', 'fat_saturated', self.gf('wger.utils.fields.Html5DecimalField')(null=True, max_digits=6, decimal_places=3))
+
+ # Changing field 'Ingredient.fibres'
+ db.alter_column(u'nutrition_ingredient', 'fibres', self.gf('wger.utils.fields.Html5DecimalField')(null=True, max_digits=6, decimal_places=3))
+
+ # Changing field 'Ingredient.protein'
+ db.alter_column(u'nutrition_ingredient', 'protein', self.gf('wger.utils.fields.Html5DecimalField')(max_digits=6, decimal_places=3))
+
+ # Changing field 'Ingredient.energy'
+ db.alter_column(u'nutrition_ingredient', 'energy', self.gf('wger.utils.fields.Html5IntegerField')())
+
+ models = {
+ u'auth.group': {
+ 'Meta': {'object_name': 'Group'},
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
+ 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
+ },
+ u'auth.permission': {
+ 'Meta': {'ordering': "(u'content_type__app_label', u'content_type__model', u'codename')", 'unique_together': "((u'content_type', u'codename'),)", 'object_name': 'Permission'},
+ 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
+ },
+ u'auth.user': {
+ 'Meta': {'object_name': 'User'},
+ 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
+ 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+ 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Group']"}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+ 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+ 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
+ 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Permission']"}),
+ 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
+ },
+ u'contenttypes.contenttype': {
+ 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
+ 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
+ },
+ u'core.language': {
+ 'Meta': {'ordering': "['full_name']", 'object_name': 'Language'},
+ 'full_name': ('django.db.models.fields.CharField', [], {'max_length': '30'}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'short_name': ('django.db.models.fields.CharField', [], {'max_length': '2'})
+ },
+ u'core.license': {
+ 'Meta': {'ordering': "['full_name']", 'object_name': 'License'},
+ 'full_name': ('django.db.models.fields.CharField', [], {'max_length': '60'}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'short_name': ('django.db.models.fields.CharField', [], {'max_length': '15'}),
+ 'url': ('django.db.models.fields.URLField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'})
+ },
+ u'nutrition.ingredient': {
+ 'Meta': {'ordering': "['name']", 'object_name': 'Ingredient'},
+ 'carbohydrates': ('django.db.models.fields.DecimalField', [], {'max_digits': '6', 'decimal_places': '3'}),
+ 'carbohydrates_sugar': ('django.db.models.fields.DecimalField', [], {'null': 'True', 'max_digits': '6', 'decimal_places': '3', 'blank': 'True'}),
+ 'creation_date': ('django.db.models.fields.DateField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+ 'energy': ('django.db.models.fields.IntegerField', [], {}),
+ 'fat': ('django.db.models.fields.DecimalField', [], {'max_digits': '6', 'decimal_places': '3'}),
+ 'fat_saturated': ('django.db.models.fields.DecimalField', [], {'null': 'True', 'max_digits': '6', 'decimal_places': '3', 'blank': 'True'}),
+ 'fibres': ('django.db.models.fields.DecimalField', [], {'null': 'True', 'max_digits': '6', 'decimal_places': '3', 'blank': 'True'}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'language': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['core.Language']"}),
+ 'license': ('django.db.models.fields.related.ForeignKey', [], {'default': '1', 'to': u"orm['core.License']"}),
+ 'license_author': ('django.db.models.fields.CharField', [], {'max_length': '50', 'null': 'True', 'blank': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '200'}),
+ 'protein': ('django.db.models.fields.DecimalField', [], {'max_digits': '6', 'decimal_places': '3'}),
+ 'sodium': ('django.db.models.fields.DecimalField', [], {'null': 'True', 'max_digits': '6', 'decimal_places': '3', 'blank': 'True'}),
+ 'status': ('django.db.models.fields.CharField', [], {'default': "'1'", 'max_length': '2'}),
+ 'update_date': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}),
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['auth.User']", 'null': 'True', 'blank': 'True'})
+ },
+ u'nutrition.ingredientweightunit': {
+ 'Meta': {'object_name': 'IngredientWeightUnit'},
+ 'amount': ('django.db.models.fields.DecimalField', [], {'default': '1', 'max_digits': '5', 'decimal_places': '2'}),
+ 'gramm': ('django.db.models.fields.IntegerField', [], {}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'ingredient': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['nutrition.Ingredient']"}),
+ 'unit': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['nutrition.WeightUnit']"})
+ },
+ u'nutrition.meal': {
+ 'Meta': {'ordering': "['time']", 'object_name': 'Meal'},
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'order': ('django.db.models.fields.IntegerField', [], {'max_length': '1', 'blank': 'True'}),
+ 'plan': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['nutrition.NutritionPlan']"}),
+ 'time': ('wger.utils.fields.Html5TimeField', [], {'null': 'True', 'blank': 'True'})
+ },
+ u'nutrition.mealitem': {
+ 'Meta': {'object_name': 'MealItem'},
+ 'amount': ('django.db.models.fields.DecimalField', [], {'max_digits': '6', 'decimal_places': '2'}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'ingredient': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['nutrition.Ingredient']"}),
+ 'meal': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['nutrition.Meal']"}),
+ 'order': ('django.db.models.fields.IntegerField', [], {'max_length': '1', 'blank': 'True'}),
+ 'weight_unit': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['nutrition.IngredientWeightUnit']", 'null': 'True', 'blank': 'True'})
+ },
+ u'nutrition.nutritionplan': {
+ 'Meta': {'ordering': "['-creation_date']", 'object_name': 'NutritionPlan'},
+ 'creation_date': ('django.db.models.fields.DateField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+ 'description': ('django.db.models.fields.TextField', [], {'max_length': '2000', 'blank': 'True'}),
+ 'has_goal_calories': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'language': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['core.Language']"}),
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['auth.User']"})
+ },
+ u'nutrition.weightunit': {
+ 'Meta': {'ordering': "['name']", 'object_name': 'WeightUnit'},
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'language': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['core.Language']"}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '200'})
+ }
+ }
+
+ complete_apps = ['nutrition']
\ No newline at end of file
diff --git a/wger/nutrition/models.py b/wger/nutrition/models.py
index e4db9340f..6b7645559 100644
--- a/wger/nutrition/models.py
+++ b/wger/nutrition/models.py
@@ -37,8 +37,6 @@ from wger.utils.constants import EMAIL_FROM
from wger.utils.constants import TWOPLACES
from wger.utils.cache import cache_mapper
from wger.utils.fields import Html5TimeField
-from wger.utils.fields import Html5DecimalField
-from wger.utils.fields import Html5IntegerField
from wger.utils.models import AbstractLicenseModel
MEALITEM_WEIGHT_GRAM = '1'
@@ -244,59 +242,65 @@ class Ingredient(AbstractLicenseModel, models.Model):
name = models.CharField(max_length=200,
verbose_name=_('Name'),)
- energy = Html5IntegerField(verbose_name=_('Energy'),
- help_text=_('In kcal per 100g'))
-
- protein = Html5DecimalField(decimal_places=3,
- max_digits=6,
- verbose_name=_('Protein'),
- help_text=_('In g per 100g of product'),
- validators=[MinValueValidator(0), MaxValueValidator(100)])
-
- carbohydrates = Html5DecimalField(decimal_places=3,
- max_digits=6,
- verbose_name=_('Carbohydrates'),
- help_text=_('In g per 100g of product'),
- validators=[MinValueValidator(0), MaxValueValidator(100)])
-
- carbohydrates_sugar = Html5DecimalField(decimal_places=3,
- max_digits=6,
- blank=True,
- null=True,
- verbose_name=_('Sugar content in carbohydrates'),
- help_text=_('In g per 100g of product'),
- validators=[MinValueValidator(0),
- MaxValueValidator(100)])
-
- fat = Html5DecimalField(decimal_places=3,
- max_digits=6,
- verbose_name=_('Fat'),
- help_text=_('In g per 100g of product'),
- validators=[MinValueValidator(0), MaxValueValidator(100)])
-
- fat_saturated = Html5DecimalField(decimal_places=3,
- max_digits=6,
- blank=True,
- null=True,
- verbose_name=_('Saturated fat content in fats'),
- help_text=_('In g per 100g of product'),
- validators=[MinValueValidator(0), MaxValueValidator(100)])
-
- fibres = Html5DecimalField(decimal_places=3,
- max_digits=6,
- blank=True,
- null=True,
- verbose_name=_('Fibres'),
- help_text=_('In g per 100g of product'),
- validators=[MinValueValidator(0), MaxValueValidator(100)])
-
- sodium = Html5DecimalField(decimal_places=3,
- max_digits=6,
- blank=True,
- null=True,
- verbose_name=_('Sodium'),
- help_text=_('In g per 100g of product'),
- validators=[MinValueValidator(0), MaxValueValidator(100)])
+ energy = models.IntegerField(verbose_name=_('Energy'),
+ help_text=_('In kcal per 100g'))
+
+ protein = models.DecimalField(decimal_places=3,
+ max_digits=6,
+ verbose_name=_('Protein'),
+ help_text=_('In g per 100g of product'),
+ validators=[MinValueValidator(0),
+ MaxValueValidator(100)])
+
+ carbohydrates = models.DecimalField(decimal_places=3,
+ max_digits=6,
+ verbose_name=_('Carbohydrates'),
+ help_text=_('In g per 100g of product'),
+ validators=[MinValueValidator(0),
+ MaxValueValidator(100)])
+
+ carbohydrates_sugar = models.DecimalField(decimal_places=3,
+ max_digits=6,
+ blank=True,
+ null=True,
+ verbose_name=_('Sugar content in carbohydrates'),
+ help_text=_('In g per 100g of product'),
+ validators=[MinValueValidator(0),
+ MaxValueValidator(100)])
+
+ fat = models.DecimalField(decimal_places=3,
+ max_digits=6,
+ verbose_name=_('Fat'),
+ help_text=_('In g per 100g of product'),
+ validators=[MinValueValidator(0),
+ MaxValueValidator(100)])
+
+ fat_saturated = models.DecimalField(decimal_places=3,
+ max_digits=6,
+ blank=True,
+ null=True,
+ verbose_name=_('Saturated fat content in fats'),
+ help_text=_('In g per 100g of product'),
+ validators=[MinValueValidator(0),
+ MaxValueValidator(100)])
+
+ fibres = models.DecimalField(decimal_places=3,
+ max_digits=6,
+ blank=True,
+ null=True,
+ verbose_name=_('Fibres'),
+ help_text=_('In g per 100g of product'),
+ validators=[MinValueValidator(0),
+ MaxValueValidator(100)])
+
+ sodium = models.DecimalField(decimal_places=3,
+ max_digits=6,
+ blank=True,
+ null=True,
+ verbose_name=_('Sodium'),
+ help_text=_('In g per 100g of product'),
+ validators=[MinValueValidator(0),
+ MaxValueValidator(100)])
#
# Django methods
@@ -565,10 +569,11 @@ class MealItem(models.Model):
max_length=1,
blank=True,
editable=False)
- amount = Html5DecimalField(decimal_places=2,
- max_digits=6,
- validators=[MinValueValidator(1), MaxValueValidator(1000)],
- verbose_name=_('Amount'))
+ amount = models.DecimalField(decimal_places=2,
+ max_digits=6,
+ verbose_name=_('Amount'),
+ validators=[MinValueValidator(1),
+ MaxValueValidator(1000)])
def __unicode__(self):
'''
diff --git a/wger/utils/fields.py b/wger/utils/fields.py
index c729fab04..d37ddf85e 100644
--- a/wger/utils/fields.py
+++ b/wger/utils/fields.py
@@ -19,9 +19,6 @@ from south.modelsinspector import add_introspection_rules
from wger.utils.widgets import Html5FormDateField
from wger.utils.widgets import Html5FormTimeField
-from wger.utils.widgets import Html5FormDecimalField
-from wger.utils.widgets import Html5FormIntegerField
-from wger.utils.widgets import Html5FormFloatField
logger = logging.getLogger('wger.custom')
@@ -54,53 +51,8 @@ class Html5DateField(models.DateField):
return super(Html5DateField, self).formfield(**defaults)
-class Html5DecimalField(models.DecimalField):
- '''
- Custom decimal field that uses the Html5NumberInput widget
- '''
-
- def formfield(self, **kwargs):
- '''
- Use our custom field
- '''
- defaults = {'form_class': Html5FormDecimalField}
- defaults.update(kwargs)
- return super(Html5DecimalField, self).formfield(**defaults)
-
-
-class Html5FloatField(models.FloatField):
- '''
- Custom decimal field that uses the Html5NumberInput widget
- '''
-
- def formfield(self, **kwargs):
- '''
- Use our custom field
- '''
- defaults = {'form_class': Html5FormFloatField}
- defaults.update(kwargs)
- return super(Html5FloatField, self).formfield(**defaults)
-
-
-class Html5IntegerField(models.IntegerField):
- '''
- Custom integer field that uses the Html5NumberInput widget
- '''
-
- def formfield(self, **kwargs):
- '''
- Use our custom field
- '''
- defaults = {'form_class': Html5FormIntegerField}
- defaults.update(kwargs)
- return super(Html5IntegerField, self).formfield(**defaults)
-
-
#
# Add instrospection rules so south can still work with these fields
#
add_introspection_rules([], ["^wger\.utils\.fields\.Html5TimeField"])
add_introspection_rules([], ["^wger\.utils\.fields\.Html5DateField"])
-add_introspection_rules([], ["^wger\.utils\.fields\.Html5DecimalField"])
-add_introspection_rules([], ["^wger\.utils\.fields\.Html5FloatField"])
-add_introspection_rules([], ["^wger\.utils\.fields\.Html5IntegerField"])
diff --git a/wger/utils/widgets.py b/wger/utils/widgets.py
index 8ffb96ec5..cbd10f6d6 100644
--- a/wger/utils/widgets.py
+++ b/wger/utils/widgets.py
@@ -85,31 +85,9 @@ class Html5NumberInput(TextInput):
input_type = 'number'
-class Html5FormDecimalField(fields.DecimalField):
- '''
- HTML5 form time field
- '''
- widget = Html5NumberInput
-
-
-class Html5FormIntegerField(fields.IntegerField):
- '''
- HTML5 form time field
- '''
- widget = Html5NumberInput
-
-
-class Html5FormFloatField(fields.FloatField):
- '''
- HTML5 form time field
- '''
- widget = Html5NumberInput
-
#
# Others
#
-
-
class ExerciseAjaxSelect(SelectMultiple):
'''
Custom widget that allows to select exercises from an autocompleter
diff --git a/wger/weight/migrations/0003_auto__chg_field_weightentry_weight.py b/wger/weight/migrations/0003_auto__chg_field_weightentry_weight.py
new file mode 100644
index 000000000..921380b10
--- /dev/null
+++ b/wger/weight/migrations/0003_auto__chg_field_weightentry_weight.py
@@ -0,0 +1,66 @@
+# -*- coding: utf-8 -*-
+from south.utils import datetime_utils as datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+
+class Migration(SchemaMigration):
+
+ def forwards(self, orm):
+
+ # Changing field 'WeightEntry.weight'
+ db.alter_column(u'weight_weightentry', 'weight', self.gf('django.db.models.fields.DecimalField')(max_digits=5, decimal_places=2))
+
+ def backwards(self, orm):
+
+ # Changing field 'WeightEntry.weight'
+ db.alter_column(u'weight_weightentry', 'weight', self.gf('django.db.models.fields.FloatField')())
+
+ models = {
+ u'auth.group': {
+ 'Meta': {'object_name': 'Group'},
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
+ 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
+ },
+ u'auth.permission': {
+ 'Meta': {'ordering': "(u'content_type__app_label', u'content_type__model', u'codename')", 'unique_together': "((u'content_type', u'codename'),)", 'object_name': 'Permission'},
+ 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
+ },
+ u'auth.user': {
+ 'Meta': {'object_name': 'User'},
+ 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
+ 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+ 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Group']"}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+ 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+ 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
+ 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Permission']"}),
+ 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
+ },
+ u'contenttypes.contenttype': {
+ 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
+ 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
+ },
+ u'weight.weightentry': {
+ 'Meta': {'ordering': "['creation_date']", 'unique_together': "(('creation_date', 'user'),)", 'object_name': 'WeightEntry'},
+ 'creation_date': ('django.db.models.fields.DateField', [], {}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['auth.User']"}),
+ 'weight': ('django.db.models.fields.DecimalField', [], {'max_digits': '5', 'decimal_places': '2'})
+ }
+ }
+
+ complete_apps = ['weight']
\ No newline at end of file
diff --git a/wger/weight/models.py b/wger/weight/models.py
index 027c7abd0..0cc3c3e5e 100644
--- a/wger/weight/models.py
+++ b/wger/weight/models.py
@@ -21,16 +21,16 @@ from django.core.validators import MinValueValidator, MaxValueValidator
from django.contrib.auth.models import User
from django.utils.translation import ugettext_lazy as _
-from wger.utils.fields import Html5FloatField
-
class WeightEntry(models.Model):
'''
Model for a weight point
'''
creation_date = models.DateField(verbose_name=_('Date'))
- weight = Html5FloatField(verbose_name=_('Weight'),
- validators=[MinValueValidator(30), MaxValueValidator(300)])
+ weight = models.DecimalField(verbose_name=_('Weight'),
+ max_digits=5,
+ decimal_places=2,
+ validators=[MinValueValidator(30), MaxValueValidator(300)])
user = models.ForeignKey(User,
verbose_name=_('User'))
'''
diff --git a/wger/weight/tests/test_csv_export.py b/wger/weight/tests/test_csv_export.py
index c67689cc0..e20dde572 100644
--- a/wger/weight/tests/test_csv_export.py
+++ b/wger/weight/tests/test_csv_export.py
@@ -36,7 +36,7 @@ class WeightCsvExportTestCase(WorkoutManagerTestCase):
self.assertEqual(response['Content-Type'], 'text/csv')
self.assertEqual(response['Content-Disposition'],
'attachment; filename=Weightdata.csv')
- self.assertEqual(len(response.content), 132)
+ self.assertEqual(len(response.content), 122)
def test_export_csv_loged_in(self):
'''
diff --git a/wger/weight/tests/test_overview.py b/wger/weight/tests/test_overview.py
index bf7de8cca..33b2740ef 100644
--- a/wger/weight/tests/test_overview.py
+++ b/wger/weight/tests/test_overview.py
@@ -54,7 +54,7 @@ class WeightExportCsvTestCase(WorkoutManagerTestCase):
self.assertEqual(response.status_code, 200)
self.assertEqual(response['Content-Type'], 'text/csv')
- self.assertEqual(len(response.content), 132)
+ self.assertEqual(len(response.content), 122)
def test_csv_export_loged_in(self):
'''