add_filters

dev
AlexP077 3 years ago
parent 1407b1a3af
commit 8ccf45133f

@ -16,3 +16,7 @@ MARTIN_PORT=3000
# The martin container settings and enviroment
DOMAIN=social.ru.com
# The frontend and nginx container settings and enviroment
EMAIL_HOST_USER = 'noreply@spatiality.website'
EMAIL_HOST_PASSWORD = "spatialitypass321"
EMAIL_HOST = 'smtp.yandex.ru'
EMAIL_PORT = 587

@ -10,13 +10,12 @@ For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.2/ref/settings/
"""
from pathlib import Path
import os
from pathlib import Path
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/
@ -28,7 +27,6 @@ DEBUG = os.getenv('DEBUG', False) == 'True'
ALLOWED_HOSTS = ['*']
# Application definition
INSTALLED_APPS = [
@ -79,7 +77,6 @@ TEMPLATES = [
WSGI_APPLICATION = 'postamates.wsgi.application'
# Database
# https://docs.djangoproject.com/en/3.2/ref/settings/#databases
@ -111,8 +108,6 @@ AUTH_PASSWORD_VALIDATORS = [
},
]
# Internationalization
# https://docs.djangoproject.com/en/3.2/topics/i18n/
@ -126,7 +121,6 @@ USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.2/howto/static-files/
@ -140,7 +134,7 @@ MEDIA_ROOT = os.path.join(BASE_DIR, 'django_media')
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
CORS_ORIGIN_ALLOW_ALL = True # If this is used then `CORS_ORIGIN_WHITELIST` will not have any effect
CORS_ORIGIN_ALLOW_ALL = True # If this is used then `CORS_ORIGIN_WHITELIST` will not have any effect
CORS_ALLOW_CREDENTIALS = True
CORS_ORIGIN_ALLOW = True
@ -150,12 +144,12 @@ if os.getenv('local') is not None:
GDAL_LIBRARY_PATH = '/opt/homebrew/opt/gdal/lib/libgdal.dylib'
GEOS_LIBRARY_PATH = '/opt/homebrew/opt/geos/lib/libgeos_c.dylib'
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' #new
EMAIL_HOST = 'smtp.yandex.ru' #new
EMAIL_PORT = 587 #new
EMAIL_HOST_USER = 'noreply@spatiality.website' #new
EMAIL_HOST_PASSWORD = "spatialitypass321" #new
EMAIL_USE_TLS = True #new
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = os.getenv('EMAIL_HOST', 'smtp.yandex.ru')
EMAIL_PORT = os.getenv('EMAIL_PORT', 587)
EMAIL_HOST_USER = os.getenv('EMAIL_HOST_USER', 'noreply@spatiality.website')
EMAIL_HOST_PASSWORD = os.getenv('EMAIL_HOST_PASSWORD', "spatialitypass321")
EMAIL_USE_TLS = True
FRONTEND_URL = os.getenv('REACT_APP_DOMAIN_URL', 'http://localhost:3000/')
REST_REGISTRATION = {
'REGISTER_VERIFICATION_ENABLED': True,

@ -174,13 +174,39 @@ class raschet(GenericAPIView):
return response
# ======
class PlacementPointViewSet(ReadOnlyModelViewSet):
serializer_class = serializers.PlacementPointSerializer
queryset = models.PlacementPoint.objects
pagination_class = pagination.MyPagination
def get_queryset(self):
return self.queryset.all()
qs = self.queryset.all()
location_ids = self.request.GET.get('location_ids[]')
prediction = self.request.GET.get('prediction[]')
categories = self.request.GET.get('categories[]')
status = self.request.GET.get('status[]')
delta = self.request.GET.get('delta[]')
fact = self.request.GET.get('fact[]')
age = self.request.GET.get('age[]')
if location_ids:
location_ids = list(location_ids.split(','))
qs = qs.filter(location_id__in=location_ids)
if prediction:
prediction = list(prediction.split(','))
qs = qs.filter(prediction__range=prediction)
if categories:
categories = list(categories.split(','))
qs = qs.filter(category__in=categories)
if status:
status = list(status.split(','))
qs = qs.filter(status__in=status)
if delta:
delta = list(delta.split(','))
qs = qs.filter(delta__range=delta)
if fact:
fact = list(fact.split(','))
qs = qs.filter(fact__range=fact)
if age:
age = list(age.split(','))
qs = qs.filter(age__range=age)
return qs

Loading…
Cancel
Save