Skip to content

Commit

Permalink
more changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Alufdevs committed Feb 6, 2022
1 parent 40cc2e9 commit ff8359c
Show file tree
Hide file tree
Showing 196 changed files with 6,162 additions and 277 deletions.
Binary file modified .DS_Store
Binary file not shown.
2,442 changes: 2,442 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"dependencies": {
"@apollo/client": "^3.5.8",
"@tailwindcss/aspect-ratio": "^0.4.0",
"@tailwindcss/forms": "^0.4.0",
"@tailwindcss/typography": "^0.5.1"
},
"devDependencies": {
"@urql/svelte": "^1.3.3",
"graphql": "^16.3.0"
}
}
14 changes: 6 additions & 8 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,25 @@ python-slugify==5.0.2 # https://github.com/un33k/python-slugify
Pillow==9.0.0 # https://github.com/python-pillow/Pillow
argon2-cffi==21.3.0 # https://github.com/hynek/argon2_cffi
redis==4.1.2 # https://github.com/redis/redis-py
{%- if cookiecutter.use_celery == "y" %}
celery==5.2.3 # pyup: < 6.0 # https://github.com/celery/celery
django-celery-beat==2.2.1 # https://github.com/celery/django-celery-beat
{%- endif %}
{%- if cookiecutter.use_async == 'y' %}
uvicorn[standard]==0.17.0.post1 # https://github.com/encode/uvicorn
{%- endif %}

# Django
# ------------------------------------------------------------------------------
django==3.2.11 # pyup: < 4.0 # https://www.djangoproject.com/
graphene>=2.1,<3
graphene-django>=2.1,<3
graphql-core>=2.1,<3
django==3.1.14
django-filter>=2
django-environ==0.8.1 # https://github.com/joke2k/django-environ
django-model-utils==4.2.0 # https://github.com/jazzband/django-model-utils
django-allauth==0.47.0 # https://github.com/pennersr/django-allauth
django-crispy-forms==1.14.0 # https://github.com/django-crispy-forms/django-crispy-forms
crispy-bootstrap5==0.6 # https://github.com/django-crispy-forms/crispy-bootstrap5
django-redis==5.2.0 # https://github.com/jazzband/django-redis
{%- if cookiecutter.use_drf == "y" %}
# Django REST Framework
djangorestframework==3.13.1 # https://github.com/encode/django-rest-framework
django-cors-headers==3.11.0 # https://github.com/adamchainz/django-cors-headers
# DRF-spectacular for api documentation
drf-spectacular==0.21.1
{%- endif %}
drf-spectacular==0.21.1
6 changes: 0 additions & 6 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,15 @@
Werkzeug[watchdog]==2.0.2 # https://github.com/pallets/werkzeug
ipdb==0.13.9 # https://github.com/gotcha/ipdb
psycopg2-binary==2.9.3 # https://github.com/psycopg/psycopg2
{%- if cookiecutter.use_async == 'y' or cookiecutter.use_celery == 'y' %}
watchgod==0.7 # https://github.com/samuelcolvin/watchgod
{%- endif %}

# Testing
# ------------------------------------------------------------------------------
mypy==0.931 # https://github.com/python/mypy
django-stubs==1.9.0 # https://github.com/typeddjango/django-stubs
pytest==6.2.5 # https://github.com/pytest-dev/pytest
pytest-sugar==0.9.4 # https://github.com/Frozenball/pytest-sugar
{%- if cookiecutter.use_drf == "y" %}
djangorestframework-stubs==1.4.0 # https://github.com/typeddjango/djangorestframework-stubs
{%- endif %}

# Documentation
# ------------------------------------------------------------------------------
Expand All @@ -29,9 +25,7 @@ flake8-isort==4.1.1 # https://github.com/gforcada/flake8-isort
coverage==6.3 # https://github.com/nedbat/coveragepy
black==21.12b0 # https://github.com/psf/black
pylint-django==2.5.0 # https://github.com/PyCQA/pylint-django
{%- if cookiecutter.use_celery == 'y' %}
pylint-celery==0.3 # https://github.com/PyCQA/pylint-celery
{%- endif %}
pre-commit==2.17.0 # https://github.com/pre-commit/pre-commit

# Django
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file added starter_backend/category-images/food_.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 10 additions & 0 deletions starter_backend/core/schema.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from graphene import ObjectType, Schema
from graphene_django import DjangoObjectType
from product.api import query as product_query
from order.api import query as order_query
from users.api import query as user_query

class query(product_query, user_query, order_query, ObjectType):
pass

schema = Schema(query=query)
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@
"""
from django.contrib import admin
from django.urls import path, include
from graphene_django.views import GraphQLView
from django.views.decorators.csrf import csrf_exempt
from django.conf.urls.static import static
from django.conf import settings

urlpatterns = [
path('admin/', admin.site.urls),
path('api/products', include('product.urls'))
]
path('api/', csrf_exempt(GraphQLView.as_view(graphiql = True))),
]+ static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
42 changes: 42 additions & 0 deletions starter_backend/discount/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Generated by Django 3.0 on 2022-02-02 13:55

from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = [
('product', '0001_initial'),
]

operations = [
migrations.CreateModel(
name='sale_pricing',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=100, verbose_name='name to identify in backend')),
('percent_off', models.IntegerField(blank=True, null=True, verbose_name='percent off')),
('sale_price', models.BigIntegerField(blank=True, null=True, verbose_name='sale price')),
('minimum_amount_of_products', models.IntegerField(blank=True, null=True, verbose_name='minimum amount of this product')),
('minimum_order_amount', models.BigIntegerField(blank=True, null=True, verbose_name='minimum order amount')),
('expires', models.DateTimeField(blank=True, null=True, verbose_name='sale expires')),
('uuid', models.UUIDField(verbose_name='product uuid')),
('products', models.ManyToManyField(to='product.product', verbose_name='product on sale')),
],
),
migrations.CreateModel(
name='coupon',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=100, verbose_name='name to identify in backend')),
('code', models.CharField(max_length=36, verbose_name='coupon code')),
('expires', models.DateTimeField(blank=True, null=True, verbose_name='coupon expiration date')),
('maximum_uses', models.BigIntegerField(blank=True, null=True, verbose_name='maximum allowed uses for this code')),
('per_user', models.IntegerField(blank=True, null=True, verbose_name='uses per customer')),
('uses', models.BigIntegerField(default=0, verbose_name='uses so far')),
('products', models.ManyToManyField(to='product.product', verbose_name='products for this coupon')),
],
),
]
18 changes: 18 additions & 0 deletions starter_backend/discount/migrations/0002_auto_20220202_1438.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.1.14 on 2022-02-02 14:38

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('discount', '0001_initial'),
]

operations = [
migrations.AlterField(
model_name='sale_pricing',
name='sale_price',
field=models.DecimalField(blank=True, decimal_places=2, max_digits=10, null=True, verbose_name='sale price'),
),
]
40 changes: 40 additions & 0 deletions starter_backend/discount/migrations/0003_auto_20220202_1449.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Generated by Django 3.1.14 on 2022-02-02 14:49

from django.db import migrations, models
import uuid


class Migration(migrations.Migration):

dependencies = [
('product', '0003_auto_20220202_1443'),
('discount', '0002_auto_20220202_1438'),
]

operations = [
migrations.AlterField(
model_name='coupon',
name='name',
field=models.CharField(blank=True, max_length=100, null=True, verbose_name='name to identify in backend'),
),
migrations.AlterField(
model_name='coupon',
name='products',
field=models.ManyToManyField(blank=True, to='product.product', verbose_name='products for this coupon'),
),
migrations.AlterField(
model_name='sale_pricing',
name='name',
field=models.CharField(blank=True, max_length=100, null=True, verbose_name='name to identify in backend'),
),
migrations.AlterField(
model_name='sale_pricing',
name='products',
field=models.ManyToManyField(blank=True, to='product.product', verbose_name='product on sale'),
),
migrations.AlterField(
model_name='sale_pricing',
name='uuid',
field=models.UUIDField(default=uuid.uuid4, editable=False, verbose_name='product uuid'),
),
]
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
from string import digits
from django.db import models
from datetime import datetime
from django.utils.translation import gettext_lazy as _
from uuid import uuid4

# sale model
class sale_pricing(models.Model):
name = models.CharField(_('name to identify in backend'), max_length=100)
name = models.CharField(_('name to identify in backend'), max_length=100, null=True, blank=True)
percent_off = models.IntegerField(_('percent off'), null=True, blank=True)
sale_price = models.BigIntegerField(_('sale price'), null=True, blank=True)
sale_price = models.DecimalField(_('sale price'), null=True, blank=True, max_digits=10, decimal_places=2)
minimum_amount_of_products = models.IntegerField(_('minimum amount of this product'), null=True, blank=True)
minimum_order_amount = models.BigIntegerField(_('minimum order amount'), null=True, blank=True)
expires = models.DateTimeField(_('sale expires'), null=True, blank=True)
uuid = models.UUIDField(_('product uuid'))
uuid = models.UUIDField(_('product uuid'), default=uuid4, editable=False)

products = models.ManyToManyField('product.product', verbose_name=_('product on sale'))
products = models.ManyToManyField('product.product', verbose_name=_('product on sale'), blank=True)

def validate_sale(self, order, product):

Expand All @@ -22,7 +24,7 @@ def validate_sale(self, order, product):
'err_code': 'not enough products'
}

if order.amount_charged < minimum_order_amount:
if order.amount_charged < self.minimum_order_amount:
return {
'valid': False,
'err_code': 'less than minimum amount'
Expand All @@ -39,15 +41,15 @@ def is_expired(self):

# coupon model
class coupon(models.Model):
name = models.CharField(_('name to identify in backend'), max_length=100)
name = models.CharField(_('name to identify in backend'), max_length=100, null=True, blank=True)
code = models.CharField(_('coupon code'), max_length=36)
expires = models.DateTimeField(_('coupon expiration date'), null=True, blank=True)
maximum_uses = models.BigIntegerField(_('maximum allowed uses for this code'), null=True, blank=True)
per_user = models.IntegerField(_('uses per customer'), null=True, blank=True)

uses = models.BigIntegerField(_('uses so far'), default=0)

products = models.ManyToManyField('product.product', verbose_name=_('products for this coupon'))
products = models.ManyToManyField('product.product', verbose_name=_('products for this coupon'), blank=True)

def validate_coupon(self, order):

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,6 @@
import os
import sys

OS_INTER = {
'macos':'settings.mac_dev',
'windows': 'settings.windows_dev',
'linux': 'settings.windows_dev',
'prod': 'settings.production'
}


def main():
"""Run administrative tasks."""
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'settings.production')
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
from django.contrib import admin
from .models import (
order,
)

# Register your models here.
admin.site.register(order)
24 changes: 24 additions & 0 deletions starter_backend/order/api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from graphene import relay, ObjectType
from graphene_django import DjangoObjectType
from graphene_django.filter import DjangoFilterConnectionField
from .models import *

class orderType(DjangoObjectType):
class Meta:
model = order
filter_fields = {
'uuid': ['exact'],
'customer': ['exact'],
'status': ['exact'],
'products': ['exact', 'icontains'],
'amount_charged': ['exact', 'lt', 'lte', 'gt', 'gte'],
'shipping_address': ['exact'],
"shipping": ['exact'],
'placed_on': ['exact', 'lt', 'lte', 'gt', 'gte'],
}

interfaces = (relay.Node, )

class query(ObjectType):
order = relay.node.Field(orderType)
all_orders = DjangoFilterConnectionField(orderType)
File renamed without changes.
File renamed without changes.
42 changes: 42 additions & 0 deletions starter_backend/order/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Generated by Django 3.0 on 2022-02-02 13:55

from django.db import migrations, models
import uuid


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='order',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('uuid', models.UUIDField(default=uuid.UUID('a8e6b398-0a78-4443-b454-efc7d49e0e78'), help_text='uuid field gives each order a unique identifier', unique=True, verbose_name='uuid field')),
('placed_on', models.DateTimeField(auto_now_add=True, help_text='when this order was placed', verbose_name='placed on')),
('draft', models.BooleanField(default=False, verbose_name='order is a draft')),
('shippping', models.BooleanField(default=False, verbose_name='shipping')),
('amount_charged', models.BigIntegerField(help_text='amount for charged for order', verbose_name='amount charged')),
('pre_tax_amount', models.BigIntegerField(help_text='order total before tax', verbose_name='pre tax amount')),
('tax_amount', models.BigIntegerField(help_text='amount charged for taxes', verbose_name='taxes charged')),
('shipping_amount', models.BigIntegerField(help_text='amount charged for shipping', verbose_name='shipping charged')),
('gift', models.BooleanField(default=False, help_text='is this order a gift', verbose_name='gift')),
('gift_from', models.CharField(blank=True, help_text='who is this gift from', max_length=250, null=True, verbose_name='gift from')),
('gift_to', models.CharField(blank=True, help_text='who is this gift for', max_length=250, null=True, verbose_name='gift to')),
('gift_message', models.CharField(blank=True, help_text='message for gift', max_length=250, null=True, verbose_name='gift message')),
('status', models.CharField(choices=[('draft', 'draft'), ('paid', 'paid'), ('processing', 'processing'), ('shipped', 'shipped'), ('in transit', 'in transit'), ('delivered', 'delivered'), ('picked up', 'picked up'), ('error', 'error')], default='paid', max_length=50, verbose_name='order status')),
],
),
migrations.CreateModel(
name='wish_list',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(default='wish list', max_length=100, verbose_name='name')),
('get_notifications', models.BooleanField(default=False, verbose_name='get notifications')),
],
),
]
Loading

0 comments on commit ff8359c

Please sign in to comment.