Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified cakeBack/cakeApi/__pycache__/__init__.cpython-311.pyc
Binary file not shown.
Binary file modified cakeBack/cakeApi/__pycache__/admin.cpython-311.pyc
Binary file not shown.
Binary file modified cakeBack/cakeApi/__pycache__/apps.cpython-311.pyc
Binary file not shown.
Binary file modified cakeBack/cakeApi/__pycache__/models.cpython-311.pyc
Binary file not shown.
Binary file modified cakeBack/cakeApi/__pycache__/serializers.cpython-311.pyc
Binary file not shown.
Binary file modified cakeBack/cakeApi/__pycache__/tools.cpython-311.pyc
Binary file not shown.
Binary file modified cakeBack/cakeApi/__pycache__/urls.cpython-311.pyc
Binary file not shown.
Binary file modified cakeBack/cakeApi/__pycache__/views.cpython-311.pyc
Binary file not shown.
4 changes: 3 additions & 1 deletion cakeBack/cakeApi/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@
from .models import *

admin.site.register(Category)
admin.site.register(Item)
admin.site.register(Item)
admin.site.register(Order)
admin.site.register(User)
25 changes: 23 additions & 2 deletions cakeBack/cakeApi/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Generated by Django 4.2.4 on 2023-09-03 14:07
# Generated by Django 4.2.4 on 2023-10-05 18:21

import autoslug.fields
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):
Expand All @@ -21,16 +22,36 @@ class Migration(migrations.Migration):
('slug', autoslug.fields.AutoSlugField(editable=False, populate_from='nameOfCategory')),
],
),
migrations.CreateModel(
name='User',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('userEmail', models.EmailField(blank=True, max_length=200, null=True, unique=True)),
('userPhoneNumber', models.CharField(max_length=10, unique=True)),
('userName', models.CharField(max_length=40)),
],
),
migrations.CreateModel(
name='Order',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('items', models.JSONField()),
('status', models.CharField(default='Workin` at order', max_length=50)),
('dataTime', models.DateTimeField(null=True)),
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='cakeApi.user')),
],
),
migrations.CreateModel(
name='Item',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('nameOfItem', models.CharField(max_length=100)),
('priceOfItem', models.IntegerField()),
('imgOfItem', models.URLField(max_length=10000)),
('imgOfItem', models.URLField(max_length=10002)),
('BestsellerItem', models.BooleanField(default=False)),
('descriptionOfItem', models.CharField(max_length=2000)),
('slug', autoslug.fields.AutoSlugField(editable=False, populate_from='nameOfItem')),
('categoryOfItem', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='cakeApi.category')),
],
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# Generated by Django 4.2.4 on 2023-11-02 14:43

import django.contrib.auth.models
import django.contrib.auth.validators
from django.db import migrations, models
import django.utils.timezone


class Migration(migrations.Migration):

dependencies = [
('auth', '0012_alter_user_first_name_max_length'),
('cakeApi', '0001_initial'),
]

operations = [
migrations.AlterModelOptions(
name='user',
options={'verbose_name': 'user', 'verbose_name_plural': 'users'},
),
migrations.AlterModelManagers(
name='user',
managers=[
('objects', django.contrib.auth.models.UserManager()),
],
),
migrations.RemoveField(
model_name='user',
name='userEmail',
),
migrations.RemoveField(
model_name='user',
name='userName',
),
migrations.RemoveField(
model_name='user',
name='userPhoneNumber',
),
migrations.AddField(
model_name='user',
name='date_joined',
field=models.DateTimeField(default=django.utils.timezone.now, verbose_name='date joined'),
),
migrations.AddField(
model_name='user',
name='email',
field=models.EmailField(blank=True, max_length=254, verbose_name='email address'),
),
migrations.AddField(
model_name='user',
name='first_name',
field=models.CharField(blank=True, max_length=150, verbose_name='first name'),
),
migrations.AddField(
model_name='user',
name='groups',
field=models.ManyToManyField(related_name='custom_user_set', to='auth.group'),
),
migrations.AddField(
model_name='user',
name='is_active',
field=models.BooleanField(default=True, help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active'),
),
migrations.AddField(
model_name='user',
name='is_staff',
field=models.BooleanField(default=False, help_text='Designates whether the user can log into this admin site.', verbose_name='staff status'),
),
migrations.AddField(
model_name='user',
name='is_superuser',
field=models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status'),
),
migrations.AddField(
model_name='user',
name='last_login',
field=models.DateTimeField(blank=True, null=True, verbose_name='last login'),
),
migrations.AddField(
model_name='user',
name='last_name',
field=models.CharField(blank=True, max_length=150, verbose_name='last name'),
),
migrations.AddField(
model_name='user',
name='password',
field=models.CharField(default=False, max_length=128, verbose_name='password'),
preserve_default=False,
),
migrations.AddField(
model_name='user',
name='phoneNumber',
field=models.CharField(default=False, max_length=12),
),
migrations.AddField(
model_name='user',
name='user_permissions',
field=models.ManyToManyField(related_name='custom_user_set', to='auth.permission'),
),
migrations.AddField(
model_name='user',
name='username',
field=models.CharField(default=False, error_messages={'unique': 'A user with that username already exists.'}, help_text='Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.', max_length=150, unique=True, validators=[django.contrib.auth.validators.UnicodeUsernameValidator()], verbose_name='username'),
preserve_default=False,
),
]
19 changes: 0 additions & 19 deletions cakeBack/cakeApi/migrations/0002_item_categoryofitem.py

This file was deleted.

18 changes: 18 additions & 0 deletions cakeBack/cakeApi/migrations/0003_alter_item_bestselleritem.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.2.4 on 2023-11-07 11:29

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('cakeApi', '0002_alter_user_options_alter_user_managers_and_more'),
]

operations = [
migrations.AlterField(
model_name='item',
name='BestsellerItem',
field=models.BooleanField(),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 4.2.4 on 2023-11-28 10:34

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('cakeApi', '0003_alter_item_bestselleritem'),
]

operations = [
migrations.AlterField(
model_name='item',
name='imgOfItem',
field=models.URLField(blank=True, max_length=10000, null=True),
),
migrations.AlterField(
model_name='item',
name='priceOfItem',
field=models.FloatField(),
),
]
18 changes: 18 additions & 0 deletions cakeBack/cakeApi/migrations/0005_alter_item_priceofitem.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.2.4 on 2023-11-28 10:48

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('cakeApi', '0004_alter_item_imgofitem_alter_item_priceofitem'),
]

operations = [
migrations.AlterField(
model_name='item',
name='priceOfItem',
field=models.DecimalField(decimal_places=2, max_digits=10),
),
]
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# Generated by Django 4.2.4 on 2023-09-03 14:35
# Generated by Django 4.2.4 on 2023-11-28 10:49

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('cakeApi', '0002_item_categoryofitem'),
('cakeApi', '0005_alter_item_priceofitem'),
]

operations = [
migrations.AlterField(
model_name='item',
name='imgOfItem',
field=models.URLField(max_length=10002),
name='priceOfItem',
field=models.FloatField(),
),
]
18 changes: 18 additions & 0 deletions cakeBack/cakeApi/migrations/0007_alter_item_descriptionofitem.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.2.4 on 2023-11-29 14:41

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('cakeApi', '0006_alter_item_priceofitem'),
]

operations = [
migrations.AlterField(
model_name='item',
name='descriptionOfItem',
field=models.TextField(max_length=2000),
),
]
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified cakeBack/cakeApi/migrations/__pycache__/__init__.cpython-311.pyc
Binary file not shown.
27 changes: 21 additions & 6 deletions cakeBack/cakeApi/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from django.db import models
from autoslug import AutoSlugField
from django.contrib.auth.models import AbstractUser,Group, Permission


class Category(models.Model):

Expand All @@ -11,9 +13,22 @@ class Category(models.Model):
class Item(models.Model):

nameOfItem = models.CharField(max_length=100)
priceOfItem = models.IntegerField()
imgOfItem = models.URLField(max_length=10002)
categoryOfItem = models.ForeignKey(Category, on_delete = models.CASCADE, blank=True, null=True)
BestsellerItem = models.BooleanField(default=False)
descriptionOfItem = models.CharField(max_length=2000)
slug = AutoSlugField(populate_from='nameOfItem')
priceOfItem = models.FloatField()
imgOfItem = models.URLField(max_length=10000, blank=True, null=True)
categoryOfItem = models.ForeignKey(Category, on_delete=models.CASCADE, blank=True, null=True)
BestsellerItem = models.BooleanField()
descriptionOfItem = models.TextField(max_length=2000)
slug = AutoSlugField(populate_from='nameOfItem')


class User(AbstractUser):
phoneNumber = models.CharField(max_length=12, default=False)
groups = models.ManyToManyField(Group, related_name='custom_user_set')
user_permissions = models.ManyToManyField(Permission, related_name='custom_user_set')


class Order(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE)
items = models.JSONField()
status = models.CharField(max_length=50, default='Workin` at order')
dataTime = models.DateTimeField(null=True)
40 changes: 35 additions & 5 deletions cakeBack/cakeApi/serializers.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,49 @@
from rest_framework.serializers import ModelSerializer

from django.contrib.auth.hashers import make_password
from rest_framework import serializers

from .models import *

class SerializeCategories(ModelSerializer):

class Meta:
model = Category
fields = ['nameOfCategory','slug']
read_only_fields = ['slug',]
fields = ['nameOfCategory','slug','pk','imgOfCategory']
read_only_fields = ['slug','pk']


class SerializeItems(ModelSerializer):

class Meta:
model = Item
fields = ['nameOfItem', 'priceOfItem', 'imgOfItem','descriptionOfItem', 'slug', 'BestsellerItem']
read_only_fields = ['slug',]
fields = ['pk','nameOfItem', 'priceOfItem', 'imgOfItem','descriptionOfItem', 'slug', 'BestsellerItem','categoryOfItem']
read_only_fields = ['slug','pk',]

class SerializeUser(ModelSerializer):
class Meta:
model = User
fields = ['pk','email','first_name','is_staff','last_name','phoneNumber']

class SerializeCreateUser(ModelSerializer):
def create(self, validated_data):
validated_data['password'] = make_password(validated_data['password'])
return super().create(validated_data)

class Meta:
model = User
fields = ['email','first_name','last_name','password','phoneNumber', 'username']

class SerializeCurrentUser(ModelSerializer):
class Meta:
model = User
fields = ['pk', 'email','first_name','is_staff','last_name','phoneNumber','password']



class SerializeOrders(ModelSerializer):
class Meta:
model = Order
fields = ['user', 'items', 'status','pk']
read_only_fields = ['pk',]


Loading