switch to uv and add cors headers
This commit is contained in:
@@ -24,6 +24,7 @@ INSTALLED_APPS = [
|
||||
'crispy_bootstrap4',
|
||||
'djconfig',
|
||||
'jsoneditor',
|
||||
'corsheaders',
|
||||
|
||||
'django.contrib.admin',
|
||||
'django.contrib.auth',
|
||||
@@ -34,7 +35,6 @@ INSTALLED_APPS = [
|
||||
|
||||
'cabinet.apps.CabinetConfig',
|
||||
'feeds.apps.FeedsConfig',
|
||||
'aggregator.apps.AggregatorConfig',
|
||||
'bots.apps.BotsConfig',
|
||||
]
|
||||
|
||||
@@ -43,6 +43,7 @@ MIDDLEWARE = [
|
||||
'django.middleware.security.SecurityMiddleware',
|
||||
'whitenoise.middleware.WhiteNoiseMiddleware',
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
"corsheaders.middleware.CorsMiddleware",
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
# 'django.middleware.csrf.CsrfViewMiddleware',
|
||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||
@@ -131,6 +132,8 @@ CRISPY_TEMPLATE_PACK = 'bootstrap4'
|
||||
JSON_EDITOR_JS = 'https://cdnjs.cloudflare.com/ajax/libs/jsoneditor/7.0.4/jsoneditor.min.js'
|
||||
JSON_EDITOR_CSS = 'https://cdnjs.cloudflare.com/ajax/libs/jsoneditor/7.0.4/jsoneditor.min.css'
|
||||
|
||||
CORS_ALLOW_ALL_ORIGINS = True
|
||||
|
||||
sentry_sdk.init(
|
||||
dsn=env.str('SENTRY_DSN', None),
|
||||
integrations=[DjangoIntegration()],
|
||||
|
@@ -2,18 +2,6 @@ from urllib.parse import urlparse
|
||||
|
||||
from django.forms import ModelForm
|
||||
from django.http import HttpRequest, HttpResponse, HttpResponseForbidden
|
||||
from pyrogram.types import Chat as PyrogramChat
|
||||
from pyrogram.raw.types.chat import Chat as MTProtoChat
|
||||
from pyrogram.raw.types.user import User as MTProtoUser
|
||||
from pyrogram.raw.types.channel import Channel as MTProtoChannel
|
||||
|
||||
|
||||
def parse_mtproto_chat(client, chat):
|
||||
if isinstance(chat, MTProtoChat):
|
||||
return PyrogramChat._parse_chat_chat(client, chat)
|
||||
elif isinstance(chat, MTProtoUser):
|
||||
return PyrogramChat._parse_user_chat(client, chat)
|
||||
return PyrogramChat._parse_channel_chat(client, chat)
|
||||
|
||||
|
||||
def same_origin(current_uri, redirect_uri):
|
||||
@@ -66,16 +54,3 @@ def get_config_form(mdl):
|
||||
exclude = mdl.EXCLUDE_FIELDS if hasattr(mdl, 'EXCLUDE_FIELDS') else ()
|
||||
widgets = mdl.CUSTOM_WIDGETS if hasattr(mdl, 'CUSTOM_WIDGETS') else {}
|
||||
return ConfigForm
|
||||
|
||||
|
||||
class AllowCORSMixin(object):
|
||||
def add_access_control_headers(self, response):
|
||||
response["Access-Control-Allow-Origin"] = "*"
|
||||
response["Access-Control-Allow-Methods"] = "GET, POST, OPTIONS"
|
||||
response["Access-Control-Max-Age"] = "1000"
|
||||
response["Access-Control-Allow-Headers"] = "X-Requested-With, Content-Type"
|
||||
|
||||
def options(self, request, *args, **kwargs):
|
||||
response = HttpResponse()
|
||||
self.add_access_control_headers(response)
|
||||
return response
|
||||
|
Reference in New Issue
Block a user