Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Merge branch 'master' into fork/scrapcode/issue-1814

Roland Geiderd27a3678aad2
diff --cc wger/core/tests/test_temporary_users.py
index 998e4abec,84b48db0b..2f5a578d1
--- a/wger/core/tests/test_temporary_users.py
+++ b/wger/core/tests/test_temporary_users.py
@@@ -126,7 -120,7 +121,7 @@@ class DemoUserTestCase(WgerTestCase)
create_demo_entries(user)
# Body weight
- self.assertEqual(WeightEntry.objects.filter(user=user).count(), 23)
- self.assertEqual(WeightEntry.objects.filter(user=user).count(), 40)
++ self.assertEqual(WeightEntry.objects.filter(user=user).count(), 44)
def test_demo_user(self):
"""
diff --cc wger/weight/forms.py
index d944d9621,03ec03b27..1efa0ed10
--- a/wger/weight/forms.py
+++ b/wger/weight/forms.py
@@@ -18,11 -18,8 +18,9 @@@
from django import forms
from django.forms import (
CharField,
+ DateTimeField,
Form,
- ModelForm,
Textarea,
- widgets,
)
from django.utils.translation import gettext as _
@@@ -30,25 -27,14 +28,20 @@@
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Layout
- # wger
- from wger.utils.constants import DATETIME_FORMATS
- from wger.utils.widgets import Html5DateInput
- from wger.weight.models import WeightEntry
-
-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)'),
+CSV_DATETIME_FORMAT = (
+ ('%d.%m.%Y %H:%M:%S', 'DD.MM.YYYY HH:MM:SS (30.01.2012 14:30:00)'),
+ ('%d.%m.%Y %H:%M', 'DD.MM.YYYY HH:MM (30.01.2012 14:30)'),
+ ('%d.%m.%y %H:%M:%S', 'DD.MM.YY HH:MM:SS (30.01.12 14:30:00)'),
+ ('%d.%m.%y %H:%M', 'DD.MM.YY HH:MM (30.01.12 14:30)'),
+ ('%Y-%m-%d %H:%M:%S', 'YYYY-MM-DD HH:MM:SS (2012-01-30 14:30:00)'),
+ ('%Y-%m-%d %H:%M', 'YYYY-MM-DD HH:MM (2012-01-30 14:30)'),
+ ('%y-%m-%d %H:%M:%S', 'YY-MM-DD HH:MM:SS (12-01-30 14:30:00)'),
+ ('%y-%m-%d %H:%M', 'YY-MM-DD HH:MM (12-01-30 14:30)'),
+ ('%m/%d/%Y %H:%M:%S', 'MM/DD/YYYY HH:MM:SS (01/30/2012 14:30:00)'),
+ ('%m/%d/%Y %H:%M', 'MM/DD/YYYY HH:MM (01/30/2012 14:30)'),
+ ('%m/%d/%y %H:%M:%S', 'MM/DD/YY HH:MM:SS (01/30/12 14:30:00)'),
+ ('%m/%d/%y %H:%M', 'MM/DD/YY HH:MM (01/30/12 14:30)'),
)
diff --cc wger/weight/tests/test_entry.py
index 2cf7c0c1c,853d2e281..b0c84bcc3
--- a/wger/weight/tests/test_entry.py
+++ b/wger/weight/tests/test_entry.py
@@@ -12,13 -12,8 +12,8 @@@
#
# You should have received a copy of the GNU Affero General Public License
--# Standard Library
--import datetime
- import decimal
-
+# Django
- from django.urls import reverse
+from django.utils import timezone
# wger
from wger.core.tests import api_base_test
@@@ -41,55 -30,9 +30,9 @@@ class MealRepresentationTestCase(WgerTe
"""
Test that the representation of an object is correct
"""
- self.assertEqual(str(WeightEntry.objects.get(pk=1)), '2012-10-01: 77.00 kg')
+ self.assertEqual(str(WeightEntry.objects.get(pk=1)), '2012-10-01 14:30:21.592000+00:00: 77.00 kg')
- class AddWeightEntryTestCase(WgerAddTestCase):
- """
- Tests adding a weight entry
- """
-
- object_class = WeightEntry
- url = 'weight:add'
- user_fail = False
- date = timezone.now()
- data = {
- 'weight': decimal.Decimal(81.1).quantize(TWOPLACES),
- 'date': date,
- 'user': 1,
- }
-
-
- class EditWeightEntryTestCase(WgerEditTestCase):
- """
- Tests editing a weight entry
- """
-
- object_class = WeightEntry
- url = 'weight:edit'
- pk = 1
- date = timezone.now() - timezone.timedelta(days=25)
- data = {
- 'weight': 100,
- 'date': date,
- 'user': 1,
- }
- user_success = 'test'
- user_fail = 'admin'
-
-
- class DeleteWeightEntryTestCase(WgerDeleteTestCase):
- """
- Tests deleting a weight entry
- """
-
- object_class = WeightEntry
- url = 'weight:delete'
- pk = 1
- user_success = 'test'
- user_fail = 'admin'
-
-
class WeightEntryTestCase(api_base_test.ApiBaseResourceTestCase):
"""
Tests the weight entry overview resource