Skip to content

Commit

Permalink
Merge pull request #4 from TheWitcher1991/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
TheWitcher1991 authored Oct 5, 2024
2 parents 465d8e9 + 4cca411 commit f6c05ce
Show file tree
Hide file tree
Showing 82 changed files with 660 additions and 113 deletions.
11 changes: 11 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
__pycache__
venv
.venv
.git
.gitignore
.gitattributes
.github
.idea
docs
scripts
bin
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<a href="https://www.typescriptlang.org/" target="_blank"><img style="margin: 10px" src="https://profilinator.rishav.dev/skills-assets/typescript-original.svg" alt="TypeScript" height="50"></a>
</div>


- Python 3.12.0
- Django ^5.1
- Django rest framework ^3.15.2
Expand Down
20 changes: 20 additions & 0 deletions backend/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
__pycache__
*.pyc
*.pyo
*.pyd
.Python
pip-log.txt
pip-delete-this-directory.txt
.tox
.coverage
.coverage.*
.cache
.gitignore
nosetests.xml
coverage.xml
.flake8
*,cover
.git
venv
.pre-commit-config.yaml
.pre-commit-hooks.yaml
6 changes: 3 additions & 3 deletions backend/.env.dev
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ RABBITMQ_DEFAULT_PORT=5672
RABBITMQ_DEFAULT_VHOST=/

DATABASE=postgres
DATABASE_ENGINE=django.db.backends.postgresql
DATABASE_ENGINE=django.db.backends.sqlite3
DATABASE_DB=talentspot
DATABASE_USER=postgres
DATABASE_PASSWORD=root
Expand All @@ -28,8 +28,8 @@ CLIENT_DOMAIN=http://127.0.0.1:3000

DJANGO_USER_MODEL=core.User

ALLOWED_HOSTS="http://localhost:5173 http://localhost:3000 http://localhost:8000"
ALLOWED_DOMAINS="localhost"
ALLOWED_HOSTS="http://localhost:5173 http://localhost:3000 http://localhost:8000 https://api.yookassa.ru"
ALLOWED_DOMAINS="localhost 127.0.0.1 api.yookassa.ru"

YOOKASSA_ACCOUNT_ID=
YOOKASSA_SECRET_KEY=
Expand Down
15 changes: 15 additions & 0 deletions backend/.env.kafka
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
ZOOKEEPER_CLIENT_PORT=2181
ZOOKEEPER_TICK_TIME=2000

KAFKA_BROKER_ID=1
KAFKA_ZOOKEEPER_CONNECT=zookeeper:2181
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP=PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://kafka:29092,PLAINTEXT_HOST://localhost:9092
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR=1
KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS=0
KAFKA_CONFLUENT_LICENSE_TOPIC_REPLICATION_FACTOR=1
KAFKA_CONFLUENT_BALANCER_TOPIC_REPLICATION_FACTOR=1
KAFKA_TRANSACTION_STATE_LOG_MIN_ISR=1
KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR=1
KAFKA_JMX_PORT=9997
KAFKA_JMX_HOSTNAME=kafka
1 change: 1 addition & 0 deletions backend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ coverage.xml
/static/redisboard/
/static/rest_framework/
celerybeat-schedule
celerybeat-schedule.*
supervisord.log
supervisord.pid

Expand Down
Binary file modified backend/business/__pycache__/__init__.cpython-312.pyc
Binary file not shown.
Binary file modified backend/business/__pycache__/apps.cpython-312.pyc
Binary file not shown.
Binary file modified backend/business/__pycache__/serializers.cpython-312.pyc
Binary file not shown.
Binary file modified backend/business/__pycache__/urls.cpython-312.pyc
Binary file not shown.
Binary file modified backend/business/__pycache__/views.cpython-312.pyc
Binary file not shown.
131 changes: 131 additions & 0 deletions backend/business/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
# Generated by Django 5.1 on 2024-10-05 07:42

from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = []

operations = [
migrations.CreateModel(
name="Invoice",
fields=[
("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
("created", models.DateTimeField(auto_now_add=True, verbose_name="Дата создания")),
("updated", models.DateTimeField(auto_now=True, verbose_name="Дата обновления")),
(
"payment_id",
models.CharField(blank=True, max_length=255, null=True, verbose_name="ID платежа YooKassa"),
),
("payment_url", models.URLField(blank=True, null=True, verbose_name="Ссылка на оплату")),
(
"payment_method",
models.CharField(
blank=True,
choices=[
("bank_card", "Банковская карта"),
("sberbank", "SberPay"),
("tinkoff_bank", "T‑Pay"),
("sbp", "СБП (Система быстрых платежей)"),
("yoo_money", "ЮMoney"),
("balance", "С лицевого счета"),
("cashless", "Безналичная оплата"),
],
max_length=32,
null=True,
verbose_name="Способ оплаты",
),
),
(
"payer_type",
models.CharField(
choices=[("INDIVIDUAL", "Физическое лицо"), ("LEGAL", "ЮЛ / ИП")],
default="INDIVIDUAL",
max_length=32,
verbose_name="Тип плательщика",
),
),
(
"target",
models.CharField(
choices=[("BALANCE", "Пополнение баланса"), ("SERVICE", "Оплата услуги")],
max_length=32,
verbose_name="Цель оплаты",
),
),
(
"description",
models.CharField(blank=True, max_length=255, null=True, verbose_name="Назначение платежа"),
),
(
"amount",
models.DecimalField(
blank=True, decimal_places=2, default=0, max_digits=10, null=True, verbose_name="Сумма оплаты"
),
),
("is_paid", models.BooleanField(default=False, verbose_name="Оплачен")),
(
"expires_at",
models.DateTimeField(blank=True, null=True, verbose_name="Дата истечения срока действия"),
),
("captured_at", models.DateTimeField(blank=True, null=True, verbose_name="Дата оплаты счета")),
],
options={
"verbose_name": "Счет",
"verbose_name_plural": "Счета",
"ordering": ("-created",),
},
),
migrations.CreateModel(
name="InvoiceOrder",
fields=[
("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
("created", models.DateTimeField(auto_now_add=True, verbose_name="Дата создания")),
("updated", models.DateTimeField(auto_now=True, verbose_name="Дата обновления")),
("quantity", models.PositiveIntegerField(default=1, verbose_name="Количество")),
],
options={
"verbose_name": "Услуга по счету",
"verbose_name_plural": "Услуги по счетам",
},
),
migrations.CreateModel(
name="Transaction",
fields=[
("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
("created", models.DateTimeField(auto_now_add=True, verbose_name="Дата создания")),
("updated", models.DateTimeField(auto_now=True, verbose_name="Дата обновления")),
(
"amount",
models.DecimalField(
blank=True,
decimal_places=2,
default=0,
max_digits=10,
null=True,
verbose_name="Сумма транзакции",
),
),
(
"transaction_type",
models.CharField(
choices=[("DEPOSIT", "Доход"), ("WITHDRAWAL", "Расход"), ("TRANSFER", "Перевод средств")],
max_length=32,
verbose_name="Тип транзакции",
),
),
(
"description",
models.CharField(blank=True, max_length=255, null=True, verbose_name="Описание транзакции"),
),
],
options={
"verbose_name": "Транзакция",
"verbose_name_plural": "Транзакции",
"ordering": ("-created",),
},
),
]
57 changes: 57 additions & 0 deletions backend/business/migrations/0002_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Generated by Django 5.1 on 2024-10-05 07:42

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


class Migration(migrations.Migration):

initial = True

dependencies = [
("business", "0001_initial"),
("employee", "0001_initial"),
("patient", "0001_initial"),
]

operations = [
migrations.AddField(
model_name="invoice",
name="patient",
field=models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, related_name="invoices", to="patient.patient"
),
),
migrations.AddField(
model_name="invoiceorder",
name="invoice",
field=models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, related_name="services", to="business.invoice"
),
),
migrations.AddField(
model_name="invoiceorder",
name="service",
field=models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, related_name="orders", to="employee.service"
),
),
migrations.AddField(
model_name="transaction",
name="invoice",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.CASCADE,
related_name="transactions",
to="business.invoice",
),
),
migrations.AddField(
model_name="transaction",
name="patient",
field=models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, related_name="transactions", to="patient.patient"
),
),
]
10 changes: 4 additions & 6 deletions backend/business/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
from django.utils.translation import gettext_lazy as _

from business.defines import InvoiceTarget, PayerType, PaymentMethod, TransactionType
from core.models import BaseModel
from core.utils import decimal_to_words


class Invoice(models.Model):
class Invoice(BaseModel):
payment_id = models.CharField(_("ID платежа YooKassa"), max_length=255, null=True, blank=True)
payment_url = models.URLField(_("Ссылка на оплату"), blank=True, null=True)
payment_method = models.CharField(
Expand Down Expand Up @@ -33,8 +34,6 @@ class Invoice(models.Model):
blank=True,
)
is_paid = models.BooleanField(_("Оплачен"), default=False)
created = models.DateTimeField(_("Дата создания"), auto_now_add=True)
updated = models.DateTimeField(_("Дата обновления"), auto_now=True)
expires_at = models.DateTimeField(
_("Дата истечения срока действия"),
blank=True,
Expand All @@ -60,7 +59,7 @@ def amount_in_words(self):
return decimal_to_words(self.amount)


class InvoiceOrder(models.Model):
class InvoiceOrder(BaseModel):
invoice = models.ForeignKey(to=Invoice, on_delete=models.CASCADE, related_name="services")
service = models.ForeignKey(
to="employee.Service",
Expand All @@ -80,7 +79,7 @@ def get_service_price(self):
return self.service.price * self.quantity


class Transaction(models.Model):
class Transaction(BaseModel):
amount = models.DecimalField(
_("Сумма транзакции"),
default=0,
Expand All @@ -95,7 +94,6 @@ class Transaction(models.Model):
max_length=32,
)
description = models.CharField(_("Описание транзакции"), max_length=255, null=True, blank=True)
created = models.DateTimeField(_("Дата создания"), auto_now_add=True)
invoice = models.ForeignKey(
to=Invoice,
related_name="transactions",
Expand Down
Binary file modified backend/business/services/__pycache__/payment.cpython-312.pyc
Binary file not shown.
Binary file modified backend/config/__pycache__/celery.cpython-312.pyc
Binary file not shown.
Binary file modified backend/config/__pycache__/settings.cpython-312.pyc
Binary file not shown.
Binary file modified backend/config/__pycache__/urls.cpython-312.pyc
Binary file not shown.
6 changes: 3 additions & 3 deletions backend/config/schema.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import graphene

import graphql.schema
import schemas


class Query(graphql.schema.Query, graphene.ObjectType):
class Query(schemas.schema.Query, graphene.ObjectType):
pass


class Mutation(graphql.schema.Mutation, graphene.ObjectType):
class Mutation(schemas.schema.Mutation, graphene.ObjectType):
pass


Expand Down
7 changes: 6 additions & 1 deletion backend/config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"patient",
"employee",
"business",
"graphql",
"schemas",
]

MIDDLEWARE = [
Expand Down Expand Up @@ -142,6 +142,11 @@
USE_I18N = True
USE_L10N = True

DJANGO_SUPERUSER_USERNAME = env("DJANGO_SUPERUSER_USERNAME", default="admin")
DJANGO_SUPERUSER_EMAIL = env("DJANGO_SUPERUSER_EMAIL", default="[email protected]")
DJANGO_SUPERUSER_PHONE = env("DJANGO_SUPERUSER_PHONE", default="+79999999999")
DJANGO_SUPERUSER_PASSWORD = env("DJANGO_SUPERUSER_PASSWORD", default="admin")

SECURE_HSTS_PRELOAD = not DEBUG
SECURE_SSL_REDIRECT = not DEBUG
SECURE_HSTS_INCLUDE_SUBDOMAINS = True
Expand Down
Binary file modified backend/core/__pycache__/defines.cpython-312.pyc
Binary file not shown.
Binary file modified backend/core/__pycache__/mixins.cpython-312.pyc
Binary file not shown.
Binary file modified backend/core/__pycache__/models.cpython-312.pyc
Binary file not shown.
Binary file modified backend/core/__pycache__/serializers.cpython-312.pyc
Binary file not shown.
Binary file modified backend/core/__pycache__/urls.cpython-312.pyc
Binary file not shown.
Binary file modified backend/core/__pycache__/utils.cpython-312.pyc
Binary file not shown.
Binary file modified backend/core/__pycache__/views.cpython-312.pyc
Binary file not shown.
File renamed without changes.
File renamed without changes.
29 changes: 29 additions & 0 deletions backend/core/management/commands/initadmin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from django.core.management.base import BaseCommand

from config.settings import (
DJANGO_SUPERUSER_EMAIL,
DJANGO_SUPERUSER_PASSWORD,
DJANGO_SUPERUSER_PHONE,
DJANGO_SUPERUSER_USERNAME,
)
from core.models import User


class Command(BaseCommand):

def handle(self, *args, **options):
username = DJANGO_SUPERUSER_USERNAME
email = DJANGO_SUPERUSER_EMAIL
phone = DJANGO_SUPERUSER_PHONE
password = DJANGO_SUPERUSER_PASSWORD

if not User.objects.filter(email=email).exists():
print("Creating account for %s (%s)" % (username, email))
User.objects.create_superuser(
email=email,
password=password,
phone=phone,
username=username,
)
else:
print("Admin account has already been initialized.")
Loading

0 comments on commit f6c05ce

Please sign in to comment.