Пример #1
0
def git_hook(request):
    if request.method != 'POST': return error404(request)
    if ('HTTP_X_HUB_SIGNATURE' not in request.META) or (
            'HTTP_X_GITHUB_DELIVERY'
            not in request.META) or ('HTTP_X_GITHUB_EVENT'
                                     not in request.META):
        return error400(request)

    signature = request.META['HTTP_X_HUB_SIGNATURE']
    mac = hmac.new(env('GITHOOK_SECRET'), msg=request.body, digestmod=sha1)
    if not hmac.compare_digest('sha1=' + str(mac.hexdigest()), str(signature)):
        return error403(request)

    try:
        call_command('dist')
    except Exception:
        print traceback.format_exc()
        return error500(request)
    return HttpResponse(content="", status=201)
Пример #2
0
from src.settings.components import BASE_DIR
from src.settings import env

# Application definition
SECRET_KEY = env("DJANGO_SECRET_KEY")

INSTALLED_APPS: list[str] = [
    "django.contrib.admin",
    "django.contrib.auth",
    "django.contrib.contenttypes",
    "django.contrib.sessions",
    "django.contrib.messages",
    "django.contrib.staticfiles",
    "src.apps.theme",
    "src.apps.main",
    "src.apps.checkout",
    "formtools",
]

MIDDLEWARE: list[str] = [
    "django.middleware.security.SecurityMiddleware",
    "django.contrib.sessions.middleware.SessionMiddleware",
    "django.middleware.common.CommonMiddleware",
    "django.middleware.csrf.CsrfViewMiddleware",
    "django.contrib.auth.middleware.AuthenticationMiddleware",
    "django.contrib.messages.middleware.MessageMiddleware",
    "django.middleware.clickjacking.XFrameOptionsMiddleware",
]

ROOT_URLCONF = "src.urls"
Пример #3
0
from django.conf.urls import include, url, handler400, handler403, handler404, handler500
from django.contrib import admin
from django.views.generic import RedirectView
from django.views.static import serve

from adminplus.sites import AdminSitePlus
from filemanager import path_end

from src.settings import MEDIA_ROOT, DEBUG, IS_MAINTENANCE, env
from src import views
from src import user

admin.site = AdminSitePlus()
admin.site.index_title = '%s Administration' % env('SERVER_NAME')
admin.autodiscover()
admin.site.login = user.user_login
admin.site.logout = user.user_logout

if IS_MAINTENANCE:
    urlpatterns = [
        url(r'^ping_test/?$', views.ping_test),
        url(r'^get_staff/?$', views.get_staff),
        url(r'^site_media/(?P<path>.*)$', serve,
            {'document_root': MEDIA_ROOT + '/media'}),
        url(r'^robots.txt$',
            serve,
            kwargs={
                'path': 'robots.txt',
                'document_root': MEDIA_ROOT
            }),
        url(r'^$', views.error503),
Пример #4
0
from django.views.decorators.csrf import csrf_exempt
from django.core.management import call_command

import hmac
from hashlib import sha1
import re
import traceback

from src.env import error400, error403, error404, error500
from src.settings import env, DEBUG
from src.views import result_json
from src.wrapper_1d import design_1d_run
from src.wrapper_2d import design_2d_run
from src.wrapper_3d import design_3d_run

ALLOWED_ORIGIN = [env('ALLOWED_CORS_HOST')] if not DEBUG else [
    env('ALLOWED_CORS_HOST'), 'http://localhost:9000'
]


@csrf_exempt
def submit(request):
    if not ('HTTP_ORIGIN' in request.META
            and request.META.get('HTTP_ORIGIN') in ALLOWED_ORIGIN):
        return error403(request)

    if request.method != 'POST' or ('type' not in request.POST) or (
            request.POST.get('type') not in ('1', '2', '3')):
        return error400(request)

    job_type = int(request.POST.get('type'))
Пример #5
0
from src.settings import env

DEBUG = False

ALLOWED_HOSTS = [
    env("DOMAIN_NAME"),
]