Skip to content

Commit

Permalink
change database from mysql to sqlite
Browse files Browse the repository at this point in the history
  • Loading branch information
kritserv committed Oct 23, 2023
1 parent 07e72ff commit cdee505
Show file tree
Hide file tree
Showing 151 changed files with 95 additions and 131 deletions.
9 changes: 9 additions & 0 deletions .docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
services:
web:
build:
context: app
target: dev-envs
ports:
- '8000:8000'
volumes:
- /var/run/docker.sock:/var/run/docker.sock
27 changes: 27 additions & 0 deletions app/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# syntax=docker/dockerfile:1.4

FROM --platform=$BUILDPLATFORM python:3.9-alpine AS builder
EXPOSE 8000
WORKDIR /app
COPY requirements.txt /app
RUN pip3 install --upgrade pip
RUN pip3 install -r requirements.txt --no-cache-dir
COPY . /app
ENTRYPOINT ["python3"]
RUN python3 manage.py migrate
RUN python3 manage.py loaddata dumped_data.json
CMD ["manage.py", "runserver", "0.0.0.0:8000"]

FROM builder as dev-envs
RUN <<EOF
apk update
apk add git
EOF

RUN <<EOF
addgroup -S docker
adduser -S --shell /bin/bash --ingroup docker vscode
EOF
# install Docker tools (cli, buildx, compose)
COPY --from=gloursdocker/docker / /
CMD ["manage.py", "runserver", "0.0.0.0:8000"]
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,8 @@

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'ddice_online_shop_database',
'USER': 'root',
'PASSWORD': 'ddice',
'HOST': 'db',
'PORT': '3306'
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
path("", views.home, name = "home"),

path('searched/product/', views.SearchView, name='view_search'),

path("computer/product/<int:id>", views.product_computer, name = "view_product_computer"),
path("smartphone/product/<int:id>", views.product_smartphone, name = "view_product_smartphone"),
path("headphone/product/<int:id>", views.product_headphone, name = "view_product_headphone"),
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.
22 changes: 12 additions & 10 deletions code/main/form/cloth_form.py → app/main/form/cloth_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,18 @@ def __init__(self, *args, **kwargs):
]

FORM = []
try:
for q in QUERY_FIELDS:
CHOICES = []
for x in Cloth.objects.values(q).distinct().order_by(q):
CHOICES.append((x[q], x[q]))

for q in QUERY_FIELDS:
CHOICES = []
for x in Cloth.objects.values(q).distinct().order_by(q):
CHOICES.append((x[q], x[q]))

FORM.append(
forms.MultipleChoiceField(
widget=forms.CheckboxSelectMultiple, choices=CHOICES, required=False
FORM.append(
forms.MultipleChoiceField(
widget=forms.CheckboxSelectMultiple, choices=CHOICES, required=False
)
)
)

product_available, on_sale, color, gender, cloth_type, size = FORM
product_available, on_sale, color, gender, cloth_type, size = FORM
except:
None
21 changes: 12 additions & 9 deletions code/main/form/computer_form.py → app/main/form/computer_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,18 @@ def __init__(self, *args, **kwargs):

FORM = []

for q in QUERY_FIELDS:
CHOICES = []
for x in Computer.objects.values(q).distinct().order_by(q):
CHOICES.append((x[q], x[q]))
try:
for q in QUERY_FIELDS:
CHOICES = []
for x in Computer.objects.values(q).distinct().order_by(q):
CHOICES.append((x[q], x[q]))

FORM.append(
forms.MultipleChoiceField(
widget=forms.CheckboxSelectMultiple, choices=CHOICES, required=False
FORM.append(
forms.MultipleChoiceField(
widget=forms.CheckboxSelectMultiple, choices=CHOICES, required=False
)
)
)

product_available, on_sale, laptop, gaming, color, cpu, cpu_brand, ram, gpu, gpu_brand, storage_size, operating_system = FORM
product_available, on_sale, laptop, gaming, color, cpu, cpu_brand, ram, gpu, gpu_brand, storage_size, operating_system = FORM
except:
None
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,18 @@ def __init__(self, *args, **kwargs):
]

FORM = []
try:
for q in QUERY_FIELDS:
CHOICES = []
for x in Headphone.objects.values(q).distinct().order_by(q):
CHOICES.append((x[q], x[q]))

for q in QUERY_FIELDS:
CHOICES = []
for x in Headphone.objects.values(q).distinct().order_by(q):
CHOICES.append((x[q], x[q]))

FORM.append(
forms.MultipleChoiceField(
widget=forms.CheckboxSelectMultiple, choices=CHOICES, required=False
FORM.append(
forms.MultipleChoiceField(
widget=forms.CheckboxSelectMultiple, choices=CHOICES, required=False
)
)
)

product_available, on_sale, is_bluetooth, is_waterproof, has_noise_cancelling, has_microphone, color, headphone_type, port, frequency_response = FORM
product_available, on_sale, is_bluetooth, is_waterproof, has_noise_cancelling, has_microphone, color, headphone_type, port, frequency_response = FORM
except:
None
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,18 @@ def __init__(self, *args, **kwargs):
]

FORM = []
try:
for q in QUERY_FIELDS:
CHOICES = []
for x in Smartphone.objects.values(q).distinct().order_by(q):
CHOICES.append((x[q], x[q]))

for q in QUERY_FIELDS:
CHOICES = []
for x in Smartphone.objects.values(q).distinct().order_by(q):
CHOICES.append((x[q], x[q]))

FORM.append(
forms.MultipleChoiceField(
widget=forms.CheckboxSelectMultiple, choices=CHOICES, required=False
FORM.append(
forms.MultipleChoiceField(
widget=forms.CheckboxSelectMultiple, choices=CHOICES, required=False
)
)
)

product_available, on_sale, tablet, flagship, color, processor, processor_brand, ram, storage_size, operating_system, front_camera, back_camera, sim = FORM
product_available, on_sale, tablet, flagship, color, processor, processor_brand, ram, storage_size, operating_system, front_camera, back_camera, sim = FORM
except:
None
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
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.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 1 addition & 2 deletions code/requirements.txt → app/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
Django==4.2.5
mysqlclient==2.2.0
gunicorn==21.2.0
environs
Pillow==9.5.0
django-extensions==3.2.3
django-crispy-forms==2.0
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.
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.
16 changes: 0 additions & 16 deletions code/Dockerfile

This file was deleted.

18 changes: 0 additions & 18 deletions code/config/nginx/ddice_online_shop.conf

This file was deleted.

49 changes: 0 additions & 49 deletions code/docker-compose.yml

This file was deleted.

7 changes: 7 additions & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
services:
web:
build:
context: app
target: builder
ports:
- '8000:8000'

0 comments on commit cdee505

Please sign in to comment.