mirror of
https://github.com/DarrenOfficial/dpaste.git
synced 2024-11-15 08:02:54 +11:00
Further cleanup along settings and debris.
This commit is contained in:
parent
27ff3fb89e
commit
dc3e797be8
6 changed files with 22 additions and 94 deletions
3
.env
3
.env
|
@ -1,3 +0,0 @@
|
|||
APPNAME = dpaste
|
||||
DJANGO_SETTINGS_MODULE=dpaste.settings.local
|
||||
|
|
@ -5,7 +5,6 @@ from django.apps import apps
|
|||
from django.db import models
|
||||
from django.urls import reverse
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from six import python_2_unicode_compatible
|
||||
|
||||
from dpaste import highlight
|
||||
|
||||
|
@ -39,7 +38,6 @@ def generate_secret_id(length):
|
|||
return generate_secret_id(length=length + 1)
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class Snippet(models.Model):
|
||||
EXPIRE_TIME = 1
|
||||
EXPIRE_KEEP = 2
|
||||
|
|
|
@ -1,53 +1,33 @@
|
|||
# ==============================================================================
|
||||
# Import global settings to make it easier to extend settings.
|
||||
# ==============================================================================
|
||||
# Calculation of directories relative to the module location
|
||||
# ==============================================================================
|
||||
import os
|
||||
import sys
|
||||
|
||||
from django.conf.global_settings import *
|
||||
|
||||
import dpaste
|
||||
import dj_database_url
|
||||
|
||||
PROJECT_DIR, PROJECT_MODULE_NAME = os.path.split(
|
||||
env = os.environ.get
|
||||
|
||||
BASE_DIR, PROJECT_MODULE_NAME = os.path.split(
|
||||
os.path.dirname(os.path.realpath(dpaste.__file__))
|
||||
)
|
||||
|
||||
PYTHON_BIN = os.path.dirname(sys.executable)
|
||||
if os.path.exists(os.path.join(PYTHON_BIN, "activate_this.py")):
|
||||
# Assume that the presence of 'activate_this.py' in the python bin/
|
||||
# directory means that we're running in a virtual environment. Set the
|
||||
# variable root to $VIRTUALENV/var.
|
||||
VAR_ROOT = os.path.join(os.path.dirname(PYTHON_BIN), "var")
|
||||
if not os.path.exists(VAR_ROOT):
|
||||
os.mkdir(VAR_ROOT)
|
||||
else:
|
||||
# Set the variable root to the local configuration location (which is
|
||||
# ignored by the repository).
|
||||
VAR_ROOT = os.path.join(PROJECT_DIR, PROJECT_MODULE_NAME, "conf", "local")
|
||||
|
||||
# ==============================================================================
|
||||
# Generic Django project settings
|
||||
# Settings
|
||||
# ==============================================================================
|
||||
|
||||
DEBUG = False
|
||||
DEBUG = env("DEBUG", False)
|
||||
|
||||
# Local time zone for this installation. Choices can be found here:
|
||||
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
|
||||
TIME_ZONE = "UTC"
|
||||
SITE_ID = 1
|
||||
|
||||
# Make this unique, and don't share it with anybody.
|
||||
SECRET_KEY = ""
|
||||
SECRET_KEY = env("SECRET_KEY", "")
|
||||
|
||||
ALLOWED_HOSTS = ["*"]
|
||||
|
||||
# ==============================================================================
|
||||
# I18N
|
||||
# ==============================================================================
|
||||
ALLOWED_HOSTS = env("ALLOWED_HOSTS", "*").split(",")
|
||||
|
||||
TIME_ZONE = "UTC"
|
||||
USE_I18N = True
|
||||
USE_L10N = False
|
||||
USE_L10N = True
|
||||
USE_TZ = True
|
||||
|
||||
LANGUAGE_CODE = "en"
|
||||
LANGUAGES = (("en", "English"),)
|
||||
|
@ -56,10 +36,6 @@ LANGUAGES = (("en", "English"),)
|
|||
# os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'locale')),
|
||||
# )
|
||||
|
||||
# ==============================================================================
|
||||
# Project URLS and media settings
|
||||
# ==============================================================================
|
||||
|
||||
STATICFILES_STORAGE = (
|
||||
"django.contrib.staticfiles.storage.ManifestStaticFilesStorage"
|
||||
)
|
||||
|
@ -69,20 +45,14 @@ STATICFILES_FINDERS = (
|
|||
"django.contrib.staticfiles.finders.AppDirectoriesFinder",
|
||||
)
|
||||
|
||||
STATIC_ROOT = os.path.join(VAR_ROOT, "static")
|
||||
STATIC_ROOT = env("STATIC_ROOT", ".static")
|
||||
MEDIA_ROOT = env("MEDIA_ROOT", ".media")
|
||||
|
||||
STATIC_URL = "/static/"
|
||||
ADMIN_MEDIA_PREFIX = "/static/admin/"
|
||||
|
||||
ROOT_URLCONF = "dpaste.urls"
|
||||
|
||||
LOGIN_URL = "/accounts/login/"
|
||||
LOGOUT_URL = "/accounts/logout/"
|
||||
LOGIN_REDIRECT_URL = "/"
|
||||
|
||||
# ==============================================================================
|
||||
# Templates
|
||||
# ==============================================================================
|
||||
WSGI_APPLICATION = "dpaste.wsgi.application"
|
||||
|
||||
MIDDLEWARE = [
|
||||
"django.middleware.csrf.CsrfViewMiddleware",
|
||||
|
@ -116,14 +86,8 @@ INSTALLED_APPS = [
|
|||
"dpaste.apps.dpasteAppConfig",
|
||||
]
|
||||
|
||||
# DATABASES = {
|
||||
# 'default': {
|
||||
# 'ENGINE': 'django.db.backends.sqlite3',
|
||||
# 'NAME': 'dev.db',
|
||||
# 'USER': '',
|
||||
# 'PASSWORD': '',
|
||||
# }
|
||||
# }
|
||||
DATABASE_URL = env("DATABASE_URL", "sqlite:///dpaste.sqlite")
|
||||
DATABASES = {"default": dj_database_url.config(DATABASE_URL)}
|
||||
|
||||
# ==============================================================================
|
||||
# App specific settings
|
||||
|
|
|
@ -1,17 +1,10 @@
|
|||
"""
|
||||
Settings for the test suite
|
||||
Settings for the testsuite runs.
|
||||
"""
|
||||
import django
|
||||
|
||||
from .base import *
|
||||
from .base import * # noqa
|
||||
|
||||
SECRET_KEY = "test-key"
|
||||
|
||||
DATABASES = {
|
||||
"default": {"ENGINE": "django.db.backends.sqlite3", "NAME": ":memory:"}
|
||||
}
|
||||
|
||||
# Drop CSP middleware for Django 3.0 until it was fixed upstream
|
||||
# https://github.com/mozilla/django-csp/issues/129
|
||||
if django.get_version().startswith("3."):
|
||||
MIDDLEWARE.remove("csp.middleware.CSPMiddleware")
|
||||
|
|
24
runtests.py
24
runtests.py
|
@ -1,24 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
|
||||
import sys
|
||||
|
||||
from django import setup
|
||||
from django.conf import settings
|
||||
from django.test.runner import DiscoverRunner as TestRunner
|
||||
|
||||
from dpaste.settings import tests as test_settings
|
||||
|
||||
|
||||
def runtests(*test_args):
|
||||
# Setup settings
|
||||
if not settings.configured:
|
||||
settings.configure(**test_settings.__dict__)
|
||||
setup()
|
||||
test_runner = TestRunner(verbosity=1)
|
||||
failures = test_runner.run_tests(['dpaste'])
|
||||
if failures:
|
||||
sys.exit(failures)
|
||||
|
||||
if __name__ == '__main__':
|
||||
runtests(*sys.argv[1:])
|
|
@ -28,11 +28,11 @@ zip_safe = False
|
|||
python_requires = >=3.5
|
||||
install_requires =
|
||||
# Essential packages
|
||||
six
|
||||
django>=2.2
|
||||
pygments>=1.6
|
||||
django-staticinline>=1.0
|
||||
django-csp>=3.3
|
||||
dj_database_url==0.5.0
|
||||
|
||||
# Additional Lexer
|
||||
jsx-lexer==0.0.8
|
||||
|
|
Loading…
Reference in a new issue