-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from Pogchamp-company/develop
Create beta version
- Loading branch information
Showing
99 changed files
with
14,520 additions
and
532 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[pytest] | ||
addopts = -v -p no:warnings --nomigrations | ||
DJANGO_SETTINGS_MODULE = config.settings | ||
testpaths = tests | ||
python_classes = Test* | ||
python_files = test_*.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env sh | ||
|
||
# Required database env variables | ||
# shellcheck disable=SC2164 | ||
cd ./src | ||
pytest |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from django.shortcuts import render | ||
from django.templatetags.static import static | ||
|
||
|
||
def http404_page_not_found(request, *args, **kwargs): | ||
return render(request, | ||
'errors/base_error.html', | ||
context=dict(video=static('media/errors/404.mp4'), | ||
error_message='Error 404: Page not found'), | ||
status=404) | ||
|
||
|
||
def http500_internal_server_error(request, *args, **kwargs): | ||
return render(request, | ||
'errors/base_error.html', | ||
context=dict(video=static('media/errors/500.mp4'), | ||
error_message='Error 500: Internal Server Error'), | ||
status=500) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class IndexConfig(AppConfig): | ||
name = 'index' |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from django.urls import path | ||
from .views import SearchView, index | ||
|
||
urlpatterns = [ | ||
path('', index), | ||
path('search/', SearchView.as_view(), name="search"), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
from django.db.models import Q | ||
from django.shortcuts import render | ||
from rest_framework import status | ||
from rest_framework.views import APIView | ||
from rest_framework.request import Request | ||
from rest_framework.response import Response | ||
|
||
from movies.models import Movie | ||
from movies.serializers import MovieSerializer | ||
from news.models import News | ||
from person.models import Person | ||
from person.serializers import PersonSerializer | ||
|
||
|
||
def index(request): | ||
context = dict( | ||
preview=Movie.objects.order_by("-id")[:3], | ||
news=News.objects.order_by("-id")[:3] | ||
) | ||
|
||
return render(request, 'index/home_page.html', context) | ||
|
||
|
||
class SearchView(APIView): | ||
movie_serializer_class = MovieSerializer | ||
person_serializer_class = PersonSerializer | ||
|
||
def get(self, request: Request): | ||
query_filter = request.GET.get('query') | ||
if not query_filter: | ||
return Response({}, status=status.HTTP_400_BAD_REQUEST) | ||
movies = Movie.objects.filter( | ||
Q(title__icontains=query_filter) | Q(original_title__icontains=query_filter))[:3] | ||
persons = Person.objects.filter( | ||
Q(fullname__icontains=query_filter) | Q(ru_fullname__icontains=query_filter))[:3] | ||
|
||
response = { | ||
# 'topResult': {}, | ||
'movies': [self.movie_serializer_class(movie).data for movie in movies], | ||
'persons': [self.person_serializer_class(person).data for person in persons] | ||
} | ||
|
||
return Response(response, status=status.HTTP_200_OK) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,18 @@ | ||
from django.contrib import admin | ||
from .models import Genre, Movie, MovieType, Poster | ||
from .models import Genre, Movie, MovieType, Poster, MovieTrailer | ||
|
||
admin.site.register(Genre) | ||
admin.site.register(Movie) | ||
admin.site.register(MovieType) | ||
admin.site.register(Poster) | ||
|
||
|
||
class MovieTrailerAdmin(admin.ModelAdmin): | ||
def get_form(self, request, obj=None, **kwargs): | ||
form = super().get_form(request, obj, **kwargs) | ||
if not form.base_fields['link'].initial: | ||
form.base_fields['link'].initial = 'https://www.youtube.com/embed/' | ||
return form | ||
|
||
|
||
admin.site.register(MovieTrailer, MovieTrailerAdmin) |
Oops, something went wrong.