diff --git a/.gitignore b/.gitignore index b26d6116..27edab89 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,379 @@ -.idea/ -.vscode/ -*.iml +# Created by https://www.toptal.com/developers/gitignore/api/pycharm,python,django +# Edit at https://www.toptal.com/developers/gitignore?templates=pycharm,python,django + +### Django ### +*.log +*.pot +*.pyc +__pycache__/ +local_settings.py +db.sqlite3 +db.sqlite3-journal +media + +# If your build process includes running collectstatic, then you probably don't need or want to include staticfiles/ +# in your Git repository. Update and uncomment the following line accordingly. +# /staticfiles/ + +### Django.Python Stack ### +# Byte-compiled / optimized / DLL files +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo + +# Django stuff: + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +#poetry.lock + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +#pdm.lock +# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it +# in version control. +# https://pdm.fming.dev/#use-with-ide +.pdm.toml + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments .env -.DS_Store +.venv +env/ venv/ -.pytest_cache/ -**__pycache__/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# PyCharm +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +#.idea/ + +### PyCharm ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# 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 + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/artifacts +# .idea/compiler.xml +# .idea/jarRepositories.xml +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# SonarLint plugin +.idea/sonarlint/ + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + +### PyCharm Patch ### +# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 + +# *.iml +# modules.xml +# .idea/misc.xml +# *.ipr + +# Sonarlint plugin +# https://plugins.jetbrains.com/plugin/7973-sonarlint +.idea/**/sonarlint/ + +# SonarQube Plugin +# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin +.idea/**/sonarIssues.xml + +# Markdown Navigator plugin +# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced +.idea/**/markdown-navigator.xml +.idea/**/markdown-navigator-enh.xml +.idea/**/markdown-navigator/ + +# Cache file creation bug +# See https://youtrack.jetbrains.com/issue/JBR-2257 +.idea/$CACHE_FILE$ + +# CodeStream plugin +# https://plugins.jetbrains.com/plugin/12206-codestream +.idea/codestream.xml + +# Azure Toolkit for IntelliJ plugin +# https://plugins.jetbrains.com/plugin/8053-azure-toolkit-for-intellij +.idea/**/azureSettings.xml + +### Python ### +# Byte-compiled / optimized / DLL files + +# C extensions + +# Distribution / packaging + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. + +# Installer logs + +# Unit test / coverage reports + +# Translations + +# Django stuff: + +# Flask stuff: + +# Scrapy stuff: + +# Sphinx documentation + +# PyBuilder + +# Jupyter Notebook + +# IPython + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it +# in version control. +# https://pdm.fming.dev/#use-with-ide + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm + +# Celery stuff + +# SageMath parsed files + +# Environments + +# Spyder project settings + +# Rope project settings + +# mkdocs documentation + +# mypy + +# Pyre type checker + +# pytype static type analyzer + +# Cython debug symbols + +# PyCharm +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. + +### Python Patch ### +# Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration +poetry.toml + +# ruff +.ruff_cache/ + +# LSP config files +pyrightconfig.json + +# End of https://www.toptal.com/developers/gitignore/api/pycharm,python,django \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 00000000..1c2fda56 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 00000000..105ce2da --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 00000000..b74f18a4 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 00000000..685a2829 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/py-api-serializers.iml b/.idea/py-api-serializers.iml new file mode 100644 index 00000000..f06ead6f --- /dev/null +++ b/.idea/py-api-serializers.iml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 00000000..c8397c94 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/cinema/migrations/0003_movie_duration.py b/cinema/migrations/0003_movie_duration.py index 7355c91a..e75f6794 100644 --- a/cinema/migrations/0003_movie_duration.py +++ b/cinema/migrations/0003_movie_duration.py @@ -6,13 +6,13 @@ class Migration(migrations.Migration): dependencies = [ - ('cinema', '0002_initial'), + ("cinema", "0002_initial"), ] operations = [ migrations.AddField( - model_name='movie', - name='duration', + model_name="movie", + name="duration", field=models.IntegerField(default=123), preserve_default=False, ), diff --git a/cinema/migrations/0004_alter_genre_name.py b/cinema/migrations/0004_alter_genre_name.py index 0a4d429e..a0c446ee 100644 --- a/cinema/migrations/0004_alter_genre_name.py +++ b/cinema/migrations/0004_alter_genre_name.py @@ -6,13 +6,13 @@ class Migration(migrations.Migration): dependencies = [ - ('cinema', '0003_movie_duration'), + ("cinema", "0003_movie_duration"), ] operations = [ migrations.AlterField( - model_name='genre', - name='name', + model_name="genre", + name="name", field=models.CharField(max_length=255, unique=True), ), ] diff --git a/cinema/models.py b/cinema/models.py index c42d2a3d..4e82185e 100644 --- a/cinema/models.py +++ b/cinema/models.py @@ -1,6 +1,6 @@ +from django.conf import settings from django.core.exceptions import ValidationError from django.db import models -from django.conf import settings class CinemaHall(models.Model): @@ -27,6 +27,9 @@ class Actor(models.Model): first_name = models.CharField(max_length=255) last_name = models.CharField(max_length=255) + def full_name(self): + return f"{self.first_name} {self.last_name}" + def __str__(self): return self.first_name + " " + self.last_name @@ -48,7 +51,9 @@ def __str__(self): class MovieSession(models.Model): show_time = models.DateTimeField() movie = models.ForeignKey(Movie, on_delete=models.CASCADE) - cinema_hall = models.ForeignKey(CinemaHall, on_delete=models.CASCADE) + cinema_hall = models.ForeignKey( + CinemaHall, on_delete=models.CASCADE, related_name="movie_sessions" + ) class Meta: ordering = ["-show_time"] @@ -59,9 +64,8 @@ def __str__(self): class Order(models.Model): created_at = models.DateTimeField(auto_now_add=True) - user = models.ForeignKey( - settings.AUTH_USER_MODEL, on_delete=models.CASCADE - ) + user = models.ForeignKey(settings.AUTH_USER_MODEL, + on_delete=models.CASCADE) def __str__(self): return str(self.created_at) @@ -74,9 +78,9 @@ class Ticket(models.Model): movie_session = models.ForeignKey( MovieSession, on_delete=models.CASCADE, related_name="tickets" ) - order = models.ForeignKey( - Order, on_delete=models.CASCADE, related_name="tickets" - ) + order = models.ForeignKey(Order, + on_delete=models.CASCADE, + related_name="tickets") row = models.IntegerField() seat = models.IntegerField() @@ -85,9 +89,8 @@ def clean(self): (self.row, "row", "count_rows"), (self.seat, "seat", "count_seats_in_row"), ]: - count_attrs = getattr( - self.movie_session.cinema_hall, cinema_hall_attr_name - ) + count_attrs = getattr(self.movie_session.cinema_hall, + cinema_hall_attr_name) if not (1 <= ticket_attr_value <= count_attrs): raise ValidationError( { @@ -99,9 +102,8 @@ def clean(self): ) def __str__(self): - return ( - f"{str(self.movie_session)} (row: {self.row}, seat: {self.seat})" - ) + return (f"{str(self.movie_session)}" + f" (row: {self.row}, seat: {self.seat})") class Meta: unique_together = ("movie_session", "row", "seat") diff --git a/cinema/serializers.py b/cinema/serializers.py index 612ca7e2..192fbc00 100644 --- a/cinema/serializers.py +++ b/cinema/serializers.py @@ -1 +1,72 @@ -# write serializers here +from rest_framework import serializers + +from cinema.models import CinemaHall, Actor, Genre, Movie, MovieSession + + +class CinemaHallSerializer(serializers.ModelSerializer): + class Meta: + model = CinemaHall + fields = ("id", "name", "rows", "seats_in_row") + + +class GenreSerializer(serializers.ModelSerializer): + class Meta: + model = Genre + fields = ("id", "name") + + +class ActorSerializer(serializers.ModelSerializer): + class Meta: + model = Actor + fields = ("id", "first_name", "last_name") + + +class MovieSerializer(serializers.ModelSerializer): + class Meta: + model = Movie + fields = ("id", "title", "description", "duration", "genres", "actors") + + +class MovieRetrieveSerializer(MovieSerializer): + genres = GenreSerializer(many=True, read_only=True) + actors = ActorSerializer(many=True, read_only=True) + + +class MovieListSerializer(MovieSerializer): + genres = serializers.SlugRelatedField(many=True, + read_only=True, + slug_field="name") + actors = serializers.SlugRelatedField( + many=True, read_only=True, slug_field="full_name" + ) + + +class MovieSessionSerializer(serializers.ModelSerializer): + class Meta: + model = MovieSession + fields = ("id", "show_time", "movie", "cinema_hall") + + +class MovieSessionListSerializer(MovieSessionSerializer): + movie_title = serializers.CharField(source="movie.title", + read_only=True) + cinema_hall_name = serializers.CharField(source="cinema_hall.name", + read_only=True) + cinema_hall_capacity = serializers.IntegerField( + source="cinema_hall.capacity", read_only=True + ) + + class Meta: + model = MovieSession + fields = ( + "id", + "show_time", + "movie_title", + "cinema_hall_name", + "cinema_hall_capacity", + ) + + +class MovieSessionRetrieveSerializer(MovieSessionSerializer): + movie = MovieListSerializer() + cinema_hall = CinemaHallSerializer() diff --git a/cinema/tests/test_actor_api.py b/cinema/tests/test_actor_api.py index 3fa7a469..097e42ca 100644 --- a/cinema/tests/test_actor_api.py +++ b/cinema/tests/test_actor_api.py @@ -16,9 +16,7 @@ def test_get_actors(self): response = self.client.get("/api/cinema/actors/") self.assertEqual(response.status_code, status.HTTP_200_OK) actors_full_names = [actor["full_name"] for actor in response.data] - self.assertEqual( - sorted(actors_full_names), ["George Clooney", "Keanu Reeves"] - ) + self.assertEqual(sorted(actors_full_names), ["George Clooney", "Keanu Reeves"]) def test_post_actors(self): response = self.client.post( diff --git a/cinema/tests/test_cinema_hall_api.py b/cinema/tests/test_cinema_hall_api.py index d3e9ea77..be74b47a 100644 --- a/cinema/tests/test_cinema_hall_api.py +++ b/cinema/tests/test_cinema_hall_api.py @@ -31,9 +31,7 @@ def test_get_cinema_halls(self): self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertEqual(response.data[0]["name"], blue_hall["name"]) self.assertEqual(response.data[0]["rows"], blue_hall["rows"]) - self.assertEqual( - response.data[0]["seats_in_row"], blue_hall["seats_in_row"] - ) + self.assertEqual(response.data[0]["seats_in_row"], blue_hall["seats_in_row"]) vip_hall = { "name": "VIP", "rows": 6, @@ -43,9 +41,7 @@ def test_get_cinema_halls(self): self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertEqual(response.data[1]["name"], vip_hall["name"]) self.assertEqual(response.data[1]["rows"], vip_hall["rows"]) - self.assertEqual( - response.data[1]["seats_in_row"], vip_hall["seats_in_row"] - ) + self.assertEqual(response.data[1]["seats_in_row"], vip_hall["seats_in_row"]) def test_post_cinema_halls(self): response = self.client.post( @@ -72,9 +68,7 @@ def test_get_cinema_hall(self): self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertEqual(response.data["name"], vip_hall["name"]) self.assertEqual(response.data["rows"], vip_hall["rows"]) - self.assertEqual( - response.data["seats_in_row"], vip_hall["seats_in_row"] - ) + self.assertEqual(response.data["seats_in_row"], vip_hall["seats_in_row"]) self.assertEqual(response.data["capacity"], vip_hall["capacity"]) def test_get_invalid_cinema_hall(self): diff --git a/cinema/tests/test_movie_api.py b/cinema/tests/test_movie_api.py index 9d6b76bf..d4852de5 100644 --- a/cinema/tests/test_movie_api.py +++ b/cinema/tests/test_movie_api.py @@ -83,9 +83,7 @@ def test_get_movie(self): self.assertEqual(response.data["genres"][1]["name"], "Comedy") self.assertEqual(response.data["actors"][0]["first_name"], "Kate") self.assertEqual(response.data["actors"][0]["last_name"], "Winslet") - self.assertEqual( - response.data["actors"][0]["full_name"], "Kate Winslet" - ) + self.assertEqual(response.data["actors"][0]["full_name"], "Kate Winslet") def test_get_invalid_movie(self): response = self.client.get("/api/cinema/movies/100/") diff --git a/cinema/tests/test_movie_session_api.py b/cinema/tests/test_movie_session_api.py index cbd02713..d165662f 100644 --- a/cinema/tests/test_movie_session_api.py +++ b/cinema/tests/test_movie_session_api.py @@ -46,9 +46,7 @@ def test_get_movie_sessions(self): } self.assertEqual(movie_sessions.status_code, status.HTTP_200_OK) for field in movie_session: - self.assertEqual( - movie_sessions.data[0][field], movie_session[field] - ) + self.assertEqual(movie_sessions.data[0][field], movie_session[field]) def test_post_movie_session(self): movies = self.client.post( @@ -67,9 +65,7 @@ def test_get_movie_session(self): response = self.client.get("/api/cinema/movie_sessions/1/") self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertEqual(response.data["movie"]["title"], "Titanic") - self.assertEqual( - response.data["movie"]["description"], "Titanic description" - ) + self.assertEqual(response.data["movie"]["description"], "Titanic description") self.assertEqual(response.data["movie"]["duration"], 123) self.assertEqual(response.data["movie"]["genres"], ["Drama", "Comedy"]) self.assertEqual(response.data["movie"]["actors"], ["Kate Winslet"]) diff --git a/cinema/urls.py b/cinema/urls.py index 420f8e8c..45ee8838 100644 --- a/cinema/urls.py +++ b/cinema/urls.py @@ -1 +1,22 @@ -# write urls here +from django.urls import path, include +from rest_framework import routers + +from cinema.views import ( + CinemaHallViewSet, + GenreViewSet, + ActorViewSet, + MovieViewSet, + MovieSessionViewSet, +) + +app_name = "cinema" + +router = routers.DefaultRouter() +router.register("halls", CinemaHallViewSet) +router.register("genres", GenreViewSet) +router.register("actors", ActorViewSet) +router.register("movies", MovieViewSet) +router.register("sessions", MovieSessionViewSet) + + +urlpatterns = [path("", include(router.urls))] diff --git a/cinema/views.py b/cinema/views.py index ae87bfde..73decb4d 100644 --- a/cinema/views.py +++ b/cinema/views.py @@ -1 +1,50 @@ -# write views here +from rest_framework import viewsets + +from cinema.models import CinemaHall, Genre, Actor, Movie, MovieSession +from cinema.serializers import ( + CinemaHallSerializer, + GenreSerializer, + ActorSerializer, + MovieSerializer, + MovieSessionSerializer, + MovieRetrieveSerializer, + MovieListSerializer, +) + + +class CinemaHallViewSet(viewsets.ModelViewSet): + queryset = CinemaHall.objects.all() + serializer_class = CinemaHallSerializer + + +class GenreViewSet(viewsets.ModelViewSet): + queryset = Genre.objects.all() + serializer_class = GenreSerializer + + +class ActorViewSet(viewsets.ModelViewSet): + queryset = Actor.objects.all() + serializer_class = ActorSerializer + + +class MovieViewSet(viewsets.ModelViewSet): + queryset = Movie.objects.all() + serializer_class = MovieSerializer + + def get_serializer_class(self): + if self.action == "retrieve": + return MovieRetrieveSerializer + elif self.action == "list": + return MovieListSerializer + return self.serializer_class + + def get_queryset(self): + queryset = self.queryset + if self.action in ("list", "retrieve"): + return queryset.prefetch_related("genres", "actors") + return queryset + + +class MovieSessionViewSet(viewsets.ModelViewSet): + queryset = MovieSession.objects.all() + serializer_class = MovieSessionSerializer diff --git a/cinema_service/settings.py b/cinema_service/settings.py index 4b981921..d564165a 100644 --- a/cinema_service/settings.py +++ b/cinema_service/settings.py @@ -10,7 +10,9 @@ https://docs.djangoproject.com/en/4.0/ref/settings/ """ +import os from pathlib import Path +from decouple import config # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent @@ -20,14 +22,12 @@ # See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = ( - "django-insecure-6vubhk2$++agnctay_4pxy_8cq)mosmn(*-#2b^v4cgsh-^!i3" -) +SECRET_KEY = config("DJANGO_SECRET_KEY", default="fallback-secret-key") # SECURITY WARNING: don't run with debug turned on in production! -DEBUG = True +DEBUG = False -ALLOWED_HOSTS = [] +ALLOWED_HOSTS = ["127.0.0.1", "localhost"] # Application definition @@ -95,16 +95,16 @@ "UserAttributeSimilarityValidator", }, { - "NAME": "django.contrib.auth.password_validation." - "MinimumLengthValidator", + "NAME": + "django.contrib.auth.password_validation." "MinimumLengthValidator", }, { - "NAME": "django.contrib.auth.password_validation." - "CommonPasswordValidator", + "NAME": + "django.contrib.auth.password_validation." "CommonPasswordValidator", }, { - "NAME": "django.contrib.auth.password_validation." - "NumericPasswordValidator", + "NAME": + "django.contrib.auth.password_validation." "NumericPasswordValidator", }, ] diff --git a/cinema_service/urls.py b/cinema_service/urls.py index 083932c6..9288016e 100644 --- a/cinema_service/urls.py +++ b/cinema_service/urls.py @@ -1,6 +1,8 @@ from django.contrib import admin -from django.urls import path +from django.urls import path, include urlpatterns = [ path("admin/", admin.site.urls), + path("api/cinema/", include("cinema.urls", + namespace="cinema")), ] diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 00000000..81a91f77 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,4 @@ +[pytest] +DJANGO_SETTINGS_MODULE=cinema_service.settings +django_find_project = True +addopts = --reuse-db --tb=short -v \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 108897e9..d1b2f423 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,4 +3,5 @@ djangorestframework==3.13.1 flake8==5.0.4 flake8-quotes==3.3.1 flake8-variables-names==0.0.5 -pep8-naming==0.13.2 \ No newline at end of file +pep8-naming==0.13.2 +serializers~=0.2.4 \ No newline at end of file