Fakultas Ilmu Komputer UI

Commit 9167e933 authored by Muzaki Azami's avatar Muzaki Azami

adding sugary_ingredients field on weekly report model + adding API to GET a...

adding sugary_ingredients field on weekly report model + adding API to GET a specific user's weekly reports
parent d4fb081d
......@@ -7,7 +7,7 @@ class UserAdmin(BaseUserAdmin):
# The fields to be used in displaying the User model.
# These override the definitions on the base UserAdmin
# that reference specific fields on auth.User.
list_display = ('email',)
list_display = ('email','id')
fieldsets = (
(None, {'fields': (\
'name',
......
# Generated by Django 3.1 on 2021-05-31 13:53
# Generated by Django 3.1 on 2021-06-01 10:40
from django.db import migrations, models
import django.db.models.deletion
......@@ -10,9 +10,9 @@ class Migration(migrations.Migration):
initial = True
dependencies = [
('auth', '0012_alter_user_first_name_max_length'),
('dietela_quiz', '0001_initial'),
('nutritionists', '0001_initial'),
('auth', '0012_alter_user_first_name_max_length'),
]
operations = [
......@@ -28,7 +28,7 @@ class Migration(migrations.Migration):
('is_staff', models.BooleanField(default=False)),
('is_active', models.BooleanField(default=True)),
('date_joined', models.DateTimeField(default=django.utils.timezone.now)),
('deadline', models.DateField(default=django.utils.timezone.now)),
('deadline', models.DateField(null=True)),
('diet_profile', models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='user', to='dietela_quiz.dietprofile')),
('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.Group', verbose_name='groups')),
('nutritionist', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='clients', to='nutritionists.nutritionist')),
......
......@@ -35,4 +35,4 @@ class CustomUser(AbstractBaseUser, PermissionsMixin):
objects = CustomUserManager()
def __str__(self):
return str(self.email)
return f"{self.email} + {self.id}"
......@@ -105,7 +105,7 @@ class UserModelTests(APITestCase):
def test_create_user(self):
user = CustomUser.objects.create_user(name='tes', email='email2@email.com',
password='tes', diet_profile=self.diet_profile_1,)
self.assertEqual(str(user), 'email2@email.com')
self.assertEqual(str(user), 'email2@email.com + ' + str(user.id))
self.assertEqual(user.email, 'email2@email.com')
self.assertTrue(user.groups.filter(name='client').exists())
self.assertTrue(user.is_active)
......
# Generated by Django 3.1 on 2021-05-31 13:53
# Generated by Django 3.1 on 2021-06-01 10:40
from django.conf import settings
from django.db import migrations, models
......@@ -38,11 +38,11 @@ class Migration(migrations.Migration):
('vegetables_portion', models.IntegerField(choices=[(1, '0'), (2, '1'), (3, '2'), (4, '3'), (5, '4'), (6, 'Lebih dari 4')])),
('water_consumption', models.PositiveIntegerField()),
('physical_activity', multiselectfield.db.fields.MultiSelectField(choices=[(1, 'Hampir tidak pernah olahraga dan/atau duduk lebih dari 9 jam perhari'), (2, 'Jalan kaki santai'), (3, 'Jalan kaki cepat'), (4, 'Pemanasan'), (5, 'Naik turun tangga'), (6, 'Jogging'), (7, 'Treadmill'), (8, 'Senam Aerobic/cardio, Recovery/Scratching, Dance dll'), (9, 'Latihan penguatan otot (strength workout, weight workout)'), (10, 'Other')], max_length=20)),
('physical_activity_other', models.TextField()),
('physical_activity_other', models.TextField(blank=True, null=True)),
('time_for_activity', models.IntegerField(choices=[(1, '0 - 60 menit'), (2, '60 - 100 menit'), (3, '100 - 120 menit'), (4, '100 - 120 menit'), (5, '120 - 150 menit'), (6, '150 - 175 menit'), (7, '175 - 200 menit'), (8, '200 - 250 menit'), (9, 'Lebih dari 250 menit')])),
('feeling_rating', models.IntegerField(choices=[(1, 'Rasanya mau menyerah saja'), (2, 'Capek, susah, bosen, males, repot, sibuk'), (3, 'Biasa aja, meski ada kendala tapi semua bisa diatur'), (4, 'Lancar terus, semangat cukup stabil, gak ada masalah'), (5, 'Super seneng, semangat banget, worry-free lah')])),
('lesson_learned', models.TextField()),
('problem_faced_and_feedbacks', models.TextField()),
('problem_faced_and_feedbacks', models.TextField(blank=True, null=True)),
('client', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='weekly_report', to=settings.AUTH_USER_MODEL)),
('nutritionist', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='weekly_report', to='nutritionists.nutritionist')),
],
......
......@@ -61,13 +61,13 @@ class WeeklyReport(models.Model):
water_consumption = models.PositiveIntegerField()
physical_activity = MultiSelectField(
choices = PhysicalActivity.choices)
physical_activity_other = models.TextField()
physical_activity_other = models.TextField(null=True, blank=True)
time_for_activity = models.IntegerField(
choices=TimeForActivity.choices)
feeling_rating = models.IntegerField(
choices = Rating.choices)
lesson_learned = models.TextField()
problem_faced_and_feedbacks = models.TextField()
problem_faced_and_feedbacks = models.TextField(null=True, blank=True)
def __str__(self):
return f"{self.client} - {self.nutritionist} - Week {self.week_num}"
......
......@@ -235,7 +235,7 @@ class WeeklyReportTest(APITestCase):
self.assertEqual(response.status_code, status.HTTP_200_OK)
def test_weekly_report_string(self):
self.assertEqual(str(self.weekly_report_1), 'email2@email.com - Test, S.Gz - Week 1')
self.assertEqual(str(self.weekly_report_1), f'email2@email.com + {self.custom_user_2.id} - Test, S.Gz - Week 1')
class WeeklyReportCommentTest(APITestCase):
......
# Generated by Django 3.1 on 2021-05-31 13:53
# Generated by Django 3.1 on 2021-06-01 10:40
from django.conf import settings
import django.contrib.postgres.fields
......
......@@ -64,7 +64,7 @@ class DietQuestionnaireTests(APITestCase):
def test_string_representation(self):
self.assertEqual(str(self.diet_questionnaire), 'email@email.com')
self.assertEqual(str(self.diet_questionnaire), f'email@email.com + {self.custom_user_1.id}')
def test_get_all_diet_questionnaire(self):
self.client.credentials(HTTP_AUTHORIZATION=self.login_credentials)
......
# Generated by Django 3.1 on 2021-05-31 13:53
# Generated by Django 3.1 on 2021-06-01 10:40
from django.db import migrations, models
......
# Generated by Django 3.1 on 2021-05-31 13:53
# Generated by Django 3.1 on 2021-06-01 10:40
from django.db import migrations, models
import django.db.models.deletion
......
# Generated by Django 3.1 on 2021-05-31 13:53
# Generated by Django 3.1 on 2021-06-01 10:40
from django.db import migrations, models
......
# Generated by Django 3.1 on 2021-05-31 13:53
# Generated by Django 3.1 on 2021-06-01 10:40
from django.conf import settings
from django.db import migrations, models
......@@ -11,8 +11,8 @@ class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('nutritionists', '0001_initial'),
('dietela_program', '0001_initial'),
('nutritionists', '0001_initial'),
]
operations = [
......
# Generated by Django 3.1 on 2021-05-31 13:53
# Generated by Django 3.1 on 2021-06-01 10:40
from django.conf import settings
from django.db import migrations, models
......
......@@ -306,7 +306,7 @@ class DietRecommendationTests(APITestCase):
cls.login_credentials = "Bearer " + cls.json_login_response['access_token']
def test_string_representation(self):
self.assertEqual(str(self.diet_recommendation), 'email2@email.com - Test, S.Gz')
self.assertEqual(str(self.diet_recommendation), f'email2@email.com + {self.custom_user_2.id} - Test, S.Gz')
def test_create_diet_recommendation_succeed(self):
tmp_file = SimpleUploadedFile("testfile.pdf", bytes("abc", 'utf-8'), content_type="application/pdf")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment