implement bots
This commit is contained in:
@@ -23,7 +23,6 @@ INSTALLED_APPS = [
|
||||
'djconfig',
|
||||
'django_celery_results',
|
||||
'django_celery_beat',
|
||||
'config.suit_config.SuitConfig',
|
||||
|
||||
'django.contrib.admin',
|
||||
'django.contrib.auth',
|
||||
@@ -35,6 +34,7 @@ INSTALLED_APPS = [
|
||||
'cabinet.apps.CabinetConfig',
|
||||
'feeds.apps.FeedsConfig',
|
||||
'aggregator.apps.AggregatorConfig',
|
||||
'bots.apps.BotsConfig',
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
|
@@ -1,5 +0,0 @@
|
||||
from suit.apps import DjangoSuitConfig
|
||||
|
||||
|
||||
class SuitConfig(DjangoSuitConfig):
|
||||
layout = 'vertical'
|
@@ -2,8 +2,11 @@ from django.contrib import admin
|
||||
from django.urls import path, include
|
||||
from django.views.generic import RedirectView
|
||||
|
||||
from bots.views import BotRPCView
|
||||
|
||||
urlpatterns = [
|
||||
path('', RedirectView.as_view(pattern_name='cabinet:index')),
|
||||
path('config/', admin.site.urls),
|
||||
path('cabinet/', include('cabinet.urls', namespace='cabinet')),
|
||||
path('bots_rpc/<str:endpoint>/', BotRPCView.as_view(), name='bots_rpc'),
|
||||
]
|
||||
|
@@ -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