created apps, db models and templates
This commit is contained in:
parent
b79369e208
commit
3ed70ba317
45 changed files with 1238 additions and 30 deletions
0
profiles/__init__.py
Normal file
0
profiles/__init__.py
Normal file
3
profiles/admin.py
Normal file
3
profiles/admin.py
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
||||
6
profiles/apps.py
Normal file
6
profiles/apps.py
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class ProfilesConfig(AppConfig):
|
||||
default_auto_field = 'django.db.models.BigAutoField'
|
||||
name = 'profiles'
|
||||
30
profiles/migrations/0001_initial.py
Normal file
30
profiles/migrations/0001_initial.py
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
# Generated by Django 3.2 on 2022-09-25 23:10
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='UserProfile',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('avatar', models.ImageField(blank=True, null=True, upload_to='avatar/')),
|
||||
('phone_number', models.CharField(blank=True, max_length=100, null=True)),
|
||||
('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'UserProfile',
|
||||
'verbose_name_plural': 'UserProfiles',
|
||||
},
|
||||
),
|
||||
]
|
||||
0
profiles/migrations/__init__.py
Normal file
0
profiles/migrations/__init__.py
Normal file
31
profiles/models.py
Normal file
31
profiles/models.py
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
import datetime
|
||||
|
||||
from django.db import models
|
||||
|
||||
from accounts.models import UserAccount
|
||||
|
||||
# Create your models here.
|
||||
|
||||
|
||||
class UserProfile(models.Model):
|
||||
"""Model definition for UserProfile."""
|
||||
# from order.models import Address
|
||||
user = models.OneToOneField(UserAccount, on_delete=models.CASCADE)
|
||||
avatar = models.ImageField(upload_to='avatar/', null=True, blank=True)
|
||||
phone_number = models.CharField(max_length=100, null=True, blank=True)
|
||||
|
||||
class Meta:
|
||||
"""Meta definition for UserProfile."""
|
||||
|
||||
verbose_name = 'UserProfile'
|
||||
verbose_name_plural = 'UserProfiles'
|
||||
|
||||
def __str__(self):
|
||||
return self.user.email
|
||||
|
||||
def get_shipping_address_data(self):
|
||||
return None if not self.shipping_address else self.get_serialized_data(self.shipping_address)
|
||||
|
||||
def get_billing_address_data(self):
|
||||
return None if not self.billing_address else self.get_serialized_data(self.billing_address)\
|
||||
|
||||
3
profiles/tests.py
Normal file
3
profiles/tests.py
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
8
profiles/urls.py
Normal file
8
profiles/urls.py
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
from django.contrib import admin
|
||||
from django.urls import include, path
|
||||
|
||||
app_name = 'profiles'
|
||||
|
||||
urlpatterns = [
|
||||
|
||||
]
|
||||
3
profiles/views.py
Normal file
3
profiles/views.py
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
from django.shortcuts import render
|
||||
|
||||
# Create your views here.
|
||||
Loading…
Add table
Add a link
Reference in a new issue