Skip to content
Open
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
Empty file added R4C/__init__.py
Empty file.
Binary file added R4C/__pycache__/__init__.cpython-311.pyc
Binary file not shown.
Binary file added R4C/__pycache__/settings.cpython-311.pyc
Binary file not shown.
Binary file added R4C/__pycache__/urls.cpython-311.pyc
Binary file not shown.
Binary file added R4C/__pycache__/wsgi.cpython-311.pyc
Binary file not shown.
16 changes: 16 additions & 0 deletions R4C/asgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
ASGI config for R4C 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.0/howto/deployment/asgi/
"""

import os

from django.core.asgi import get_asgi_application

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

application = get_asgi_application()
132 changes: 132 additions & 0 deletions R4C/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
"""
Django settings for R4C project.

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

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

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

import os

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))


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

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'mztx@x_-=gfhc9xs@bm58m&@3pc7##opo14zob!(l2tus05+jo'

# 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',
'customers',
'orders',
'robots'
]

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 = 'R4C.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 = 'R4C.wsgi.application'


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

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}


# Password validation
# https://docs.djangoproject.com/en/3.0/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.0/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


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

STATIC_URL = '/static/'

#Email settings
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587 # для использования TLS, 465 для SSL
EMAIL_USE_TLS = True
EMAIL_USE_SSL = False
EMAIL_HOST_USER = ''
EMAIL_HOST_PASSWORD = ''
23 changes: 23 additions & 0 deletions R4C/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"""R4C URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/3.0/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 django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
path('robots/',include('robots.urls')),
path('orders/',include('orders.urls')),
]
16 changes: 16 additions & 0 deletions R4C/wsgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
WSGI config for R4C 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.0/howto/deployment/wsgi/
"""

import os

from django.core.wsgi import get_wsgi_application

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

application = get_wsgi_application()
35 changes: 33 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,33 @@
# Robots
Это заготовка для сервиса, который ведет учет произведенных роботов, а также выполняет некие операции связанные с этим процессом.
# R4C - Robots for consumers

## Небольшая предыстория.
Давным-давно, в далёкой-далёкой галактике, была компания производящая различных
роботов.

Каждый робот(**Robot**) имел определенную модель выраженную двух-символьной
последовательностью(например R2). Одновременно с этим, модель имела различные
версии(например D2). Напоминает популярный телефон различных моделей(11,12,13...) и его версии
(X,XS,Pro...). Вне компании роботов чаще всего называли по серийному номеру, объединяя модель и версию(например R2-D2).

Также у компании были покупатели(**Customer**) которые периодически заказывали того или иного робота.

Когда роботов не было в наличии - заказы покупателей(**Order**) попадали в список ожидания.

---
## Что делает данный код?
Это заготовка для сервиса, который ведет учет произведенных роботов,а также
выполняет некие операции связанные с этим процессом.

Сервис нацелен на удовлетворение потребностей трёх категорий пользователей:
- Технические специалисты компании. Они будут присылать информацию
- Менеджмент компании. Они будут запрашивать информацию
- Клиенты. Им будут отправляться информация
___

## Как с этим работать?
- Создать для этого проекта репозиторий на GitHub
- Открыть данный проект в редакторе/среде разработки которую вы используете
- Ознакомиться с задачами в файле tasks.md
- Написать понятный и поддерживаемый код для каждой задачи
- Сделать по 1 отдельному PR с решением для каждой задачи
- Прислать ссылку на своё решение
Empty file added customers/__init__.py
Empty file.
Binary file added customers/__pycache__/__init__.cpython-311.pyc
Binary file not shown.
Binary file added customers/__pycache__/admin.cpython-311.pyc
Binary file not shown.
Binary file added customers/__pycache__/apps.cpython-311.pyc
Binary file not shown.
Binary file added customers/__pycache__/models.cpython-311.pyc
Binary file not shown.
3 changes: 3 additions & 0 deletions customers/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
5 changes: 5 additions & 0 deletions customers/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.apps import AppConfig


class CustomersConfig(AppConfig):
name = 'customers'
21 changes: 21 additions & 0 deletions customers/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Generated by Django 3.0.9 on 2023-01-30 06:40

from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='Customer',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('email', models.CharField(max_length=255)),
],
),
]
23 changes: 23 additions & 0 deletions customers/migrations/0002_customer_name_alter_customer_email.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 4.2.1 on 2023-09-29 11:29

from django.db import migrations, models


class Migration(migrations.Migration):

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

operations = [
migrations.AddField(
model_name='customer',
name='name',
field=models.CharField(default='NoName', max_length=255),
),
migrations.AlterField(
model_name='customer',
name='email',
field=models.CharField(max_length=255, unique=True),
),
]
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
5 changes: 5 additions & 0 deletions customers/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.db import models

class Customer(models.Model):
email = models.CharField(max_length=255,blank=False, null=False,unique=True)
name = models.CharField(max_length=255,default='NoName')
3 changes: 3 additions & 0 deletions customers/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
3 changes: 3 additions & 0 deletions customers/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.shortcuts import render

# Create your views here.
Binary file added db.sqlite3
Binary file not shown.
21 changes: 21 additions & 0 deletions manage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys


def main():
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'R4C.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()
Empty file added orders/__init__.py
Empty file.
Binary file added orders/__pycache__/__init__.cpython-311.pyc
Binary file not shown.
Binary file added orders/__pycache__/admin.cpython-311.pyc
Binary file not shown.
Binary file added orders/__pycache__/apps.cpython-311.pyc
Binary file not shown.
Binary file added orders/__pycache__/models.cpython-311.pyc
Binary file not shown.
Binary file added orders/__pycache__/urls.cpython-311.pyc
Binary file not shown.
Binary file added orders/__pycache__/views.cpython-311.pyc
Binary file not shown.
3 changes: 3 additions & 0 deletions orders/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
5 changes: 5 additions & 0 deletions orders/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.apps import AppConfig


class OrdersConfig(AppConfig):
name = 'orders'
24 changes: 24 additions & 0 deletions orders/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 3.0.9 on 2023-01-30 06:40

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


class Migration(migrations.Migration):

initial = True

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

operations = [
migrations.CreateModel(
name='Order',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('robot_serial', models.CharField(max_length=5)),
('customer', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='customers.Customer')),
],
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Generated by Django 4.2.1 on 2023-09-29 11:29

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


class Migration(migrations.Migration):

dependencies = [
('robots', '0002_robot_quantity'),
('customers', '0002_customer_name_alter_customer_email'),
('orders', '0001_initial'),
]

operations = [
migrations.RemoveField(
model_name='order',
name='robot_serial',
),
migrations.AddField(
model_name='order',
name='robot',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='robot_order', to='robots.robot'),
),
migrations.AlterField(
model_name='order',
name='customer',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='customer_order', to='customers.customer'),
),
migrations.CreateModel(
name='WaitlistOrder',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('model', models.CharField(max_length=255)),
('version', models.CharField(max_length=255)),
('is_backordered', models.BooleanField()),
('customer', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='customer_waitlist_order', to='customers.customer')),
],
),
]
Empty file added orders/migrations/__init__.py
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading