Commit ee3d2eec authored by EL HASSANE GARGEM's avatar EL HASSANE GARGEM
Browse files

onboarding for each step

parent 1861ee3f
......@@ -78,15 +78,7 @@ class TranscriptionSerializer(serializers.ModelSerializer):
class UserOnboardingSerializer(serializers.ModelSerializer):
class Meta:
model = User
fields = ('onboarding',)
def __init__(self, user, *args, **kwargs):
self.user = user
super().__init__(*args, **kwargs)
def complete(self):
self.user.onboarding = self.validated_data['onboarding']
self.user.save()
fields = ('onboarding_images','onboarding_edit','onboarding_models','onboarding_trans')
class BlockTypeSerializer(serializers.ModelSerializer):
......
......@@ -11,6 +11,27 @@ from django.urls import reverse
from core.models import Block, Line, Transcription, LineTranscription
from core.tests.factory import CoreFactoryTestCase
class UserViewSetTestCase(CoreFactoryTestCase):
def setUp(self):
super().setUp()
def test_onboarding(self):
user = self.factory.make_user()
self.client.force_login(user)
uri = reverse('api:user-onboarding')
resp = self.client.put(uri, {
'onboarding_edit' : 'False',
}, content_type='application/json')
user.refresh_from_db()
self.assertEqual(resp.status_code, 200)
self.assertEqual(user.onboarding_edit, False)
self.assertEqual(user.onboarding_images, True)
class DocumentViewSetTestCase(CoreFactoryTestCase):
def setUp(self):
......
......@@ -51,9 +51,9 @@ class UserViewSet(ModelViewSet):
@action(detail=False, methods=['put'])
def onboarding(self, request):
serializer = UserOnboardingSerializer(data=request.data, user=self.request.user)
serializer = UserOnboardingSerializer(self.request.user,data=request.data, partial=True)
if serializer.is_valid(raise_exception=True):
serializer.complete()
serializer.save()
return Response(status=status.HTTP_200_OK)
......
# Generated by Django 2.1.4 on 2020-08-18 10:10
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('users', '0008_auto_20200520_1007'),
]
operations = [
migrations.RemoveField(
model_name='user',
name='onboarding',
),
migrations.AddField(
model_name='user',
name='onboarding_edit',
field=models.BooleanField(default=False),
),
migrations.AddField(
model_name='user',
name='onboarding_images',
field=models.BooleanField(default=False, verbose_name='first connection'),
),
migrations.AddField(
model_name='user',
name='onboarding_models',
field=models.BooleanField(default=False),
),
migrations.AddField(
model_name='user',
name='onboarding_trans',
field=models.BooleanField(default=False),
),
]
Supports Markdown
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