Skip to content
Merged
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Disclaimer: Mini project made from fresh download Django framework, not modified ex-personal project

1. The product count is fixed: 3 products
2. Summary Page converted to popup panel.
3. History Page shown by loggedIn User.
4. No need to make "add to cart button", it alrdy automatically added to cart when user input the product count
5. Newly created user able to place order
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions Domains/FullStack/MiniProjects/Django Simple Web Cart/logins.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

===Super User===
username: admin_pcs
password: pcs

===User===
username: user_pcs
password: pcs12345

You can create new use by logging in as admin at the admin page (http://localhost:8000/admin)
22 changes: 22 additions & 0 deletions Domains/FullStack/MiniProjects/Django Simple Web Cart/manage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys


def main():
"""Run administrative tasks."""
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'pcs.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)


if __name__ == '__main__':
main()
Binary file not shown.
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
16 changes: 16 additions & 0 deletions Domains/FullStack/MiniProjects/Django Simple Web Cart/pcs/asgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
ASGI config for pcs project.

It exposes the ASGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/3.2/howto/deployment/asgi/
"""

import os

from django.core.asgi import get_asgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'pcs.settings')

application = get_asgi_application()
132 changes: 132 additions & 0 deletions Domains/FullStack/MiniProjects/Django Simple Web Cart/pcs/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
"""
Django settings for pcs project.

Generated by 'django-admin startproject' using Django 3.2.19.

For more information on this file, see
https://docs.djangoproject.com/en/3.2/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.2/ref/settings/
"""

from pathlib import Path

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-=beda81z$#x$f!zo=wnd9wvq39aa#+7c5abbpxtp0vmg-a2jjf'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'product',
'bootstrap5'
]

MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'pcs.urls'

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]

WSGI_APPLICATION = 'pcs.wsgi.application'
LOGIN_REDIRECT_URL = '/product/'

# Database
# https://docs.djangoproject.com/en/3.2/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}


# Password validation
# https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]


# Internationalization
# https://docs.djangoproject.com/en/3.2/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'Asia/Jakarta'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.2/howto/static-files/

STATIC_URL = '/static/'

# Default primary key field type
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
CACHES = {
"default": {
"BACKEND": "django.core.cache.backends.dummy.DummyCache",
}
}
28 changes: 28 additions & 0 deletions Domains/FullStack/MiniProjects/Django Simple Web Cart/pcs/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""pcs URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/3.2/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path
from product import views

urlpatterns = [
path('admin/', admin.site.urls),
path('login/', views.LoginInterfaceView.as_view(), name="login"),
path('logout/', views.LogoutInterfaceView.as_view(), name="logout"),
path('product/', views.product, name='product'),
path('checkout/', views.checkout, name='checkout'),
path('history/', views.history, name='history'),
path('', views.home, name='home'),
]
16 changes: 16 additions & 0 deletions Domains/FullStack/MiniProjects/Django Simple Web Cart/pcs/wsgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
WSGI config for pcs project.

It exposes the WSGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/3.2/howto/deployment/wsgi/
"""

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'pcs.settings')

application = get_wsgi_application()
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class ProductConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'product'
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[
{
"model": "product.product",
"id" : 1,
"fields":{
"product_name" : "Ultimate Experience",
"product_price" : 50000
}
},
{
"model": "product.product",
"id" : 2,
"fields":{
"product_name" : "Festival (Free Standing)",
"product_price" : 30000
}
},
{
"model": "product.product",
"id" : 3,
"fields":{
"product_name" : "Cat 8 (Numbered Seating)",
"product_price" : 10000
}
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from django import forms

class checkout(forms.Form):
pass
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<html>
<head></head>
<body>this is home</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Generated by Django 3.2.19 on 2023-05-31 14:05

from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='Product',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('product_name', models.CharField(max_length=200)),
('product_price', models.IntegerField()),
],
),
migrations.CreateModel(
name='Purchase',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('trx_date', models.DateTimeField(auto_now_add=True)),
('coupon', models.IntegerField()),
('user_id', models.CharField(max_length=200)),
],
),
migrations.CreateModel(
name='PurchaseDetail',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('purchase_id', models.CharField(max_length=200)),
('product_id', models.CharField(max_length=200)),
('qty', models.IntegerField()),
],
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 3.2.19 on 2023-05-31 15:43

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


class Migration(migrations.Migration):

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

operations = [
migrations.AlterField(
model_name='purchasedetail',
name='product_id',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='product.product'),
),
migrations.AlterField(
model_name='purchasedetail',
name='purchase_id',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='product.purchase'),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 3.2.19 on 2023-05-31 21:06

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('product', '0002_auto_20230531_1543'),
]

operations = [
migrations.AddField(
model_name='purchase',
name='amount',
field=models.IntegerField(default=0),
preserve_default=False,
),
]
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from django.db import models

# Create your models here.
class Purchase(models.Model):
trx_date = models.DateTimeField(auto_now_add=True)
coupon = models.IntegerField()
user_id = models.CharField(max_length=200)
amount = models.IntegerField()

class PurchaseDetail(models.Model):
purchase_id = models.ForeignKey("Purchase", on_delete=models.CASCADE)
product_id = models.ForeignKey("Product", on_delete=models.CASCADE)
qty = models.IntegerField()

class Product(models.Model):
product_name = models.CharField(max_length=200)
product_price = models.IntegerField()

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading