rename mabras -> marbas, fix not condition in search, allow page_size for pagination
This commit was merged in pull request #4.
This commit is contained in:
@@ -9,9 +9,9 @@ WORKDIR /app
|
|||||||
COPY --chown=appuser:appuser manage.py /app/manage.py
|
COPY --chown=appuser:appuser manage.py /app/manage.py
|
||||||
COPY requirements.txt .
|
COPY requirements.txt .
|
||||||
RUN python -m pip install --no-cache-dir --upgrade -r requirements.txt
|
RUN python -m pip install --no-cache-dir --upgrade -r requirements.txt
|
||||||
COPY --chown=appuser:appuser mabras /app/mabras
|
COPY --chown=appuser:appuser marbas /app/marbas
|
||||||
COPY --chown=appuser:appuser sde /app/sde
|
COPY --chown=appuser:appuser sde /app/sde
|
||||||
COPY --chown=appuser:appuser api /app/api
|
COPY --chown=appuser:appuser api /app/api
|
||||||
|
|
||||||
USER appuser
|
USER appuser
|
||||||
CMD ["uvicorn", "mabras.asgi:application", "--host", "0.0.0.0", "--port", "8000"]
|
CMD ["uvicorn", "marbas.asgi:application", "--host", "0.0.0.0", "--port", "8000"]
|
||||||
15
api/views.py
15
api/views.py
@@ -42,24 +42,21 @@ def custom_types_search(request):
|
|||||||
items = []
|
items = []
|
||||||
|
|
||||||
for q in request.data:
|
for q in request.data:
|
||||||
condition = Q()
|
conditions = Q()
|
||||||
for k in q.keys():
|
for k in q.keys():
|
||||||
value = q[k]
|
value = q[k]
|
||||||
|
|
||||||
token = k.split('___')
|
token = k.split('___')
|
||||||
key, mods = token[0], token[1:]
|
key, mods = token[0], token[1:]
|
||||||
|
|
||||||
if "i" in mods:
|
cond = Q(**{key: value})
|
||||||
condition = condition & Q(**{key + '__icontains': value})
|
|
||||||
elif "in" in mods:
|
|
||||||
condition = condition & Q(**{key + '__in': value})
|
|
||||||
else:
|
|
||||||
condition = condition & Q(**{key: value})
|
|
||||||
|
|
||||||
if "not" in mods:
|
if "not" in mods:
|
||||||
condition = ~condition
|
cond = ~cond
|
||||||
|
|
||||||
items.extend(sde_models.SDEType.objects.filter(condition))
|
conditions = conditions & cond
|
||||||
|
|
||||||
|
items.extend(sde_models.SDEType.objects.filter(conditions))
|
||||||
|
|
||||||
paginator = settings.api_settings.DEFAULT_PAGINATION_CLASS()
|
paginator = settings.api_settings.DEFAULT_PAGINATION_CLASS()
|
||||||
result_page = paginator.paginate_queryset(items, request)
|
result_page = paginator.paginate_queryset(items, request)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
version: '3'
|
version: '3'
|
||||||
services:
|
services:
|
||||||
migrations:
|
migrations:
|
||||||
image: mabras:local
|
image: marbas:local
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
@@ -9,7 +9,7 @@ services:
|
|||||||
- .env
|
- .env
|
||||||
user: "1000:1000"
|
user: "1000:1000"
|
||||||
volumes:
|
volumes:
|
||||||
- ./mabras:/app/mabras
|
- ./marbas:/app/marbas
|
||||||
- ./api:/app/api
|
- ./api:/app/api
|
||||||
- ./sde:/app/sde
|
- ./sde:/app/sde
|
||||||
- ./manage.py:/app/manage.py
|
- ./manage.py:/app/manage.py
|
||||||
@@ -19,19 +19,19 @@ services:
|
|||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
|
|
||||||
eveal:
|
eveal:
|
||||||
image: mabras:local
|
image: marbas:local
|
||||||
env_file:
|
env_file:
|
||||||
- .env
|
- .env
|
||||||
ports:
|
ports:
|
||||||
- 8000:8000
|
- 8000:8000
|
||||||
user: "1000:1000"
|
user: "1000:1000"
|
||||||
volumes:
|
volumes:
|
||||||
- ./mabras:/app/mabras
|
- ./marbas:/app/marbas
|
||||||
- ./api:/app/api
|
- ./api:/app/api
|
||||||
- ./sde:/app/sde
|
- ./sde:/app/sde
|
||||||
- ./manage.py:/app/manage.py
|
- ./manage.py:/app/manage.py
|
||||||
# - ./static_eve:/app/static_eve
|
# - ./static_eve:/app/static_eve
|
||||||
command: ["uvicorn", "mabras.asgi:application", "--host", "0.0.0.0", "--port", "8000", "--reload"]
|
command: ["uvicorn", "marbas.asgi:application", "--host", "0.0.0.0", "--port", "8000", "--reload"]
|
||||||
depends_on:
|
depends_on:
|
||||||
redis:
|
redis:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
@@ -55,7 +55,7 @@ services:
|
|||||||
ports:
|
ports:
|
||||||
- 5432:5432
|
- 5432:5432
|
||||||
volumes:
|
volumes:
|
||||||
- mabras_dbdata:/var/lib/postgresql/data
|
- marbas_dbdata:/var/lib/postgresql/data
|
||||||
env_file:
|
env_file:
|
||||||
- .env
|
- .env
|
||||||
healthcheck:
|
healthcheck:
|
||||||
@@ -80,4 +80,4 @@ services:
|
|||||||
# retries: 3
|
# retries: 3
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
mabras_dbdata:
|
marbas_dbdata:
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import sys
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
"""Run administrative tasks."""
|
"""Run administrative tasks."""
|
||||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mabras.settings')
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'marbas.settings')
|
||||||
try:
|
try:
|
||||||
from django.core.management import execute_from_command_line
|
from django.core.management import execute_from_command_line
|
||||||
except ImportError as exc:
|
except ImportError as exc:
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
"""
|
"""
|
||||||
ASGI config for mabras project.
|
ASGI config for marbas project.
|
||||||
|
|
||||||
It exposes the ASGI callable as a module-level variable named ``application``.
|
It exposes the ASGI callable as a module-level variable named ``application``.
|
||||||
|
|
||||||
@@ -11,6 +11,6 @@ import os
|
|||||||
|
|
||||||
from django.core.asgi import get_asgi_application
|
from django.core.asgi import get_asgi_application
|
||||||
|
|
||||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mabras.settings')
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'marbas.settings')
|
||||||
|
|
||||||
application = get_asgi_application()
|
application = get_asgi_application()
|
||||||
8
marbas/pagination.py
Normal file
8
marbas/pagination.py
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
from rest_framework import pagination
|
||||||
|
|
||||||
|
|
||||||
|
class CustomPagination(pagination.PageNumberPagination):
|
||||||
|
page_size = 10
|
||||||
|
page_size_query_param = 'page_size'
|
||||||
|
max_page_size = 250
|
||||||
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
"""
|
"""
|
||||||
Django settings for mabras project.
|
Django settings for marbas project.
|
||||||
|
|
||||||
Generated by 'django-admin startproject' using Django 4.2.6.
|
Generated by 'django-admin startproject' using Django 4.2.6.
|
||||||
|
|
||||||
@@ -11,7 +11,7 @@ https://docs.djangoproject.com/en/4.2/ref/settings/
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import os, socket
|
import os
|
||||||
|
|
||||||
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
||||||
BASE_DIR = Path(__file__).resolve().parent.parent
|
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||||
@@ -32,8 +32,7 @@ ALLOWED_HOSTS = [] if not any(ALLOWED_HOSTS) else ALLOWED_HOSTS
|
|||||||
# Application definition
|
# Application definition
|
||||||
|
|
||||||
REST_FRAMEWORK = {
|
REST_FRAMEWORK = {
|
||||||
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
|
'DEFAULT_PAGINATION_CLASS': 'marbas.pagination.CustomPagination',
|
||||||
'PAGE_SIZE': 100,
|
|
||||||
'DEFAULT_RENDERER_CLASSES': [
|
'DEFAULT_RENDERER_CLASSES': [
|
||||||
'rest_framework.renderers.JSONRenderer',
|
'rest_framework.renderers.JSONRenderer',
|
||||||
],
|
],
|
||||||
@@ -67,12 +66,12 @@ MIDDLEWARE = [
|
|||||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||||
]
|
]
|
||||||
|
|
||||||
ROOT_URLCONF = 'mabras.urls'
|
ROOT_URLCONF = 'marbas.urls'
|
||||||
|
|
||||||
TEMPLATES = [
|
TEMPLATES = [
|
||||||
{
|
{
|
||||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||||
'DIRS': ["mabras/templates"],
|
'DIRS': ["marbas/templates"],
|
||||||
'APP_DIRS': True,
|
'APP_DIRS': True,
|
||||||
'OPTIONS': {
|
'OPTIONS': {
|
||||||
'context_processors': [
|
'context_processors': [
|
||||||
@@ -85,7 +84,7 @@ TEMPLATES = [
|
|||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
WSGI_APPLICATION = 'mabras.wsgi.application'
|
WSGI_APPLICATION = 'marbas.wsgi.application'
|
||||||
|
|
||||||
|
|
||||||
CACHES = {
|
CACHES = {
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
"""
|
"""
|
||||||
URL configuration for mabras project.
|
URL configuration for marbas project.
|
||||||
|
|
||||||
The `urlpatterns` list routes URLs to views. For more information please see:
|
The `urlpatterns` list routes URLs to views. For more information please see:
|
||||||
https://docs.djangoproject.com/en/4.2/topics/http/urls/
|
https://docs.djangoproject.com/en/4.2/topics/http/urls/
|
||||||
@@ -25,7 +25,7 @@ urlpatterns = [
|
|||||||
path('api-auth/', include('rest_framework.urls', namespace='rest_framework')),
|
path('api-auth/', include('rest_framework.urls', namespace='rest_framework')),
|
||||||
path('sso/', include('esi.urls', namespace='esi')),
|
path('sso/', include('esi.urls', namespace='esi')),
|
||||||
path('openapi/', get_schema_view(
|
path('openapi/', get_schema_view(
|
||||||
title="Mabras",
|
title="marbas",
|
||||||
description="API for EvEal",
|
description="API for EvEal",
|
||||||
version="0.0.9"
|
version="0.0.9"
|
||||||
), name='openapi-schema'),
|
), name='openapi-schema'),
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
"""
|
"""
|
||||||
WSGI config for mabras project.
|
WSGI config for marbas project.
|
||||||
|
|
||||||
It exposes the WSGI callable as a module-level variable named ``application``.
|
It exposes the WSGI callable as a module-level variable named ``application``.
|
||||||
|
|
||||||
@@ -11,6 +11,6 @@ import os
|
|||||||
|
|
||||||
from django.core.wsgi import get_wsgi_application
|
from django.core.wsgi import get_wsgi_application
|
||||||
|
|
||||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mabras.settings')
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'marbas.settings')
|
||||||
|
|
||||||
application = get_wsgi_application()
|
application = get_wsgi_application()
|
||||||
Reference in New Issue
Block a user