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/R4C/__init__.py
Empty file.
Binary file added R4C/R4C/__pycache__/__init__.cpython-311.pyc
Binary file not shown.
Binary file added R4C/R4C/__pycache__/settings.cpython-311.pyc
Binary file not shown.
Binary file added R4C/R4C/__pycache__/urls.cpython-311.pyc
Binary file not shown.
Binary file added R4C/R4C/__pycache__/wsgi.cpython-311.pyc
Binary file not shown.
16 changes: 16 additions & 0 deletions R4C/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()
123 changes: 123 additions & 0 deletions R4C/R4C/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
"""
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/'
22 changes: 22 additions & 0 deletions R4C/R4C/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"""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')),
]
16 changes: 16 additions & 0 deletions R4C/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()
33 changes: 33 additions & 0 deletions R4C/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# 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 R4C/customers/__init__.py
Empty file.
Binary file added R4C/customers/__pycache__/__init__.cpython-311.pyc
Binary file not shown.
Binary file added R4C/customers/__pycache__/admin.cpython-311.pyc
Binary file not shown.
Binary file added R4C/customers/__pycache__/apps.cpython-311.pyc
Binary file not shown.
Binary file added R4C/customers/__pycache__/models.cpython-311.pyc
Binary file not shown.
3 changes: 3 additions & 0 deletions R4C/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 R4C/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 R4C/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)),
],
),
]
Empty file.
Binary file not shown.
Binary file not shown.
5 changes: 5 additions & 0 deletions R4C/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)
3 changes: 3 additions & 0 deletions R4C/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 R4C/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 R4C/db.sqlite3
Binary file not shown.
21 changes: 21 additions & 0 deletions R4C/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 R4C/orders/__init__.py
Empty file.
Binary file added R4C/orders/__pycache__/__init__.cpython-311.pyc
Binary file not shown.
Binary file added R4C/orders/__pycache__/admin.cpython-311.pyc
Binary file not shown.
Binary file added R4C/orders/__pycache__/apps.cpython-311.pyc
Binary file not shown.
Binary file added R4C/orders/__pycache__/models.cpython-311.pyc
Binary file not shown.
3 changes: 3 additions & 0 deletions R4C/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 R4C/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 R4C/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')),
],
),
]
Empty file.
Binary file not shown.
Binary file not shown.
8 changes: 8 additions & 0 deletions R4C/orders/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from django.db import models

from customers.models import Customer


class Order(models.Model):
customer = models.ForeignKey(Customer,on_delete=models.CASCADE)
robot_serial = models.CharField(max_length=5,blank=False, null=False)
3 changes: 3 additions & 0 deletions R4C/orders/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 R4C/orders/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.
Empty file added R4C/robots/__init__.py
Empty file.
Binary file added R4C/robots/__pycache__/__init__.cpython-311.pyc
Binary file not shown.
Binary file added R4C/robots/__pycache__/admin.cpython-311.pyc
Binary file not shown.
Binary file added R4C/robots/__pycache__/apps.cpython-311.pyc
Binary file not shown.
Binary file added R4C/robots/__pycache__/models.cpython-311.pyc
Binary file not shown.
Binary file added R4C/robots/__pycache__/urls.cpython-311.pyc
Binary file not shown.
Binary file added R4C/robots/__pycache__/views.cpython-311.pyc
Binary file not shown.
3 changes: 3 additions & 0 deletions R4C/robots/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 R4C/robots/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.apps import AppConfig


class RobotsConfig(AppConfig):
name = 'robots'
24 changes: 24 additions & 0 deletions R4C/robots/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


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='Robot',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('serial', models.CharField(max_length=5)),
('model', models.CharField(max_length=2)),
('version', models.CharField(max_length=2)),
('created', models.DateTimeField()),
],
),
]
19 changes: 19 additions & 0 deletions R4C/robots/migrations/0002_robot_quantity.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 4.2.1 on 2023-09-24 16:59

from django.db import migrations, models


class Migration(migrations.Migration):

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

operations = [
migrations.AddField(
model_name='robot',
name='quantity',
field=models.PositiveIntegerField(default=0),
preserve_default=False,
),
]
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading