Fakultas Ilmu Komputer UI

Commit 2c2939e6 authored by Muzaki Azami's avatar Muzaki Azami
Browse files

Merge branch 'adding-id-on-customuser-in-admin' into 'staging'

Adding id on customuser in admin

See merge request !78
parents d4fb081d 9167e933
Pipeline #80644 passed with stages
in 13 minutes and 47 seconds
...@@ -7,7 +7,7 @@ class UserAdmin(BaseUserAdmin): ...@@ -7,7 +7,7 @@ class UserAdmin(BaseUserAdmin):
# The fields to be used in displaying the User model. # The fields to be used in displaying the User model.
# These override the definitions on the base UserAdmin # These override the definitions on the base UserAdmin
# that reference specific fields on auth.User. # that reference specific fields on auth.User.
list_display = ('email',) list_display = ('email','id')
fieldsets = ( fieldsets = (
(None, {'fields': (\ (None, {'fields': (\
'name', '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 from django.db import migrations, models
import django.db.models.deletion import django.db.models.deletion
...@@ -10,9 +10,9 @@ class Migration(migrations.Migration): ...@@ -10,9 +10,9 @@ class Migration(migrations.Migration):
initial = True initial = True
dependencies = [ dependencies = [
('auth', '0012_alter_user_first_name_max_length'),
('dietela_quiz', '0001_initial'), ('dietela_quiz', '0001_initial'),
('nutritionists', '0001_initial'), ('nutritionists', '0001_initial'),
('auth', '0012_alter_user_first_name_max_length'),
] ]
operations = [ operations = [
...@@ -28,7 +28,7 @@ class Migration(migrations.Migration): ...@@ -28,7 +28,7 @@ class Migration(migrations.Migration):
('is_staff', models.BooleanField(default=False)), ('is_staff', models.BooleanField(default=False)),
('is_active', models.BooleanField(default=True)), ('is_active', models.BooleanField(default=True)),
('date_joined', models.DateTimeField(default=django.utils.timezone.now)), ('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')), ('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')), ('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')), ('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): ...@@ -35,4 +35,4 @@ class CustomUser(AbstractBaseUser, PermissionsMixin):
objects = CustomUserManager() objects = CustomUserManager()
def __str__(self): def __str__(self):
return str(self.email) return f"{self.email} + {self.id}"
...@@ -105,7 +105,7 @@ class UserModelTests(APITestCase): ...@@ -105,7 +105,7 @@ class UserModelTests(APITestCase):
def test_create_user(self): def test_create_user(self):
user = CustomUser.objects.create_user(name='tes', email='email2@email.com', user = CustomUser.objects.create_user(name='tes', email='email2@email.com',
password='tes', diet_profile=self.diet_profile_1,) 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.assertEqual(user.email, 'email2@email.com')
self.assertTrue(user.groups.filter(name='client').exists()) self.assertTrue(user.groups.filter(name='client').exists())
self.assertTrue(user.is_active) 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.conf import settings
from django.db import migrations, models from django.db import migrations, models
...@@ -38,11 +38,11 @@ class Migration(migrations.Migration): ...@@ -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')])), ('vegetables_portion', models.IntegerField(choices=[(1, '0'), (2, '1'), (3, '2'), (4, '3'), (5, '4'), (6, 'Lebih dari 4')])),
('water_consumption', models.PositiveIntegerField()), ('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', 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')])), ('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')])), ('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()), ('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)), ('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')), ('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): ...@@ -61,13 +61,13 @@ class WeeklyReport(models.Model):
water_consumption = models.PositiveIntegerField() water_consumption = models.PositiveIntegerField()
physical_activity = MultiSelectField( physical_activity = MultiSelectField(
choices = PhysicalActivity.choices) choices = PhysicalActivity.choices)
physical_activity_other = models.TextField() physical_activity_other = models.TextField(null=True, blank=True)
time_for_activity = models.IntegerField( time_for_activity = models.IntegerField(
choices=TimeForActivity.choices) choices=TimeForActivity.choices)
feeling_rating = models.IntegerField( feeling_rating = models.IntegerField(
choices = Rating.choices) choices = Rating.choices)
lesson_learned = models.TextField() lesson_learned = models.TextField()
problem_faced_and_feedbacks = models.TextField() problem_faced_and_feedbacks = models.TextField(null=True, blank=True)
def __str__(self): def __str__(self):
return f"{self.client} - {self.nutritionist} - Week {self.week_num}" return f"{self.client} - {self.nutritionist} - Week {self.week_num}"
......
...@@ -235,7 +235,7 @@ class WeeklyReportTest(APITestCase): ...@@ -235,7 +235,7 @@ class WeeklyReportTest(APITestCase):
self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertEqual(response.status_code, status.HTTP_200_OK)
def test_weekly_report_string(self): 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): 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 from django.conf import settings
import django.contrib.postgres.fields import django.contrib.postgres.fields
......
...@@ -64,7 +64,7 @@ class DietQuestionnaireTests(APITestCase): ...@@ -64,7 +64,7 @@ class DietQuestionnaireTests(APITestCase):
def test_string_representation(self): 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): def test_get_all_diet_questionnaire(self):
self.client.credentials(HTTP_AUTHORIZATION=self.login_credentials) 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 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 from django.db import migrations, models
import django.db.models.deletion 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 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.conf import settings
from django.db import migrations, models from django.db import migrations, models
...@@ -11,8 +11,8 @@ class Migration(migrations.Migration): ...@@ -11,8 +11,8 @@ class Migration(migrations.Migration):
dependencies = [ dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL), migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('nutritionists', '0001_initial'),
('dietela_program', '0001_initial'), ('dietela_program', '0001_initial'),
('nutritionists', '0001_initial'),
] ]
operations = [ operations = [
......
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