From 624ef3ca169aa23cf88e68849ff9a3227be8e084 Mon Sep 17 00:00:00 2001 From: maciejrusek Date: Tue, 10 Mar 2026 20:53:37 +0100 Subject: [PATCH] init --- .gitignore | 140 ++++++++++++++++++ backend/apps/shelves/__init__.py | 0 backend/apps/shelves/admin.py | 3 + backend/apps/shelves/apps.py | 5 + .../apps/shelves/migrations/0001_initial.py | 21 +++ .../apps/shelves/migrations/0002_initial.py | 23 +++ backend/apps/shelves/migrations/__init__.py | 0 backend/apps/shelves/models.py | 8 + backend/apps/shelves/tests.py | 3 + backend/apps/shelves/views.py | 3 + backend/apps/user/__init__.py | 0 backend/apps/user/admin.py | 3 + backend/apps/user/apps.py | 5 + backend/apps/user/migrations/0001_initial.py | 45 ++++++ backend/apps/user/migrations/__init__.py | 0 backend/apps/user/models.py | 10 ++ backend/apps/user/tests.py | 3 + backend/apps/user/views.py | 3 + backend/config/__init__.py | 0 backend/config/asgi.py | 16 ++ backend/config/django/__init__.py | 0 backend/config/django/base.py | 106 +++++++++++++ backend/config/django/dev.py | 1 + backend/config/django/prod.py | 0 backend/config/env.py | 7 + backend/config/urls.py | 6 + backend/config/wsgi.py | 16 ++ backend/manage.py | 22 +++ backend/requirements.txt | 5 + 29 files changed, 454 insertions(+) create mode 100644 .gitignore create mode 100644 backend/apps/shelves/__init__.py create mode 100644 backend/apps/shelves/admin.py create mode 100644 backend/apps/shelves/apps.py create mode 100644 backend/apps/shelves/migrations/0001_initial.py create mode 100644 backend/apps/shelves/migrations/0002_initial.py create mode 100644 backend/apps/shelves/migrations/__init__.py create mode 100644 backend/apps/shelves/models.py create mode 100644 backend/apps/shelves/tests.py create mode 100644 backend/apps/shelves/views.py create mode 100644 backend/apps/user/__init__.py create mode 100644 backend/apps/user/admin.py create mode 100644 backend/apps/user/apps.py create mode 100644 backend/apps/user/migrations/0001_initial.py create mode 100644 backend/apps/user/migrations/__init__.py create mode 100644 backend/apps/user/models.py create mode 100644 backend/apps/user/tests.py create mode 100644 backend/apps/user/views.py create mode 100644 backend/config/__init__.py create mode 100644 backend/config/asgi.py create mode 100644 backend/config/django/__init__.py create mode 100644 backend/config/django/base.py create mode 100644 backend/config/django/dev.py create mode 100644 backend/config/django/prod.py create mode 100644 backend/config/env.py create mode 100644 backend/config/urls.py create mode 100644 backend/config/wsgi.py create mode 100755 backend/manage.py create mode 100644 backend/requirements.txt diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..31b611d --- /dev/null +++ b/.gitignore @@ -0,0 +1,140 @@ +# Django # +*.log +*.pot +*.pyc +__pycache__ +db.sqlite3 +media + +# Backup files # +*.bak + +# If you are using PyCharm # +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf +.idea/misc.xml, +.idea/jsLibraryMappings.xml + +# AWS User-specific +.idea/**/aws.xml + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# File-based project format +*.iws + +# IntelliJ +out/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Python # +*.py[cod] +*$py.class + +# Distribution / packaging +.Python build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +*.whl +*.egg-info/ +.installed.cfg +*.egg +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +.pytest_cache/ +nosetests.xml +coverage.xml +*.cover +.hypothesis/ + +# Jupyter Notebook +.ipynb_checkpoints + +# pyenv +.python-version + +# celery +celerybeat-schedule.* + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ + +# Sublime Text # +*.tmlanguage.cache +*.tmPreferences.cache +*.stTheme.cache +*.sublime-workspace +*.sublime-project + +# sftp configuration file +sftp-config.json + +# Package control specific files Package +Control.last-run +Control.ca-list +Control.ca-bundle +Control.system-ca-bundle +GitHub.sublime-settings + +# Visual Studio Code # +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +.history \ No newline at end of file diff --git a/backend/apps/shelves/__init__.py b/backend/apps/shelves/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/backend/apps/shelves/admin.py b/backend/apps/shelves/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/backend/apps/shelves/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/backend/apps/shelves/apps.py b/backend/apps/shelves/apps.py new file mode 100644 index 0000000..dec4376 --- /dev/null +++ b/backend/apps/shelves/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class ShelvesConfig(AppConfig): + name = 'apps.shelves' diff --git a/backend/apps/shelves/migrations/0001_initial.py b/backend/apps/shelves/migrations/0001_initial.py new file mode 100644 index 0000000..64985fd --- /dev/null +++ b/backend/apps/shelves/migrations/0001_initial.py @@ -0,0 +1,21 @@ +# Generated by Django 6.0.3 on 2026-03-10 19:49 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Shelf', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=100)), + ], + ), + ] diff --git a/backend/apps/shelves/migrations/0002_initial.py b/backend/apps/shelves/migrations/0002_initial.py new file mode 100644 index 0000000..926b85a --- /dev/null +++ b/backend/apps/shelves/migrations/0002_initial.py @@ -0,0 +1,23 @@ +# Generated by Django 6.0.3 on 2026-03-10 19:49 + +import django.db.models.deletion +from django.conf import settings +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ('shelves', '0001_initial'), + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ] + + operations = [ + migrations.AddField( + model_name='shelf', + name='user', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='shelves', to=settings.AUTH_USER_MODEL), + ), + ] diff --git a/backend/apps/shelves/migrations/__init__.py b/backend/apps/shelves/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/backend/apps/shelves/models.py b/backend/apps/shelves/models.py new file mode 100644 index 0000000..3a0fa99 --- /dev/null +++ b/backend/apps/shelves/models.py @@ -0,0 +1,8 @@ +from django.db import models +from apps.user.models import User + + +class Shelf(models.Model): + user = models.ForeignKey(User, on_delete=models.CASCADE, related_name="shelves") + name = models.CharField(max_length=100) + \ No newline at end of file diff --git a/backend/apps/shelves/tests.py b/backend/apps/shelves/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/backend/apps/shelves/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/backend/apps/shelves/views.py b/backend/apps/shelves/views.py new file mode 100644 index 0000000..91ea44a --- /dev/null +++ b/backend/apps/shelves/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff --git a/backend/apps/user/__init__.py b/backend/apps/user/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/backend/apps/user/admin.py b/backend/apps/user/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/backend/apps/user/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/backend/apps/user/apps.py b/backend/apps/user/apps.py new file mode 100644 index 0000000..850997f --- /dev/null +++ b/backend/apps/user/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class UserConfig(AppConfig): + name = 'apps.user' diff --git a/backend/apps/user/migrations/0001_initial.py b/backend/apps/user/migrations/0001_initial.py new file mode 100644 index 0000000..7728c97 --- /dev/null +++ b/backend/apps/user/migrations/0001_initial.py @@ -0,0 +1,45 @@ +# Generated by Django 6.0.3 on 2026-03-10 19:49 + +import django.contrib.auth.models +import django.contrib.auth.validators +import django.utils.timezone +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ('auth', '0012_alter_user_first_name_max_length'), + ] + + operations = [ + migrations.CreateModel( + name='User', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('password', models.CharField(max_length=128, verbose_name='password')), + ('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')), + ('is_superuser', models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')), + ('username', models.CharField(error_messages={'unique': 'A user with that username already exists.'}, help_text='Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.', max_length=150, unique=True, validators=[django.contrib.auth.validators.UnicodeUsernameValidator()], verbose_name='username')), + ('first_name', models.CharField(blank=True, max_length=150, verbose_name='first name')), + ('last_name', models.CharField(blank=True, max_length=150, verbose_name='last name')), + ('email', models.EmailField(blank=True, max_length=254, verbose_name='email address')), + ('is_staff', models.BooleanField(default=False, help_text='Designates whether the user can log into this admin site.', verbose_name='staff status')), + ('is_active', models.BooleanField(default=True, help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active')), + ('date_joined', models.DateTimeField(default=django.utils.timezone.now, verbose_name='date joined')), + ('avatar', models.ImageField(blank=True, null=True, upload_to='avatars/')), + ('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.group', verbose_name='groups')), + ('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.permission', verbose_name='user permissions')), + ], + options={ + 'verbose_name': 'user', + 'verbose_name_plural': 'users', + 'abstract': False, + }, + managers=[ + ('objects', django.contrib.auth.models.UserManager()), + ], + ), + ] diff --git a/backend/apps/user/migrations/__init__.py b/backend/apps/user/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/backend/apps/user/models.py b/backend/apps/user/models.py new file mode 100644 index 0000000..5f1d9bb --- /dev/null +++ b/backend/apps/user/models.py @@ -0,0 +1,10 @@ +from django.contrib.auth.models import AbstractUser +from django.db import models + +class User(AbstractUser): + + avatar = models.ImageField( + upload_to="avatars/", + null=True, + blank=True + ) \ No newline at end of file diff --git a/backend/apps/user/tests.py b/backend/apps/user/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/backend/apps/user/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/backend/apps/user/views.py b/backend/apps/user/views.py new file mode 100644 index 0000000..91ea44a --- /dev/null +++ b/backend/apps/user/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff --git a/backend/config/__init__.py b/backend/config/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/backend/config/asgi.py b/backend/config/asgi.py new file mode 100644 index 0000000..de0bd1b --- /dev/null +++ b/backend/config/asgi.py @@ -0,0 +1,16 @@ +""" +ASGI config for config 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/6.0/howto/deployment/asgi/ +""" + +import os + +from django.core.asgi import get_asgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.django.dev') + +application = get_asgi_application() diff --git a/backend/config/django/__init__.py b/backend/config/django/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/backend/config/django/base.py b/backend/config/django/base.py new file mode 100644 index 0000000..223ccbb --- /dev/null +++ b/backend/config/django/base.py @@ -0,0 +1,106 @@ +import os + +from config.env import BASE_DIR, env + +env.read_env(os.path.join(BASE_DIR, "../.env")) + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = env("SECRET_KEY") + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = env.bool("DJANGO_DEBUG", default=True) + +ALLOWED_HOSTS = ["*"] + + +# Application definition + +INSTALLED_APPS = [ + "apps.user.apps.UserConfig", + "apps.shelves.apps.ShelvesConfig", + "django.contrib.admin", + "django.contrib.auth", + "django.contrib.contenttypes", + "django.contrib.sessions", + "django.contrib.messages", + "django.contrib.staticfiles", +] + +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 = "config.urls" + +TEMPLATES = [ + { + "BACKEND": "django.template.backends.django.DjangoTemplates", + "DIRS": [], + "APP_DIRS": True, + "OPTIONS": { + "context_processors": [ + "django.template.context_processors.request", + "django.contrib.auth.context_processors.auth", + "django.contrib.messages.context_processors.messages", + ], + }, + }, +] + +WSGI_APPLICATION = "config.wsgi.application" + + +# Database +# https://docs.djangoproject.com/en/6.0/ref/settings/#databases + +DATABASES = { + "default": { + "ENGINE": "django.db.backends.sqlite3", + "NAME": BASE_DIR / "db.sqlite3", + } +} + + +# Password validation +# https://docs.djangoproject.com/en/6.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", + }, +] + +AUTH_USER_MODEL = "user.User" + + +# Internationalization +# https://docs.djangoproject.com/en/6.0/topics/i18n/ + +LANGUAGE_CODE = "en-us" + +TIME_ZONE = "UTC" + +USE_I18N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/6.0/howto/static-files/ + +STATIC_URL = "static/" diff --git a/backend/config/django/dev.py b/backend/config/django/dev.py new file mode 100644 index 0000000..773cfc4 --- /dev/null +++ b/backend/config/django/dev.py @@ -0,0 +1 @@ +from .base import * \ No newline at end of file diff --git a/backend/config/django/prod.py b/backend/config/django/prod.py new file mode 100644 index 0000000..e69de29 diff --git a/backend/config/env.py b/backend/config/env.py new file mode 100644 index 0000000..55ec0b9 --- /dev/null +++ b/backend/config/env.py @@ -0,0 +1,7 @@ +from pathlib import Path + +import environ + +env = environ.Env() + +BASE_DIR = Path(__file__).resolve().parent.parent diff --git a/backend/config/urls.py b/backend/config/urls.py new file mode 100644 index 0000000..083932c --- /dev/null +++ b/backend/config/urls.py @@ -0,0 +1,6 @@ +from django.contrib import admin +from django.urls import path + +urlpatterns = [ + path("admin/", admin.site.urls), +] diff --git a/backend/config/wsgi.py b/backend/config/wsgi.py new file mode 100644 index 0000000..1ba6f27 --- /dev/null +++ b/backend/config/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for config 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/6.0/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.django.dev') + +application = get_wsgi_application() diff --git a/backend/manage.py b/backend/manage.py new file mode 100755 index 0000000..a21d9a5 --- /dev/null +++ b/backend/manage.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +"""Django's command-line utility for administrative tasks.""" +import os +import sys + + +def main(): + """Run administrative tasks.""" + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.django.dev') + 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() diff --git a/backend/requirements.txt b/backend/requirements.txt new file mode 100644 index 0000000..b08c5cb --- /dev/null +++ b/backend/requirements.txt @@ -0,0 +1,5 @@ +django==6.0.3 +django-environ==0.13.0 +djangorestframework==3.16.1 +django-filter==25.2 +pillow==12.1.1 \ No newline at end of file