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 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 api /app/api
|
||||
|
||||
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 = []
|
||||
|
||||
for q in request.data:
|
||||
condition = Q()
|
||||
conditions = Q()
|
||||
for k in q.keys():
|
||||
value = q[k]
|
||||
|
||||
token = k.split('___')
|
||||
key, mods = token[0], token[1:]
|
||||
|
||||
if "i" in mods:
|
||||
condition = condition & Q(**{key + '__icontains': value})
|
||||
elif "in" in mods:
|
||||
condition = condition & Q(**{key + '__in': value})
|
||||
else:
|
||||
condition = condition & Q(**{key: value})
|
||||
cond = Q(**{key: value})
|
||||
|
||||
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()
|
||||
result_page = paginator.paginate_queryset(items, request)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
version: '3'
|
||||
services:
|
||||
migrations:
|
||||
image: mabras:local
|
||||
image: marbas:local
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
@@ -9,7 +9,7 @@ services:
|
||||
- .env
|
||||
user: "1000:1000"
|
||||
volumes:
|
||||
- ./mabras:/app/mabras
|
||||
- ./marbas:/app/marbas
|
||||
- ./api:/app/api
|
||||
- ./sde:/app/sde
|
||||
- ./manage.py:/app/manage.py
|
||||
@@ -19,19 +19,19 @@ services:
|
||||
condition: service_healthy
|
||||
|
||||
eveal:
|
||||
image: mabras:local
|
||||
image: marbas:local
|
||||
env_file:
|
||||
- .env
|
||||
ports:
|
||||
- 8000:8000
|
||||
user: "1000:1000"
|
||||
volumes:
|
||||
- ./mabras:/app/mabras
|
||||
- ./marbas:/app/marbas
|
||||
- ./api:/app/api
|
||||
- ./sde:/app/sde
|
||||
- ./manage.py:/app/manage.py
|
||||
# - ./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:
|
||||
redis:
|
||||
condition: service_healthy
|
||||
@@ -55,7 +55,7 @@ services:
|
||||
ports:
|
||||
- 5432:5432
|
||||
volumes:
|
||||
- mabras_dbdata:/var/lib/postgresql/data
|
||||
- marbas_dbdata:/var/lib/postgresql/data
|
||||
env_file:
|
||||
- .env
|
||||
healthcheck:
|
||||
@@ -80,4 +80,4 @@ services:
|
||||
# retries: 3
|
||||
|
||||
volumes:
|
||||
mabras_dbdata:
|
||||
marbas_dbdata:
|
||||
|
||||
@@ -6,7 +6,7 @@ import sys
|
||||
|
||||
def main():
|
||||
"""Run administrative tasks."""
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mabras.settings')
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'marbas.settings')
|
||||
try:
|
||||
from django.core.management import execute_from_command_line
|
||||
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``.
|
||||
|
||||
@@ -11,6 +11,6 @@ import os
|
||||
|
||||
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()
|
||||
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.
|
||||
|
||||
@@ -11,7 +11,7 @@ https://docs.djangoproject.com/en/4.2/ref/settings/
|
||||
"""
|
||||
|
||||
from pathlib import Path
|
||||
import os, socket
|
||||
import os
|
||||
|
||||
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
||||
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||
@@ -32,8 +32,7 @@ ALLOWED_HOSTS = [] if not any(ALLOWED_HOSTS) else ALLOWED_HOSTS
|
||||
# Application definition
|
||||
|
||||
REST_FRAMEWORK = {
|
||||
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
|
||||
'PAGE_SIZE': 100,
|
||||
'DEFAULT_PAGINATION_CLASS': 'marbas.pagination.CustomPagination',
|
||||
'DEFAULT_RENDERER_CLASSES': [
|
||||
'rest_framework.renderers.JSONRenderer',
|
||||
],
|
||||
@@ -67,12 +66,12 @@ MIDDLEWARE = [
|
||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||
]
|
||||
|
||||
ROOT_URLCONF = 'mabras.urls'
|
||||
ROOT_URLCONF = 'marbas.urls'
|
||||
|
||||
TEMPLATES = [
|
||||
{
|
||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||
'DIRS': ["mabras/templates"],
|
||||
'DIRS': ["marbas/templates"],
|
||||
'APP_DIRS': True,
|
||||
'OPTIONS': {
|
||||
'context_processors': [
|
||||
@@ -85,7 +84,7 @@ TEMPLATES = [
|
||||
},
|
||||
]
|
||||
|
||||
WSGI_APPLICATION = 'mabras.wsgi.application'
|
||||
WSGI_APPLICATION = 'marbas.wsgi.application'
|
||||
|
||||
|
||||
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:
|
||||
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('sso/', include('esi.urls', namespace='esi')),
|
||||
path('openapi/', get_schema_view(
|
||||
title="Mabras",
|
||||
title="marbas",
|
||||
description="API for EvEal",
|
||||
version="0.0.9"
|
||||
), 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``.
|
||||
|
||||
@@ -11,6 +11,6 @@ import os
|
||||
|
||||
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()
|
||||
Reference in New Issue
Block a user