Modellar tayyor
This commit is contained in:
@@ -1 +1,2 @@
|
||||
from .user import * # noqa
|
||||
from .notification_type import * # noqa
|
||||
|
||||
11
core/apps/accounts/choices/notification_type.py
Normal file
11
core/apps/accounts/choices/notification_type.py
Normal file
@@ -0,0 +1,11 @@
|
||||
from django.db import models
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
|
||||
class NotificationType(models.TextChoices):
|
||||
"""
|
||||
Notification Types
|
||||
"""
|
||||
|
||||
SYSTEM = "System", _("System")
|
||||
ANOTHER = "Another", _("Another")
|
||||
@@ -10,3 +10,10 @@ class RoleChoice(models.TextChoices):
|
||||
SUPERUSER = "superuser", _("Superuser")
|
||||
ADMIN = "admin", _("Admin")
|
||||
USER = "user", _("User")
|
||||
|
||||
class AccountType(models.TextChoices):
|
||||
"""
|
||||
User Account Type
|
||||
"""
|
||||
PERSONAL = "personal", _("Personal")
|
||||
BUSINESS = "business", _("Business")
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
# Generated by Django 5.2.7 on 2025-11-22 07:29
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('accounts', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='user',
|
||||
name='account_type',
|
||||
field=models.CharField(choices=[('personal', 'Personal'), ('business', 'Business')], default='personal', max_length=255),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='user',
|
||||
name='is_verify',
|
||||
field=models.BooleanField(default=False),
|
||||
),
|
||||
]
|
||||
30
core/apps/accounts/migrations/0003_address.py
Normal file
30
core/apps/accounts/migrations/0003_address.py
Normal file
@@ -0,0 +1,30 @@
|
||||
# Generated by Django 5.2.7 on 2025-11-22 11:34
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('accounts', '0002_user_account_type_user_is_verify'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Address',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('created_at', models.DateTimeField(auto_now_add=True)),
|
||||
('updated_at', models.DateTimeField(auto_now=True)),
|
||||
('name', models.CharField(max_length=255, verbose_name='Name')),
|
||||
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='addresses', to=settings.AUTH_USER_MODEL, verbose_name='User')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'Address',
|
||||
'verbose_name_plural': 'Addresses',
|
||||
'db_table': 'address',
|
||||
},
|
||||
),
|
||||
]
|
||||
54
core/apps/accounts/migrations/0004_business_searchhistory.py
Normal file
54
core/apps/accounts/migrations/0004_business_searchhistory.py
Normal file
@@ -0,0 +1,54 @@
|
||||
# Generated by Django 5.2.7 on 2025-11-24 06:45
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('accounts', '0003_address'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Business',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('created_at', models.DateTimeField(auto_now_add=True)),
|
||||
('updated_at', models.DateTimeField(auto_now=True)),
|
||||
('name', models.CharField(max_length=255, verbose_name='Business Name')),
|
||||
('work_time', models.CharField(max_length=255, verbose_name='Work Time')),
|
||||
('contact', models.CharField(max_length=255, verbose_name='Contact')),
|
||||
('instagram', models.CharField(max_length=255, verbose_name='Instagram')),
|
||||
('facebook', models.CharField(max_length=255, verbose_name='Facebook')),
|
||||
('telegram', models.CharField(max_length=255, verbose_name='Telegram')),
|
||||
('bio', models.TextField(verbose_name='Bio')),
|
||||
('address_name', models.CharField(max_length=255, verbose_name='Address Name')),
|
||||
('longitude', models.FloatField(verbose_name='Longitude')),
|
||||
('latitude', models.FloatField(verbose_name='Latitude')),
|
||||
('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'Business',
|
||||
'verbose_name_plural': 'Business',
|
||||
'db_table': 'business',
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='SearchHistory',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('created_at', models.DateTimeField(auto_now_add=True)),
|
||||
('updated_at', models.DateTimeField(auto_now=True)),
|
||||
('value', models.CharField(max_length=255, verbose_name='Search History')),
|
||||
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='User')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'Search History',
|
||||
'verbose_name_plural': 'Search History',
|
||||
'db_table': 'search_history',
|
||||
},
|
||||
),
|
||||
]
|
||||
@@ -1,3 +1,7 @@
|
||||
# isort: skip_file
|
||||
from .user import * # noqa
|
||||
from .reset_token import * # noqa
|
||||
from .address import * # noqa
|
||||
from .business import * # noqa
|
||||
from .user_like import * # noqa
|
||||
from .search_history import * # noqa
|
||||
|
||||
18
core/apps/accounts/models/address.py
Normal file
18
core/apps/accounts/models/address.py
Normal file
@@ -0,0 +1,18 @@
|
||||
from django.db import models
|
||||
from django_core.models.base import AbstractBaseModel
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.contrib.auth import get_user_model
|
||||
|
||||
|
||||
class Address(AbstractBaseModel):
|
||||
user = models.ForeignKey(get_user_model(), on_delete=models.CASCADE, related_name='addresses',
|
||||
verbose_name=_('User'))
|
||||
name = models.CharField(max_length=255, verbose_name=_('Name'))
|
||||
|
||||
def __str__(self):
|
||||
return str(self.pk)
|
||||
|
||||
class Meta:
|
||||
db_table = 'address'
|
||||
verbose_name = _('Address')
|
||||
verbose_name_plural = _('Addresses')
|
||||
26
core/apps/accounts/models/business.py
Normal file
26
core/apps/accounts/models/business.py
Normal file
@@ -0,0 +1,26 @@
|
||||
from django.db import models
|
||||
from django_core.models.base import AbstractBaseModel
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.contrib.auth import get_user_model
|
||||
|
||||
|
||||
class Business(AbstractBaseModel):
|
||||
name = models.CharField(max_length=255, verbose_name=_('Business Name'))
|
||||
user = models.OneToOneField(get_user_model(), on_delete=models.CASCADE)
|
||||
work_time = models.CharField(max_length=255, verbose_name=_('Work Time'))
|
||||
contact = models.CharField(max_length=255, verbose_name=_('Contact'))
|
||||
instagram = models.CharField(max_length=255, verbose_name=_('Instagram'))
|
||||
facebook = models.CharField(max_length=255, verbose_name=_('Facebook'))
|
||||
telegram = models.CharField(max_length=255, verbose_name=_('Telegram'))
|
||||
bio = models.TextField(verbose_name=_('Bio'))
|
||||
address_name = models.CharField(max_length=255, verbose_name=_('Address Name'))
|
||||
longitude = models.FloatField(verbose_name=_('Longitude'))
|
||||
latitude = models.FloatField(verbose_name=_('Latitude'))
|
||||
|
||||
def __str__(self):
|
||||
return str(self.pk)
|
||||
|
||||
class Meta:
|
||||
db_table = 'business'
|
||||
verbose_name = _('Business')
|
||||
verbose_name_plural = _('Business')
|
||||
35
core/apps/accounts/models/notification.py
Normal file
35
core/apps/accounts/models/notification.py
Normal file
@@ -0,0 +1,35 @@
|
||||
from django.db import models
|
||||
from django_core.models.base import AbstractBaseModel
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from core.apps.accounts.choices import NotificationType
|
||||
from django.contrib.auth import get_user_model
|
||||
|
||||
|
||||
class Notification(AbstractBaseModel):
|
||||
title = models.CharField(max_length=255, verbose_name=_("Title"))
|
||||
description = models.TextField(verbose_name=_("Description"))
|
||||
notification_type = models.CharField(max_length=255, choices=NotificationType, verbose_name=_("Type"))
|
||||
long = models.FloatField(verbose_name=_("Long"))
|
||||
lat = models.FloatField(verbose_name=_("Lat"))
|
||||
|
||||
def __str__(self):
|
||||
return str(self.pk)
|
||||
|
||||
class Meta:
|
||||
db_table = "notification"
|
||||
verbose_name = _("Notification")
|
||||
verbose_name_plural = _("Notifications")
|
||||
|
||||
|
||||
class UserNotification(AbstractBaseModel):
|
||||
user = models.ForeignKey(get_user_model(), verbose_name=_("User"), on_delete=models.CASCADE)
|
||||
notification = models.ForeignKey(Notification, verbose_name=_("Notification"), on_delete=models.CASCADE)
|
||||
is_read = models.BooleanField(verbose_name=_("Read"), default=False)
|
||||
|
||||
def __str__(self):
|
||||
return str(self.pk)
|
||||
|
||||
class Meta:
|
||||
db_table = "user_notification"
|
||||
verbose_name = _("User Notification")
|
||||
verbose_name_plural = _("User Notifications")
|
||||
17
core/apps/accounts/models/search_history.py
Normal file
17
core/apps/accounts/models/search_history.py
Normal file
@@ -0,0 +1,17 @@
|
||||
from django.db import models
|
||||
from django_core.models.base import AbstractBaseModel
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.contrib.auth import get_user_model
|
||||
|
||||
|
||||
class SearchHistory(AbstractBaseModel):
|
||||
value = models.CharField(verbose_name=_('Search History'), max_length=255)
|
||||
user = models.ForeignKey(get_user_model(), verbose_name=_('User'), on_delete=models.CASCADE)
|
||||
|
||||
def __str__(self):
|
||||
return str(self.pk)
|
||||
|
||||
class Meta:
|
||||
db_table = 'search_history'
|
||||
verbose_name = _('Search History')
|
||||
verbose_name_plural = _('Search History')
|
||||
@@ -1,7 +1,7 @@
|
||||
from django.contrib.auth import models as auth_models
|
||||
from django.db import models
|
||||
|
||||
from ..choices import RoleChoice
|
||||
from ..choices import RoleChoice, AccountType
|
||||
from ..managers import UserManager
|
||||
|
||||
|
||||
@@ -11,6 +11,8 @@ class User(auth_models.AbstractUser):
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
updated_at = models.DateTimeField(auto_now=True)
|
||||
validated_at = models.DateTimeField(null=True, blank=True)
|
||||
is_verify = models.BooleanField(default=False)
|
||||
account_type = models.CharField(choices=AccountType, max_length=255, default=AccountType.PERSONAL)
|
||||
role = models.CharField(
|
||||
max_length=255,
|
||||
choices=RoleChoice,
|
||||
|
||||
0
core/apps/accounts/models/user_like.py
Normal file
0
core/apps/accounts/models/user_like.py
Normal file
31
core/apps/accounts/models/user_plan.py
Normal file
31
core/apps/accounts/models/user_plan.py
Normal file
@@ -0,0 +1,31 @@
|
||||
from django.db import models
|
||||
from django_core.models.base import AbstractBaseModel
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.contrib.auth import get_user_model
|
||||
|
||||
|
||||
class Plan(AbstractBaseModel):
|
||||
name = models.CharField(verbose_name=_("Name"), max_length=255)
|
||||
price = models.DecimalField(verbose_name=_("Price"), max_digits=10, decimal_places=2)
|
||||
|
||||
def __str__(self):
|
||||
return str(self.id)
|
||||
|
||||
class Meta:
|
||||
db_table = "plan"
|
||||
verbose_name = _("Plan")
|
||||
verbose_name_plural = _("Plans")
|
||||
|
||||
|
||||
class UserPlan(AbstractBaseModel):
|
||||
user = models.ForeignKey(get_user_model(), on_delete=models.CASCADE, verbose_name=_("User"))
|
||||
plan = models.ForeignKey(Plan, on_delete=models.CASCADE, verbose_name=_("Plan"))
|
||||
expire = models.DateTimeField(verbose_name=_("Expire"))
|
||||
|
||||
def __str__(self):
|
||||
return str(self.id)
|
||||
|
||||
class Meta:
|
||||
db_table = "user_plan"
|
||||
verbose_name = _("User Plan")
|
||||
verbose_name_plural = _("User Plans")
|
||||
Reference in New Issue
Block a user