SMART-29 created user_profile app, UserProfile class and made migration

This commit is contained in:
s460930 2020-11-30 22:42:24 +01:00
parent 91e974ac10
commit 60fac95880
21 changed files with 99 additions and 2 deletions

11
.idea/dataSources.xml Normal file
View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
<data-source source="LOCAL" name="db" uuid="7f4bb91e-1fe8-4fbb-957b-243ac1847b2b">
<driver-ref>sqlite.xerial</driver-ref>
<synchronize>true</synchronize>
<jdbc-driver>org.sqlite.JDBC</jdbc-driver>
<jdbc-url>jdbc:sqlite:$PROJECT_DIR$/rest-app/db.sqlite3</jdbc-url>
</data-source>
</component>
</project>

Binary file not shown.

View File

@ -0,0 +1,17 @@
# Generated by Django 3.1.3 on 2020-11-30 21:19
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('user', '0001_initial'),
]
operations = [
migrations.AlterModelTable(
name='user',
table='user',
),
]

View File

@ -69,4 +69,4 @@ class User(AbstractBaseUser):
""" """
Class to set table name in database Class to set table name in database
""" """
db_table = 'login' db_table = 'user'

View File

@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.

View File

@ -0,0 +1,5 @@
from django.apps import AppConfig
class UserProfileConfig(AppConfig):
name = 'user_profile'

View File

@ -0,0 +1,30 @@
# Generated by Django 3.1.3 on 2020-11-30 21:41
from django.db import migrations, models
import django.db.models.deletion
import uuid
class Migration(migrations.Migration):
initial = True
dependencies = [
('user', '0002_auto_20201130_2119'),
]
operations = [
migrations.CreateModel(
name='UserProfile',
fields=[
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
('first_name', models.CharField(max_length=50)),
('last_name', models.CharField(max_length=50)),
('phone_number', models.CharField(blank=True, max_length=10, null=True)),
('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='profile', to='user.user')),
],
options={
'db_table': 'user_profile',
},
),
]

View File

@ -0,0 +1,24 @@
"""
@author p.dolata
"""
import uuid
from django.db import models
from smartpicasso.app.user.models import User
class UserProfile(models.Model):
"""
Model representing user's profile
"""
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
user = models.OneToOneField(User, on_delete=models.CASCADE, related_name='profile')
first_name = models.CharField(max_length=50, unique=False)
last_name = models.CharField(max_length=50, unique=False)
phone_number = models.CharField(max_length=10, unique=False, null=True, blank=True)
class Meta:
"""
Meta to se table name in database
"""
db_table = 'user_profile'

View File

@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

View File

@ -0,0 +1,3 @@
from django.shortcuts import render
# Create your views here.

View File

@ -38,7 +38,8 @@ INSTALLED_APPS = [
'django.contrib.messages', 'django.contrib.messages',
'django.contrib.staticfiles', 'django.contrib.staticfiles',
'smartpicasso.app.user' 'smartpicasso.app.user',
'smartpicasso.app.user_profile'
] ]
MIDDLEWARE = [ MIDDLEWARE = [