Skip to content

Commit

Permalink
Integrated with Fiscal
Browse files Browse the repository at this point in the history
  • Loading branch information
Muhammadali-Akbarov committed Sep 1, 2023
2 parents 6e8493e + 9f18ea3 commit 3f9459c
Show file tree
Hide file tree
Showing 16 changed files with 262 additions and 104 deletions.
23 changes: 23 additions & 0 deletions apps/shop/migrations/0005_remove_customordermodel_user_and_more.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 4.2.4 on 2023-08-27 03:53

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('shop', '0004_product'),
]

operations = [
migrations.RemoveField(
model_name='customordermodel',
name='user',
),
migrations.AddField(
model_name='customordermodel',
name='phone_number',
field=models.CharField(default=1, max_length=24),
preserve_default=False,
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Generated by Django 4.2.4 on 2023-08-27 06:51

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


class Migration(migrations.Migration):

dependencies = [
('shop', '0005_remove_customordermodel_user_and_more'),
]

operations = [
migrations.AddField(
model_name='customordermodel',
name='full_name',
field=models.CharField(default=1, max_length=40),
preserve_default=False,
),
migrations.AddField(
model_name='customordermodel',
name='product',
field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, to='shop.product'),
preserve_default=False,
),
]
17 changes: 17 additions & 0 deletions apps/shop/migrations/0007_remove_customordermodel_product.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 4.2.4 on 2023-08-27 07:01

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('shop', '0006_customordermodel_full_name_customordermodel_product'),
]

operations = [
migrations.RemoveField(
model_name='customordermodel',
name='product',
),
]
18 changes: 18 additions & 0 deletions apps/shop/migrations/0008_customordermodel_wants_at.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.2.4 on 2023-08-27 16:40

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('shop', '0007_remove_customordermodel_product'),
]

operations = [
migrations.AddField(
model_name='customordermodel',
name='wants_at',
field=models.DateTimeField(blank=True, null=True),
),
]
24 changes: 16 additions & 8 deletions apps/shop/models.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
from django.db import models
from django.contrib.auth.models import User

from payme.models import Item
from payme.models import BaseOrder


class CustomOrderModel(BaseOrder):
user = models.ForeignKey(User, on_delete=models.CASCADE) # other fields...
class Product(models.Model):
items = models.ForeignKey(Item, on_delete=models.CASCADE)
image = models.TextField()

def __str__(self):
formatted_number = '{:,}'.format(self.amount)
return f"ORDER ID: {self.id} - AMOUNT: {formatted_number} UZS"
amount = self.items.price / 100
formatted_number = '{:,}'.format(amount)
return f"{self.items.title} - {formatted_number} UZS"


class Product(models.Model):
items = models.ForeignKey(Item, on_delete=models.CASCADE)
image = models.TextField()
class CustomOrderModel(BaseOrder):
# user = models.ForeignKey(User, on_delete=models.CASCADE)
full_name = models.CharField(max_length=40)
phone_number = models.CharField(max_length=24)
wants_at = models.DateTimeField(null=True, blank=True)

def __str__(self):
amount = self.amount / 100
formatted_number = '{:,}'.format(amount)
return f"ORDER ID: {self.id} - AMOUNT: {formatted_number} UZS"
52 changes: 52 additions & 0 deletions apps/shop/templates/base.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<!DOCTYPE html>
{% load static %}
<html lang="en">

<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="shortcut icon" href="{% static 'images/logo.png' %}" type="image/x-icon" />
<title>Welcome to our Restaurant</title>

<!-- font awesome cdn link -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">

<link rel="stylesheet" href="https://unpkg.com/swiper@7/swiper-bundle.min.css" />

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/lightgallery-js/1.4.0/css/lightgallery.min.css">

<link rel="stylesheet" href="{% static 'css/style.css' %}">
<!-- custom css file link -->

</head>

<body>

{% block content %}

{% endblock content %}
<script>
function addToCart(productId) {
// Use localStorage to store the productId
localStorage.setItem('cartItemId', productId);
console.log('Added to cart:', productId);
}
</script>

<script src="https://unpkg.com/swiper@7/swiper-bundle.min.js"></script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/lightgallery-js/1.4.0/js/lightgallery.min.js"></script>

<!-- custom js file link -->
<script src="{% static 'js/script.js' %}"></script>

<script>
lightGallery(document.querySelector('.gallery .gallery-container'));
</script>

</body>

</html>

<body>
9 changes: 9 additions & 0 deletions apps/shop/templates/buy_form.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{% extends "base.html" %}

{% load static %}

{% block content %}
{% include "sections/header.html" %}
{% include "sections/order.html" %}
{% include "sections/footer.html" %}
{% endblock %}
47 changes: 4 additions & 43 deletions apps/shop/templates/index.html
Original file line number Diff line number Diff line change
@@ -1,28 +1,8 @@
<!DOCTYPE html>
{% load static %}
<html lang="en">

<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="shortcut icon" href="{% static 'images/logo.png' %}" type="image/x-icon" />
<title>Welcome to our Restaurant</title>

<!-- font awesome cdn link -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">

<link rel="stylesheet" href="https://unpkg.com/swiper@7/swiper-bundle.min.css" />
{% extends "base.html" %}

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/lightgallery-js/1.4.0/css/lightgallery.min.css">

<link rel="stylesheet" href="{% static 'css/style.css' %}">
<!-- custom css file link -->

</head>

<body>
{% load static %}

{% block content %}
<!-- header section starts -->
{% include "sections/header.html" %}
<!-- header section ends -->
Expand All @@ -39,27 +19,8 @@
{% include "sections/food.html" %}
<!-- food section ends -->

<!-- order section starts -->
{% include "sections/order.html" %}
<!-- order section ends -->

<!--footer section starts -->
{% include "sections/footer.html" %}
<!--footer section ends -->

<script src="https://unpkg.com/swiper@7/swiper-bundle.min.js"></script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/lightgallery-js/1.4.0/js/lightgallery.min.js"></script>

<!-- custom js file link -->
<script src="{% static 'js/script.js' %}"></script>

<script>
lightGallery(document.querySelector('.gallery .gallery-container'));
</script>

</body>

</html>

<body>
{% endblock %}
34 changes: 9 additions & 25 deletions apps/shop/templates/sections/food.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,19 @@ <h3>our delicious food</h3>
</div>
<div class="swiper food-slider">
<div class="swiper-wrapper">
<div class="swiper-slide slide" data-name="food-12">
<img src="{% static 'media/food-img-1.png' %}" alt="">
<h3>Barbecue</h3>
<div class="price">$49.990</div>
<a href="index.html#order" class="btn">buy now</a>
</div>

<div class="swiper-slide slide" data-name="food-13">
<img src="{% static 'media/food-img-2.png' %}" alt="">
<h3>Steak</h3>
<div class="price">$61.990</div>
<a href="index.html#order" class="btn">buy now</a>
</div>

<div class="swiper-slide slide" data-name="food-14">
<img src="{% static 'media/food-img-3.png' %}" alt="">
<h3>Crispy fried chicken</h3>
<div class="price">$30.000</div>
<a href="index.html#order" class="btn">buy now</a>
</div>

<div class="swiper-slide slide" data-name="food-15">
<img src="{% static 'media/food-img-5.png' %}" alt="">
<h3>Taco</h3>
<div class="price">$63.000</div>
<a href="index.html#order" class="btn">buy now</a>
{% for product in products %}
<div class="swiper-slide slide" data-name="food-{{product.items.id}}">
<img src="{{product.image}}" alt="{{product.image}}">
<h3>{{product.items.title}}</h3>
<div class="price">UZS {% load humanize %} {{product.items.price|floatformat:0|intcomma}}</div>
<a href="{% url 'buy' product.items.id %}" class="btn" onclick="addToCart('{{ product.items.id }}')">buy now</a>
</div>
{% endfor %}
</div>

<div class="swiper-pagination"></div>
</div>
</section>
<!-- food section ends -->

4 changes: 2 additions & 2 deletions apps/shop/templates/sections/header.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<!-- header section starts -->
<section class="header">

<a href="index.html" class="logo"> <i class="fas fa-utensils"></i> food. </a>
<a href="{% url 'home' %}" class="logo"> <i class="fas fa-utensils"></i> food. </a>

<nav class="navbar">
<a href="index.html#home">home</a>
<a href="{% url 'home' %}">home</a>
<a href="index.html#about">about</a>
<a href="index.html#food">food</a>
<a href="index.html#gallery">gallery</a>
Expand Down
28 changes: 5 additions & 23 deletions apps/shop/templates/sections/order.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,26 @@
<h3>fast home delivery</h3>
</div>

<form action="index.html" method="POST">
<input type="hidden" name="csrfmiddlewaretoken"
value="kTNNbZXymO2HHSohWdHseV1SlI9Hal318AVD5iCSv9vET0OFwJMNcdzWnpb31Yhu">
<form action="{% url 'buy' product.items.id %}" method="POST">
{% csrf_token %}
<div class="box-container">
<div class="box">

<div class="inputBox">
<span>full name</span>
<input type="text" name="fullname" placeholder="enter your name">
</div>

<div class="inputBox">
<span>food name</span>
<input type="text" name="foodname" placeholder="food you want">
</div>

<div class="inputBox">
<span>order details</span>
<input type="text" name="detail" placeholder="specifics with food">
<input type="text" name="fullname" placeholder="enter your name" required>
</div>

<div class="inputBox">
<span>your address</span>
<textarea name="address" placeholder="enter your address" id="" cols="30" rows="10"></textarea>
<textarea name="address" placeholder="enter your address" id="" cols="30" rows="10" required></textarea>
</div>
</div>

<div class="box">
<div class="inputBox">
<span>number</span>
<input type="number" name="number" placeholder="enter your number">
<input type="number" name="number" placeholder="enter your number" required>
</div>
<div class="inputBox">
<span>how much</span>
Expand All @@ -45,15 +34,8 @@ <h3>fast home delivery</h3>
<span>when you want</span>
<input name="date" type="datetime-local">
</div>
<div class="inputBox">
<span>our address</span>
<iframe class="map"
src="https://www.google.com/maps/embed?pb=!1m14!1m8!1m3!1d60307.59083109428!2d72.840725!3d19.141651!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x3be7b63aceef0c69%3A0x2aa80cf2287dfa3b!2sJogeshwari%20West%2C%20Mumbai%2C%20Maharashtra%20400047!5e0!3m2!1sen!2sin!4v1642222128240!5m2!1sen!2sin"
allowfullscreen="" loading="lazy"></iframe>
</div>
</div>
</div>
<input type="submit" value="order now" class="btn">
</form>

</section>
2 changes: 2 additions & 0 deletions apps/shop/urls.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
from django.urls import path

from apps.shop.views.buy import buy_view
from apps.shop.views.home import home_view
from apps.shop.views.pay_link import GeneratePayLinkAPIView


urlpatterns = [
path('', home_view, name='home'),
path('<str:pk>/buy/', buy_view, name='buy'),
path('pay-link/', GeneratePayLinkAPIView.as_view(), name='generate-pay-link')
]
Loading

0 comments on commit 3f9459c

Please sign in to comment.