implement bots
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
from urllib.parse import urlparse
|
||||
|
||||
from django.forms import ModelForm
|
||||
from django.http import HttpRequest, HttpResponse, HttpResponseForbidden
|
||||
from pyrogram import Chat as PyrogramChat
|
||||
from pyrogram.api.types.chat import Chat as MTProtoChat
|
||||
@@ -54,3 +55,26 @@ class TurbolinksMiddleware:
|
||||
response['Turbolinks-Location'] = loc
|
||||
|
||||
return response
|
||||
|
||||
|
||||
def get_config_form(mdl):
|
||||
class ConfigForm(ModelForm):
|
||||
prefix = 'config'
|
||||
|
||||
class Meta:
|
||||
model = mdl
|
||||
exclude = ()
|
||||
return ConfigForm
|
||||
|
||||
|
||||
class AllowCORSMixin(object):
|
||||
def add_access_control_headers(self, response):
|
||||
response["Access-Control-Allow-Origin"] = "*"
|
||||
response["Access-Control-Allow-Methods"] = "GET, 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