mirror of
https://github.com/Hopiu/django-fobi.git
synced 2026-03-16 22:10:28 +00:00
Blackify and isortify
This commit is contained in:
parent
fb3f227965
commit
bb7eb31528
746 changed files with 15635 additions and 14187 deletions
433
docs/conf.py
433
docs/conf.py
|
|
@ -17,196 +17,187 @@ import os
|
|||
# If extensions (or modules to document with autodoc) are in another directory,
|
||||
# add these directories to sys.path here. If the directory is relative to the
|
||||
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
||||
#sys.path.insert(0, os.path.abspath('.'))
|
||||
sys.path.insert(0, os.path.abspath('../src'))
|
||||
sys.path.insert(0, os.path.abspath('../examples'))
|
||||
sys.path.insert(0, os.path.abspath('../examples/simple'))
|
||||
# sys.path.insert(0, os.path.abspath('.'))
|
||||
sys.path.insert(0, os.path.abspath("../src"))
|
||||
sys.path.insert(0, os.path.abspath("../examples"))
|
||||
sys.path.insert(0, os.path.abspath("../examples/simple"))
|
||||
|
||||
from django_nine.versions import DJANGO_GTE_3_0
|
||||
|
||||
import django
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'simple.settings.docs')
|
||||
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "simple.settings.docs")
|
||||
django.setup()
|
||||
|
||||
try:
|
||||
import fobi
|
||||
|
||||
version = fobi.__version__
|
||||
project = fobi.__title__
|
||||
copyright = fobi.__copyright__
|
||||
except ImportError as err:
|
||||
version = '0.1'
|
||||
project = u'django-fobi'
|
||||
copyright = u'2014-2018, Artur Barseghyan <artur.barseghyan@gmail.com>'
|
||||
version = "0.1"
|
||||
project = "django-fobi"
|
||||
copyright = "2014-2018, Artur Barseghyan <artur.barseghyan@gmail.com>"
|
||||
|
||||
try:
|
||||
from simple.settings import docs as docs_settings
|
||||
except Exception as e:
|
||||
PROJECT_DIR = lambda base : os.path.abspath(os.path.join(os.path.dirname(__file__), base).replace('\\','/'))
|
||||
PROJECT_DIR = lambda base: os.path.abspath(
|
||||
os.path.join(os.path.dirname(__file__), base).replace("\\", "/")
|
||||
)
|
||||
gettext = lambda s: s
|
||||
|
||||
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
||||
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
|
||||
|
||||
class DocsSettings(object):
|
||||
"""
|
||||
"""
|
||||
""" """
|
||||
|
||||
INSTALLED_APPS = (
|
||||
# Admin dashboard
|
||||
'admin_tools',
|
||||
'admin_tools.menu',
|
||||
'admin_tools.dashboard',
|
||||
|
||||
"admin_tools",
|
||||
"admin_tools.menu",
|
||||
"admin_tools.dashboard",
|
||||
# Django core and contrib apps
|
||||
'django.contrib.auth',
|
||||
'django.contrib.contenttypes',
|
||||
'django.contrib.sessions',
|
||||
'django.contrib.sites',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
'django.contrib.admin',
|
||||
'django.contrib.sitemaps',
|
||||
|
||||
"django.contrib.auth",
|
||||
"django.contrib.contenttypes",
|
||||
"django.contrib.sessions",
|
||||
"django.contrib.sites",
|
||||
"django.contrib.messages",
|
||||
"django.contrib.staticfiles",
|
||||
"django.contrib.admin",
|
||||
"django.contrib.sitemaps",
|
||||
# Third party apps used in the project
|
||||
'easy_thumbnails', # Thumbnailer
|
||||
"easy_thumbnails", # Thumbnailer
|
||||
# Auth views and registration app
|
||||
'django_registration' if DJANGO_GTE_3_0 else 'registration',
|
||||
|
||||
"django_registration" if DJANGO_GTE_3_0 else "registration",
|
||||
# *****************************************************************
|
||||
# *****************************************************************
|
||||
# **************************** Fobi core **************************
|
||||
# *****************************************************************
|
||||
# *****************************************************************
|
||||
'fobi',
|
||||
|
||||
"fobi",
|
||||
# *****************************************************************
|
||||
# *****************************************************************
|
||||
# ************************* Fobi form elements ********************
|
||||
# *****************************************************************
|
||||
# *****************************************************************
|
||||
|
||||
# *****************************************************************
|
||||
# **************************** Form fields ************************
|
||||
# *****************************************************************
|
||||
#'fobi.contrib.plugins.form_elements.fields.birthday',
|
||||
'fobi.contrib.plugins.form_elements.fields.boolean',
|
||||
'fobi.contrib.plugins.form_elements.fields.checkbox_select_multiple',
|
||||
'fobi.contrib.plugins.form_elements.fields.date',
|
||||
'fobi.contrib.plugins.form_elements.fields.date_drop_down',
|
||||
'fobi.contrib.plugins.form_elements.fields.datetime',
|
||||
'fobi.contrib.plugins.form_elements.fields.decimal',
|
||||
'fobi.contrib.plugins.form_elements.fields.email',
|
||||
'fobi.contrib.plugins.form_elements.fields.file',
|
||||
'fobi.contrib.plugins.form_elements.fields.float',
|
||||
'fobi.contrib.plugins.form_elements.fields.hidden',
|
||||
"fobi.contrib.plugins.form_elements.fields.boolean",
|
||||
"fobi.contrib.plugins.form_elements.fields.checkbox_select_multiple",
|
||||
"fobi.contrib.plugins.form_elements.fields.date",
|
||||
"fobi.contrib.plugins.form_elements.fields.date_drop_down",
|
||||
"fobi.contrib.plugins.form_elements.fields.datetime",
|
||||
"fobi.contrib.plugins.form_elements.fields.decimal",
|
||||
"fobi.contrib.plugins.form_elements.fields.email",
|
||||
"fobi.contrib.plugins.form_elements.fields.file",
|
||||
"fobi.contrib.plugins.form_elements.fields.float",
|
||||
"fobi.contrib.plugins.form_elements.fields.hidden",
|
||||
# 'fobi.contrib.plugins.form_elements.fields.hidden_model_object',
|
||||
'fobi.contrib.plugins.form_elements.fields.input',
|
||||
'fobi.contrib.plugins.form_elements.fields.integer',
|
||||
'fobi.contrib.plugins.form_elements.fields.ip_address',
|
||||
'fobi.contrib.plugins.form_elements.fields.null_boolean',
|
||||
'fobi.contrib.plugins.form_elements.fields.password',
|
||||
'fobi.contrib.plugins.form_elements.fields.radio',
|
||||
'fobi.contrib.plugins.form_elements.fields.regex',
|
||||
'fobi.contrib.plugins.form_elements.fields.select',
|
||||
'fobi.contrib.plugins.form_elements.fields.select_model_object',
|
||||
'fobi.contrib.plugins.form_elements.fields.select_multiple',
|
||||
'fobi.contrib.plugins.form_elements.fields.select_multiple_model_objects',
|
||||
'fobi.contrib.plugins.form_elements.fields.slug',
|
||||
'fobi.contrib.plugins.form_elements.fields.text',
|
||||
'fobi.contrib.plugins.form_elements.fields.textarea',
|
||||
'fobi.contrib.plugins.form_elements.fields.time',
|
||||
'fobi.contrib.plugins.form_elements.fields.url',
|
||||
|
||||
"fobi.contrib.plugins.form_elements.fields.input",
|
||||
"fobi.contrib.plugins.form_elements.fields.integer",
|
||||
"fobi.contrib.plugins.form_elements.fields.ip_address",
|
||||
"fobi.contrib.plugins.form_elements.fields.null_boolean",
|
||||
"fobi.contrib.plugins.form_elements.fields.password",
|
||||
"fobi.contrib.plugins.form_elements.fields.radio",
|
||||
"fobi.contrib.plugins.form_elements.fields.regex",
|
||||
"fobi.contrib.plugins.form_elements.fields.select",
|
||||
"fobi.contrib.plugins.form_elements.fields.select_model_object",
|
||||
"fobi.contrib.plugins.form_elements.fields.select_multiple",
|
||||
"fobi.contrib.plugins.form_elements.fields.select_multiple_model_objects",
|
||||
"fobi.contrib.plugins.form_elements.fields.slug",
|
||||
"fobi.contrib.plugins.form_elements.fields.text",
|
||||
"fobi.contrib.plugins.form_elements.fields.textarea",
|
||||
"fobi.contrib.plugins.form_elements.fields.time",
|
||||
"fobi.contrib.plugins.form_elements.fields.url",
|
||||
# *****************************************************************
|
||||
# ************************ Security elements **********************
|
||||
# *****************************************************************
|
||||
'fobi.contrib.plugins.form_elements.security.honeypot',
|
||||
|
||||
"fobi.contrib.plugins.form_elements.security.honeypot",
|
||||
# *****************************************************************
|
||||
# ************************* Testing elements **********************
|
||||
# *****************************************************************
|
||||
'fobi.contrib.plugins.form_elements.test.dummy',
|
||||
|
||||
"fobi.contrib.plugins.form_elements.test.dummy",
|
||||
# *****************************************************************
|
||||
# ************************* Content elements **********************
|
||||
# *****************************************************************
|
||||
'fobi.contrib.plugins.form_elements.content.content_image',
|
||||
'fobi.contrib.plugins.form_elements.content.content_text',
|
||||
'fobi.contrib.plugins.form_elements.content.content_video',
|
||||
|
||||
"fobi.contrib.plugins.form_elements.content.content_image",
|
||||
"fobi.contrib.plugins.form_elements.content.content_text",
|
||||
"fobi.contrib.plugins.form_elements.content.content_video",
|
||||
# *****************************************************************
|
||||
# *****************************************************************
|
||||
# ************************* Fobi form handlers ********************
|
||||
# *****************************************************************
|
||||
# *****************************************************************
|
||||
'fobi.contrib.plugins.form_handlers.db_store',
|
||||
'fobi.contrib.plugins.form_handlers.http_repost',
|
||||
'fobi.contrib.plugins.form_handlers.mail',
|
||||
|
||||
"fobi.contrib.plugins.form_handlers.db_store",
|
||||
"fobi.contrib.plugins.form_handlers.http_repost",
|
||||
"fobi.contrib.plugins.form_handlers.mail",
|
||||
# *****************************************************************
|
||||
# *****************************************************************
|
||||
# ************************** Fobi themes **************************
|
||||
# *****************************************************************
|
||||
# *****************************************************************
|
||||
|
||||
# *****************************************************************
|
||||
# ************************ Bootstrap 3 theme **********************
|
||||
# *****************************************************************
|
||||
'fobi.contrib.themes.bootstrap3', # Bootstrap 3 theme
|
||||
"fobi.contrib.themes.bootstrap3", # Bootstrap 3 theme
|
||||
# DateTime widget
|
||||
'fobi.contrib.themes.bootstrap3.widgets.form_elements.datetime_bootstrap3_widget',
|
||||
'fobi.contrib.themes.bootstrap3.widgets.form_elements.date_bootstrap3_widget',
|
||||
|
||||
"fobi.contrib.themes.bootstrap3.widgets.form_elements.datetime_bootstrap3_widget",
|
||||
"fobi.contrib.themes.bootstrap3.widgets.form_elements.date_bootstrap3_widget",
|
||||
# *****************************************************************
|
||||
# ************************ Foundation 5 theme *********************
|
||||
# *****************************************************************
|
||||
'fobi.contrib.themes.foundation5', # Foundation 5 theme
|
||||
'fobi.contrib.themes.foundation5.widgets.form_handlers.db_store_foundation5_widget',
|
||||
|
||||
"fobi.contrib.themes.foundation5", # Foundation 5 theme
|
||||
"fobi.contrib.themes.foundation5.widgets.form_handlers.db_store_foundation5_widget",
|
||||
# *****************************************************************
|
||||
# **************************** Simple theme ***********************
|
||||
# *****************************************************************
|
||||
'fobi.contrib.themes.simple', # Simple theme
|
||||
"fobi.contrib.themes.simple", # Simple theme
|
||||
)
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.sqlite3',
|
||||
'NAME': PROJECT_DIR('../db/example.db'),
|
||||
"default": {
|
||||
"ENGINE": "django.db.backends.sqlite3",
|
||||
"NAME": PROJECT_DIR("../db/example.db"),
|
||||
}
|
||||
}
|
||||
MEDIA_ROOT = PROJECT_DIR(os.path.join('..', 'media'))
|
||||
MEDIA_URL = '/media/'
|
||||
MEDIA_ROOT = PROJECT_DIR(os.path.join("..", "media"))
|
||||
MEDIA_URL = "/media/"
|
||||
MIDDLEWARE_CLASSES = (
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
"django.contrib.sessions.middleware.SessionMiddleware",
|
||||
# 'localeurl.middleware.LocaleURLMiddleware',
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
'django.middleware.csrf.CsrfViewMiddleware',
|
||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||
'django.contrib.messages.middleware.MessageMiddleware',
|
||||
"django.middleware.common.CommonMiddleware",
|
||||
"django.middleware.csrf.CsrfViewMiddleware",
|
||||
"django.contrib.auth.middleware.AuthenticationMiddleware",
|
||||
"django.contrib.messages.middleware.MessageMiddleware",
|
||||
# Uncomment the next line for simple clickjacking protection:
|
||||
# 'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||
)
|
||||
ROOT_URLCONF = 'urls'
|
||||
SECRET_KEY = '97818c*w97Zi8a-m^1coRRrmurMI6+q5_kyn*)s@(*_Pk6q423'
|
||||
ROOT_URLCONF = "urls"
|
||||
SECRET_KEY = "97818c*w97Zi8a-m^1coRRrmurMI6+q5_kyn*)s@(*_Pk6q423"
|
||||
SITE_ID = 1
|
||||
STATICFILES_DIRS = (
|
||||
PROJECT_DIR(os.path.join('..', 'media', 'static')),
|
||||
)
|
||||
STATICFILES_DIRS = (PROJECT_DIR(os.path.join("..", "media", "static")),)
|
||||
STATICFILES_FINDERS = (
|
||||
'django.contrib.staticfiles.finders.FileSystemFinder',
|
||||
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
|
||||
"django.contrib.staticfiles.finders.FileSystemFinder",
|
||||
"django.contrib.staticfiles.finders.AppDirectoriesFinder",
|
||||
#'django.contrib.staticfiles.finders.DefaultStorageFinder',
|
||||
)
|
||||
STATIC_URL = '/static/'
|
||||
STATIC_ROOT = PROJECT_DIR(os.path.join('..', 'static'))
|
||||
STATIC_URL = "/static/"
|
||||
STATIC_ROOT = PROJECT_DIR(os.path.join("..", "static"))
|
||||
|
||||
TEMPLATES = [
|
||||
{
|
||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||
"BACKEND": "django.template.backends.django.DjangoTemplates",
|
||||
#'APP_DIRS': True,
|
||||
'DIRS': [PROJECT_DIR('templates'),],
|
||||
'OPTIONS': {
|
||||
'context_processors': [
|
||||
"DIRS": [
|
||||
PROJECT_DIR("templates"),
|
||||
],
|
||||
"OPTIONS": {
|
||||
"context_processors": [
|
||||
"django.contrib.auth.context_processors.auth",
|
||||
"django.core.context_processors.debug",
|
||||
"django.core.context_processors.i18n",
|
||||
|
|
@ -215,17 +206,17 @@ except Exception as e:
|
|||
"django.core.context_processors.tz",
|
||||
"django.contrib.messages.context_processors.messages",
|
||||
"django.core.context_processors.request",
|
||||
"fobi.context_processors.theme", # Important!
|
||||
"fobi.context_processors.dynamic_values", # Optional
|
||||
"fobi.context_processors.theme", # Important!
|
||||
"fobi.context_processors.dynamic_values", # Optional
|
||||
],
|
||||
'loaders': [
|
||||
'django.template.loaders.filesystem.Loader',
|
||||
'django.template.loaders.app_directories.Loader',
|
||||
'django.template.loaders.eggs.Loader',
|
||||
'admin_tools.template_loaders.Loader',
|
||||
"loaders": [
|
||||
"django.template.loaders.filesystem.Loader",
|
||||
"django.template.loaders.app_directories.Loader",
|
||||
"django.template.loaders.eggs.Loader",
|
||||
"admin_tools.template_loaders.Loader",
|
||||
],
|
||||
'debug': False,
|
||||
}
|
||||
"debug": False,
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
|
|
@ -239,231 +230,232 @@ from django.conf import settings
|
|||
if not settings.configured:
|
||||
INSTALLED_APPS = list(docs_settings.INSTALLED_APPS)
|
||||
|
||||
INSTALLED_APPS.append('mptt')
|
||||
INSTALLED_APPS.append('cms')
|
||||
INSTALLED_APPS.append('fobi.contrib.apps.djangocms_integration')
|
||||
INSTALLED_APPS.append('feincms')
|
||||
INSTALLED_APPS.append('fobi.contrib.apps.feincms_integration')
|
||||
INSTALLED_APPS.append('captcha')
|
||||
INSTALLED_APPS.append('fobi.contrib.plugins.form_elements.security.captcha')
|
||||
INSTALLED_APPS.append("mptt")
|
||||
INSTALLED_APPS.append("cms")
|
||||
INSTALLED_APPS.append("fobi.contrib.apps.djangocms_integration")
|
||||
INSTALLED_APPS.append("feincms")
|
||||
INSTALLED_APPS.append("fobi.contrib.apps.feincms_integration")
|
||||
INSTALLED_APPS.append("captcha")
|
||||
INSTALLED_APPS.append("fobi.contrib.plugins.form_elements.security.captcha")
|
||||
|
||||
if 'foo' in INSTALLED_APPS:
|
||||
INSTALLED_APPS.remove('foo')
|
||||
if "foo" in INSTALLED_APPS:
|
||||
INSTALLED_APPS.remove("foo")
|
||||
|
||||
django_configuration = {
|
||||
'DATABASES': docs_settings.DATABASES,
|
||||
'INSTALLED_APPS': INSTALLED_APPS,
|
||||
'MEDIA_ROOT': docs_settings.MEDIA_ROOT,
|
||||
'MEDIA_URL': docs_settings.MEDIA_URL,
|
||||
'MIDDLEWARE_CLASSES': docs_settings.MIDDLEWARE_CLASSES,
|
||||
'ROOT_URLCONF': docs_settings.ROOT_URLCONF,
|
||||
'SECRET_KEY': docs_settings.SECRET_KEY,
|
||||
'SITE_ID': docs_settings.SITE_ID,
|
||||
'STATICFILES_DIRS': docs_settings.STATICFILES_DIRS,
|
||||
'STATICFILES_FINDERS': docs_settings.STATICFILES_FINDERS,
|
||||
'STATIC_URL': docs_settings.STATIC_URL,
|
||||
'STATIC_ROOT': docs_settings.STATIC_ROOT,
|
||||
"DATABASES": docs_settings.DATABASES,
|
||||
"INSTALLED_APPS": INSTALLED_APPS,
|
||||
"MEDIA_ROOT": docs_settings.MEDIA_ROOT,
|
||||
"MEDIA_URL": docs_settings.MEDIA_URL,
|
||||
"MIDDLEWARE_CLASSES": docs_settings.MIDDLEWARE_CLASSES,
|
||||
"ROOT_URLCONF": docs_settings.ROOT_URLCONF,
|
||||
"SECRET_KEY": docs_settings.SECRET_KEY,
|
||||
"SITE_ID": docs_settings.SITE_ID,
|
||||
"STATICFILES_DIRS": docs_settings.STATICFILES_DIRS,
|
||||
"STATICFILES_FINDERS": docs_settings.STATICFILES_FINDERS,
|
||||
"STATIC_URL": docs_settings.STATIC_URL,
|
||||
"STATIC_ROOT": docs_settings.STATIC_ROOT,
|
||||
}
|
||||
|
||||
django_configuration.update({
|
||||
'TEMPLATES': docs_settings.TEMPLATES
|
||||
})
|
||||
django_configuration.update({"TEMPLATES": docs_settings.TEMPLATES})
|
||||
|
||||
settings.configure(**django_configuration)
|
||||
|
||||
# -- General configuration -----------------------------------------------------
|
||||
|
||||
# If your documentation needs a minimal Sphinx version, state it here.
|
||||
#needs_sphinx = '1.0'
|
||||
# needs_sphinx = '1.0'
|
||||
|
||||
# Add any Sphinx extension module names here, as strings. They can be extensions
|
||||
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
|
||||
extensions = [
|
||||
'sphinx.ext.autodoc',
|
||||
'sphinx.ext.viewcode',
|
||||
"sphinx.ext.autodoc",
|
||||
"sphinx.ext.viewcode",
|
||||
# 'rst2pdf.pdfbuilder',
|
||||
]
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
templates_path = ['_templates']
|
||||
templates_path = ["_templates"]
|
||||
|
||||
# The suffix of source filenames.
|
||||
source_suffix = '.rst'
|
||||
source_suffix = ".rst"
|
||||
|
||||
# The encoding of source files.
|
||||
#source_encoding = 'utf-8-sig'
|
||||
# source_encoding = 'utf-8-sig'
|
||||
|
||||
# The master toctree document.
|
||||
master_doc = 'index'
|
||||
master_doc = "index"
|
||||
|
||||
# General information about the project.
|
||||
#project = u'django-fobi'
|
||||
#copyright = u'2014, Artur Barseghyan <artur.barseghyan@gmail.com>'
|
||||
# project = u'django-fobi'
|
||||
# copyright = u'2014, Artur Barseghyan <artur.barseghyan@gmail.com>'
|
||||
|
||||
# The version info for the project you're documenting, acts as replacement for
|
||||
# |version| and |release|, also used in various other places throughout the
|
||||
# built documents.
|
||||
#
|
||||
# The short X.Y version.
|
||||
#version = '0.1'
|
||||
# version = '0.1'
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
#release = '0.1'
|
||||
# release = '0.1'
|
||||
release = version
|
||||
|
||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||
# for a list of supported languages.
|
||||
#language = None
|
||||
# language = None
|
||||
|
||||
# There are two options for replacing |today|: either, you set today to some
|
||||
# non-false value, then it is used:
|
||||
#today = ''
|
||||
# today = ''
|
||||
# Else, today_fmt is used as the format for a strftime call.
|
||||
#today_fmt = '%B %d, %Y'
|
||||
# today_fmt = '%B %d, %Y'
|
||||
|
||||
# List of patterns, relative to source directory, that match files and
|
||||
# directories to ignore when looking for source files.
|
||||
exclude_patterns = ['_build']
|
||||
exclude_patterns = ["_build"]
|
||||
|
||||
# The reST default role (used for this markup: `text`) to use for all documents.
|
||||
#default_role = None
|
||||
# default_role = None
|
||||
|
||||
# If true, '()' will be appended to :func: etc. cross-reference text.
|
||||
#add_function_parentheses = True
|
||||
# add_function_parentheses = True
|
||||
|
||||
# If true, the current module name will be prepended to all description
|
||||
# unit titles (such as .. function::).
|
||||
#add_module_names = True
|
||||
# add_module_names = True
|
||||
|
||||
# If true, sectionauthor and moduleauthor directives will be shown in the
|
||||
# output. They are ignored by default.
|
||||
#show_authors = False
|
||||
# show_authors = False
|
||||
|
||||
# The name of the Pygments (syntax highlighting) style to use.
|
||||
pygments_style = 'sphinx'
|
||||
pygments_style = "sphinx"
|
||||
|
||||
# A list of ignored prefixes for module index sorting.
|
||||
#modindex_common_prefix = []
|
||||
# modindex_common_prefix = []
|
||||
|
||||
|
||||
# -- Options for HTML output ---------------------------------------------------
|
||||
|
||||
# The theme to use for HTML and HTML Help pages. See the documentation for
|
||||
# a list of builtin themes.
|
||||
html_theme = 'default'
|
||||
html_theme = "default"
|
||||
|
||||
# Theme options are theme-specific and customize the look and feel of a theme
|
||||
# further. For a list of options available for each theme, see the
|
||||
# documentation.
|
||||
#html_theme_options = {}
|
||||
# html_theme_options = {}
|
||||
|
||||
# Add any paths that contain custom themes here, relative to this directory.
|
||||
#html_theme_path = []
|
||||
# html_theme_path = []
|
||||
|
||||
# The name for this set of Sphinx documents. If None, it defaults to
|
||||
# "<project> v<release> documentation".
|
||||
#html_title = None
|
||||
# html_title = None
|
||||
|
||||
# A shorter title for the navigation bar. Default is the same as html_title.
|
||||
#html_short_title = None
|
||||
# html_short_title = None
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top
|
||||
# of the sidebar.
|
||||
#html_logo = None
|
||||
# html_logo = None
|
||||
|
||||
# The name of an image file (within the static path) to use as favicon of the
|
||||
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
|
||||
# pixels large.
|
||||
#html_favicon = None
|
||||
# html_favicon = None
|
||||
|
||||
# Add any paths that contain custom static files (such as style sheets) here,
|
||||
# relative to this directory. They are copied after the builtin static files,
|
||||
# so a file named "default.css" will overwrite the builtin "default.css".
|
||||
html_static_path = ['_static']
|
||||
html_static_path = ["_static"]
|
||||
|
||||
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
|
||||
# using the given strftime format.
|
||||
#html_last_updated_fmt = '%b %d, %Y'
|
||||
# html_last_updated_fmt = '%b %d, %Y'
|
||||
|
||||
# If true, SmartyPants will be used to convert quotes and dashes to
|
||||
# typographically correct entities.
|
||||
#html_use_smartypants = True
|
||||
# html_use_smartypants = True
|
||||
|
||||
# Custom sidebar templates, maps document names to template names.
|
||||
#html_sidebars = {}
|
||||
# html_sidebars = {}
|
||||
|
||||
# Additional templates that should be rendered to pages, maps page names to
|
||||
# template names.
|
||||
#html_additional_pages = {}
|
||||
# html_additional_pages = {}
|
||||
|
||||
# If false, no module index is generated.
|
||||
#html_domain_indices = True
|
||||
# html_domain_indices = True
|
||||
|
||||
# If false, no index is generated.
|
||||
#html_use_index = True
|
||||
# html_use_index = True
|
||||
|
||||
# If true, the index is split into individual pages for each letter.
|
||||
#html_split_index = False
|
||||
# html_split_index = False
|
||||
|
||||
# If true, links to the reST sources are added to the pages.
|
||||
#html_show_sourcelink = True
|
||||
# html_show_sourcelink = True
|
||||
|
||||
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
|
||||
#html_show_sphinx = True
|
||||
# html_show_sphinx = True
|
||||
|
||||
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
|
||||
#html_show_copyright = True
|
||||
# html_show_copyright = True
|
||||
|
||||
# If true, an OpenSearch description file will be output, and all pages will
|
||||
# contain a <link> tag referring to it. The value of this option must be the
|
||||
# base URL from which the finished HTML is served.
|
||||
#html_use_opensearch = ''
|
||||
# html_use_opensearch = ''
|
||||
|
||||
# This is the file name suffix for HTML files (e.g. ".xhtml").
|
||||
#html_file_suffix = None
|
||||
# html_file_suffix = None
|
||||
|
||||
# Output file base name for HTML help builder.
|
||||
htmlhelp_basename = 'django-fobidoc'
|
||||
htmlhelp_basename = "django-fobidoc"
|
||||
|
||||
|
||||
# -- Options for LaTeX output --------------------------------------------------
|
||||
|
||||
latex_elements = {
|
||||
# The paper size ('letterpaper' or 'a4paper').
|
||||
#'papersize': 'letterpaper',
|
||||
|
||||
# The font size ('10pt', '11pt' or '12pt').
|
||||
#'pointsize': '10pt',
|
||||
|
||||
# Additional stuff for the LaTeX preamble.
|
||||
#'preamble': '',
|
||||
# The paper size ('letterpaper' or 'a4paper').
|
||||
#'papersize': 'letterpaper',
|
||||
# The font size ('10pt', '11pt' or '12pt').
|
||||
#'pointsize': '10pt',
|
||||
# Additional stuff for the LaTeX preamble.
|
||||
#'preamble': '',
|
||||
}
|
||||
|
||||
# Grouping the document tree into LaTeX files. List of tuples
|
||||
# (source start file, target name, title, author, documentclass [howto/manual]).
|
||||
latex_documents = [
|
||||
('index', 'django-fobi.tex', u'django-fobi Documentation',
|
||||
u'Artur Barseghyan \\textless{}artur.barseghyan@gmail.com\\textgreater{}', 'manual'),
|
||||
(
|
||||
"index",
|
||||
"django-fobi.tex",
|
||||
"django-fobi Documentation",
|
||||
"Artur Barseghyan \\textless{}artur.barseghyan@gmail.com\\textgreater{}",
|
||||
"manual",
|
||||
),
|
||||
]
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top of
|
||||
# the title page.
|
||||
#latex_logo = None
|
||||
# latex_logo = None
|
||||
|
||||
# For "manual" documents, if this is true, then toplevel headings are parts,
|
||||
# not chapters.
|
||||
#latex_use_parts = False
|
||||
# latex_use_parts = False
|
||||
|
||||
# If true, show page references after internal links.
|
||||
#latex_show_pagerefs = False
|
||||
# latex_show_pagerefs = False
|
||||
|
||||
# If true, show URL addresses after external links.
|
||||
#latex_show_urls = False
|
||||
# latex_show_urls = False
|
||||
|
||||
# Documents to append as an appendix to all manuals.
|
||||
#latex_appendices = []
|
||||
# latex_appendices = []
|
||||
|
||||
# If false, no module index is generated.
|
||||
#latex_domain_indices = True
|
||||
# latex_domain_indices = True
|
||||
|
||||
|
||||
# -- Options for manual page output --------------------------------------------
|
||||
|
|
@ -471,12 +463,17 @@ latex_documents = [
|
|||
# One entry per manual page. List of tuples
|
||||
# (source start file, name, description, authors, manual section).
|
||||
man_pages = [
|
||||
('index', 'django-fobi', u'django-fobi Documentation',
|
||||
[u'Artur Barseghyan <artur.barseghyan@gmail.com>'], 1)
|
||||
(
|
||||
"index",
|
||||
"django-fobi",
|
||||
"django-fobi Documentation",
|
||||
["Artur Barseghyan <artur.barseghyan@gmail.com>"],
|
||||
1,
|
||||
)
|
||||
]
|
||||
|
||||
# If true, show URL addresses after external links.
|
||||
#man_show_urls = False
|
||||
# man_show_urls = False
|
||||
|
||||
|
||||
# -- Options for Texinfo output ------------------------------------------------
|
||||
|
|
@ -485,62 +482,68 @@ man_pages = [
|
|||
# (source start file, target name, title, author,
|
||||
# dir menu entry, description, category)
|
||||
texinfo_documents = [
|
||||
('index', 'django-fobi', u'django-fobi Documentation',
|
||||
u'Artur Barseghyan <artur.barseghyan@gmail.com>', 'django-fobi', 'One line description of project.',
|
||||
'Miscellaneous'),
|
||||
(
|
||||
"index",
|
||||
"django-fobi",
|
||||
"django-fobi Documentation",
|
||||
"Artur Barseghyan <artur.barseghyan@gmail.com>",
|
||||
"django-fobi",
|
||||
"One line description of project.",
|
||||
"Miscellaneous",
|
||||
),
|
||||
]
|
||||
|
||||
# Documents to append as an appendix to all manuals.
|
||||
#texinfo_appendices = []
|
||||
# texinfo_appendices = []
|
||||
|
||||
# If false, no module index is generated.
|
||||
#texinfo_domain_indices = True
|
||||
# texinfo_domain_indices = True
|
||||
|
||||
# How to display URL addresses: 'footnote', 'no', or 'inline'.
|
||||
#texinfo_show_urls = 'footnote'
|
||||
# texinfo_show_urls = 'footnote'
|
||||
|
||||
|
||||
# -- Options for Epub output ---------------------------------------------------
|
||||
|
||||
# Bibliographic Dublin Core info.
|
||||
epub_title = u'django-fobi'
|
||||
epub_author = u'Artur Barseghyan <artur.barseghyan@gmail.com>'
|
||||
epub_publisher = u'Artur Barseghyan <artur.barseghyan@gmail.com>'
|
||||
epub_copyright = u'2014, Artur Barseghyan <artur.barseghyan@gmail.com>'
|
||||
epub_title = "django-fobi"
|
||||
epub_author = "Artur Barseghyan <artur.barseghyan@gmail.com>"
|
||||
epub_publisher = "Artur Barseghyan <artur.barseghyan@gmail.com>"
|
||||
epub_copyright = "2014, Artur Barseghyan <artur.barseghyan@gmail.com>"
|
||||
|
||||
# The language of the text. It defaults to the language option
|
||||
# or en if the language is not set.
|
||||
#epub_language = ''
|
||||
# epub_language = ''
|
||||
|
||||
# The scheme of the identifier. Typical schemes are ISBN or URL.
|
||||
#epub_scheme = ''
|
||||
# epub_scheme = ''
|
||||
|
||||
# The unique identifier of the text. This can be a ISBN number
|
||||
# or the project homepage.
|
||||
#epub_identifier = ''
|
||||
# epub_identifier = ''
|
||||
|
||||
# A unique identification for the text.
|
||||
#epub_uid = ''
|
||||
# epub_uid = ''
|
||||
|
||||
# A tuple containing the cover image and cover page html template filenames.
|
||||
#epub_cover = ()
|
||||
# epub_cover = ()
|
||||
|
||||
# HTML files that should be inserted before the pages created by sphinx.
|
||||
# The format is a list of tuples containing the path and title.
|
||||
#epub_pre_files = []
|
||||
# epub_pre_files = []
|
||||
|
||||
# HTML files shat should be inserted after the pages created by sphinx.
|
||||
# The format is a list of tuples containing the path and title.
|
||||
#epub_post_files = []
|
||||
# epub_post_files = []
|
||||
|
||||
# A list of files that should not be packed into the epub file.
|
||||
#epub_exclude_files = []
|
||||
# epub_exclude_files = []
|
||||
|
||||
# The depth of the table of contents in toc.ncx.
|
||||
#epub_tocdepth = 3
|
||||
# epub_tocdepth = 3
|
||||
|
||||
# Allow duplicate toc entries.
|
||||
#epub_tocdup = True
|
||||
# epub_tocdup = True
|
||||
|
||||
# -- Options for PDF output ---------------------------------------------------
|
||||
|
||||
|
|
|
|||
97
examples/mezzanine_example/fabfile.py
vendored
97
examples/mezzanine_example/fabfile.py
vendored
|
|
@ -99,6 +99,7 @@ templates = {
|
|||
# Context for virtualenv and project #
|
||||
######################################
|
||||
|
||||
|
||||
@contextmanager
|
||||
def virtualenv():
|
||||
"""
|
||||
|
|
@ -152,6 +153,7 @@ def update_changed_requirements():
|
|||
# Utils and wrappers for various commands #
|
||||
###########################################
|
||||
|
||||
|
||||
def _print(output):
|
||||
print()
|
||||
print(output)
|
||||
|
|
@ -159,9 +161,11 @@ def _print(output):
|
|||
|
||||
|
||||
def print_command(command):
|
||||
_print(blue("$ ", bold=True) +
|
||||
yellow(command, bold=True) +
|
||||
red(" ->", bold=True))
|
||||
_print(
|
||||
blue("$ ", bold=True)
|
||||
+ yellow(command, bold=True)
|
||||
+ red(" ->", bold=True)
|
||||
)
|
||||
|
||||
|
||||
@task
|
||||
|
|
@ -192,6 +196,7 @@ def log_call(func):
|
|||
header = "-" * len(func.__name__)
|
||||
_print(green("\n".join([header, func.__name__, header]), bold=True))
|
||||
return func(*args, **kawrgs)
|
||||
|
||||
return logged
|
||||
|
||||
|
||||
|
|
@ -308,7 +313,7 @@ def python(code, show=True):
|
|||
"""
|
||||
Runs Python code in the project's virtual environment, with Django loaded.
|
||||
"""
|
||||
setup = "import os; os.environ[\'DJANGO_SETTINGS_MODULE\']=\'settings\';"
|
||||
setup = "import os; os.environ['DJANGO_SETTINGS_MODULE']='settings';"
|
||||
full_code = 'python -c "%s%s"' % (setup, code.replace("`", "\\\`"))
|
||||
with project():
|
||||
result = run(full_code, show=False)
|
||||
|
|
@ -321,8 +326,10 @@ def static():
|
|||
"""
|
||||
Returns the live STATIC_ROOT directory.
|
||||
"""
|
||||
return python("from django.conf import settings;"
|
||||
"print settings.STATIC_ROOT", show=False).split("\n")[-1]
|
||||
return python(
|
||||
"from django.conf import settings;" "print settings.STATIC_ROOT",
|
||||
show=False,
|
||||
).split("\n")[-1]
|
||||
|
||||
|
||||
@task
|
||||
|
|
@ -337,6 +344,7 @@ def manage(command):
|
|||
# Install and configure #
|
||||
#########################
|
||||
|
||||
|
||||
@task
|
||||
@log_call
|
||||
def install():
|
||||
|
|
@ -349,8 +357,10 @@ def install():
|
|||
sudo("update-locale %s" % locale)
|
||||
run("exit")
|
||||
sudo("apt-get update -y -q")
|
||||
apt("nginx libjpeg-dev python-dev python-setuptools git-core "
|
||||
"postgresql libpq-dev memcached supervisor")
|
||||
apt(
|
||||
"nginx libjpeg-dev python-dev python-setuptools git-core "
|
||||
"postgresql libpq-dev memcached supervisor"
|
||||
)
|
||||
sudo("easy_install pip")
|
||||
sudo("pip install virtualenv mercurial")
|
||||
|
||||
|
|
@ -368,9 +378,10 @@ def create():
|
|||
# Create virtualenv
|
||||
with cd(env.venv_home):
|
||||
if exists(env.proj_name):
|
||||
prompt = input("\nVirtualenv exists: %s"
|
||||
"\nWould you like to replace it? (yes/no) "
|
||||
% env.proj_name)
|
||||
prompt = input(
|
||||
"\nVirtualenv exists: %s"
|
||||
"\nWould you like to replace it? (yes/no) " % env.proj_name
|
||||
)
|
||||
if prompt.lower() != "yes":
|
||||
print("\nAborting!")
|
||||
return False
|
||||
|
|
@ -381,14 +392,16 @@ def create():
|
|||
|
||||
# Create DB and DB user.
|
||||
pw = db_pass()
|
||||
user_sql_args = (env.proj_name, pw.replace("'", "\'"))
|
||||
user_sql_args = (env.proj_name, pw.replace("'", "'"))
|
||||
user_sql = "CREATE USER %s WITH ENCRYPTED PASSWORD '%s';" % user_sql_args
|
||||
psql(user_sql, show=False)
|
||||
shadowed = "*" * len(pw)
|
||||
print_command(user_sql.replace("'%s'" % pw, "'%s'" % shadowed))
|
||||
psql("CREATE DATABASE %s WITH OWNER %s ENCODING = 'UTF8' "
|
||||
"LC_CTYPE = '%s' LC_COLLATE = '%s' TEMPLATE template0;" %
|
||||
(env.proj_name, env.proj_name, env.locale, env.locale))
|
||||
psql(
|
||||
"CREATE DATABASE %s WITH OWNER %s ENCODING = 'UTF8' "
|
||||
"LC_CTYPE = '%s' LC_COLLATE = '%s' TEMPLATE template0;"
|
||||
% (env.proj_name, env.proj_name, env.locale, env.locale)
|
||||
)
|
||||
|
||||
# Set up SSL certificate.
|
||||
if not env.ssl_disabled:
|
||||
|
|
@ -400,12 +413,14 @@ def create():
|
|||
key_file = env.proj_name + ".key"
|
||||
if not exists(crt_file) and not exists(key_file):
|
||||
try:
|
||||
crt_local, = glob(join("deploy", "*.crt"))
|
||||
key_local, = glob(join("deploy", "*.key"))
|
||||
(crt_local,) = glob(join("deploy", "*.crt"))
|
||||
(key_local,) = glob(join("deploy", "*.key"))
|
||||
except ValueError:
|
||||
parts = (crt_file, key_file, env.domains[0])
|
||||
sudo("openssl req -new -x509 -nodes -out %s -keyout %s "
|
||||
"-subj '/CN=%s' -days 3650" % parts)
|
||||
sudo(
|
||||
"openssl req -new -x509 -nodes -out %s -keyout %s "
|
||||
"-subj '/CN=%s' -days 3650" % parts
|
||||
)
|
||||
else:
|
||||
upload_template(crt_local, crt_file, use_sudo=True)
|
||||
upload_template(key_local, key_file, use_sudo=True)
|
||||
|
|
@ -415,24 +430,32 @@ def create():
|
|||
with project():
|
||||
if env.reqs_path:
|
||||
pip("-r %s/%s" % (env.proj_path, env.reqs_path))
|
||||
pip("gunicorn setproctitle south psycopg2 "
|
||||
"django-compressor python-memcached")
|
||||
pip(
|
||||
"gunicorn setproctitle south psycopg2 "
|
||||
"django-compressor python-memcached"
|
||||
)
|
||||
manage("createdb --noinput --nodata")
|
||||
python("from django.conf import settings;"
|
||||
"from django.contrib.sites.models import Site;"
|
||||
"Site.objects.filter(id=settings.SITE_ID).update(domain='%s');"
|
||||
% env.domains[0])
|
||||
python(
|
||||
"from django.conf import settings;"
|
||||
"from django.contrib.sites.models import Site;"
|
||||
"Site.objects.filter(id=settings.SITE_ID).update(domain='%s');"
|
||||
% env.domains[0]
|
||||
)
|
||||
for domain in env.domains:
|
||||
python("from django.contrib.sites.models import Site;"
|
||||
"Site.objects.get_or_create(domain='%s');" % domain)
|
||||
python(
|
||||
"from django.contrib.sites.models import Site;"
|
||||
"Site.objects.get_or_create(domain='%s');" % domain
|
||||
)
|
||||
if env.admin_pass:
|
||||
pw = env.admin_pass
|
||||
user_py = ("from mezzanine.utils.models import get_user_model;"
|
||||
"User = get_user_model();"
|
||||
"u, _ = User.objects.get_or_create(username='admin');"
|
||||
"u.is_staff = u.is_superuser = True;"
|
||||
"u.set_password('%s');"
|
||||
"u.save();" % pw)
|
||||
user_py = (
|
||||
"from mezzanine.utils.models import get_user_model;"
|
||||
"User = get_user_model();"
|
||||
"u, _ = User.objects.get_or_create(username='admin');"
|
||||
"u.is_staff = u.is_superuser = True;"
|
||||
"u.set_password('%s');"
|
||||
"u.save();" % pw
|
||||
)
|
||||
python(user_py, show=False)
|
||||
shadowed = "*" * len(pw)
|
||||
print_command(user_py.replace("'%s'" % pw, "'%s'" % shadowed))
|
||||
|
|
@ -460,6 +483,7 @@ def remove():
|
|||
# Deployment #
|
||||
##############
|
||||
|
||||
|
||||
@task
|
||||
@log_call
|
||||
def restart():
|
||||
|
|
@ -485,9 +509,10 @@ def deploy():
|
|||
processes for the project.
|
||||
"""
|
||||
if not exists(env.venv_path):
|
||||
prompt = input("\nVirtualenv doesn't exist: %s"
|
||||
"\nWould you like to create it? (yes/no) "
|
||||
% env.proj_name)
|
||||
prompt = input(
|
||||
"\nVirtualenv doesn't exist: %s"
|
||||
"\nWould you like to create it? (yes/no) " % env.proj_name
|
||||
)
|
||||
if prompt.lower() != "yes":
|
||||
print("\nAborting!")
|
||||
return False
|
||||
|
|
|
|||
|
|
@ -1,9 +1,11 @@
|
|||
from django.core.management.base import BaseCommand
|
||||
|
||||
from fobi.tests.helpers import (
|
||||
get_or_create_admin_user, create_form_with_entries
|
||||
create_form_with_entries,
|
||||
get_or_create_admin_user,
|
||||
)
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
def handle(self, *args, **options):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -4,10 +4,10 @@ from __future__ import absolute_import, unicode_literals
|
|||
import os
|
||||
import sys
|
||||
|
||||
|
||||
# Corrects some pathing issues in various contexts, such as cron jobs,
|
||||
# and the project layout still being in Django 1.3 format.
|
||||
from settings import PROJECT_ROOT, PROJECT_DIRNAME
|
||||
from settings import PROJECT_DIRNAME, PROJECT_ROOT
|
||||
|
||||
sys.path.append(os.path.abspath(os.path.join(PROJECT_ROOT, "..")))
|
||||
|
||||
|
||||
|
|
@ -25,4 +25,5 @@ if __name__ == "__main__":
|
|||
settings_module = "%s.settings" % PROJECT_DIRNAME
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", settings_module)
|
||||
from django.core.management import execute_from_command_line
|
||||
|
||||
execute_from_command_line(sys.argv)
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
from __future__ import absolute_import, unicode_literals
|
||||
|
||||
import os
|
||||
from django_nine.versions import (
|
||||
DJANGO_GTE_1_10,
|
||||
DJANGO_GTE_1_9,
|
||||
)
|
||||
|
||||
from django_nine.versions import DJANGO_GTE_1_9, DJANGO_GTE_1_10
|
||||
|
||||
# Full filesystem path to the project.
|
||||
PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
|
||||
|
|
@ -125,9 +124,7 @@ LANGUAGE_CODE = "en"
|
|||
|
||||
# Supported languages
|
||||
_ = lambda s: s
|
||||
LANGUAGES = (
|
||||
('en', _('English')),
|
||||
)
|
||||
LANGUAGES = (("en", _("English")),)
|
||||
|
||||
# A boolean that turns on/off debug mode. When set to ``True``, stack traces
|
||||
# are displayed for error pages. Should always be set to ``False`` in
|
||||
|
|
@ -157,34 +154,32 @@ except Exception as err:
|
|||
|
||||
TEMPLATES = [
|
||||
{
|
||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||
"BACKEND": "django.template.backends.django.DjangoTemplates",
|
||||
# 'APP_DIRS': True,
|
||||
'DIRS': [os.path.join(PROJECT_ROOT, "templates")],
|
||||
'OPTIONS': {
|
||||
'context_processors': [
|
||||
"DIRS": [os.path.join(PROJECT_ROOT, "templates")],
|
||||
"OPTIONS": {
|
||||
"context_processors": [
|
||||
"django.template.context_processors.debug",
|
||||
'django.template.context_processors.request',
|
||||
"django.template.context_processors.request",
|
||||
"django.contrib.auth.context_processors.auth",
|
||||
# "django.template.context_processors.i18n",
|
||||
# "django.template.context_processors.media",
|
||||
# "django.template.context_processors.static",
|
||||
"django.template.context_processors.tz",
|
||||
"django.contrib.messages.context_processors.messages",
|
||||
|
||||
"mezzanine.conf.context_processors.settings",
|
||||
"mezzanine.pages.context_processors.page",
|
||||
|
||||
"fobi.context_processors.theme", # Important!
|
||||
"fobi.context_processors.dynamic_values", # Optional
|
||||
# "context_processors.testing", # Testing
|
||||
],
|
||||
'loaders': [
|
||||
"loaders": [
|
||||
"django.template.loaders.filesystem.Loader",
|
||||
"django.template.loaders.app_directories.Loader",
|
||||
'django.template.loaders.eggs.Loader',
|
||||
"django.template.loaders.eggs.Loader",
|
||||
],
|
||||
'debug': DEBUG_TEMPLATE,
|
||||
}
|
||||
"debug": DEBUG_TEMPLATE,
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
|
|
@ -283,109 +278,95 @@ INSTALLED_APPS = (
|
|||
"mezzanine.twitter",
|
||||
# "mezzanine.accounts",
|
||||
# "mezzanine.mobile",
|
||||
|
||||
# Third party apps used in the project
|
||||
'tinymce', # TinyMCE
|
||||
'easy_thumbnails', # Thumbnailer
|
||||
"tinymce", # TinyMCE
|
||||
"easy_thumbnails", # Thumbnailer
|
||||
# 'registration', # Auth views and registration app
|
||||
|
||||
# ***********************************************************************
|
||||
# ***********************************************************************
|
||||
# **************************** Fobi core ********************************
|
||||
# ***********************************************************************
|
||||
# ***********************************************************************
|
||||
'fobi',
|
||||
|
||||
"fobi",
|
||||
# ***********************************************************************
|
||||
# ***********************************************************************
|
||||
# ************************** Fobi themes ********************************
|
||||
# ***********************************************************************
|
||||
# ***********************************************************************
|
||||
|
||||
# ***********************************************************************
|
||||
# ************************ Bootstrap 3 theme ****************************
|
||||
# ***********************************************************************
|
||||
'fobi.contrib.themes.bootstrap3', # Bootstrap 3 theme
|
||||
|
||||
"fobi.contrib.themes.bootstrap3", # Bootstrap 3 theme
|
||||
# ***********************************************************************
|
||||
# ************************ Foundation 5 theme ***************************
|
||||
# ***********************************************************************
|
||||
'fobi.contrib.themes.foundation5', # Foundation 5 theme
|
||||
'fobi.contrib.themes.foundation5.widgets.form_handlers.db_store_foundation5_widget',
|
||||
|
||||
"fobi.contrib.themes.foundation5", # Foundation 5 theme
|
||||
"fobi.contrib.themes.foundation5.widgets.form_handlers.db_store_foundation5_widget",
|
||||
# ***********************************************************************
|
||||
# **************************** Simple theme *****************************
|
||||
# ***********************************************************************
|
||||
'fobi.contrib.themes.simple', # Simple theme
|
||||
|
||||
"fobi.contrib.themes.simple", # Simple theme
|
||||
# ***********************************************************************
|
||||
# ***********************************************************************
|
||||
# ************************* Fobi form elements **************************
|
||||
# ***********************************************************************
|
||||
# ***********************************************************************
|
||||
|
||||
# ***********************************************************************
|
||||
# **************************** Form fields ******************************
|
||||
# ***********************************************************************
|
||||
#'fobi.contrib.plugins.form_elements.fields.birthday',
|
||||
'fobi.contrib.plugins.form_elements.fields.boolean',
|
||||
'fobi.contrib.plugins.form_elements.fields.date',
|
||||
'fobi.contrib.plugins.form_elements.fields.date_drop_down',
|
||||
'fobi.contrib.plugins.form_elements.fields.datetime',
|
||||
'fobi.contrib.plugins.form_elements.fields.email',
|
||||
'fobi.contrib.plugins.form_elements.fields.file',
|
||||
'fobi.contrib.plugins.form_elements.fields.hidden',
|
||||
'fobi.contrib.plugins.form_elements.fields.input',
|
||||
'fobi.contrib.plugins.form_elements.fields.integer',
|
||||
'fobi.contrib.plugins.form_elements.fields.password',
|
||||
'fobi.contrib.plugins.form_elements.fields.radio',
|
||||
'fobi.contrib.plugins.form_elements.fields.select',
|
||||
'fobi.contrib.plugins.form_elements.fields.select_model_object',
|
||||
'fobi.contrib.plugins.form_elements.fields.select_multiple',
|
||||
"fobi.contrib.plugins.form_elements.fields.boolean",
|
||||
"fobi.contrib.plugins.form_elements.fields.date",
|
||||
"fobi.contrib.plugins.form_elements.fields.date_drop_down",
|
||||
"fobi.contrib.plugins.form_elements.fields.datetime",
|
||||
"fobi.contrib.plugins.form_elements.fields.email",
|
||||
"fobi.contrib.plugins.form_elements.fields.file",
|
||||
"fobi.contrib.plugins.form_elements.fields.hidden",
|
||||
"fobi.contrib.plugins.form_elements.fields.input",
|
||||
"fobi.contrib.plugins.form_elements.fields.integer",
|
||||
"fobi.contrib.plugins.form_elements.fields.password",
|
||||
"fobi.contrib.plugins.form_elements.fields.radio",
|
||||
"fobi.contrib.plugins.form_elements.fields.select",
|
||||
"fobi.contrib.plugins.form_elements.fields.select_model_object",
|
||||
"fobi.contrib.plugins.form_elements.fields.select_multiple",
|
||||
# 'fobi.contrib.plugins.form_elements.fields.select_multiple_model_objects',
|
||||
'fobi.contrib.plugins.form_elements.fields.text',
|
||||
'fobi.contrib.plugins.form_elements.fields.textarea',
|
||||
'fobi.contrib.plugins.form_elements.fields.url',
|
||||
|
||||
"fobi.contrib.plugins.form_elements.fields.text",
|
||||
"fobi.contrib.plugins.form_elements.fields.textarea",
|
||||
"fobi.contrib.plugins.form_elements.fields.url",
|
||||
# ***********************************************************************
|
||||
# ************************ Security elements ****************************
|
||||
# ***********************************************************************
|
||||
'fobi.contrib.plugins.form_elements.security.honeypot',
|
||||
|
||||
"fobi.contrib.plugins.form_elements.security.honeypot",
|
||||
# ***********************************************************************
|
||||
# ************************* Testing elements ****************************
|
||||
# ***********************************************************************
|
||||
'fobi.contrib.plugins.form_elements.test.dummy',
|
||||
|
||||
"fobi.contrib.plugins.form_elements.test.dummy",
|
||||
# ***********************************************************************
|
||||
# ************************* Content elements ****************************
|
||||
# ***********************************************************************
|
||||
'fobi.contrib.plugins.form_elements.content.content_image',
|
||||
'fobi.contrib.plugins.form_elements.content.content_text',
|
||||
'fobi.contrib.plugins.form_elements.content.content_video',
|
||||
|
||||
"fobi.contrib.plugins.form_elements.content.content_image",
|
||||
"fobi.contrib.plugins.form_elements.content.content_text",
|
||||
"fobi.contrib.plugins.form_elements.content.content_video",
|
||||
# ***********************************************************************
|
||||
# ***********************************************************************
|
||||
# ************************* Fobi form handlers **************************
|
||||
# ***********************************************************************
|
||||
# ***********************************************************************
|
||||
'fobi.contrib.plugins.form_handlers.db_store',
|
||||
'fobi.contrib.plugins.form_handlers.http_repost',
|
||||
'fobi.contrib.plugins.form_handlers.mail',
|
||||
|
||||
"fobi.contrib.plugins.form_handlers.db_store",
|
||||
"fobi.contrib.plugins.form_handlers.http_repost",
|
||||
"fobi.contrib.plugins.form_handlers.mail",
|
||||
# ***********************************************************************
|
||||
# ***********************************************************************
|
||||
# *********************** Mezzanine integration *************************
|
||||
# ***********************************************************************
|
||||
# ***********************************************************************
|
||||
'fobi.contrib.apps.mezzanine_integration',
|
||||
|
||||
"fobi.contrib.apps.mezzanine_integration",
|
||||
# ***********************************************************************
|
||||
# ***********************************************************************
|
||||
# ****************************** Test app *******************************
|
||||
# ***********************************************************************
|
||||
# ***********************************************************************
|
||||
'foo',
|
||||
"foo",
|
||||
)
|
||||
|
||||
# List of middleware classes to use. Order is important; in the request phase,
|
||||
|
|
@ -412,7 +393,7 @@ MIDDLEWARE_CLASSES = (
|
|||
)
|
||||
|
||||
MIGRATION_MODULES = {
|
||||
'fobi': 'fobi.migrations',
|
||||
"fobi": "fobi.migrations",
|
||||
}
|
||||
|
||||
# Store these package names here as they may change in the future since
|
||||
|
|
@ -421,9 +402,9 @@ PACKAGE_NAME_FILEBROWSER = "filebrowser_safe"
|
|||
PACKAGE_NAME_GRAPPELLI = "grappelli_safe"
|
||||
|
||||
# Fobi extra configuration
|
||||
FOBI_DEFAULT_THEME = 'bootstrap3'
|
||||
FOBI_DEFAULT_THEME = "bootstrap3"
|
||||
|
||||
FOBI_THEME_FOOTER_TEXT = gettext('© django-fobi example site 2014')
|
||||
FOBI_THEME_FOOTER_TEXT = gettext("© django-fobi example site 2014")
|
||||
|
||||
|
||||
#########################
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
from .settings import *
|
||||
|
||||
# Fobi extra configuration
|
||||
FOBI_DEFAULT_THEME = 'bootstrap3'
|
||||
FOBI_DEFAULT_THEME = "bootstrap3"
|
||||
|
|
|
|||
|
|
@ -1,35 +1,31 @@
|
|||
from __future__ import unicode_literals
|
||||
|
||||
from django.urls import include, re_path as url
|
||||
from django.conf.urls.i18n import i18n_patterns
|
||||
from django.contrib import admin
|
||||
|
||||
from mezzanine.core.views import direct_to_template
|
||||
|
||||
from django.urls import include, re_path as url
|
||||
# ***********
|
||||
# Fobi things
|
||||
# ***********
|
||||
from django.views.generic import TemplateView
|
||||
from mezzanine.core.views import direct_to_template
|
||||
|
||||
from fobi.settings import DEFAULT_THEME
|
||||
|
||||
|
||||
# Mapping.
|
||||
fobi_theme_home_template_mapping = {
|
||||
'bootstrap3': 'home/bootstrap3.html',
|
||||
'foundation5': 'home/foundation5.html',
|
||||
'simple': 'home/simple.html',
|
||||
"bootstrap3": "home/bootstrap3.html",
|
||||
"foundation5": "home/foundation5.html",
|
||||
"simple": "home/simple.html",
|
||||
}
|
||||
|
||||
# Get the template to be used.
|
||||
fobi_home_template = fobi_theme_home_template_mapping.get(
|
||||
DEFAULT_THEME,
|
||||
'home/base.html'
|
||||
DEFAULT_THEME, "home/base.html"
|
||||
)
|
||||
|
||||
FOBI_EDIT_URLS_PREFIX = ''
|
||||
if 'simple' == DEFAULT_THEME:
|
||||
FOBI_EDIT_URLS_PREFIX = 'admin/'
|
||||
FOBI_EDIT_URLS_PREFIX = ""
|
||||
if "simple" == DEFAULT_THEME:
|
||||
FOBI_EDIT_URLS_PREFIX = "admin/"
|
||||
|
||||
# ***********
|
||||
# / End Fobi things
|
||||
|
|
@ -54,17 +50,17 @@ urlpatterns = []
|
|||
|
||||
urlpatterns += [
|
||||
url("^admin/", include(admin.site.urls)),
|
||||
|
||||
# DB Store plugin URLs
|
||||
url(r'^fobi/plugins/form-handlers/db-store/',
|
||||
include('fobi.contrib.plugins.form_handlers.db_store.urls')),
|
||||
|
||||
url(
|
||||
r"^fobi/plugins/form-handlers/db-store/",
|
||||
include("fobi.contrib.plugins.form_handlers.db_store.urls"),
|
||||
),
|
||||
# django-fobi URLs:
|
||||
url(r'^fobi/', include('fobi.urls.view')),
|
||||
url(r'^{0}fobi/'.format(FOBI_EDIT_URLS_PREFIX), include('fobi.urls.edit')),
|
||||
|
||||
url(r'^fobi-home/$',
|
||||
TemplateView.as_view(template_name=fobi_home_template)),
|
||||
url(r"^fobi/", include("fobi.urls.view")),
|
||||
url(r"^{0}fobi/".format(FOBI_EDIT_URLS_PREFIX), include("fobi.urls.edit")),
|
||||
url(
|
||||
r"^fobi-home/$", TemplateView.as_view(template_name=fobi_home_template)
|
||||
),
|
||||
]
|
||||
|
||||
# ***********
|
||||
|
|
@ -72,19 +68,15 @@ urlpatterns += [
|
|||
# ***********
|
||||
|
||||
urlpatterns += [
|
||||
|
||||
# We don't want to presume how your homepage works, so here are a
|
||||
# few patterns you can use to set it up.
|
||||
|
||||
# HOMEPAGE AS STATIC TEMPLATE
|
||||
# ---------------------------
|
||||
# This pattern simply loads the index.html template. It isn't
|
||||
# commented out like the others, so it's the default. You only need
|
||||
# one homepage pattern, so if you use a different one, comment this
|
||||
# one out.
|
||||
|
||||
url("^$", direct_to_template, {"template": "index.html"}, name="home"),
|
||||
|
||||
# HOMEPAGE AS AN EDITABLE PAGE IN THE PAGE TREE
|
||||
# ---------------------------------------------
|
||||
# This pattern gives us a normal ``Page`` object, so that your
|
||||
|
|
@ -97,9 +89,7 @@ urlpatterns += [
|
|||
# doesn't apply here, since we can't have a template called
|
||||
# "/.html" - so for this case, the template "pages/index.html"
|
||||
# should be used if you want to customize the homepage's template.
|
||||
|
||||
# url("^$", "mezzanine.pages.views.page", {"slug": "/"}, name="home"),
|
||||
|
||||
# HOMEPAGE FOR A BLOG-ONLY SITE
|
||||
# -----------------------------
|
||||
# This pattern points the homepage to the blog post listing page,
|
||||
|
|
@ -107,22 +97,18 @@ urlpatterns += [
|
|||
# pattern, you'll also need to set BLOG_SLUG = "" in your
|
||||
# ``settings.py`` module, and delete the blog page object from the
|
||||
# page tree in the admin if it was installed.
|
||||
|
||||
# url("^$", "mezzanine.blog.views.blog_post_list", name="home"),
|
||||
|
||||
# MEZZANINE'S URLS
|
||||
# ----------------
|
||||
# ADD YOUR OWN URLPATTERNS *ABOVE* THE LINE BELOW.
|
||||
# ``mezzanine.urls`` INCLUDES A *CATCH ALL* PATTERN
|
||||
# FOR PAGES, SO URLPATTERNS ADDED BELOW ``mezzanine.urls``
|
||||
# WILL NEVER BE MATCHED!
|
||||
|
||||
# If you'd like more granular control over the patterns in
|
||||
# ``mezzanine.urls``, go right ahead and take the parts you want
|
||||
# from it, and use them directly below instead of using
|
||||
# ``mezzanine.urls``.
|
||||
url("^", include("mezzanine.urls")),
|
||||
|
||||
# MOUNTING MEZZANINE UNDER A PREFIX
|
||||
# ---------------------------------
|
||||
# You can also mount all of Mezzanine's urlpatterns under a
|
||||
|
|
@ -136,9 +122,7 @@ urlpatterns += [
|
|||
# of this file as well.
|
||||
# Note that for any of the various homepage patterns above, you'll
|
||||
# need to use the ``SITE_PREFIX`` setting as well.
|
||||
|
||||
# ("^%s/" % settings.SITE_PREFIX, include("mezzanine.urls"))
|
||||
|
||||
]
|
||||
|
||||
# Adds ``STATIC_URL`` to the context of error pages, so that error
|
||||
|
|
|
|||
|
|
@ -7,4 +7,5 @@ settings_module = "%s.settings" % PROJECT_ROOT.split(os.sep)[-1]
|
|||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", settings_module)
|
||||
|
||||
from django.core.wsgi import get_wsgi_application
|
||||
|
||||
application = get_wsgi_application()
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ https://docs.djangoproject.com/en/1.7/ref/settings/
|
|||
|
||||
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
||||
import os
|
||||
|
||||
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
|
||||
|
||||
|
||||
|
|
@ -17,109 +18,105 @@ BASE_DIR = os.path.dirname(os.path.dirname(__file__))
|
|||
# See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/
|
||||
|
||||
# SECURITY WARNING: keep the secret key used in production secret!
|
||||
SECRET_KEY = 'uzc&9xi6b#dz^z7tpa+br3ohq)-9%v9ux@9^t!(5fl41n%&mn$'
|
||||
SECRET_KEY = "uzc&9xi6b#dz^z7tpa+br3ohq)-9%v9ux@9^t!(5fl41n%&mn$"
|
||||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = True
|
||||
|
||||
TEMPLATE_DEBUG = True
|
||||
|
||||
ALLOWED_HOSTS = ['*',]
|
||||
ALLOWED_HOSTS = [
|
||||
"*",
|
||||
]
|
||||
|
||||
|
||||
# Application definition
|
||||
|
||||
INSTALLED_APPS = (
|
||||
'django.contrib.admin',
|
||||
'django.contrib.auth',
|
||||
'django.contrib.contenttypes',
|
||||
'django.contrib.sessions',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
|
||||
"django.contrib.admin",
|
||||
"django.contrib.auth",
|
||||
"django.contrib.contenttypes",
|
||||
"django.contrib.sessions",
|
||||
"django.contrib.messages",
|
||||
"django.contrib.staticfiles",
|
||||
# Core
|
||||
'fobi',
|
||||
|
||||
"fobi",
|
||||
# Theme
|
||||
'fobi.contrib.themes.bootstrap3',
|
||||
|
||||
"fobi.contrib.themes.bootstrap3",
|
||||
# Form field plugins
|
||||
'fobi.contrib.plugins.form_elements.fields.boolean',
|
||||
'fobi.contrib.plugins.form_elements.fields.date',
|
||||
'fobi.contrib.plugins.form_elements.fields.datetime',
|
||||
'fobi.contrib.plugins.form_elements.fields.email',
|
||||
'fobi.contrib.plugins.form_elements.fields.file',
|
||||
'fobi.contrib.plugins.form_elements.fields.hidden',
|
||||
'fobi.contrib.plugins.form_elements.fields.integer',
|
||||
'fobi.contrib.plugins.form_elements.fields.password',
|
||||
'fobi.contrib.plugins.form_elements.fields.radio',
|
||||
'fobi.contrib.plugins.form_elements.fields.select',
|
||||
'fobi.contrib.plugins.form_elements.fields.select_model_object',
|
||||
'fobi.contrib.plugins.form_elements.fields.select_multiple',
|
||||
'fobi.contrib.plugins.form_elements.fields.select_multiple_model_objects',
|
||||
'fobi.contrib.plugins.form_elements.fields.text',
|
||||
'fobi.contrib.plugins.form_elements.fields.textarea',
|
||||
'fobi.contrib.plugins.form_elements.fields.url',
|
||||
|
||||
"fobi.contrib.plugins.form_elements.fields.boolean",
|
||||
"fobi.contrib.plugins.form_elements.fields.date",
|
||||
"fobi.contrib.plugins.form_elements.fields.datetime",
|
||||
"fobi.contrib.plugins.form_elements.fields.email",
|
||||
"fobi.contrib.plugins.form_elements.fields.file",
|
||||
"fobi.contrib.plugins.form_elements.fields.hidden",
|
||||
"fobi.contrib.plugins.form_elements.fields.integer",
|
||||
"fobi.contrib.plugins.form_elements.fields.password",
|
||||
"fobi.contrib.plugins.form_elements.fields.radio",
|
||||
"fobi.contrib.plugins.form_elements.fields.select",
|
||||
"fobi.contrib.plugins.form_elements.fields.select_model_object",
|
||||
"fobi.contrib.plugins.form_elements.fields.select_multiple",
|
||||
"fobi.contrib.plugins.form_elements.fields.select_multiple_model_objects",
|
||||
"fobi.contrib.plugins.form_elements.fields.text",
|
||||
"fobi.contrib.plugins.form_elements.fields.textarea",
|
||||
"fobi.contrib.plugins.form_elements.fields.url",
|
||||
# Form element plugins
|
||||
'easy_thumbnails', # Required by `content_image` plugin
|
||||
'fobi.contrib.plugins.form_elements.content.content_image',
|
||||
'fobi.contrib.plugins.form_elements.content.content_text',
|
||||
'fobi.contrib.plugins.form_elements.content.content_video',
|
||||
|
||||
"easy_thumbnails", # Required by `content_image` plugin
|
||||
"fobi.contrib.plugins.form_elements.content.content_image",
|
||||
"fobi.contrib.plugins.form_elements.content.content_text",
|
||||
"fobi.contrib.plugins.form_elements.content.content_video",
|
||||
# Form handlers
|
||||
'fobi.contrib.plugins.form_handlers.db_store',
|
||||
'fobi.contrib.plugins.form_handlers.http_repost',
|
||||
'fobi.contrib.plugins.form_handlers.mail',
|
||||
"fobi.contrib.plugins.form_handlers.db_store",
|
||||
"fobi.contrib.plugins.form_handlers.http_repost",
|
||||
"fobi.contrib.plugins.form_handlers.mail",
|
||||
)
|
||||
|
||||
MIDDLEWARE_CLASSES = (
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
'django.middleware.csrf.CsrfViewMiddleware',
|
||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
|
||||
'django.contrib.messages.middleware.MessageMiddleware',
|
||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||
"django.contrib.sessions.middleware.SessionMiddleware",
|
||||
"django.middleware.common.CommonMiddleware",
|
||||
"django.middleware.csrf.CsrfViewMiddleware",
|
||||
"django.contrib.auth.middleware.AuthenticationMiddleware",
|
||||
"django.contrib.auth.middleware.SessionAuthenticationMiddleware",
|
||||
"django.contrib.messages.middleware.MessageMiddleware",
|
||||
"django.middleware.clickjacking.XFrameOptionsMiddleware",
|
||||
)
|
||||
|
||||
TEMPLATE_CONTEXT_PROCESSORS = (
|
||||
'django.contrib.auth.context_processors.auth',
|
||||
'django.core.context_processors.debug',
|
||||
'django.core.context_processors.i18n',
|
||||
'django.core.context_processors.media',
|
||||
'django.core.context_processors.static',
|
||||
'django.core.context_processors.tz',
|
||||
'django.contrib.messages.context_processors.messages',
|
||||
|
||||
# Required by ``fobi``.
|
||||
"django.core.context_processors.request",
|
||||
"fobi.context_processors.theme",
|
||||
"django.contrib.auth.context_processors.auth",
|
||||
"django.core.context_processors.debug",
|
||||
"django.core.context_processors.i18n",
|
||||
"django.core.context_processors.media",
|
||||
"django.core.context_processors.static",
|
||||
"django.core.context_processors.tz",
|
||||
"django.contrib.messages.context_processors.messages",
|
||||
# Required by ``fobi``.
|
||||
"django.core.context_processors.request",
|
||||
"fobi.context_processors.theme",
|
||||
)
|
||||
|
||||
FOBI_RESTRICT_PLUGIN_ACCESS = False
|
||||
|
||||
ROOT_URLCONF = 'quick_start.urls'
|
||||
ROOT_URLCONF = "quick_start.urls"
|
||||
|
||||
WSGI_APPLICATION = 'quick_start.wsgi.application'
|
||||
WSGI_APPLICATION = "quick_start.wsgi.application"
|
||||
|
||||
|
||||
# Database
|
||||
# https://docs.djangoproject.com/en/1.7/ref/settings/#databases
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.sqlite3',
|
||||
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
|
||||
"default": {
|
||||
"ENGINE": "django.db.backends.sqlite3",
|
||||
"NAME": os.path.join(BASE_DIR, "db.sqlite3"),
|
||||
}
|
||||
}
|
||||
|
||||
# Internationalization
|
||||
# https://docs.djangoproject.com/en/1.7/topics/i18n/
|
||||
|
||||
LANGUAGE_CODE = 'en-us'
|
||||
LANGUAGE_CODE = "en-us"
|
||||
|
||||
TIME_ZONE = 'UTC'
|
||||
TIME_ZONE = "UTC"
|
||||
|
||||
USE_I18N = True
|
||||
|
||||
|
|
@ -131,8 +128,8 @@ USE_TZ = True
|
|||
# Static files (CSS, JavaScript, Images)
|
||||
# https://docs.djangoproject.com/en/1.7/howto/static-files/
|
||||
|
||||
STATIC_URL = '/static/'
|
||||
STATIC_URL = "/static/"
|
||||
|
||||
MIGRATION_MODULES = {
|
||||
'fobi': 'fobi.migrations',
|
||||
"fobi": "fobi.migrations",
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,23 +1,21 @@
|
|||
from django.urls import include, re_path as url
|
||||
from django.contrib import admin
|
||||
from django.urls import include, re_path as url
|
||||
|
||||
urlpatterns = [
|
||||
# Examples:
|
||||
# url(r'^$', 'quick_start.views.home', name='home'),
|
||||
# url(r'^blog/', include('blog.urls')),
|
||||
|
||||
url(r'^admin/', include(admin.site.urls)),
|
||||
|
||||
url(r"^admin/", include(admin.site.urls)),
|
||||
# DB Store plugin URLs
|
||||
url(r'^fobi/plugins/form-handlers/db-store/',
|
||||
include('fobi.contrib.plugins.form_handlers.db_store.urls')),
|
||||
#, namespace='fobi'
|
||||
|
||||
url(
|
||||
r"^fobi/plugins/form-handlers/db-store/",
|
||||
include("fobi.contrib.plugins.form_handlers.db_store.urls"),
|
||||
),
|
||||
# , namespace='fobi'
|
||||
# View URLs
|
||||
url(r'^fobi/', include('fobi.urls.view')),
|
||||
#, namespace='fobi'
|
||||
|
||||
url(r"^fobi/", include("fobi.urls.view")),
|
||||
# , namespace='fobi'
|
||||
# Edit URLs
|
||||
url(r'^fobi/', include('fobi.urls.edit')),
|
||||
#, namespace='fobi'
|
||||
url(r"^fobi/", include("fobi.urls.edit")),
|
||||
# , namespace='fobi'
|
||||
]
|
||||
|
|
|
|||
|
|
@ -8,7 +8,9 @@ https://docs.djangoproject.com/en/1.7/howto/deployment/wsgi/
|
|||
"""
|
||||
|
||||
import os
|
||||
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "quick_start.settings")
|
||||
|
||||
from django.core.wsgi import get_wsgi_application
|
||||
|
||||
application = get_wsgi_application()
|
||||
|
|
|
|||
|
|
@ -10,14 +10,14 @@ And to activate the app index dashboard::
|
|||
ADMIN_TOOLS_APP_INDEX_DASHBOARD = \
|
||||
'admin_tools_dashboard.CustomAppIndexDashboard'
|
||||
"""
|
||||
from admin_tools.dashboard import AppIndexDashboard, Dashboard, modules
|
||||
from django.conf import settings
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from admin_tools.dashboard import modules, Dashboard, AppIndexDashboard
|
||||
# from admin_tools.utils import get_admin_site_name
|
||||
|
||||
from . import conf
|
||||
|
||||
# from admin_tools.utils import get_admin_site_name
|
||||
|
||||
|
||||
class CustomIndexDashboard(Dashboard):
|
||||
"""Custom index dashboard."""
|
||||
|
|
@ -38,91 +38,91 @@ class CustomIndexDashboard(Dashboard):
|
|||
# Fobi
|
||||
self.children.append(
|
||||
modules.Group(
|
||||
title=_('Fobi'),
|
||||
display='stacked',
|
||||
title=_("Fobi"),
|
||||
display="stacked",
|
||||
children=[
|
||||
modules.ModelList(
|
||||
_('Plugins'),
|
||||
_("Plugins"),
|
||||
models=conf.fobi_plugins,
|
||||
collapsible=False,
|
||||
deletable=False
|
||||
deletable=False,
|
||||
),
|
||||
modules.ModelList(
|
||||
_('Forms'),
|
||||
_("Forms"),
|
||||
models=conf.fobi_forms,
|
||||
collapsible=False,
|
||||
deletable=False
|
||||
deletable=False,
|
||||
),
|
||||
modules.ModelList(
|
||||
_('Data'),
|
||||
_("Data"),
|
||||
models=conf.fobi_data,
|
||||
collapsible=False,
|
||||
deletable=False
|
||||
deletable=False,
|
||||
),
|
||||
]
|
||||
],
|
||||
)
|
||||
)
|
||||
|
||||
if 'feincms' in settings.INSTALLED_APPS:
|
||||
if "feincms" in settings.INSTALLED_APPS:
|
||||
# FeinCMS pages
|
||||
self.children.append(
|
||||
modules.AppList(
|
||||
_('FeinCMS Pages'),
|
||||
_("FeinCMS Pages"),
|
||||
models=conf.feincms_pages,
|
||||
collapsible=False,
|
||||
deletable=False
|
||||
deletable=False,
|
||||
)
|
||||
)
|
||||
|
||||
if 'cms' in settings.INSTALLED_APPS:
|
||||
if "cms" in settings.INSTALLED_APPS:
|
||||
# DjangoCMS pages
|
||||
self.children.append(
|
||||
modules.AppList(
|
||||
_('DjangoCMS Pages'),
|
||||
_("DjangoCMS Pages"),
|
||||
models=conf.djangocms_pages,
|
||||
collapsible=False,
|
||||
deletable=False
|
||||
deletable=False,
|
||||
)
|
||||
)
|
||||
|
||||
# Append an app list module for "Administration"
|
||||
self.children.append(
|
||||
modules.AppList(
|
||||
_('Administration'),
|
||||
_("Administration"),
|
||||
models=conf.django_contrib_apps,
|
||||
collapsible=False,
|
||||
deletable=False
|
||||
deletable=False,
|
||||
)
|
||||
)
|
||||
|
||||
# Append an app list module for "Administration"
|
||||
self.children.append(
|
||||
modules.AppList(
|
||||
_('Other apps'),
|
||||
_("Other apps"),
|
||||
models=conf.other_apps,
|
||||
collapsible=False,
|
||||
deletable=False
|
||||
deletable=False,
|
||||
)
|
||||
)
|
||||
|
||||
# Append a recent actions module
|
||||
self.children.append(modules.RecentActions(_('Recent Actions'), 10))
|
||||
self.children.append(modules.RecentActions(_("Recent Actions"), 10))
|
||||
|
||||
|
||||
class CustomAppIndexDashboard(AppIndexDashboard):
|
||||
"""Custom app index dashboard."""
|
||||
|
||||
# We disable title because its redundant with the model list module
|
||||
title = ''
|
||||
title = ""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
AppIndexDashboard.__init__(self, *args, **kwargs)
|
||||
|
||||
self.children.append(
|
||||
modules.RecentActions(
|
||||
_('Recent Actions'),
|
||||
_("Recent Actions"),
|
||||
include_list=self.get_app_content_types(),
|
||||
limit=10
|
||||
limit=10,
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -2,42 +2,39 @@
|
|||
# ************ Foo **************
|
||||
# *******************************
|
||||
foo_apps = [
|
||||
'foo.models.*',
|
||||
'bar.models.*',
|
||||
"foo.models.*",
|
||||
"bar.models.*",
|
||||
]
|
||||
|
||||
# *******************************
|
||||
# ************ Fobi *************
|
||||
# *******************************
|
||||
fobi_plugins = [
|
||||
'fobi.models.FormElement',
|
||||
'fobi.models.FormHandler'
|
||||
]
|
||||
fobi_plugins = ["fobi.models.FormElement", "fobi.models.FormHandler"]
|
||||
|
||||
fobi_forms = [
|
||||
'fobi.models.FormWizardEntry',
|
||||
'fobi.models.FormEntry',
|
||||
'fobi.models.FormElementEntry',
|
||||
'fobi.models.FormFieldsetEntry',
|
||||
'fobi.models.FormHandlerEntry',
|
||||
"fobi.models.FormWizardEntry",
|
||||
"fobi.models.FormEntry",
|
||||
"fobi.models.FormElementEntry",
|
||||
"fobi.models.FormFieldsetEntry",
|
||||
"fobi.models.FormHandlerEntry",
|
||||
]
|
||||
|
||||
fobi_data = [
|
||||
'fobi.contrib.plugins.form_handlers.db_store.models.*',
|
||||
"fobi.contrib.plugins.form_handlers.db_store.models.*",
|
||||
]
|
||||
|
||||
feincms_pages = [
|
||||
'page.*',
|
||||
"page.*",
|
||||
]
|
||||
|
||||
djangocms_pages = [
|
||||
'cms.models.*',
|
||||
"cms.models.*",
|
||||
]
|
||||
|
||||
# *******************************
|
||||
# ************ Django ***********
|
||||
# *******************************
|
||||
django_contrib_apps = [
|
||||
'django.contrib.*',
|
||||
"django.contrib.*",
|
||||
]
|
||||
other_apps = foo_apps
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
from admin_tools.dashboard.models import DashboardPreferences
|
||||
from django.core.management import BaseCommand
|
||||
|
||||
from admin_tools.dashboard.models import DashboardPreferences
|
||||
|
||||
__all__ = ('Command',)
|
||||
__all__ = ("Command",)
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
|
|
|
|||
|
|
@ -6,15 +6,14 @@ To activate your custom menu add the following to your settings.py::
|
|||
ADMIN_TOOLS_MENU = 'admin_tools_dashboard.menu.CustomMenu'
|
||||
"""
|
||||
|
||||
from admin_tools.menu import Menu, items
|
||||
from django.conf import settings
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from admin_tools.menu import items, Menu
|
||||
|
||||
from . import conf
|
||||
|
||||
__all__ = ('CustomMenu',)
|
||||
__all__ = ("CustomMenu",)
|
||||
|
||||
|
||||
class CustomMenu(Menu):
|
||||
|
|
@ -23,53 +22,39 @@ class CustomMenu(Menu):
|
|||
def __init__(self, **kwargs):
|
||||
Menu.__init__(self, **kwargs)
|
||||
self.children += [
|
||||
items.MenuItem(_('Dashboard'), reverse('admin:index')),
|
||||
items.MenuItem(_("Dashboard"), reverse("admin:index")),
|
||||
]
|
||||
|
||||
# Foo
|
||||
self.children.append(
|
||||
items.ModelList(
|
||||
_('Foo'),
|
||||
models=conf.foo_apps
|
||||
)
|
||||
)
|
||||
self.children.append(items.ModelList(_("Foo"), models=conf.foo_apps))
|
||||
|
||||
# Fobi
|
||||
self.children.append(
|
||||
items.MenuItem(
|
||||
_('Fobi'),
|
||||
_("Fobi"),
|
||||
children=[
|
||||
items.ModelList(_('Plugins'), models=conf.fobi_plugins),
|
||||
items.ModelList(_('Forms'), models=conf.fobi_forms),
|
||||
items.ModelList(_('Data'), models=conf.fobi_data),
|
||||
]
|
||||
items.ModelList(_("Plugins"), models=conf.fobi_plugins),
|
||||
items.ModelList(_("Forms"), models=conf.fobi_forms),
|
||||
items.ModelList(_("Data"), models=conf.fobi_data),
|
||||
],
|
||||
)
|
||||
)
|
||||
|
||||
if 'feincms' in settings.INSTALLED_APPS:
|
||||
if "feincms" in settings.INSTALLED_APPS:
|
||||
# FeinCMS pages integration
|
||||
self.children.append(
|
||||
items.AppList(
|
||||
_('FeinCMS Pages'),
|
||||
models=conf.feincms_pages
|
||||
)
|
||||
items.AppList(_("FeinCMS Pages"), models=conf.feincms_pages)
|
||||
)
|
||||
|
||||
if 'cms' in settings.INSTALLED_APPS:
|
||||
if "cms" in settings.INSTALLED_APPS:
|
||||
# DjangoCMS pages integration
|
||||
self.children.append(
|
||||
items.AppList(
|
||||
_('DjangoCMS Pages'),
|
||||
models=conf.djangocms_pages
|
||||
)
|
||||
items.AppList(_("DjangoCMS Pages"), models=conf.djangocms_pages)
|
||||
)
|
||||
|
||||
# append an app list module for "Administration"
|
||||
self.children.append(
|
||||
items.AppList(
|
||||
_('Administration'),
|
||||
models=['django.contrib.*']
|
||||
)
|
||||
items.AppList(_("Administration"), models=["django.contrib.*"])
|
||||
)
|
||||
|
||||
def init_with_context(self, context):
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
from django.contrib import admin
|
||||
|
||||
from mptt.admin import MPTTModelAdmin
|
||||
|
||||
from .models import Genre
|
||||
|
|
|
|||
|
|
@ -1,10 +1,8 @@
|
|||
from django.db import models
|
||||
from mptt.models import MPTTModel, TreeForeignKey
|
||||
from six import python_2_unicode_compatible
|
||||
|
||||
from django.db import models
|
||||
|
||||
from mptt.models import MPTTModel, TreeForeignKey
|
||||
|
||||
__all__ = ('Genre',)
|
||||
__all__ = ("Genre",)
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
|
|
@ -12,14 +10,15 @@ class Genre(MPTTModel):
|
|||
"""Genre."""
|
||||
|
||||
name = models.CharField(max_length=50, unique=True)
|
||||
parent = TreeForeignKey('self', null=True, blank=True,
|
||||
related_name='children', db_index=True)
|
||||
parent = TreeForeignKey(
|
||||
"self", null=True, blank=True, related_name="children", db_index=True
|
||||
)
|
||||
|
||||
class MPTTMeta:
|
||||
"""MPTT meta."""
|
||||
|
||||
# level_attr = 'mptt_level'
|
||||
order_insertion_by = ['name']
|
||||
order_insertion_by = ["name"]
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
|
|
|||
|
|
@ -4,5 +4,5 @@ from django.utils.translation import gettext_lazy as _
|
|||
from .views import my_view
|
||||
|
||||
urlpatterns = [
|
||||
url(_(r'^$'), my_view, name='bar.my_view'),
|
||||
url(_(r"^$"), my_view, name="bar.my_view"),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -4,11 +4,11 @@ from .forms import MyForm
|
|||
|
||||
|
||||
def my_view(request):
|
||||
if request.method == 'POST':
|
||||
if request.method == "POST":
|
||||
form = MyForm(data=request.POST)
|
||||
else:
|
||||
form = MyForm()
|
||||
|
||||
context = {'form': form}
|
||||
context = {"form": form}
|
||||
|
||||
return render(request, 'bar/form.html', context)
|
||||
return render(request, "bar/form.html", context)
|
||||
|
|
|
|||
|
|
@ -6,6 +6,6 @@ from fobi.contrib.apps.djangocms_integration.cms_version import (
|
|||
|
||||
def cms_version(request):
|
||||
return {
|
||||
'CMS_VERSION_GT_3_0': CMS_VERSION_GT_3_0,
|
||||
'CMS_VERSION_LTE_3_0': CMS_VERSION_LTE_3_0,
|
||||
"CMS_VERSION_GT_3_0": CMS_VERSION_GT_3_0,
|
||||
"CMS_VERSION_LTE_3_0": CMS_VERSION_LTE_3_0,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,16 @@
|
|||
from django.conf import settings
|
||||
|
||||
__all__ = ('disable_admin_tools', 'testing',)
|
||||
__all__ = (
|
||||
"disable_admin_tools",
|
||||
"testing",
|
||||
)
|
||||
|
||||
|
||||
def disable_admin_tools(request):
|
||||
"""Disable admin tools."""
|
||||
return {'ADMIN_TOOLS_DISABLED': True}
|
||||
return {"ADMIN_TOOLS_DISABLED": True}
|
||||
|
||||
|
||||
def testing(request):
|
||||
"""Put `testing` into context."""
|
||||
return {'testing': settings.TESTING}
|
||||
return {"testing": settings.TESTING}
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
from django import forms
|
||||
from django.contrib import admin
|
||||
from django.contrib.auth.models import Group
|
||||
from django.contrib.auth.admin import UserAdmin
|
||||
from django.contrib.auth.forms import ReadOnlyPasswordHashField
|
||||
from django.contrib.auth.models import Group
|
||||
|
||||
from .models import MyUser
|
||||
|
||||
__all__ = (
|
||||
'UserCreationForm',
|
||||
'UserChangeForm',
|
||||
'MyUserAdmin',
|
||||
"UserCreationForm",
|
||||
"UserChangeForm",
|
||||
"MyUserAdmin",
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -19,17 +19,22 @@ class UserCreationForm(forms.ModelForm):
|
|||
Includes all the required fields, plus a repeated password.
|
||||
"""
|
||||
|
||||
password1 = forms.CharField(label='Password',
|
||||
widget=forms.PasswordInput)
|
||||
password2 = forms.CharField(label='Password confirmation',
|
||||
widget=forms.PasswordInput)
|
||||
password1 = forms.CharField(label="Password", widget=forms.PasswordInput)
|
||||
password2 = forms.CharField(
|
||||
label="Password confirmation", widget=forms.PasswordInput
|
||||
)
|
||||
|
||||
class Meta:
|
||||
"""Meta."""
|
||||
|
||||
model = MyUser
|
||||
fields = ('username', 'email', 'first_name', 'last_name',
|
||||
'date_of_birth',)
|
||||
fields = (
|
||||
"username",
|
||||
"email",
|
||||
"first_name",
|
||||
"last_name",
|
||||
"date_of_birth",
|
||||
)
|
||||
|
||||
def clean_password2(self):
|
||||
# Check that the two password entries match
|
||||
|
|
@ -61,8 +66,15 @@ class UserChangeForm(forms.ModelForm):
|
|||
"""Meta."""
|
||||
|
||||
model = MyUser
|
||||
fields = ('username', 'email', 'first_name', 'last_name', 'password',
|
||||
'date_of_birth', 'is_active',)
|
||||
fields = (
|
||||
"username",
|
||||
"email",
|
||||
"first_name",
|
||||
"last_name",
|
||||
"password",
|
||||
"date_of_birth",
|
||||
"is_active",
|
||||
)
|
||||
|
||||
def clean_password(self):
|
||||
# Regardless of what the user provides, return the initial value.
|
||||
|
|
@ -81,24 +93,59 @@ class MyUserAdmin(UserAdmin):
|
|||
# The fields to be used in displaying the User model.
|
||||
# These override the definitions on the base UserAdmin
|
||||
# that reference specific fields on auth.User.
|
||||
list_display = ('username', 'email', 'first_name', 'last_name',
|
||||
'date_of_birth',)
|
||||
list_display = (
|
||||
"username",
|
||||
"email",
|
||||
"first_name",
|
||||
"last_name",
|
||||
"date_of_birth",
|
||||
)
|
||||
fieldsets = (
|
||||
(None, {'fields': ('username', 'email', 'password')}),
|
||||
('Personal info', {'fields': ('first_name', 'last_name',
|
||||
'date_of_birth',)}),
|
||||
('Permissions', {'fields': ('is_active', 'is_staff', 'is_superuser',
|
||||
'groups', 'user_permissions')}),
|
||||
(None, {"fields": ("username", "email", "password")}),
|
||||
(
|
||||
"Personal info",
|
||||
{
|
||||
"fields": (
|
||||
"first_name",
|
||||
"last_name",
|
||||
"date_of_birth",
|
||||
)
|
||||
},
|
||||
),
|
||||
(
|
||||
"Permissions",
|
||||
{
|
||||
"fields": (
|
||||
"is_active",
|
||||
"is_staff",
|
||||
"is_superuser",
|
||||
"groups",
|
||||
"user_permissions",
|
||||
)
|
||||
},
|
||||
),
|
||||
)
|
||||
# add_fieldsets is not a standard ModelAdmin attribute. UserAdmin
|
||||
# overrides get_fieldsets to use this attribute when creating a user.
|
||||
add_fieldsets = (
|
||||
(None, {'classes': ('wide',),
|
||||
'fields': ('username', 'email', 'first_name', 'last_name',
|
||||
'date_of_birth', 'password1', 'password2')}),
|
||||
(
|
||||
None,
|
||||
{
|
||||
"classes": ("wide",),
|
||||
"fields": (
|
||||
"username",
|
||||
"email",
|
||||
"first_name",
|
||||
"last_name",
|
||||
"date_of_birth",
|
||||
"password1",
|
||||
"password2",
|
||||
),
|
||||
},
|
||||
),
|
||||
)
|
||||
search_fields = ('email',)
|
||||
ordering = ('email',)
|
||||
search_fields = ("email",)
|
||||
ordering = ("email",)
|
||||
filter_horizontal = []
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
from django.db import models
|
||||
from django.contrib.auth.models import AbstractUser
|
||||
from django.db import models
|
||||
|
||||
__all__ = ('MyUser',)
|
||||
__all__ = ("MyUser",)
|
||||
|
||||
|
||||
class MyUser(AbstractUser):
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
from .auth_user import *
|
||||
from .medialibrary_mediafile import *
|
||||
from .page_page import *
|
||||
|
||||
# from .sites_site import *
|
||||
|
|
|
|||
|
|
@ -1,36 +1,33 @@
|
|||
from django.conf import settings
|
||||
|
||||
from factory import (
|
||||
PostGenerationMethodCall, Sequence
|
||||
)
|
||||
from factory import PostGenerationMethodCall, Sequence
|
||||
from factory.django import DjangoModelFactory
|
||||
|
||||
from .factory_faker import Faker
|
||||
|
||||
__all__ = (
|
||||
'TEST_USERNAME',
|
||||
'TEST_PASSWORD',
|
||||
'AbstractUserFactory',
|
||||
'InactiveUserFactory',
|
||||
'UserFactory',
|
||||
'StaffUserFactory',
|
||||
'SuperuserUserFactory',
|
||||
'SuperAdminUserFactory',
|
||||
'TestUsernameSuperAdminUserFactory',
|
||||
"TEST_USERNAME",
|
||||
"TEST_PASSWORD",
|
||||
"AbstractUserFactory",
|
||||
"InactiveUserFactory",
|
||||
"UserFactory",
|
||||
"StaffUserFactory",
|
||||
"SuperuserUserFactory",
|
||||
"SuperAdminUserFactory",
|
||||
"TestUsernameSuperAdminUserFactory",
|
||||
)
|
||||
|
||||
TEST_USERNAME = 'test_user'
|
||||
TEST_PASSWORD = 'test_password'
|
||||
TEST_USERNAME = "test_user"
|
||||
TEST_PASSWORD = "test_password"
|
||||
|
||||
|
||||
class AbstractUserFactory(DjangoModelFactory):
|
||||
"""Abstract factory for creating users."""
|
||||
|
||||
password = PostGenerationMethodCall('set_password', TEST_PASSWORD)
|
||||
username = Sequence(lambda n: 'user%d' % n)
|
||||
first_name = Faker('first_name')
|
||||
last_name = Faker('last_name')
|
||||
email = Faker('email')
|
||||
password = PostGenerationMethodCall("set_password", TEST_PASSWORD)
|
||||
username = Sequence(lambda n: "user%d" % n)
|
||||
first_name = Faker("first_name")
|
||||
last_name = Faker("last_name")
|
||||
email = Faker("email")
|
||||
|
||||
is_active = False
|
||||
is_staff = False
|
||||
|
|
@ -38,7 +35,7 @@ class AbstractUserFactory(DjangoModelFactory):
|
|||
|
||||
class Meta:
|
||||
model = settings.AUTH_USER_MODEL
|
||||
django_get_or_create = ('username',)
|
||||
django_get_or_create = ("username",)
|
||||
abstract = True
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,24 +1,22 @@
|
|||
from __future__ import unicode_literals
|
||||
|
||||
from django.core.files.base import File
|
||||
|
||||
from factory import Faker as OriginalFaker
|
||||
|
||||
from faker import Faker as FakerFaker
|
||||
from faker.generator import random
|
||||
from faker.providers import BaseProvider
|
||||
from faker.providers.phone_number import Provider as PhoneNumberProvider
|
||||
from faker.providers.person.nl_NL import Provider as PersonProvider
|
||||
from faker.providers.phone_number import Provider as PhoneNumberProvider
|
||||
|
||||
from .files import get_temporary_file
|
||||
|
||||
__all__ = ('Faker',)
|
||||
__all__ = ("Faker",)
|
||||
|
||||
|
||||
class Faker(OriginalFaker):
|
||||
"""Override to change the default locale."""
|
||||
|
||||
_DEFAULT_LOCALE = 'nl_NL'
|
||||
_DEFAULT_LOCALE = "nl_NL"
|
||||
|
||||
|
||||
class SpacelessPostalcodeProvider(BaseProvider):
|
||||
|
|
@ -26,16 +24,14 @@ class SpacelessPostalcodeProvider(BaseProvider):
|
|||
|
||||
def postcode_spaceless(self):
|
||||
"""Spaceless postal code."""
|
||||
return self.bothify('%###??').upper()
|
||||
return self.bothify("%###??").upper()
|
||||
|
||||
|
||||
class NLPhoneNumberProvider(PhoneNumberProvider):
|
||||
"""Phone number provider `compatible django.contrib.localflavor.nl`."""
|
||||
|
||||
# NLPhoneNumberField validates with max=12
|
||||
formats = ('### ### ####',
|
||||
'##########',
|
||||
'###-#######',
|
||||
'+31#########')
|
||||
formats = ("### ### ####", "##########", "###-#######", "+31#########")
|
||||
|
||||
|
||||
class NLPersonProvider(PersonProvider):
|
||||
|
|
@ -43,6 +39,7 @@ class NLPersonProvider(PersonProvider):
|
|||
|
||||
Overridden to make it compatible with our database model.
|
||||
"""
|
||||
|
||||
last_names = [n for n in PersonProvider.last_names if len(n) <= 30]
|
||||
|
||||
|
||||
|
|
@ -50,8 +47,8 @@ class PyStrWithPrefixProvider(BaseProvider):
|
|||
"""pystr with prefix provider."""
|
||||
|
||||
@classmethod
|
||||
def pystr_with_prefix(cls, min_chars=None, max_chars=20, prefix=''):
|
||||
""" Generates a random string of upper and lowercase letters.
|
||||
def pystr_with_prefix(cls, min_chars=None, max_chars=20, prefix=""):
|
||||
"""Generates a random string of upper and lowercase letters.
|
||||
|
||||
:type min_chars: int
|
||||
:type max_chars: int
|
||||
|
|
@ -61,13 +58,14 @@ class PyStrWithPrefixProvider(BaseProvider):
|
|||
if min_chars is None:
|
||||
return "".join(cls.random_letter() for i in range(max_chars))
|
||||
else:
|
||||
assert (max_chars >= min_chars), "Maximum length must be " \
|
||||
"greater than or equal to " \
|
||||
"minium length"
|
||||
assert max_chars >= min_chars, (
|
||||
"Maximum length must be "
|
||||
"greater than or equal to "
|
||||
"minium length"
|
||||
)
|
||||
pystr = "".join(
|
||||
cls.random_letter()
|
||||
for i
|
||||
in range(0, random.randint(min_chars, max_chars))
|
||||
for i in range(0, random.randint(min_chars, max_chars))
|
||||
)
|
||||
return "%s%s" % (prefix, pystr)
|
||||
|
||||
|
|
@ -93,8 +91,9 @@ class LoremWithPrefixProvider(BaseProvider):
|
|||
return [cls.word_with_prefix() for _ in range(0, nb)]
|
||||
|
||||
@classmethod
|
||||
def sentence_with_prefix(cls, nb_words=6, variable_nb_words=True,
|
||||
prefix=''):
|
||||
def sentence_with_prefix(
|
||||
cls, nb_words=6, variable_nb_words=True, prefix=""
|
||||
):
|
||||
"""Generate a random sentence.
|
||||
|
||||
:example: 'Lorem ipsum dolor sit amet.'.
|
||||
|
|
@ -104,7 +103,7 @@ class LoremWithPrefixProvider(BaseProvider):
|
|||
of 1.
|
||||
"""
|
||||
if nb_words <= 0:
|
||||
return ''
|
||||
return ""
|
||||
|
||||
if variable_nb_words:
|
||||
nb_words = cls.randomize_nb_elements(nb_words)
|
||||
|
|
@ -112,7 +111,7 @@ class LoremWithPrefixProvider(BaseProvider):
|
|||
words = cls.words_with_prefix(nb_words)
|
||||
words[0] = words[0].title()
|
||||
|
||||
sentence = " ".join(words) + '.'
|
||||
sentence = " ".join(words) + "."
|
||||
|
||||
return "%s%s" % (prefix, sentence)
|
||||
|
||||
|
|
@ -122,7 +121,7 @@ class DjangoFile(BaseProvider):
|
|||
|
||||
@classmethod
|
||||
def django_file(cls, extension=None):
|
||||
""" Generates a random image file.
|
||||
"""Generates a random image file.
|
||||
|
||||
:return: File object.
|
||||
"""
|
||||
|
|
@ -134,7 +133,7 @@ class DjangoFile(BaseProvider):
|
|||
|
||||
Faker.add_provider(SpacelessPostalcodeProvider)
|
||||
Faker.add_provider(NLPhoneNumberProvider)
|
||||
Faker.add_provider(NLPersonProvider, locale='nl_NL')
|
||||
Faker.add_provider(PyStrWithPrefixProvider, locale='la')
|
||||
Faker.add_provider(LoremWithPrefixProvider, locale='la')
|
||||
Faker.add_provider(NLPersonProvider, locale="nl_NL")
|
||||
Faker.add_provider(PyStrWithPrefixProvider, locale="la")
|
||||
Faker.add_provider(LoremWithPrefixProvider, locale="la")
|
||||
Faker.add_provider(DjangoFile)
|
||||
|
|
|
|||
|
|
@ -5,25 +5,25 @@ from PIL import Image
|
|||
from six import BytesIO
|
||||
|
||||
__all__ = (
|
||||
'BASE64_PREFIX',
|
||||
'TEMPORARY_FILE_LIST',
|
||||
'TEMPORARY_FILE_LIST_FILE_CONTENT',
|
||||
'TEMPORARY_FILE_LIST_FILE_BASE64',
|
||||
'TEMPORARY_FILE_VIEW',
|
||||
'TEMPORARY_FILE_VIEW_FILE_CONTENT',
|
||||
'TEMPORARY_FILE_VIEW_FILE_BASE64',
|
||||
'TEMPORARY_FILE_ADD',
|
||||
'TEMPORARY_FILE_ADD_FILE_CONTENT',
|
||||
'TEMPORARY_FILE_ADD_FILE_BASE64',
|
||||
'TEMPORARY_FILE_CHANGE',
|
||||
'TEMPORARY_FILE_CHANGE_FILE_CONTENT',
|
||||
'TEMPORARY_FILE_CHANGE_FILE_BASE64',
|
||||
'TEMPORARY_FILE_CHANGE_CHANGED',
|
||||
'TEMPORARY_FILE_CHANGE_CHANGED_FILE_CONTENT',
|
||||
'TEMPORARY_FILE_CHANGE_CHANGED_FILE_BASE64',
|
||||
'TEMPORARY_FILE_DELETE',
|
||||
'TEMPORARY_FILE_DELETE_FILE_CONTENT',
|
||||
'TEMPORARY_FILE_DELETE_FILE_BASE64',
|
||||
"BASE64_PREFIX",
|
||||
"TEMPORARY_FILE_LIST",
|
||||
"TEMPORARY_FILE_LIST_FILE_CONTENT",
|
||||
"TEMPORARY_FILE_LIST_FILE_BASE64",
|
||||
"TEMPORARY_FILE_VIEW",
|
||||
"TEMPORARY_FILE_VIEW_FILE_CONTENT",
|
||||
"TEMPORARY_FILE_VIEW_FILE_BASE64",
|
||||
"TEMPORARY_FILE_ADD",
|
||||
"TEMPORARY_FILE_ADD_FILE_CONTENT",
|
||||
"TEMPORARY_FILE_ADD_FILE_BASE64",
|
||||
"TEMPORARY_FILE_CHANGE",
|
||||
"TEMPORARY_FILE_CHANGE_FILE_CONTENT",
|
||||
"TEMPORARY_FILE_CHANGE_FILE_BASE64",
|
||||
"TEMPORARY_FILE_CHANGE_CHANGED",
|
||||
"TEMPORARY_FILE_CHANGE_CHANGED_FILE_CONTENT",
|
||||
"TEMPORARY_FILE_CHANGE_CHANGED_FILE_BASE64",
|
||||
"TEMPORARY_FILE_DELETE",
|
||||
"TEMPORARY_FILE_DELETE_FILE_CONTENT",
|
||||
"TEMPORARY_FILE_DELETE_FILE_BASE64",
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -32,56 +32,60 @@ def get_temporary_file(prefix):
|
|||
|
||||
:return:
|
||||
"""
|
||||
image = Image.new('RGBA', size=(100, 100), color=(256, 0, 0))
|
||||
image = Image.new("RGBA", size=(100, 100), color=(256, 0, 0))
|
||||
tmp_file = BytesIO()
|
||||
_tmp_file = tempfile.NamedTemporaryFile(prefix=prefix, suffix='.png')
|
||||
_tmp_file = tempfile.NamedTemporaryFile(prefix=prefix, suffix=".png")
|
||||
image.save(tmp_file, "PNG")
|
||||
tmp_file.seek(0)
|
||||
tmp_file.name = _tmp_file.name
|
||||
return tmp_file
|
||||
|
||||
|
||||
BASE64_PREFIX = 'data:image/png;base64,'
|
||||
BASE64_PREFIX = "data:image/png;base64,"
|
||||
|
||||
TEMPORARY_FILE_LIST = get_temporary_file(prefix='LIST')
|
||||
TEMPORARY_FILE_LIST = get_temporary_file(prefix="LIST")
|
||||
TEMPORARY_FILE_LIST_FILE_CONTENT = TEMPORARY_FILE_LIST.read()
|
||||
TEMPORARY_FILE_LIST_FILE_BASE64 = BASE64_PREFIX + base64.b64encode(
|
||||
TEMPORARY_FILE_LIST_FILE_CONTENT
|
||||
).decode()
|
||||
TEMPORARY_FILE_LIST_FILE_BASE64 = (
|
||||
BASE64_PREFIX + base64.b64encode(TEMPORARY_FILE_LIST_FILE_CONTENT).decode()
|
||||
)
|
||||
TEMPORARY_FILE_LIST.seek(0)
|
||||
|
||||
TEMPORARY_FILE_VIEW = get_temporary_file(prefix='VIEW')
|
||||
TEMPORARY_FILE_VIEW = get_temporary_file(prefix="VIEW")
|
||||
TEMPORARY_FILE_VIEW_FILE_CONTENT = TEMPORARY_FILE_VIEW.read()
|
||||
TEMPORARY_FILE_VIEW_FILE_BASE64 = BASE64_PREFIX + base64.b64encode(
|
||||
TEMPORARY_FILE_VIEW_FILE_CONTENT
|
||||
).decode()
|
||||
TEMPORARY_FILE_VIEW_FILE_BASE64 = (
|
||||
BASE64_PREFIX + base64.b64encode(TEMPORARY_FILE_VIEW_FILE_CONTENT).decode()
|
||||
)
|
||||
TEMPORARY_FILE_VIEW.seek(0)
|
||||
|
||||
TEMPORARY_FILE_ADD = get_temporary_file(prefix='ADD')
|
||||
TEMPORARY_FILE_ADD = get_temporary_file(prefix="ADD")
|
||||
TEMPORARY_FILE_ADD_FILE_CONTENT = TEMPORARY_FILE_ADD.read()
|
||||
TEMPORARY_FILE_ADD_FILE_BASE64 = BASE64_PREFIX + base64.b64encode(
|
||||
TEMPORARY_FILE_ADD_FILE_CONTENT
|
||||
).decode()
|
||||
TEMPORARY_FILE_ADD_FILE_BASE64 = (
|
||||
BASE64_PREFIX + base64.b64encode(TEMPORARY_FILE_ADD_FILE_CONTENT).decode()
|
||||
)
|
||||
TEMPORARY_FILE_ADD.seek(0)
|
||||
|
||||
TEMPORARY_FILE_CHANGE = get_temporary_file(prefix='CHANGE')
|
||||
TEMPORARY_FILE_CHANGE = get_temporary_file(prefix="CHANGE")
|
||||
TEMPORARY_FILE_CHANGE_FILE_CONTENT = TEMPORARY_FILE_CHANGE.read()
|
||||
TEMPORARY_FILE_CHANGE_FILE_BASE64 = BASE64_PREFIX + base64.b64encode(
|
||||
TEMPORARY_FILE_CHANGE_FILE_CONTENT
|
||||
).decode()
|
||||
TEMPORARY_FILE_CHANGE_FILE_BASE64 = (
|
||||
BASE64_PREFIX
|
||||
+ base64.b64encode(TEMPORARY_FILE_CHANGE_FILE_CONTENT).decode()
|
||||
)
|
||||
TEMPORARY_FILE_CHANGE.seek(0)
|
||||
|
||||
TEMPORARY_FILE_CHANGE_CHANGED = get_temporary_file(prefix='CHANGE_CHANGED')
|
||||
TEMPORARY_FILE_CHANGE_CHANGED_FILE_CONTENT = \
|
||||
TEMPORARY_FILE_CHANGE_CHANGED = get_temporary_file(prefix="CHANGE_CHANGED")
|
||||
TEMPORARY_FILE_CHANGE_CHANGED_FILE_CONTENT = (
|
||||
TEMPORARY_FILE_CHANGE_CHANGED.read()
|
||||
TEMPORARY_FILE_CHANGE_CHANGED_FILE_BASE64 = BASE64_PREFIX + base64.b64encode(
|
||||
TEMPORARY_FILE_CHANGE_CHANGED_FILE_CONTENT
|
||||
).decode()
|
||||
)
|
||||
TEMPORARY_FILE_CHANGE_CHANGED_FILE_BASE64 = (
|
||||
BASE64_PREFIX
|
||||
+ base64.b64encode(TEMPORARY_FILE_CHANGE_CHANGED_FILE_CONTENT).decode()
|
||||
)
|
||||
TEMPORARY_FILE_CHANGE_CHANGED.seek(0)
|
||||
|
||||
TEMPORARY_FILE_DELETE = get_temporary_file(prefix='DELETE')
|
||||
TEMPORARY_FILE_DELETE = get_temporary_file(prefix="DELETE")
|
||||
TEMPORARY_FILE_DELETE_FILE_CONTENT = TEMPORARY_FILE_DELETE.read()
|
||||
TEMPORARY_FILE_DELETE_FILE_BASE64 = BASE64_PREFIX + base64.b64encode(
|
||||
TEMPORARY_FILE_DELETE_FILE_CONTENT
|
||||
).decode()
|
||||
TEMPORARY_FILE_DELETE_FILE_BASE64 = (
|
||||
BASE64_PREFIX
|
||||
+ base64.b64encode(TEMPORARY_FILE_DELETE_FILE_CONTENT).decode()
|
||||
)
|
||||
TEMPORARY_FILE_DELETE.seek(0)
|
||||
|
|
|
|||
|
|
@ -1,17 +1,17 @@
|
|||
from factory.django import DjangoModelFactory
|
||||
|
||||
from fobi.models import FormEntry
|
||||
|
||||
from .factory_faker import Faker
|
||||
|
||||
__all__ = ('FormEntryFactory',)
|
||||
from fobi.models import FormEntry
|
||||
|
||||
__all__ = ("FormEntryFactory",)
|
||||
|
||||
|
||||
class BaseFormEntryFactory(DjangoModelFactory):
|
||||
"""Factory for creating a site."""
|
||||
|
||||
domain = Faker('domain_name')
|
||||
name = Faker('domain_name')
|
||||
domain = Faker("domain_name")
|
||||
name = Faker("domain_name")
|
||||
|
||||
class Meta(object):
|
||||
"""Options."""
|
||||
|
|
|
|||
|
|
@ -1,41 +1,40 @@
|
|||
from factory.django import DjangoModelFactory
|
||||
from factory.fuzzy import FuzzyChoice
|
||||
|
||||
from feincms.module.medialibrary.models import MediaFile
|
||||
|
||||
from .factory_faker import Faker
|
||||
|
||||
__all__ = (
|
||||
'ImageMediaFileFactory',
|
||||
'MediaFileFactory',
|
||||
'TextMediaFileFactory',
|
||||
'VideoMediaFileFactory',
|
||||
"ImageMediaFileFactory",
|
||||
"MediaFileFactory",
|
||||
"TextMediaFileFactory",
|
||||
"VideoMediaFileFactory",
|
||||
)
|
||||
|
||||
|
||||
class MediaFileFactory(DjangoModelFactory):
|
||||
"""MediaFile factory."""
|
||||
|
||||
file = Faker('django_file')
|
||||
file = Faker("django_file")
|
||||
type = FuzzyChoice(
|
||||
[
|
||||
'image',
|
||||
'video',
|
||||
'pdf',
|
||||
'audio',
|
||||
'swf',
|
||||
'txt',
|
||||
'rtf',
|
||||
'zip',
|
||||
'doc',
|
||||
'xls',
|
||||
'ppt',
|
||||
'other',
|
||||
"image",
|
||||
"video",
|
||||
"pdf",
|
||||
"audio",
|
||||
"swf",
|
||||
"txt",
|
||||
"rtf",
|
||||
"zip",
|
||||
"doc",
|
||||
"xls",
|
||||
"ppt",
|
||||
"other",
|
||||
]
|
||||
)
|
||||
created = Faker('date_time_ad')
|
||||
copyright = Faker('name')
|
||||
file_size = Faker('pyint')
|
||||
created = Faker("date_time_ad")
|
||||
copyright = Faker("name")
|
||||
file_size = Faker("pyint")
|
||||
|
||||
class Meta(object):
|
||||
"""Meta options."""
|
||||
|
|
@ -46,19 +45,19 @@ class MediaFileFactory(DjangoModelFactory):
|
|||
class VideoMediaFileFactory(MediaFileFactory):
|
||||
"""Video."""
|
||||
|
||||
file = Faker('django_file', extension='video')
|
||||
type = 'video'
|
||||
file = Faker("django_file", extension="video")
|
||||
type = "video"
|
||||
|
||||
|
||||
class ImageMediaFileFactory(MediaFileFactory):
|
||||
"""Image."""
|
||||
|
||||
file = Faker('django_file', extension='image')
|
||||
type = 'image'
|
||||
file = Faker("django_file", extension="image")
|
||||
type = "image"
|
||||
|
||||
|
||||
class TextMediaFileFactory(MediaFileFactory):
|
||||
"""Text."""
|
||||
|
||||
file = Faker('django_file', extension='text')
|
||||
type = 'txt'
|
||||
file = Faker("django_file", extension="text")
|
||||
type = "txt"
|
||||
|
|
|
|||
|
|
@ -2,19 +2,18 @@ import datetime
|
|||
import random
|
||||
|
||||
from django.utils.text import slugify
|
||||
|
||||
from factory import LazyAttribute
|
||||
from factory.django import DjangoModelFactory
|
||||
|
||||
from .factory_faker import Faker
|
||||
|
||||
__all__ = (
|
||||
'FeincmsBaseMixinFactory',
|
||||
'TimeStampedMixinFactory',
|
||||
'SortableMixinFactory',
|
||||
'PublishedContentMixinFactory',
|
||||
'OrderedContentMixinFactory',
|
||||
'ContentMixinFactory',
|
||||
"FeincmsBaseMixinFactory",
|
||||
"TimeStampedMixinFactory",
|
||||
"SortableMixinFactory",
|
||||
"PublishedContentMixinFactory",
|
||||
"OrderedContentMixinFactory",
|
||||
"ContentMixinFactory",
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -30,11 +29,10 @@ class FeincmsBaseMixinFactory(DjangoModelFactory):
|
|||
class TimeStampedMixinFactory(DjangoModelFactory):
|
||||
"""Mixin for time stamped model."""
|
||||
|
||||
created_date = Faker('date_time')
|
||||
created_date = Faker("date_time")
|
||||
modified_date = LazyAttribute(
|
||||
lambda __x: __x.created_date + datetime.timedelta(
|
||||
days=random.randint(1, 100)
|
||||
)
|
||||
lambda __x: __x.created_date
|
||||
+ datetime.timedelta(days=random.randint(1, 100))
|
||||
)
|
||||
publish_date = datetime.datetime.now() - datetime.timedelta(days=1)
|
||||
|
||||
|
|
@ -47,7 +45,7 @@ class TimeStampedMixinFactory(DjangoModelFactory):
|
|||
class SortableMixinFactory(DjangoModelFactory):
|
||||
"""Sortable mixin factory."""
|
||||
|
||||
order = Faker('pyint')
|
||||
order = Faker("pyint")
|
||||
|
||||
class Meta(object):
|
||||
"""Meta class."""
|
||||
|
|
@ -78,12 +76,14 @@ class OrderedContentMixinFactory(DjangoModelFactory):
|
|||
abstract = True
|
||||
|
||||
|
||||
class BaseContentMixinFactory(FeincmsBaseMixinFactory,
|
||||
TimeStampedMixinFactory,
|
||||
PublishedContentMixinFactory):
|
||||
class BaseContentMixinFactory(
|
||||
FeincmsBaseMixinFactory,
|
||||
TimeStampedMixinFactory,
|
||||
PublishedContentMixinFactory,
|
||||
):
|
||||
"""BaseContentMixinFactory."""
|
||||
|
||||
title = Faker('text', max_nb_chars=100)
|
||||
title = Faker("text", max_nb_chars=100)
|
||||
slug = LazyAttribute(lambda obj: slugify(obj.title)[:100])
|
||||
|
||||
class Meta(object):
|
||||
|
|
@ -101,8 +101,7 @@ class DjangoContentMixinFactory(DjangoModelFactory):
|
|||
abstract = True
|
||||
|
||||
|
||||
class ContentMixinFactory(BaseContentMixinFactory,
|
||||
DjangoContentMixinFactory):
|
||||
class ContentMixinFactory(BaseContentMixinFactory, DjangoContentMixinFactory):
|
||||
"""ContentMixinFactory."""
|
||||
|
||||
class Meta(object):
|
||||
|
|
|
|||
|
|
@ -1,40 +1,32 @@
|
|||
import logging
|
||||
|
||||
from django.utils.text import slugify
|
||||
|
||||
from factory import (
|
||||
LazyAttribute,
|
||||
SubFactory,
|
||||
post_generation,
|
||||
)
|
||||
from factory import LazyAttribute, SubFactory, post_generation
|
||||
from factory.django import DjangoModelFactory
|
||||
from factory.fuzzy import FuzzyChoice
|
||||
|
||||
from fobi.tests.helpers import create_form_with_entries
|
||||
|
||||
from page.models import Page
|
||||
|
||||
from .factory_faker import Faker
|
||||
|
||||
from fobi.tests.helpers import create_form_with_entries
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
__all__ = (
|
||||
'TEMPLATE_KEYS',
|
||||
'PageFactory',
|
||||
'FobiFormPageFactory',
|
||||
"TEMPLATE_KEYS",
|
||||
"PageFactory",
|
||||
"FobiFormPageFactory",
|
||||
)
|
||||
|
||||
TEMPLATE_DEFAULT = 'page/base.html'
|
||||
TEMPLATE_DEFAULT = "page/base.html"
|
||||
|
||||
TEMPLATE_KEYS = (
|
||||
TEMPLATE_DEFAULT,
|
||||
)
|
||||
TEMPLATE_KEYS = (TEMPLATE_DEFAULT,)
|
||||
|
||||
|
||||
class BasePageFactory(DjangoModelFactory):
|
||||
"""Base page factory."""
|
||||
|
||||
title = Faker('text', max_nb_chars=200)
|
||||
title = Faker("text", max_nb_chars=200)
|
||||
slug = LazyAttribute(lambda __x: slugify(__x.title))
|
||||
active = True
|
||||
in_navigation = FuzzyChoice([True, False])
|
||||
|
|
@ -55,7 +47,7 @@ class PageFactory(BasePageFactory):
|
|||
class HomePageFactory(BasePageFactory):
|
||||
"""Home page factory."""
|
||||
|
||||
override_url = '/'
|
||||
override_url = "/"
|
||||
title = "Home"
|
||||
slug = "home"
|
||||
|
||||
|
|
@ -63,7 +55,7 @@ class HomePageFactory(BasePageFactory):
|
|||
"""Meta class."""
|
||||
|
||||
model = Page
|
||||
django_get_or_create = ('slug',)
|
||||
django_get_or_create = ("slug",)
|
||||
|
||||
|
||||
class FobiFormPageFactory(BasePageFactory):
|
||||
|
|
@ -76,7 +68,7 @@ class FobiFormPageFactory(BasePageFactory):
|
|||
"""Meta class."""
|
||||
|
||||
model = Page
|
||||
django_get_or_create = ('slug',)
|
||||
django_get_or_create = ("slug",)
|
||||
|
||||
@post_generation
|
||||
def fobi_form_content(obj, created, extracted, **kwargs):
|
||||
|
|
@ -85,7 +77,5 @@ class FobiFormPageFactory(BasePageFactory):
|
|||
if created:
|
||||
form_entry = create_form_with_entries(is_public=True)
|
||||
obj.content.item.fobiformwidget_set.model.objects.create(
|
||||
parent=obj,
|
||||
region='main',
|
||||
form_entry=form_entry
|
||||
parent=obj, region="main", form_entry=form_entry
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,18 +1,20 @@
|
|||
from factory.django import DjangoModelFactory
|
||||
|
||||
from django.conf import settings
|
||||
from django.contrib.sites.models import Site
|
||||
from factory.django import DjangoModelFactory
|
||||
|
||||
from .factory_faker import Faker
|
||||
|
||||
__all__ = ('SiteFactory', 'DefaultSiteFactory',)
|
||||
__all__ = (
|
||||
"SiteFactory",
|
||||
"DefaultSiteFactory",
|
||||
)
|
||||
|
||||
|
||||
class SiteFactory(DjangoModelFactory):
|
||||
"""Factory for creating a site."""
|
||||
|
||||
domain = Faker('domain_name')
|
||||
name = Faker('domain_name')
|
||||
domain = Faker("domain_name")
|
||||
name = Faker("domain_name")
|
||||
|
||||
class Meta:
|
||||
model = Site
|
||||
|
|
@ -27,4 +29,4 @@ class DefaultSiteFactory(SiteFactory):
|
|||
"""Meta class."""
|
||||
|
||||
model = Site
|
||||
django_get_or_create = ('id',)
|
||||
django_get_or_create = ("id",)
|
||||
|
|
|
|||
|
|
@ -3,12 +3,11 @@ from __future__ import print_function
|
|||
import logging
|
||||
|
||||
from fobi.base import (
|
||||
form_callback_registry,
|
||||
FormCallback,
|
||||
integration_form_callback_registry,
|
||||
IntegrationFormCallback,
|
||||
form_callback_registry,
|
||||
integration_form_callback_registry,
|
||||
)
|
||||
|
||||
from fobi.constants import (
|
||||
CALLBACK_BEFORE_FORM_VALIDATION,
|
||||
CALLBACK_FORM_INVALID,
|
||||
|
|
@ -16,8 +15,8 @@ from fobi.constants import (
|
|||
CALLBACK_FORM_VALID_AFTER_FORM_HANDLERS,
|
||||
CALLBACK_FORM_VALID_BEFORE_SUBMIT_PLUGIN_FORM_DATA,
|
||||
)
|
||||
|
||||
from fobi.contrib.apps.drf_integration import UID as INTEGRATE_WITH
|
||||
|
||||
# from fobi.contrib.plugins.form_handlers.db_store.callbacks import (
|
||||
# AutoFormDbStore
|
||||
# )
|
||||
|
|
@ -25,11 +24,11 @@ from fobi.contrib.apps.drf_integration import UID as INTEGRATE_WITH
|
|||
# AutoFormMail
|
||||
# )
|
||||
|
||||
logger = logging.getLogger('fobi')
|
||||
logger = logging.getLogger("fobi")
|
||||
|
||||
__all__ = (
|
||||
'SaveAsFooItem',
|
||||
'DummyInvalidCallback',
|
||||
"SaveAsFooItem",
|
||||
"DummyInvalidCallback",
|
||||
)
|
||||
|
||||
# *************************************************************
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
from django.core.management.base import BaseCommand
|
||||
|
||||
from fobi.tests.helpers import (
|
||||
create_form_with_entries,
|
||||
get_or_create_admin_user,
|
||||
create_form_with_entries
|
||||
)
|
||||
|
||||
__all__ = ('Command',)
|
||||
__all__ = ("Command",)
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
from django.db import models
|
||||
|
||||
__all__ = ('FileTest',)
|
||||
__all__ = ("FileTest",)
|
||||
|
||||
|
||||
class FileTest(models.Model):
|
||||
"""File test."""
|
||||
|
||||
file = models.FileField(upload_to='foo/')
|
||||
file = models.FileField(upload_to="foo/")
|
||||
|
|
|
|||
|
|
@ -1,14 +1,11 @@
|
|||
from django.urls import re_path as url
|
||||
|
||||
from .views import (
|
||||
endpoint as foo_views_endpoint,
|
||||
forms_list as foo_forms_list
|
||||
)
|
||||
from .views import endpoint as foo_views_endpoint, forms_list as foo_forms_list
|
||||
|
||||
__all__ = ('urlpatterns',)
|
||||
__all__ = ("urlpatterns",)
|
||||
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^endpoint/$', view=foo_views_endpoint, name='foo.endpoint'),
|
||||
url(r'^forms-list/$', view=foo_forms_list, name='foo.forms_list'),
|
||||
url(r"^endpoint/$", view=foo_views_endpoint, name="foo.endpoint"),
|
||||
url(r"^forms-list/$", view=foo_forms_list, name="foo.forms_list"),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -2,21 +2,20 @@ import logging
|
|||
import uuid
|
||||
|
||||
from django.http import HttpResponse
|
||||
from django.shortcuts import render
|
||||
from django.template import RequestContext
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
from django.shortcuts import render
|
||||
from django_nine import versions
|
||||
|
||||
from fobi.base import get_theme
|
||||
from fobi.helpers import handle_uploaded_file
|
||||
from fobi.models import FormEntry
|
||||
|
||||
from django_nine import versions
|
||||
|
||||
logger = logging.getLogger('fobi')
|
||||
logger = logging.getLogger("fobi")
|
||||
|
||||
__all__ = (
|
||||
'endpoint',
|
||||
'forms_list',
|
||||
"endpoint",
|
||||
"forms_list",
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -30,30 +29,31 @@ def endpoint(request):
|
|||
logger.debug("POST: {0}\nFILES: {1}".format(request.POST, request.FILES))
|
||||
|
||||
for field_name, imf in request.FILES.items():
|
||||
handle_uploaded_file('foo', "{0}".format(uuid.uuid4()))
|
||||
handle_uploaded_file("foo", "{0}".format(uuid.uuid4()))
|
||||
|
||||
return HttpResponse(
|
||||
"POST: {0}\nFILES: {1}".format(request.POST, request.FILES)
|
||||
)
|
||||
|
||||
|
||||
def forms_list(request, template_name='foo/forms_list.html'):
|
||||
def forms_list(request, template_name="foo/forms_list.html"):
|
||||
"""Fobi forms list.
|
||||
|
||||
:param django.http.HttpRequest request:
|
||||
:param string template_name:
|
||||
:return django.http.HttpResponse:
|
||||
"""
|
||||
form_entries = FormEntry._default_manager.filter(is_public=True) \
|
||||
.select_related('user')
|
||||
form_entries = FormEntry._default_manager.filter(
|
||||
is_public=True
|
||||
).select_related("user")
|
||||
theme = get_theme(request=request, as_instance=True)
|
||||
context = {
|
||||
'form_entries': form_entries,
|
||||
'theme': theme,
|
||||
'show_custom_actions': False,
|
||||
'show_edit_link': False,
|
||||
'show_delete_link': False,
|
||||
'show_export_link': False,
|
||||
"form_entries": form_entries,
|
||||
"theme": theme,
|
||||
"show_custom_actions": False,
|
||||
"show_edit_link": False,
|
||||
"show_delete_link": False,
|
||||
"show_export_link": False,
|
||||
}
|
||||
|
||||
return render(request, template_name, context)
|
||||
|
|
|
|||
|
|
@ -3,14 +3,14 @@ from django.utils.translation import gettext_lazy as _
|
|||
|
||||
from .models import SavedFormDataEntryReference
|
||||
|
||||
__all__ = ('SavedFormDataEntryReferenceAdmin',)
|
||||
__all__ = ("SavedFormDataEntryReferenceAdmin",)
|
||||
|
||||
|
||||
class SavedFormDataEntryReferenceAdmin(admin.ModelAdmin):
|
||||
list_display = ('form',)
|
||||
list_display = ("form",)
|
||||
|
||||
class Meta:
|
||||
app_label = _('ForeignKey to db_store.SavedFormDataEntry')
|
||||
app_label = _("ForeignKey to db_store.SavedFormDataEntry")
|
||||
|
||||
|
||||
admin.site.register(
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
from django.db import models
|
||||
from six import python_2_unicode_compatible
|
||||
|
||||
from django.db import models
|
||||
|
||||
__all__ = ('SavedFormDataEntryReference',)
|
||||
__all__ = ("SavedFormDataEntryReference",)
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
|
|
@ -14,7 +13,7 @@ class SavedFormDataEntryReference(models.Model):
|
|||
"""
|
||||
|
||||
form = models.ForeignKey(
|
||||
'fobi_contrib_plugins_form_handlers_db_store.SavedFormDataEntry'
|
||||
"fobi_contrib_plugins_form_handlers_db_store.SavedFormDataEntry"
|
||||
)
|
||||
|
||||
def __str__(self):
|
||||
|
|
|
|||
|
|
@ -2,15 +2,15 @@ from django.forms.fields import ChoiceField
|
|||
from django.forms.widgets import RadioSelect
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from .forms import RadioInputForm
|
||||
|
||||
from fobi.base import FormFieldPlugin, form_element_plugin_registry, get_theme
|
||||
from fobi.contrib.plugins.form_elements.fields.radio import UID
|
||||
from fobi.helpers import safe_text, get_select_field_choices
|
||||
|
||||
from .forms import RadioInputForm
|
||||
from fobi.helpers import get_select_field_choices, safe_text
|
||||
|
||||
theme = get_theme(request=None, as_instance=True)
|
||||
|
||||
__all__ = ('RadioInputPlugin',)
|
||||
__all__ = ("RadioInputPlugin",)
|
||||
|
||||
|
||||
class RadioInputPlugin(FormFieldPlugin):
|
||||
|
|
@ -21,25 +21,27 @@ class RadioInputPlugin(FormFieldPlugin):
|
|||
group = _("Fields")
|
||||
form = RadioInputForm
|
||||
|
||||
def get_form_field_instances(self, request=None, form_entry=None,
|
||||
form_element_entries=None, **kwargs):
|
||||
def get_form_field_instances(
|
||||
self, request=None, form_entry=None, form_element_entries=None, **kwargs
|
||||
):
|
||||
"""Get form field instances."""
|
||||
choices = get_select_field_choices(self.data.choices)
|
||||
|
||||
widget_attrs = {'class': theme.form_radio_element_html_class}
|
||||
widget_attrs = {"class": theme.form_radio_element_html_class}
|
||||
field_kwargs = {
|
||||
'label': self.data.label,
|
||||
'help_text': self.data.help_text,
|
||||
'initial': self.data.initial,
|
||||
'required': self.data.required,
|
||||
'choices': choices,
|
||||
'widget': RadioSelect(attrs=widget_attrs),
|
||||
"label": self.data.label,
|
||||
"help_text": self.data.help_text,
|
||||
"initial": self.data.initial,
|
||||
"required": self.data.required,
|
||||
"choices": choices,
|
||||
"widget": RadioSelect(attrs=widget_attrs),
|
||||
}
|
||||
|
||||
return [(self.data.name, ChoiceField, field_kwargs)]
|
||||
|
||||
def submit_plugin_form_data(self, form_entry, request, form,
|
||||
form_element_entries=None, **kwargs):
|
||||
def submit_plugin_form_data(
|
||||
self, form_entry, request, form, form_element_entries=None, **kwargs
|
||||
):
|
||||
"""Submit plugin form data/process.
|
||||
|
||||
:param fobi.models.FormEntry form_entry: Instance of
|
||||
|
|
@ -53,7 +55,7 @@ class RadioInputPlugin(FormFieldPlugin):
|
|||
if value:
|
||||
choices = dict(get_select_field_choices(self.data.choices))
|
||||
# Handle the submitted form value
|
||||
value = '{0}'.format(safe_text(choices.get(value)))
|
||||
value = "{0}".format(safe_text(choices.get(value)))
|
||||
|
||||
# Overwrite ``cleaned_data`` of the ``form`` with object qualifier.
|
||||
form.cleaned_data[self.data.name] = value
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ from fobi.helpers import validate_initial_for_choices
|
|||
|
||||
theme = get_theme(request=None, as_instance=True)
|
||||
|
||||
__all__ = ('RadioInputForm',)
|
||||
__all__ = ("RadioInputForm",)
|
||||
|
||||
|
||||
class RadioInputForm(forms.Form, BaseFormFieldPluginForm):
|
||||
|
|
@ -18,76 +18,78 @@ class RadioInputForm(forms.Form, BaseFormFieldPluginForm):
|
|||
("choices", ""),
|
||||
("help_text", ""),
|
||||
("initial", ""),
|
||||
("required", False)
|
||||
("required", False),
|
||||
]
|
||||
|
||||
label = forms.CharField(
|
||||
label=_("Label"),
|
||||
required=True,
|
||||
widget=forms.widgets.TextInput(
|
||||
attrs={'class': theme.form_element_html_class}
|
||||
)
|
||||
attrs={"class": theme.form_element_html_class}
|
||||
),
|
||||
)
|
||||
name = forms.CharField(
|
||||
label=_("Name"),
|
||||
required=True,
|
||||
widget=forms.widgets.TextInput(
|
||||
attrs={'class': theme.form_element_html_class}
|
||||
)
|
||||
attrs={"class": theme.form_element_html_class}
|
||||
),
|
||||
)
|
||||
choices = forms.CharField(
|
||||
label=_("Choices"),
|
||||
required=False,
|
||||
help_text=_("Enter single values/pairs per line. Example:<code><br/>"
|
||||
" 1<br/>"
|
||||
" 2<br/>"
|
||||
" alpha, Alpha<br/>"
|
||||
" beta, Beta<br/>"
|
||||
" omega"
|
||||
"</code><br/>"
|
||||
"It finally transforms into the following HTML code:"
|
||||
"<code><br/>"
|
||||
' <select '
|
||||
'id="id_NAME_OF_THE_ELEMENT" '
|
||||
'name="NAME_OF_THE_ELEMENT"><br/>'
|
||||
' '
|
||||
'<option value="1">1</option><br/>'
|
||||
' '
|
||||
'<option value="2">2</option><br/>'
|
||||
' '
|
||||
'<option value="alpha">Alpha</option><br/>'
|
||||
' '
|
||||
'<option value="beta">Beta</option><br/>'
|
||||
' '
|
||||
'<option value="omega">omega</option><br/>'
|
||||
' </select>'
|
||||
"</code>"),
|
||||
help_text=_(
|
||||
"Enter single values/pairs per line. Example:<code><br/>"
|
||||
" 1<br/>"
|
||||
" 2<br/>"
|
||||
" alpha, Alpha<br/>"
|
||||
" beta, Beta<br/>"
|
||||
" omega"
|
||||
"</code><br/>"
|
||||
"It finally transforms into the following HTML code:"
|
||||
"<code><br/>"
|
||||
" <select "
|
||||
'id="id_NAME_OF_THE_ELEMENT" '
|
||||
'name="NAME_OF_THE_ELEMENT"><br/>'
|
||||
" "
|
||||
'<option value="1">1</option><br/>'
|
||||
" "
|
||||
'<option value="2">2</option><br/>'
|
||||
" "
|
||||
'<option value="alpha">Alpha</option><br/>'
|
||||
" "
|
||||
'<option value="beta">Beta</option><br/>'
|
||||
" "
|
||||
'<option value="omega">omega</option><br/>'
|
||||
" </select>"
|
||||
"</code>"
|
||||
),
|
||||
widget=forms.widgets.Textarea(
|
||||
attrs={'class': theme.form_element_html_class}
|
||||
)
|
||||
attrs={"class": theme.form_element_html_class}
|
||||
),
|
||||
)
|
||||
help_text = forms.CharField(
|
||||
label=_("Help text"),
|
||||
required=False,
|
||||
widget=forms.widgets.Textarea(
|
||||
attrs={'class': theme.form_element_html_class}
|
||||
)
|
||||
attrs={"class": theme.form_element_html_class}
|
||||
),
|
||||
)
|
||||
initial = forms.CharField(
|
||||
label=_("Initial"),
|
||||
required=False,
|
||||
widget=forms.widgets.TextInput(
|
||||
attrs={'class': theme.form_element_html_class}
|
||||
)
|
||||
attrs={"class": theme.form_element_html_class}
|
||||
),
|
||||
)
|
||||
required = forms.BooleanField(
|
||||
label=_("Required"),
|
||||
required=False,
|
||||
widget=forms.widgets.CheckboxInput(
|
||||
attrs={'class': theme.form_element_checkbox_html_class}
|
||||
)
|
||||
attrs={"class": theme.form_element_checkbox_html_class}
|
||||
),
|
||||
)
|
||||
|
||||
def clean_initial(self):
|
||||
"""Validating the initial value."""
|
||||
return validate_initial_for_choices(self, 'choices', 'initial')
|
||||
return validate_initial_for_choices(self, "choices", "initial")
|
||||
|
|
|
|||
|
|
@ -3,15 +3,15 @@ from django.forms.models import ModelChoiceField
|
|||
from django.forms.widgets import Select
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from .forms import SelectModelObjectInputForm
|
||||
|
||||
from fobi.base import FormFieldPlugin, form_element_plugin_registry, get_theme
|
||||
from fobi.contrib.plugins.form_elements.fields.select_model_object import UID
|
||||
from fobi.helpers import safe_text
|
||||
|
||||
from .forms import SelectModelObjectInputForm
|
||||
|
||||
theme = get_theme(request=None, as_instance=True)
|
||||
|
||||
__all__ = ('SelectModelObjectInputPlugin',)
|
||||
__all__ = ("SelectModelObjectInputPlugin",)
|
||||
|
||||
|
||||
class SelectModelObjectInputPlugin(FormFieldPlugin):
|
||||
|
|
@ -22,26 +22,28 @@ class SelectModelObjectInputPlugin(FormFieldPlugin):
|
|||
group = _("Fields")
|
||||
form = SelectModelObjectInputForm
|
||||
|
||||
def get_form_field_instances(self, request=None, form_entry=None,
|
||||
form_element_entries=None, **kwargs):
|
||||
def get_form_field_instances(
|
||||
self, request=None, form_entry=None, form_element_entries=None, **kwargs
|
||||
):
|
||||
"""Get form field instances."""
|
||||
app_label, model_name = self.data.model.split('.')
|
||||
app_label, model_name = self.data.model.split(".")
|
||||
model = models.get_model(app_label, model_name)
|
||||
queryset = model._default_manager.all()
|
||||
|
||||
field_kwargs = {
|
||||
'label': self.data.label,
|
||||
'help_text': self.data.help_text,
|
||||
'initial': self.data.initial,
|
||||
'required': self.data.required,
|
||||
'queryset': queryset,
|
||||
'widget': Select(attrs={'class': theme.form_element_html_class}),
|
||||
"label": self.data.label,
|
||||
"help_text": self.data.help_text,
|
||||
"initial": self.data.initial,
|
||||
"required": self.data.required,
|
||||
"queryset": queryset,
|
||||
"widget": Select(attrs={"class": theme.form_element_html_class}),
|
||||
}
|
||||
|
||||
return [(self.data.name, ModelChoiceField, field_kwargs)]
|
||||
|
||||
def submit_plugin_form_data(self, form_entry, request, form,
|
||||
form_element_entries=None, **kwargs):
|
||||
def submit_plugin_form_data(
|
||||
self, form_entry, request, form, form_element_entries=None, **kwargs
|
||||
):
|
||||
"""Submit plugin form data/process.
|
||||
|
||||
:param fobi.models.FormEntry form_entry: Instance of
|
||||
|
|
@ -53,7 +55,7 @@ class SelectModelObjectInputPlugin(FormFieldPlugin):
|
|||
obj = form.cleaned_data.get(self.data.name, None)
|
||||
if obj:
|
||||
# Handle the submitted form value
|
||||
value = '{0}'.format(safe_text(obj))
|
||||
value = "{0}".format(safe_text(obj))
|
||||
|
||||
# Overwrite ``cleaned_data`` of the ``form`` with object qualifier.
|
||||
form.cleaned_data[self.data.name] = value
|
||||
|
|
|
|||
|
|
@ -2,13 +2,14 @@ from django import forms
|
|||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from fobi.base import BaseFormFieldPluginForm, get_theme
|
||||
from fobi.contrib.plugins.form_elements.fields.select_model_object.settings import (
|
||||
IGNORED_MODELS,
|
||||
)
|
||||
from fobi.helpers import get_registered_models
|
||||
from fobi.contrib.plugins.form_elements.fields.select_model_object.settings \
|
||||
import IGNORED_MODELS
|
||||
|
||||
theme = get_theme(request=None, as_instance=True)
|
||||
|
||||
__all__ = ('SelectModelObjectInputForm',)
|
||||
__all__ = ("SelectModelObjectInputForm",)
|
||||
|
||||
|
||||
class SelectModelObjectInputForm(forms.Form, BaseFormFieldPluginForm):
|
||||
|
|
@ -20,56 +21,56 @@ class SelectModelObjectInputForm(forms.Form, BaseFormFieldPluginForm):
|
|||
("model", ""),
|
||||
("help_text", ""),
|
||||
("initial", ""),
|
||||
("required", False)
|
||||
("required", False),
|
||||
]
|
||||
|
||||
label = forms.CharField(
|
||||
label=_("Label"),
|
||||
required=True,
|
||||
widget=forms.widgets.TextInput(
|
||||
attrs={'class': theme.form_element_html_class}
|
||||
)
|
||||
attrs={"class": theme.form_element_html_class}
|
||||
),
|
||||
)
|
||||
name = forms.CharField(
|
||||
label=_("Name"),
|
||||
required=True,
|
||||
widget=forms.widgets.TextInput(
|
||||
attrs={'class': theme.form_element_html_class}
|
||||
)
|
||||
attrs={"class": theme.form_element_html_class}
|
||||
),
|
||||
)
|
||||
model = forms.ChoiceField(
|
||||
label=_("Model"),
|
||||
choices=[],
|
||||
required=False,
|
||||
widget=forms.widgets.Select(
|
||||
attrs={'class': theme.form_element_html_class}
|
||||
)
|
||||
attrs={"class": theme.form_element_html_class}
|
||||
),
|
||||
)
|
||||
help_text = forms.CharField(
|
||||
label=_("Help text"),
|
||||
required=False,
|
||||
widget=forms.widgets.Textarea(
|
||||
attrs={'class': theme.form_element_html_class}
|
||||
)
|
||||
attrs={"class": theme.form_element_html_class}
|
||||
),
|
||||
)
|
||||
initial = forms.CharField(
|
||||
label=_("Initial"),
|
||||
required=False,
|
||||
widget=forms.widgets.TextInput(
|
||||
attrs={'class': theme.form_element_html_class}
|
||||
)
|
||||
attrs={"class": theme.form_element_html_class}
|
||||
),
|
||||
)
|
||||
required = forms.BooleanField(
|
||||
label=_("Required"),
|
||||
required=False,
|
||||
widget=forms.widgets.CheckboxInput(
|
||||
attrs={'class': theme.form_element_checkbox_html_class}
|
||||
)
|
||||
attrs={"class": theme.form_element_checkbox_html_class}
|
||||
),
|
||||
)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
"""In order to avoid static calls to `get_registered_models`."""
|
||||
super(SelectModelObjectInputForm, self).__init__(*args, **kwargs)
|
||||
self.fields['model'].choices = get_registered_models(
|
||||
self.fields["model"].choices = get_registered_models(
|
||||
ignore=IGNORED_MODELS
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,18 +1,18 @@
|
|||
from fobi.base import theme_registry
|
||||
|
||||
from fobi.contrib.themes.simple.fobi_themes import SimpleTheme
|
||||
|
||||
__all__ = ('MySimpleTheme',)
|
||||
__all__ = ("MySimpleTheme",)
|
||||
|
||||
|
||||
class MySimpleTheme(SimpleTheme):
|
||||
"""Overriding the "simple" theme."""
|
||||
|
||||
html_classes = ['my-simple-theme']
|
||||
base_view_template = 'override_simple_theme/base_view.html'
|
||||
form_ajax = 'override_simple_theme/snippets/form_ajax.html'
|
||||
form_snippet_template_name = \
|
||||
'override_simple_theme/snippets/form_snippet.html'
|
||||
html_classes = ["my-simple-theme"]
|
||||
base_view_template = "override_simple_theme/base_view.html"
|
||||
form_ajax = "override_simple_theme/snippets/form_ajax.html"
|
||||
form_snippet_template_name = (
|
||||
"override_simple_theme/snippets/form_snippet.html"
|
||||
)
|
||||
|
||||
|
||||
# It's important to set the `force` argument to True, in
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
from django.contrib import admin
|
||||
|
||||
from feincms.module.page.modeladmins import PageAdmin
|
||||
|
||||
from page.models import Page
|
||||
|
||||
admin.site.register(Page, PageAdmin)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from feincms.content.raw.models import RawContent
|
||||
from feincms.content.richtext.models import RichTextContent
|
||||
from feincms.module.page.models import Page
|
||||
|
|
@ -7,18 +6,20 @@ from feincms.module.page.models import Page
|
|||
# Import the ``django-fobi`` widget.
|
||||
from fobi.contrib.apps.feincms_integration.widgets import FobiFormWidget
|
||||
|
||||
Page.register_extensions('feincms.module.extensions.translations',)
|
||||
Page.register_extensions(
|
||||
"feincms.module.extensions.translations",
|
||||
)
|
||||
|
||||
# Register basic template.
|
||||
Page.register_templates(
|
||||
{
|
||||
'title': _(u"Base template"),
|
||||
'path': 'page/base.html',
|
||||
'key': 'page_base',
|
||||
'regions': (
|
||||
('main', _(u"Main")),
|
||||
('sidebar', _(u"Sidebar")),
|
||||
)
|
||||
"title": _("Base template"),
|
||||
"path": "page/base.html",
|
||||
"key": "page_base",
|
||||
"regions": (
|
||||
("main", _("Main")),
|
||||
("sidebar", _("Sidebar")),
|
||||
),
|
||||
},
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
from captcha.fields import CaptchaField
|
||||
|
||||
from django_nine.versions import DJANGO_GTE_3_0
|
||||
|
||||
if DJANGO_GTE_3_0:
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
import os
|
||||
|
||||
from .base import *
|
||||
|
||||
LOCALE_PATHS = [
|
||||
os.path.abspath(os.path.join(BASE_DIR, 'fobi_locale')),
|
||||
os.path.abspath(os.path.join(BASE_DIR, 'locale')),
|
||||
os.path.abspath(os.path.join(BASE_DIR, "fobi_locale")),
|
||||
os.path.abspath(os.path.join(BASE_DIR, "locale")),
|
||||
]
|
||||
FOBI_SORT_PLUGINS_BY_VALUE = True
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -3,11 +3,14 @@ from .base import *
|
|||
INSTALLED_APPS = list(INSTALLED_APPS)
|
||||
|
||||
try:
|
||||
INSTALLED_APPS.remove('admin_tools') \
|
||||
if 'admin_tools' in INSTALLED_APPS else None
|
||||
INSTALLED_APPS.remove('admin_tools.menu') \
|
||||
if 'admin_tools.menu' in INSTALLED_APPS else None
|
||||
INSTALLED_APPS.remove('admin_tools.dashboard') \
|
||||
if 'admin_tools.dashboard' in INSTALLED_APPS else None
|
||||
INSTALLED_APPS.remove(
|
||||
"admin_tools"
|
||||
) if "admin_tools" in INSTALLED_APPS else None
|
||||
INSTALLED_APPS.remove(
|
||||
"admin_tools.menu"
|
||||
) if "admin_tools.menu" in INSTALLED_APPS else None
|
||||
INSTALLED_APPS.remove(
|
||||
"admin_tools.dashboard"
|
||||
) if "admin_tools.dashboard" in INSTALLED_APPS else None
|
||||
except Exception as err:
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -2,17 +2,14 @@ from .base import *
|
|||
|
||||
INSTALLED_APPS = list(INSTALLED_APPS)
|
||||
|
||||
if 'captcha' not in INSTALLED_APPS:
|
||||
INSTALLED_APPS.append('captcha')
|
||||
if "captcha" not in INSTALLED_APPS:
|
||||
INSTALLED_APPS.append("captcha")
|
||||
|
||||
|
||||
if 'fobi.contrib.plugins.form_elements.security.captcha' \
|
||||
not in INSTALLED_APPS:
|
||||
INSTALLED_APPS.append(
|
||||
'fobi.contrib.plugins.form_elements.security.captcha'
|
||||
)
|
||||
if "fobi.contrib.plugins.form_elements.security.captcha" not in INSTALLED_APPS:
|
||||
INSTALLED_APPS.append("fobi.contrib.plugins.form_elements.security.captcha")
|
||||
|
||||
CAPTCHA_TEXT_FIELD_TEMPLATE = 'bootstrap3/captcha/text_field.html'
|
||||
CAPTCHA_TEXT_FIELD_TEMPLATE = "bootstrap3/captcha/text_field.html"
|
||||
|
||||
ENABLE_CAPTCHA = True
|
||||
|
||||
|
|
|
|||
|
|
@ -4,13 +4,15 @@ INSTALLED_APPS = list(INSTALLED_APPS)
|
|||
|
||||
try:
|
||||
|
||||
if 'captcha' not in INSTALLED_APPS:
|
||||
INSTALLED_APPS.append('captcha')
|
||||
if "captcha" not in INSTALLED_APPS:
|
||||
INSTALLED_APPS.append("captcha")
|
||||
|
||||
if 'fobi.contrib.plugins.form_elements.security.captcha' \
|
||||
not in INSTALLED_APPS:
|
||||
if (
|
||||
"fobi.contrib.plugins.form_elements.security.captcha"
|
||||
not in INSTALLED_APPS
|
||||
):
|
||||
INSTALLED_APPS.append(
|
||||
'fobi.contrib.plugins.form_elements.security.captcha'
|
||||
"fobi.contrib.plugins.form_elements.security.captcha"
|
||||
)
|
||||
|
||||
except Exception as err:
|
||||
|
|
|
|||
|
|
@ -2,61 +2,63 @@ from .base import *
|
|||
|
||||
INSTALLED_APPS = list(INSTALLED_APPS)
|
||||
INSTALLED_APPS += [
|
||||
'cms', # DjangoCMS
|
||||
'mptt',
|
||||
'menus',
|
||||
'sekizai',
|
||||
"cms", # DjangoCMS
|
||||
"mptt",
|
||||
"menus",
|
||||
"sekizai",
|
||||
# 'djangocms_admin_style',
|
||||
|
||||
# Some plugins
|
||||
'djangocms_picture',
|
||||
'djangocms_snippet',
|
||||
|
||||
'fobi.contrib.apps.djangocms_integration', # Fobi DjangoCMS app
|
||||
|
||||
"djangocms_picture",
|
||||
"djangocms_snippet",
|
||||
"fobi.contrib.apps.djangocms_integration", # Fobi DjangoCMS app
|
||||
# 'djangocms_page', # Example
|
||||
]
|
||||
|
||||
try:
|
||||
INSTALLED_APPS.remove('admin_tools.dashboard') \
|
||||
if 'admin_tools.dashboard' in INSTALLED_APPS else None
|
||||
INSTALLED_APPS.remove(
|
||||
"admin_tools.dashboard"
|
||||
) if "admin_tools.dashboard" in INSTALLED_APPS else None
|
||||
except Exception as err:
|
||||
pass
|
||||
|
||||
MIDDLEWARE_CLASSES = list(MIDDLEWARE_CLASSES)
|
||||
MIDDLEWARE_CLASSES += [
|
||||
# 'django.middleware.cache.UpdateCacheMiddleware',
|
||||
'cms.middleware.page.CurrentPageMiddleware',
|
||||
'cms.middleware.user.CurrentUserMiddleware',
|
||||
'cms.middleware.toolbar.ToolbarMiddleware',
|
||||
'cms.middleware.language.LanguageCookieMiddleware',
|
||||
"cms.middleware.page.CurrentPageMiddleware",
|
||||
"cms.middleware.user.CurrentUserMiddleware",
|
||||
"cms.middleware.toolbar.ToolbarMiddleware",
|
||||
"cms.middleware.language.LanguageCookieMiddleware",
|
||||
# 'django.middleware.cache.FetchFromCacheMiddleware',
|
||||
]
|
||||
|
||||
TEMPLATE_CONTEXT_PROCESSORS = list(TEMPLATE_CONTEXT_PROCESSORS)
|
||||
TEMPLATE_CONTEXT_PROCESSORS += [
|
||||
'cms.context_processors.media',
|
||||
'sekizai.context_processors.sekizai',
|
||||
'cms.context_processors.cms_settings',
|
||||
"cms.context_processors.media",
|
||||
"sekizai.context_processors.sekizai",
|
||||
"cms.context_processors.cms_settings",
|
||||
]
|
||||
|
||||
FOBI_DEFAULT_THEME = 'bootstrap3'
|
||||
FOBI_DEFAULT_THEME = "bootstrap3"
|
||||
# FOBI_DEFAULT_THEME = 'foundation5'
|
||||
# FOBI_DEFAULT_THEME = 'simple'
|
||||
|
||||
CMS_TEMPLATES = (
|
||||
('cms_page/{0}/page_with_sidebar.html'.format(FOBI_DEFAULT_THEME),
|
||||
'General template with sidebar for {0}'.format(FOBI_DEFAULT_THEME)),
|
||||
('cms_page/{0}/page_without_sidebar.html'.format(FOBI_DEFAULT_THEME),
|
||||
'General template without sidebar for {0}'.format(FOBI_DEFAULT_THEME)),
|
||||
(
|
||||
"cms_page/{0}/page_with_sidebar.html".format(FOBI_DEFAULT_THEME),
|
||||
"General template with sidebar for {0}".format(FOBI_DEFAULT_THEME),
|
||||
),
|
||||
(
|
||||
"cms_page/{0}/page_without_sidebar.html".format(FOBI_DEFAULT_THEME),
|
||||
"General template without sidebar for {0}".format(FOBI_DEFAULT_THEME),
|
||||
),
|
||||
)
|
||||
|
||||
MIGRATION_MODULES = {
|
||||
'cms': 'cms.migrations_django',
|
||||
'menus': 'menus.migrations_django',
|
||||
"cms": "cms.migrations_django",
|
||||
"menus": "menus.migrations_django",
|
||||
}
|
||||
|
||||
LANGUAGE_CODE = 'en'
|
||||
LANGUAGE_CODE = "en"
|
||||
|
||||
# FEINCMS_RICHTEXT_INIT_CONTEXT = {
|
||||
# 'TINYMCE_JS_URL': STATIC_URL + 'tiny_mce/tiny_mce.js',
|
||||
|
|
|
|||
|
|
@ -1,23 +1,21 @@
|
|||
from cms import __version__
|
||||
|
||||
from .base import *
|
||||
|
||||
CMS_VERSION = [int(__v) for __v in __version__.split('.')]
|
||||
CMS_VERSION = [int(__v) for __v in __version__.split(".")]
|
||||
|
||||
INSTALLED_APPS = list(INSTALLED_APPS)
|
||||
INSTALLED_APPS += [
|
||||
'cms', # DjangoCMS
|
||||
'menus',
|
||||
'sekizai',
|
||||
'djangocms_admin_style',
|
||||
|
||||
"cms", # DjangoCMS
|
||||
"menus",
|
||||
"sekizai",
|
||||
"djangocms_admin_style",
|
||||
# Some plugins
|
||||
'filer',
|
||||
"filer",
|
||||
# 'cmsplugin_filer_image',
|
||||
# 'djangocms_picture',
|
||||
# 'djangocms_snippet',
|
||||
|
||||
'fobi.contrib.apps.djangocms_integration', # Fobi DjangoCMS app
|
||||
|
||||
"fobi.contrib.apps.djangocms_integration", # Fobi DjangoCMS app
|
||||
# 'djangocms_page', # Example
|
||||
]
|
||||
|
||||
|
|
@ -25,63 +23,67 @@ DJANGO_CMS_CONTEXT_PROCESSORS = []
|
|||
MIGRATION_MODULES = {}
|
||||
|
||||
if CMS_VERSION[0] <= 2 or (CMS_VERSION[0] == 3 and CMS_VERSION[1] == 0):
|
||||
INSTALLED_APPS.append('mptt')
|
||||
INSTALLED_APPS.append("mptt")
|
||||
DJANGO_CMS_CONTEXT_PROCESSORS = [
|
||||
'cms.context_processors.media',
|
||||
'sekizai.context_processors.sekizai',
|
||||
'cms.context_processors.cms_settings',
|
||||
'nine.context_processors.versions',
|
||||
'cms_addons.context_processors.cms_version',
|
||||
"cms.context_processors.media",
|
||||
"sekizai.context_processors.sekizai",
|
||||
"cms.context_processors.cms_settings",
|
||||
"nine.context_processors.versions",
|
||||
"cms_addons.context_processors.cms_version",
|
||||
]
|
||||
MIGRATION_MODULES = {
|
||||
'cms': 'cms.migrations_django',
|
||||
'menus': 'menus.migrations_django',
|
||||
"cms": "cms.migrations_django",
|
||||
"menus": "menus.migrations_django",
|
||||
}
|
||||
|
||||
else:
|
||||
INSTALLED_APPS.append('treebeard')
|
||||
INSTALLED_APPS.append('cms_addons')
|
||||
INSTALLED_APPS.append("treebeard")
|
||||
INSTALLED_APPS.append("cms_addons")
|
||||
DJANGO_CMS_CONTEXT_PROCESSORS = [
|
||||
'cms.context_processors.cms_settings',
|
||||
'sekizai.context_processors.sekizai',
|
||||
'cms.context_processors.cms_settings',
|
||||
'nine.context_processors.versions',
|
||||
'cms_addons.context_processors.cms_version',
|
||||
"cms.context_processors.cms_settings",
|
||||
"sekizai.context_processors.sekizai",
|
||||
"cms.context_processors.cms_settings",
|
||||
"nine.context_processors.versions",
|
||||
"cms_addons.context_processors.cms_version",
|
||||
]
|
||||
MIGRATION_MODULES = {
|
||||
'cms': 'cms.migrations',
|
||||
'menus': 'menus.migrations',
|
||||
"cms": "cms.migrations",
|
||||
"menus": "menus.migrations",
|
||||
}
|
||||
|
||||
try:
|
||||
INSTALLED_APPS.remove('admin_tools.dashboard') \
|
||||
if 'admin_tools.dashboard' in INSTALLED_APPS else None
|
||||
INSTALLED_APPS.remove(
|
||||
"admin_tools.dashboard"
|
||||
) if "admin_tools.dashboard" in INSTALLED_APPS else None
|
||||
except Exception as err:
|
||||
pass
|
||||
|
||||
MIDDLEWARE_CLASSES = list(MIDDLEWARE_CLASSES)
|
||||
MIDDLEWARE_CLASSES += [
|
||||
# 'django.middleware.cache.UpdateCacheMiddleware',
|
||||
'cms.middleware.page.CurrentPageMiddleware',
|
||||
'cms.middleware.user.CurrentUserMiddleware',
|
||||
'cms.middleware.toolbar.ToolbarMiddleware',
|
||||
'cms.middleware.language.LanguageCookieMiddleware',
|
||||
"cms.middleware.page.CurrentPageMiddleware",
|
||||
"cms.middleware.user.CurrentUserMiddleware",
|
||||
"cms.middleware.toolbar.ToolbarMiddleware",
|
||||
"cms.middleware.language.LanguageCookieMiddleware",
|
||||
# 'django.middleware.cache.FetchFromCacheMiddleware',
|
||||
]
|
||||
|
||||
|
||||
TEMPLATES[0]['OPTIONS']['context_processors'] += \
|
||||
DJANGO_CMS_CONTEXT_PROCESSORS
|
||||
TEMPLATES[0]["OPTIONS"]["context_processors"] += DJANGO_CMS_CONTEXT_PROCESSORS
|
||||
|
||||
FOBI_DEFAULT_THEME = 'bootstrap3'
|
||||
FOBI_DEFAULT_THEME = "bootstrap3"
|
||||
# FOBI_DEFAULT_THEME = 'foundation5'
|
||||
# FOBI_DEFAULT_THEME = 'simple'
|
||||
|
||||
CMS_TEMPLATES = (
|
||||
('cms_page/{0}/page_with_sidebar.html'.format(FOBI_DEFAULT_THEME),
|
||||
'General template with sidebar for {0}'.format(FOBI_DEFAULT_THEME)),
|
||||
('cms_page/{0}/page_without_sidebar.html'.format(FOBI_DEFAULT_THEME),
|
||||
'General template without sidebar for {0}'.format(FOBI_DEFAULT_THEME)),
|
||||
(
|
||||
"cms_page/{0}/page_with_sidebar.html".format(FOBI_DEFAULT_THEME),
|
||||
"General template with sidebar for {0}".format(FOBI_DEFAULT_THEME),
|
||||
),
|
||||
(
|
||||
"cms_page/{0}/page_without_sidebar.html".format(FOBI_DEFAULT_THEME),
|
||||
"General template without sidebar for {0}".format(FOBI_DEFAULT_THEME),
|
||||
),
|
||||
)
|
||||
|
||||
LANGUAGE_CODE = 'en'
|
||||
LANGUAGE_CODE = "en"
|
||||
|
|
|
|||
|
|
@ -1,36 +1,33 @@
|
|||
from .base import *
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
"default": {
|
||||
# Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
|
||||
'ENGINE': 'django.db.backends.sqlite3',
|
||||
"ENGINE": "django.db.backends.sqlite3",
|
||||
# Or path to database file if using sqlite3.
|
||||
'NAME': PROJECT_DIR('../db/example_djangocms_2.db'),
|
||||
"NAME": PROJECT_DIR("../db/example_djangocms_2.db"),
|
||||
# The following settings are not used with sqlite3:
|
||||
'USER': '',
|
||||
'PASSWORD': '',
|
||||
"USER": "",
|
||||
"PASSWORD": "",
|
||||
# Empty for localhost through domain sockets or '127.0.0.1' for
|
||||
# localhost through TCP.
|
||||
'HOST': '',
|
||||
"HOST": "",
|
||||
# Set to empty string for default.
|
||||
'PORT': '',
|
||||
"PORT": "",
|
||||
}
|
||||
}
|
||||
|
||||
INSTALLED_APPS = list(INSTALLED_APPS)
|
||||
INSTALLED_APPS += [
|
||||
'cms', # DjangoCMS
|
||||
'mptt',
|
||||
'menus',
|
||||
'sekizai',
|
||||
"cms", # DjangoCMS
|
||||
"mptt",
|
||||
"menus",
|
||||
"sekizai",
|
||||
# 'djangocms_admin_style',
|
||||
|
||||
# Some plugins
|
||||
'cms.plugins.picture',
|
||||
'cms.plugins.snippet',
|
||||
|
||||
'fobi.contrib.apps.djangocms_integration', # Fobi DjangoCMS app
|
||||
|
||||
"cms.plugins.picture",
|
||||
"cms.plugins.snippet",
|
||||
"fobi.contrib.apps.djangocms_integration", # Fobi DjangoCMS app
|
||||
# 'djangocms_page', # Example
|
||||
]
|
||||
|
||||
|
|
@ -39,45 +36,50 @@ try:
|
|||
# if 'admin_tools' in INSTALLED_APPS else None
|
||||
# INSTALLED_APPS.remove('admin_tools.menu') \
|
||||
# if 'admin_tools.menu' in INSTALLED_APPS else None
|
||||
INSTALLED_APPS.remove('admin_tools.dashboard') \
|
||||
if 'admin_tools.dashboard' in INSTALLED_APPS else None
|
||||
INSTALLED_APPS.remove(
|
||||
"admin_tools.dashboard"
|
||||
) if "admin_tools.dashboard" in INSTALLED_APPS else None
|
||||
except Exception as err:
|
||||
pass
|
||||
|
||||
MIDDLEWARE_CLASSES = list(MIDDLEWARE_CLASSES)
|
||||
MIDDLEWARE_CLASSES += [
|
||||
# 'django.middleware.cache.UpdateCacheMiddleware',
|
||||
'cms.middleware.page.CurrentPageMiddleware',
|
||||
'cms.middleware.user.CurrentUserMiddleware',
|
||||
'cms.middleware.toolbar.ToolbarMiddleware',
|
||||
'cms.middleware.language.LanguageCookieMiddleware',
|
||||
"cms.middleware.page.CurrentPageMiddleware",
|
||||
"cms.middleware.user.CurrentUserMiddleware",
|
||||
"cms.middleware.toolbar.ToolbarMiddleware",
|
||||
"cms.middleware.language.LanguageCookieMiddleware",
|
||||
# 'django.middleware.cache.FetchFromCacheMiddleware',
|
||||
]
|
||||
|
||||
TEMPLATE_CONTEXT_PROCESSORS = list(TEMPLATE_CONTEXT_PROCESSORS)
|
||||
TEMPLATE_CONTEXT_PROCESSORS += [
|
||||
'cms.context_processors.media',
|
||||
'sekizai.context_processors.sekizai',
|
||||
"cms.context_processors.media",
|
||||
"sekizai.context_processors.sekizai",
|
||||
# 'cms.context_processors.cms_settings',
|
||||
]
|
||||
|
||||
FOBI_DEFAULT_THEME = 'bootstrap3'
|
||||
FOBI_DEFAULT_THEME = "bootstrap3"
|
||||
# FOBI_DEFAULT_THEME = 'foundation5'
|
||||
# FOBI_DEFAULT_THEME = 'simple'
|
||||
|
||||
CMS_TEMPLATES = (
|
||||
('cms_page/{0}/page_with_sidebar.html'.format(FOBI_DEFAULT_THEME),
|
||||
'General template with sidebar for {0}'.format(FOBI_DEFAULT_THEME)),
|
||||
('cms_page/{0}/page_without_sidebar.html'.format(FOBI_DEFAULT_THEME),
|
||||
'General template without sidebar for {0}'.format(FOBI_DEFAULT_THEME)),
|
||||
(
|
||||
"cms_page/{0}/page_with_sidebar.html".format(FOBI_DEFAULT_THEME),
|
||||
"General template with sidebar for {0}".format(FOBI_DEFAULT_THEME),
|
||||
),
|
||||
(
|
||||
"cms_page/{0}/page_without_sidebar.html".format(FOBI_DEFAULT_THEME),
|
||||
"General template without sidebar for {0}".format(FOBI_DEFAULT_THEME),
|
||||
),
|
||||
)
|
||||
|
||||
MIGRATION_MODULES = {
|
||||
'cms': 'cms.migrations_django',
|
||||
'menus': 'menus.migrations_django',
|
||||
"cms": "cms.migrations_django",
|
||||
"menus": "menus.migrations_django",
|
||||
}
|
||||
|
||||
LANGUAGE_CODE = 'en'
|
||||
LANGUAGE_CODE = "en"
|
||||
|
||||
# FEINCMS_RICHTEXT_INIT_CONTEXT = {
|
||||
# 'TINYMCE_JS_URL': STATIC_URL + 'tiny_mce/tiny_mce.js',
|
||||
|
|
|
|||
|
|
@ -2,26 +2,24 @@ from .base import *
|
|||
|
||||
INSTALLED_APPS = list(INSTALLED_APPS)
|
||||
INSTALLED_APPS += [
|
||||
'feincms', # FeinCMS
|
||||
|
||||
'fobi.contrib.apps.feincms_integration', # Fobi FeinCMS app
|
||||
|
||||
'page', # Example
|
||||
|
||||
"feincms", # FeinCMS
|
||||
"fobi.contrib.apps.feincms_integration", # Fobi FeinCMS app
|
||||
"page", # Example
|
||||
# 'tinymce', # TinyMCE
|
||||
]
|
||||
|
||||
try:
|
||||
INSTALLED_APPS.remove('admin_tools.dashboard') \
|
||||
if 'admin_tools.dashboard' in INSTALLED_APPS else None
|
||||
INSTALLED_APPS.remove(
|
||||
"admin_tools.dashboard"
|
||||
) if "admin_tools.dashboard" in INSTALLED_APPS else None
|
||||
except Exception as err:
|
||||
pass
|
||||
|
||||
FEINCMS_RICHTEXT_INIT_CONTEXT = {
|
||||
'TINYMCE_JS_URL': STATIC_URL + 'tiny_mce/tiny_mce.js',
|
||||
"TINYMCE_JS_URL": STATIC_URL + "tiny_mce/tiny_mce.js",
|
||||
}
|
||||
|
||||
MIGRATION_MODULES = {
|
||||
'fobi': 'fobi.migrations',
|
||||
'db_store': 'fobi.contrib.plugins.form_handlers.db_store.migrations',
|
||||
"fobi": "fobi.migrations",
|
||||
"db_store": "fobi.contrib.plugins.form_handlers.db_store.migrations",
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,13 +3,13 @@ from .base import *
|
|||
INSTALLED_APPS = list(INSTALLED_APPS)
|
||||
|
||||
try:
|
||||
INSTALLED_APPS.append('mptt')
|
||||
INSTALLED_APPS.append('bar')
|
||||
INSTALLED_APPS.append("mptt")
|
||||
INSTALLED_APPS.append("bar")
|
||||
INSTALLED_APPS.append(
|
||||
'fobi.contrib.plugins.form_elements.fields.select_mptt_model_object'
|
||||
"fobi.contrib.plugins.form_elements.fields.select_mptt_model_object"
|
||||
)
|
||||
INSTALLED_APPS.append(
|
||||
'fobi.contrib.plugins.form_elements.fields.select_multiple_mptt_model_objects' # NOQA
|
||||
"fobi.contrib.plugins.form_elements.fields.select_multiple_mptt_model_objects" # NOQA
|
||||
)
|
||||
except Exception as err:
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -2,19 +2,21 @@ from .base import *
|
|||
|
||||
INSTALLED_APPS = list(INSTALLED_APPS)
|
||||
|
||||
if not 'captcha' in INSTALLED_APPS:
|
||||
INSTALLED_APPS.append('captcha')
|
||||
if not "captcha" in INSTALLED_APPS:
|
||||
INSTALLED_APPS.append("captcha")
|
||||
|
||||
if not 'fobi.contrib.plugins.form_elements.security.recaptcha' \
|
||||
in INSTALLED_APPS:
|
||||
if (
|
||||
not "fobi.contrib.plugins.form_elements.security.recaptcha"
|
||||
in INSTALLED_APPS
|
||||
):
|
||||
INSTALLED_APPS.append(
|
||||
'fobi.contrib.plugins.form_elements.security.recaptcha'
|
||||
"fobi.contrib.plugins.form_elements.security.recaptcha"
|
||||
)
|
||||
|
||||
# Test keys are taken from official dedicated Google page
|
||||
# https://developers.google.com/recaptcha/docs/faq#id-like-to-run-automated-tests-with-recaptcha.-what-should-i-do
|
||||
RECAPTCHA_PUBLIC_KEY = '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI'
|
||||
RECAPTCHA_PRIVATE_KEY = '6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe'
|
||||
RECAPTCHA_PUBLIC_KEY = "6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI"
|
||||
RECAPTCHA_PRIVATE_KEY = "6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe"
|
||||
RECAPTCHA_USE_SSL = True
|
||||
SILENCED_SYSTEM_CHECKS = ['captcha.recaptcha_test_key_error']
|
||||
SILENCED_SYSTEM_CHECKS = ["captcha.recaptcha_test_key_error"]
|
||||
# FOBI_DEFAULT_THEME = 'simple'
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
from .base import *
|
||||
|
||||
# Using custom user model
|
||||
AUTH_USER_MODEL = 'customauth.MyUser'
|
||||
AUTH_USER_MODEL = "customauth.MyUser"
|
||||
|
||||
INSTALLED_APPS = list(INSTALLED_APPS)
|
||||
INSTALLED_APPS.append('customauth')
|
||||
INSTALLED_APPS.append("customauth")
|
||||
|
|
|
|||
|
|
@ -1,69 +1,73 @@
|
|||
from .base import *
|
||||
|
||||
INSTALLED_APPS = list(INSTALLED_APPS)
|
||||
INSTALLED_APPS.remove('django.contrib.admin')
|
||||
INSTALLED_APPS.remove("django.contrib.admin")
|
||||
INSTALLED_APPS += [
|
||||
'cms', # DjangoCMS
|
||||
'mptt',
|
||||
'menus',
|
||||
'sekizai',
|
||||
"cms", # DjangoCMS
|
||||
"mptt",
|
||||
"menus",
|
||||
"sekizai",
|
||||
# 'djangocms_admin_style',
|
||||
|
||||
# Some plugins
|
||||
'djangocms_picture',
|
||||
'djangocms_snippet',
|
||||
'treebeard',
|
||||
|
||||
'fobi.contrib.apps.djangocms_integration', # Fobi DjangoCMS app
|
||||
|
||||
"djangocms_picture",
|
||||
"djangocms_snippet",
|
||||
"treebeard",
|
||||
"fobi.contrib.apps.djangocms_integration", # Fobi DjangoCMS app
|
||||
# Django-CMS admin style
|
||||
'djangocms_admin_style',
|
||||
'django.contrib.admin',
|
||||
'fobi.contrib.themes.djangocms_admin_style_theme',
|
||||
"djangocms_admin_style",
|
||||
"django.contrib.admin",
|
||||
"fobi.contrib.themes.djangocms_admin_style_theme",
|
||||
]
|
||||
|
||||
try:
|
||||
INSTALLED_APPS.remove('admin_tools') \
|
||||
if 'admin_tools' in INSTALLED_APPS else None
|
||||
INSTALLED_APPS.remove('admin_tools.menu') \
|
||||
if 'admin_tools.menu' in INSTALLED_APPS else None
|
||||
INSTALLED_APPS.remove('admin_tools.dashboard') \
|
||||
if 'admin_tools.dashboard' in INSTALLED_APPS else None
|
||||
INSTALLED_APPS.remove(
|
||||
"admin_tools"
|
||||
) if "admin_tools" in INSTALLED_APPS else None
|
||||
INSTALLED_APPS.remove(
|
||||
"admin_tools.menu"
|
||||
) if "admin_tools.menu" in INSTALLED_APPS else None
|
||||
INSTALLED_APPS.remove(
|
||||
"admin_tools.dashboard"
|
||||
) if "admin_tools.dashboard" in INSTALLED_APPS else None
|
||||
except Exception as e:
|
||||
pass
|
||||
|
||||
MIDDLEWARE_CLASSES = list(MIDDLEWARE_CLASSES)
|
||||
MIDDLEWARE_CLASSES += [
|
||||
# 'django.middleware.cache.UpdateCacheMiddleware',
|
||||
'cms.middleware.page.CurrentPageMiddleware',
|
||||
'cms.middleware.user.CurrentUserMiddleware',
|
||||
'cms.middleware.toolbar.ToolbarMiddleware',
|
||||
'cms.middleware.language.LanguageCookieMiddleware',
|
||||
"cms.middleware.page.CurrentPageMiddleware",
|
||||
"cms.middleware.user.CurrentUserMiddleware",
|
||||
"cms.middleware.toolbar.ToolbarMiddleware",
|
||||
"cms.middleware.language.LanguageCookieMiddleware",
|
||||
# 'django.middleware.cache.FetchFromCacheMiddleware',
|
||||
]
|
||||
|
||||
|
||||
TEMPLATES[0]['OPTIONS']['context_processors'] += [
|
||||
'cms.context_processors.cms_settings',
|
||||
'sekizai.context_processors.sekizai',
|
||||
'cms.context_processors.cms_settings',
|
||||
TEMPLATES[0]["OPTIONS"]["context_processors"] += [
|
||||
"cms.context_processors.cms_settings",
|
||||
"sekizai.context_processors.sekizai",
|
||||
"cms.context_processors.cms_settings",
|
||||
]
|
||||
|
||||
# FOBI_DEFAULT_THEME = 'bootstrap3'
|
||||
# FOBI_DEFAULT_THEME = 'foundation5'
|
||||
# FOBI_DEFAULT_THEME = 'simple'
|
||||
FOBI_DEFAULT_THEME = 'djangocms_admin_style_theme'
|
||||
FOBI_DEFAULT_THEME = "djangocms_admin_style_theme"
|
||||
|
||||
CMS_TEMPLATES = (
|
||||
('cms_page/{0}/page_with_sidebar.html'.format(FOBI_DEFAULT_THEME),
|
||||
'General template with sidebar for {0}'.format(FOBI_DEFAULT_THEME)),
|
||||
('cms_page/{0}/page_without_sidebar.html'.format(FOBI_DEFAULT_THEME),
|
||||
'General template without sidebar for {0}'.format(FOBI_DEFAULT_THEME)),
|
||||
(
|
||||
"cms_page/{0}/page_with_sidebar.html".format(FOBI_DEFAULT_THEME),
|
||||
"General template with sidebar for {0}".format(FOBI_DEFAULT_THEME),
|
||||
),
|
||||
(
|
||||
"cms_page/{0}/page_without_sidebar.html".format(FOBI_DEFAULT_THEME),
|
||||
"General template without sidebar for {0}".format(FOBI_DEFAULT_THEME),
|
||||
),
|
||||
)
|
||||
|
||||
MIGRATION_MODULES = {
|
||||
'cms': 'cms.migrations_django',
|
||||
'menus': 'menus.migrations_django',
|
||||
"cms": "cms.migrations_django",
|
||||
"menus": "menus.migrations_django",
|
||||
}
|
||||
|
||||
LANGUAGE_CODE = 'en'
|
||||
LANGUAGE_CODE = "en"
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
from chromedriver_py import binary_path
|
||||
from selenium import webdriver
|
||||
|
||||
from .bootstrap3_theme import *
|
||||
|
||||
|
||||
def project_dir(base):
|
||||
return os.path.abspath(
|
||||
os.path.join(os.path.dirname(__file__), base).replace('\\', '/')
|
||||
os.path.join(os.path.dirname(__file__), base).replace("\\", "/")
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -20,54 +21,52 @@ DEBUG_TEMPLATE = True
|
|||
# TEMPLATE_DEBUG = True
|
||||
DEV = True
|
||||
|
||||
POSTGRES_ENGINE = 'django.db.backends.postgresql'
|
||||
POSTGRES_ENGINE = "django.db.backends.postgresql"
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': POSTGRES_ENGINE,
|
||||
'HOST': 'postgresql',
|
||||
'NAME': 'fobi',
|
||||
'USER': 'postgres',
|
||||
'PASSWORD': 'test',
|
||||
"default": {
|
||||
"ENGINE": POSTGRES_ENGINE,
|
||||
"HOST": "postgresql",
|
||||
"NAME": "fobi",
|
||||
"USER": "postgres",
|
||||
"PASSWORD": "test",
|
||||
}
|
||||
}
|
||||
|
||||
TEST_DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': POSTGRES_ENGINE,
|
||||
'HOST': 'postgresql',
|
||||
'NAME': 'fobi',
|
||||
'USER': 'postgres',
|
||||
'PASSWORD': 'test',
|
||||
"default": {
|
||||
"ENGINE": POSTGRES_ENGINE,
|
||||
"HOST": "postgresql",
|
||||
"NAME": "fobi",
|
||||
"USER": "postgres",
|
||||
"PASSWORD": "test",
|
||||
}
|
||||
}
|
||||
|
||||
# FeinCMS addons
|
||||
|
||||
INSTALLED_APPS += [
|
||||
'feincms', # FeinCMS
|
||||
|
||||
'fobi.contrib.apps.feincms_integration', # Fobi FeinCMS app
|
||||
|
||||
'page', # Example
|
||||
"feincms", # FeinCMS
|
||||
"fobi.contrib.apps.feincms_integration", # Fobi FeinCMS app
|
||||
"page", # Example
|
||||
]
|
||||
|
||||
MIGRATION_MODULES = {
|
||||
'fobi': 'fobi.migrations',
|
||||
'db_store': 'fobi.contrib.plugins.form_handlers.db_store.migrations',
|
||||
'page': 'page.migrations',
|
||||
"fobi": "fobi.migrations",
|
||||
"db_store": "fobi.contrib.plugins.form_handlers.db_store.migrations",
|
||||
"page": "page.migrations",
|
||||
}
|
||||
|
||||
INTERNAL_IPS = ('127.0.0.1',)
|
||||
ALLOWED_HOSTS = ['*']
|
||||
INTERNAL_IPS = ("127.0.0.1",)
|
||||
ALLOWED_HOSTS = ["*"]
|
||||
|
||||
EMAIL_BACKEND = 'django.core.mail.backends.filebased.EmailBackend'
|
||||
EMAIL_FILE_PATH = PROJECT_DIR('../../tmp')
|
||||
EMAIL_BACKEND = "django.core.mail.backends.filebased.EmailBackend"
|
||||
EMAIL_FILE_PATH = PROJECT_DIR("../../tmp")
|
||||
|
||||
FOBI_DEBUG = True
|
||||
FOBI_RESTRICT_PLUGIN_ACCESS = False
|
||||
FOBI_RESTRICT_FIELDS_ACCESS = False
|
||||
FOBI_FORM_ELEMENT_SELECT_MODEL_OBJECT_IGNORED_MODELS = ['auth.User']
|
||||
FOBI_FORM_ELEMENT_SELECT_MODEL_OBJECT_IGNORED_MODELS = ["auth.User"]
|
||||
FOBI_FAIL_ON_MISSING_FORM_ELEMENT_PLUGINS = True
|
||||
# FOBI_FAIL_ON_MISSING_FORM_HANDLER_PLUGINS = False
|
||||
FOBI_FAIL_ON_ERRORS_IN_FORM_HANDLER_PLUGINS = True
|
||||
|
|
@ -84,12 +83,12 @@ FOBI_FAIL_ON_ERRORS_IN_FORM_WIZARD_HANDLER_PLUGINS = True
|
|||
ENABLE_CAPTCHA = True
|
||||
|
||||
CHROME_DRIVER_OPTIONS = webdriver.ChromeOptions()
|
||||
CHROME_DRIVER_OPTIONS.add_argument('-headless')
|
||||
CHROME_DRIVER_OPTIONS.add_argument('-no-sandbox')
|
||||
CHROME_DRIVER_OPTIONS.set_capability('chrome.binary', "/usr/bin/google-chrome")
|
||||
CHROME_DRIVER_OPTIONS.add_argument("-headless")
|
||||
CHROME_DRIVER_OPTIONS.add_argument("-no-sandbox")
|
||||
CHROME_DRIVER_OPTIONS.set_capability("chrome.binary", "/usr/bin/google-chrome")
|
||||
|
||||
# CHROME_DRIVER_OPTIONS.add_argument('-single-process')
|
||||
|
||||
CHROME_DRIVER_EXECUTABLE_PATH = binary_path # '/usr/bin/chromedriver'
|
||||
FIREFOX_BIN_PATH = '/usr/lib/firefox/firefox'
|
||||
PHANTOM_JS_EXECUTABLE_PATH = ''
|
||||
FIREFOX_BIN_PATH = "/usr/lib/firefox/firefox"
|
||||
PHANTOM_JS_EXECUTABLE_PATH = ""
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
from chromedriver_py import binary_path
|
||||
from selenium import webdriver
|
||||
|
||||
from .bootstrap3_theme import *
|
||||
|
||||
TESTING = True
|
||||
|
|
@ -11,42 +12,39 @@ LOGGING = {}
|
|||
DEBUG_TOOLBAR = False
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.postgresql',
|
||||
'NAME': 'fobi',
|
||||
'USER': 'postgres',
|
||||
'PASSWORD': 'test',
|
||||
|
||||
"default": {
|
||||
"ENGINE": "django.db.backends.postgresql",
|
||||
"NAME": "fobi",
|
||||
"USER": "postgres",
|
||||
"PASSWORD": "test",
|
||||
# Empty for localhost through domain sockets or '127.0.0.1' for
|
||||
# localhost through TCP.
|
||||
'HOST': 'postgresql',
|
||||
'TEST': {
|
||||
'HOST': 'postgresql',
|
||||
'NAME': 'fobi_tests',
|
||||
'USER': 'postgres',
|
||||
'PASSWORD': 'test',
|
||||
}
|
||||
"HOST": "postgresql",
|
||||
"TEST": {
|
||||
"HOST": "postgresql",
|
||||
"NAME": "fobi_tests",
|
||||
"USER": "postgres",
|
||||
"PASSWORD": "test",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
# FeinCMS addons
|
||||
|
||||
INSTALLED_APPS += [
|
||||
'feincms', # FeinCMS
|
||||
|
||||
'fobi.contrib.apps.feincms_integration', # Fobi FeinCMS app
|
||||
|
||||
'page', # Example
|
||||
"feincms", # FeinCMS
|
||||
"fobi.contrib.apps.feincms_integration", # Fobi FeinCMS app
|
||||
"page", # Example
|
||||
]
|
||||
|
||||
MIGRATION_MODULES = {
|
||||
'fobi': 'fobi.migrations',
|
||||
'db_store': 'fobi.contrib.plugins.form_handlers.db_store.migrations',
|
||||
'page': 'page.migrations',
|
||||
"fobi": "fobi.migrations",
|
||||
"db_store": "fobi.contrib.plugins.form_handlers.db_store.migrations",
|
||||
"page": "page.migrations",
|
||||
}
|
||||
|
||||
CHROME_DRIVER_EXECUTABLE_PATH = binary_path # '/usr/bin/chromedriver'
|
||||
CHROME_DRIVER_OPTIONS = webdriver.ChromeOptions()
|
||||
CHROME_DRIVER_OPTIONS.add_argument('-headless')
|
||||
CHROME_DRIVER_OPTIONS.add_argument('-no-sandbox')
|
||||
CHROME_DRIVER_OPTIONS.set_capability('chrome.binary', "/usr/bin/google-chrome")
|
||||
CHROME_DRIVER_OPTIONS.add_argument("-headless")
|
||||
CHROME_DRIVER_OPTIONS.add_argument("-no-sandbox")
|
||||
CHROME_DRIVER_OPTIONS.set_capability("chrome.binary", "/usr/bin/google-chrome")
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ from .base import *
|
|||
|
||||
INSTALLED_APPS = list(INSTALLED_APPS)
|
||||
|
||||
if 'foo' in INSTALLED_APPS:
|
||||
INSTALLED_APPS.remove('foo')
|
||||
if "foo" in INSTALLED_APPS:
|
||||
INSTALLED_APPS.remove("foo")
|
||||
|
||||
LOGGING = {}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,6 @@ from .base import *
|
|||
INSTALLED_APPS = list(INSTALLED_APPS)
|
||||
|
||||
try:
|
||||
INSTALLED_APPS.append('foreign_key_to_saved_form_data_entry')
|
||||
INSTALLED_APPS.append("foreign_key_to_saved_form_data_entry")
|
||||
except Exception as e:
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
from .base import *
|
||||
|
||||
FOBI_DEFAULT_THEME = 'foundation5'
|
||||
FOBI_DEFAULT_THEME = "foundation5"
|
||||
|
||||
INSTALLED_APPS = list(INSTALLED_APPS)
|
||||
|
||||
INSTALLED_APPS.append(
|
||||
'fobi.contrib.themes.foundation5.widgets.form_elements.date_foundation5_widget' # NOQA
|
||||
"fobi.contrib.themes.foundation5.widgets.form_elements.date_foundation5_widget" # NOQA
|
||||
)
|
||||
INSTALLED_APPS.append(
|
||||
'fobi.contrib.themes.foundation5.widgets.form_elements.datetime_foundation5_widget' # NOQA
|
||||
"fobi.contrib.themes.foundation5.widgets.form_elements.datetime_foundation5_widget" # NOQA
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,27 +1,29 @@
|
|||
from .base import *
|
||||
|
||||
FOBI_DEFAULT_THEME = 'foundation5'
|
||||
FOBI_DEFAULT_THEME = "foundation5"
|
||||
|
||||
INSTALLED_APPS = list(INSTALLED_APPS)
|
||||
|
||||
INSTALLED_APPS.append(
|
||||
'fobi.contrib.themes.foundation5.widgets.form_elements.date_foundation5_widget' # NOQA
|
||||
"fobi.contrib.themes.foundation5.widgets.form_elements.date_foundation5_widget" # NOQA
|
||||
)
|
||||
INSTALLED_APPS.append(
|
||||
'fobi.contrib.themes.foundation5.widgets.form_elements.datetime_foundation5_widget' # NOQA
|
||||
"fobi.contrib.themes.foundation5.widgets.form_elements.datetime_foundation5_widget" # NOQA
|
||||
)
|
||||
|
||||
try:
|
||||
if 'captcha' not in INSTALLED_APPS:
|
||||
INSTALLED_APPS.append('captcha')
|
||||
if "captcha" not in INSTALLED_APPS:
|
||||
INSTALLED_APPS.append("captcha")
|
||||
|
||||
if 'fobi.contrib.plugins.form_elements.security.captcha' \
|
||||
not in INSTALLED_APPS:
|
||||
if (
|
||||
"fobi.contrib.plugins.form_elements.security.captcha"
|
||||
not in INSTALLED_APPS
|
||||
):
|
||||
INSTALLED_APPS.append(
|
||||
'fobi.contrib.plugins.form_elements.security.captcha'
|
||||
"fobi.contrib.plugins.form_elements.security.captcha"
|
||||
)
|
||||
|
||||
CAPTCHA_TEXT_FIELD_TEMPLATE = 'foundation5/captcha/text_field.html'
|
||||
CAPTCHA_TEXT_FIELD_TEMPLATE = "foundation5/captcha/text_field.html"
|
||||
|
||||
ENABLE_CAPTCHA = True
|
||||
|
||||
|
|
|
|||
|
|
@ -2,15 +2,13 @@ from .base import *
|
|||
|
||||
INSTALLED_APPS = list(INSTALLED_APPS)
|
||||
INSTALLED_APPS += [
|
||||
'feincms', # FeinCMS
|
||||
|
||||
'fobi.contrib.apps.feincms_integration', # Fobi FeinCMS app
|
||||
|
||||
'page', # Example
|
||||
"feincms", # FeinCMS
|
||||
"fobi.contrib.apps.feincms_integration", # Fobi FeinCMS app
|
||||
"page", # Example
|
||||
]
|
||||
|
||||
FEINCMS_RICHTEXT_INIT_CONTEXT = {
|
||||
'TINYMCE_JS_URL': STATIC_URL + 'tiny_mce/tiny_mce.js',
|
||||
"TINYMCE_JS_URL": STATIC_URL + "tiny_mce/tiny_mce.js",
|
||||
}
|
||||
|
||||
FOBI_DEFAULT_THEME = 'foundation5'
|
||||
FOBI_DEFAULT_THEME = "foundation5"
|
||||
|
|
|
|||
|
|
@ -3,6 +3,6 @@ from .base import *
|
|||
INSTALLED_APPS = list(INSTALLED_APPS)
|
||||
|
||||
try:
|
||||
INSTALLED_APPS.append('override_radio_plugin')
|
||||
INSTALLED_APPS.append("override_radio_plugin")
|
||||
except Exception as err:
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -3,6 +3,6 @@ from .base import *
|
|||
INSTALLED_APPS = list(INSTALLED_APPS)
|
||||
|
||||
try:
|
||||
INSTALLED_APPS.append('override_select_model_object_plugin')
|
||||
INSTALLED_APPS.append("override_select_model_object_plugin")
|
||||
except Exception as err:
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -3,14 +3,14 @@ from .base import *
|
|||
INSTALLED_APPS = list(INSTALLED_APPS)
|
||||
|
||||
try:
|
||||
INSTALLED_APPS.append('override_simple_theme')
|
||||
INSTALLED_APPS.append('crispy_forms')
|
||||
INSTALLED_APPS.append("override_simple_theme")
|
||||
INSTALLED_APPS.append("crispy_forms")
|
||||
except Exception as err:
|
||||
pass
|
||||
|
||||
FOBI_DEFAULT_THEME = 'simple'
|
||||
FOBI_DEFAULT_THEME = "simple"
|
||||
|
||||
CRISPY_TEMPLATE_PACK = 'uni_form'
|
||||
CRISPY_TEMPLATE_PACK = "uni_form"
|
||||
|
||||
# Make crispy-forms fail loud
|
||||
CRISPY_FAIL_SILENTLY = not DEBUG
|
||||
|
|
|
|||
|
|
@ -6,85 +6,81 @@ from .base import *
|
|||
# See http://docs.djangoproject.com/en/dev/topics/logging for
|
||||
# more details on how to customize your logging configuration.
|
||||
LOGGING = {
|
||||
'version': 1,
|
||||
'disable_existing_loggers': False,
|
||||
'filters': {
|
||||
'require_debug_false': {
|
||||
'()': 'django.utils.log.RequireDebugFalse'
|
||||
}
|
||||
"version": 1,
|
||||
"disable_existing_loggers": False,
|
||||
"filters": {
|
||||
"require_debug_false": {"()": "django.utils.log.RequireDebugFalse"}
|
||||
},
|
||||
'root': {
|
||||
'level': 'INFO',
|
||||
'handlers': ['all_log'],
|
||||
"root": {
|
||||
"level": "INFO",
|
||||
"handlers": ["all_log"],
|
||||
},
|
||||
'formatters': {
|
||||
'verbose': {
|
||||
'format': '\n%(levelname)s %(asctime)s [%(pathname)s:%(lineno)s] '
|
||||
'%(message)s'
|
||||
"formatters": {
|
||||
"verbose": {
|
||||
"format": "\n%(levelname)s %(asctime)s [%(pathname)s:%(lineno)s] "
|
||||
"%(message)s"
|
||||
},
|
||||
'simple': {
|
||||
'format': '\n%(levelname)s %(message)s'
|
||||
"simple": {"format": "\n%(levelname)s %(message)s"},
|
||||
},
|
||||
"handlers": {
|
||||
"mail_admins": {
|
||||
"level": "ERROR",
|
||||
"filters": ["require_debug_false"],
|
||||
"class": "django.utils.log.AdminEmailHandler",
|
||||
},
|
||||
"console": {
|
||||
"level": "ERROR",
|
||||
"class": "logging.StreamHandler",
|
||||
"formatter": "verbose",
|
||||
},
|
||||
"all_log": {
|
||||
"level": "ERROR",
|
||||
"class": "logging.handlers.RotatingFileHandler",
|
||||
"filename": PROJECT_DIR("../../logs/all.log"),
|
||||
"maxBytes": 1048576,
|
||||
"backupCount": 99,
|
||||
"formatter": "verbose",
|
||||
},
|
||||
"django_log": {
|
||||
"level": "ERROR",
|
||||
"class": "logging.handlers.RotatingFileHandler",
|
||||
"filename": PROJECT_DIR("../../logs/django.log"),
|
||||
"maxBytes": 1048576,
|
||||
"backupCount": 99,
|
||||
"formatter": "verbose",
|
||||
},
|
||||
"django_request_log": {
|
||||
"level": "ERROR",
|
||||
"class": "logging.handlers.RotatingFileHandler",
|
||||
"filename": PROJECT_DIR("../../logs/django_request.log"),
|
||||
"maxBytes": 1048576,
|
||||
"backupCount": 99,
|
||||
"formatter": "verbose",
|
||||
},
|
||||
"fobi_log": {
|
||||
"level": "ERROR",
|
||||
"class": "logging.handlers.RotatingFileHandler",
|
||||
"filename": PROJECT_DIR("../../logs/fobi.log"),
|
||||
"maxBytes": 1048576,
|
||||
"backupCount": 99,
|
||||
"formatter": "verbose",
|
||||
},
|
||||
},
|
||||
'handlers': {
|
||||
'mail_admins': {
|
||||
'level': 'ERROR',
|
||||
'filters': ['require_debug_false'],
|
||||
'class': 'django.utils.log.AdminEmailHandler'
|
||||
"loggers": {
|
||||
"django.request": {
|
||||
"handlers": ["django_request_log"],
|
||||
"level": "INFO",
|
||||
"propagate": True,
|
||||
},
|
||||
'console': {
|
||||
'level': 'ERROR',
|
||||
'class': 'logging.StreamHandler',
|
||||
'formatter': 'verbose'
|
||||
"django": {
|
||||
"handlers": ["django_log"],
|
||||
"level": "ERROR",
|
||||
"propagate": False,
|
||||
},
|
||||
'all_log': {
|
||||
'level': 'ERROR',
|
||||
'class': 'logging.handlers.RotatingFileHandler',
|
||||
'filename': PROJECT_DIR("../../logs/all.log"),
|
||||
'maxBytes': 1048576,
|
||||
'backupCount': 99,
|
||||
'formatter': 'verbose',
|
||||
},
|
||||
'django_log': {
|
||||
'level': 'ERROR',
|
||||
'class': 'logging.handlers.RotatingFileHandler',
|
||||
'filename': PROJECT_DIR("../../logs/django.log"),
|
||||
'maxBytes': 1048576,
|
||||
'backupCount': 99,
|
||||
'formatter': 'verbose',
|
||||
},
|
||||
'django_request_log': {
|
||||
'level': 'ERROR',
|
||||
'class': 'logging.handlers.RotatingFileHandler',
|
||||
'filename': PROJECT_DIR("../../logs/django_request.log"),
|
||||
'maxBytes': 1048576,
|
||||
'backupCount': 99,
|
||||
'formatter': 'verbose',
|
||||
},
|
||||
'fobi_log': {
|
||||
'level': 'ERROR',
|
||||
'class': 'logging.handlers.RotatingFileHandler',
|
||||
'filename': PROJECT_DIR("../../logs/fobi.log"),
|
||||
'maxBytes': 1048576,
|
||||
'backupCount': 99,
|
||||
'formatter': 'verbose',
|
||||
},
|
||||
},
|
||||
'loggers': {
|
||||
'django.request': {
|
||||
'handlers': ['django_request_log'],
|
||||
'level': 'INFO',
|
||||
'propagate': True,
|
||||
},
|
||||
'django': {
|
||||
'handlers': ['django_log'],
|
||||
'level': 'ERROR',
|
||||
'propagate': False,
|
||||
},
|
||||
'fobi': {
|
||||
'handlers': ['console', 'fobi_log'],
|
||||
'level': 'ERROR',
|
||||
'propagate': True,
|
||||
"fobi": {
|
||||
"handlers": ["console", "fobi_log"],
|
||||
"level": "ERROR",
|
||||
"propagate": True,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
from .base import *
|
||||
|
||||
FOBI_DEFAULT_THEME = 'simple'
|
||||
FOBI_DEFAULT_THEME = "simple"
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
Used in `tox` on GitHub CI.
|
||||
"""
|
||||
from chromedriver_py import binary_path
|
||||
|
||||
from .base import *
|
||||
|
||||
TESTING = True
|
||||
|
|
@ -13,45 +14,42 @@ LOGGING = {}
|
|||
DEBUG_TOOLBAR = False
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.postgresql',
|
||||
'NAME': 'fobi',
|
||||
'USER': 'postgres',
|
||||
'PASSWORD': 'test',
|
||||
|
||||
"default": {
|
||||
"ENGINE": "django.db.backends.postgresql",
|
||||
"NAME": "fobi",
|
||||
"USER": "postgres",
|
||||
"PASSWORD": "test",
|
||||
# Empty for localhost through domain sockets or '127.0.0.1' for
|
||||
# localhost through TCP.
|
||||
'HOST': 'localhost',
|
||||
'TEST': {
|
||||
'HOST': 'localhost',
|
||||
'NAME': 'fobi_tests',
|
||||
'USER': 'postgres',
|
||||
'PASSWORD': 'test',
|
||||
}
|
||||
"HOST": "localhost",
|
||||
"TEST": {
|
||||
"HOST": "localhost",
|
||||
"NAME": "fobi_tests",
|
||||
"USER": "postgres",
|
||||
"PASSWORD": "test",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
# FeinCMS addons
|
||||
|
||||
INSTALLED_APPS += [
|
||||
'feincms', # FeinCMS
|
||||
|
||||
'fobi.contrib.apps.feincms_integration', # Fobi FeinCMS app
|
||||
|
||||
'page', # Example
|
||||
"feincms", # FeinCMS
|
||||
"fobi.contrib.apps.feincms_integration", # Fobi FeinCMS app
|
||||
"page", # Example
|
||||
]
|
||||
|
||||
MIGRATION_MODULES = {
|
||||
'fobi': 'fobi.migrations',
|
||||
'db_store': 'fobi.contrib.plugins.form_handlers.db_store.migrations',
|
||||
'page': 'page.migrations',
|
||||
"fobi": "fobi.migrations",
|
||||
"db_store": "fobi.contrib.plugins.form_handlers.db_store.migrations",
|
||||
"page": "page.migrations",
|
||||
}
|
||||
|
||||
CHROME_DRIVER_EXECUTABLE_PATH = binary_path # '/usr/bin/chromedriver'
|
||||
CHROME_DRIVER_OPTIONS = webdriver.ChromeOptions()
|
||||
CHROME_DRIVER_OPTIONS.add_argument('-headless')
|
||||
CHROME_DRIVER_OPTIONS.add_argument('-no-sandbox')
|
||||
CHROME_DRIVER_OPTIONS.set_capability('chrome.binary', "/usr/bin/google-chrome")
|
||||
CHROME_DRIVER_OPTIONS.add_argument("-headless")
|
||||
CHROME_DRIVER_OPTIONS.add_argument("-no-sandbox")
|
||||
CHROME_DRIVER_OPTIONS.set_capability("chrome.binary", "/usr/bin/google-chrome")
|
||||
|
||||
try:
|
||||
from .local_settings import TEST_DATABASES as DATABASES
|
||||
|
|
|
|||
|
|
@ -1,88 +1,89 @@
|
|||
from django.urls import include, re_path as url
|
||||
from django.conf.urls.i18n import i18n_patterns
|
||||
from django.conf import settings
|
||||
from django.contrib import admin
|
||||
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
|
||||
from django.conf.urls.i18n import i18n_patterns
|
||||
from django.conf.urls.static import static
|
||||
from django.views.generic import TemplateView
|
||||
from django.contrib import admin
|
||||
from django.contrib.auth import views as auth_views
|
||||
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
|
||||
from django.urls import include, re_path as url
|
||||
from django.views.generic import TemplateView
|
||||
from django_nine import versions
|
||||
|
||||
from fobi.settings import DEFAULT_THEME
|
||||
|
||||
from django_nine import versions
|
||||
|
||||
admin.autodiscover()
|
||||
|
||||
# Mapping.
|
||||
fobi_theme_home_template_mapping = {
|
||||
'bootstrap3': 'home/bootstrap3.html',
|
||||
'foundation5': 'home/foundation5.html',
|
||||
'simple': 'home/simple.html',
|
||||
"bootstrap3": "home/bootstrap3.html",
|
||||
"foundation5": "home/foundation5.html",
|
||||
"simple": "home/simple.html",
|
||||
}
|
||||
|
||||
# Get the template to be used.
|
||||
fobi_home_template = fobi_theme_home_template_mapping.get(
|
||||
DEFAULT_THEME,
|
||||
'home/base.html'
|
||||
DEFAULT_THEME, "home/base.html"
|
||||
)
|
||||
|
||||
FOBI_EDIT_URLS_PREFIX = ''
|
||||
if DEFAULT_THEME in ('simple', 'djangocms_admin_style_theme'):
|
||||
FOBI_EDIT_URLS_PREFIX = 'admin/'
|
||||
FOBI_EDIT_URLS_PREFIX = ""
|
||||
if DEFAULT_THEME in ("simple", "djangocms_admin_style_theme"):
|
||||
FOBI_EDIT_URLS_PREFIX = "admin/"
|
||||
|
||||
urlpatterns = []
|
||||
|
||||
url_patterns_args = [
|
||||
# DB Store plugin URLs
|
||||
# namespace='fobi'
|
||||
url(r'^fobi/plugins/form-handlers/db-store/',
|
||||
include('fobi.contrib.plugins.form_handlers.db_store.urls')),
|
||||
url(r'^fobi/plugins/form-wizard-handlers/db-store/',
|
||||
include('fobi.contrib.plugins.form_handlers.db_store.urls.'
|
||||
'form_wizard_handlers')),
|
||||
|
||||
url(
|
||||
r"^fobi/plugins/form-handlers/db-store/",
|
||||
include("fobi.contrib.plugins.form_handlers.db_store.urls"),
|
||||
),
|
||||
url(
|
||||
r"^fobi/plugins/form-wizard-handlers/db-store/",
|
||||
include(
|
||||
"fobi.contrib.plugins.form_handlers.db_store.urls."
|
||||
"form_wizard_handlers"
|
||||
),
|
||||
),
|
||||
# django-fobi URLs:
|
||||
# namespace='fobi'
|
||||
url(r'^fobi/', include('fobi.urls.class_based.view')),
|
||||
url(r"^fobi/", include("fobi.urls.class_based.view")),
|
||||
# namespace='fobi'
|
||||
url(r'^{0}fobi/'.format(FOBI_EDIT_URLS_PREFIX),
|
||||
include('fobi.urls.class_based.edit')),
|
||||
|
||||
url(r'^admin_tools/', include('admin_tools.urls')),
|
||||
|
||||
url(r'^login/$',
|
||||
auth_views.LoginView.as_view(template_name='registration/login.html'),
|
||||
name='auth_login'),
|
||||
url(
|
||||
r"^{0}fobi/".format(FOBI_EDIT_URLS_PREFIX),
|
||||
include("fobi.urls.class_based.edit"),
|
||||
),
|
||||
url(r"^admin_tools/", include("admin_tools.urls")),
|
||||
url(
|
||||
r"^login/$",
|
||||
auth_views.LoginView.as_view(template_name="registration/login.html"),
|
||||
name="auth_login",
|
||||
),
|
||||
]
|
||||
|
||||
if versions.DJANGO_GTE_2_0:
|
||||
url_patterns_args += [
|
||||
url(r'^admin/', admin.site.urls),
|
||||
url(r"^admin/", admin.site.urls),
|
||||
]
|
||||
else:
|
||||
url_patterns_args += [
|
||||
url(r'^admin/', include(admin.site.urls)),
|
||||
url(r"^admin/", include(admin.site.urls)),
|
||||
]
|
||||
|
||||
url_patterns_args += [
|
||||
# django-registration URLs:
|
||||
url(
|
||||
r'^accounts/',
|
||||
r"^accounts/",
|
||||
include(
|
||||
'django_registration.backends.one_step.urls'
|
||||
"django_registration.backends.one_step.urls"
|
||||
if versions.DJANGO_GTE_3_0
|
||||
else 'registration.backends.simple.urls'
|
||||
)
|
||||
else "registration.backends.simple.urls"
|
||||
),
|
||||
),
|
||||
|
||||
# foo URLs:
|
||||
url(r'^foo/', include('foo.urls')),
|
||||
|
||||
url(r"^foo/", include("foo.urls")),
|
||||
# bar URLs:
|
||||
# url(r'^bar/', include('bar.urls')),
|
||||
|
||||
url(r'^$', TemplateView.as_view(template_name=fobi_home_template)),
|
||||
|
||||
url(r"^$", TemplateView.as_view(template_name=fobi_home_template)),
|
||||
# django-fobi public forms contrib app:
|
||||
# url(r'^', include('fobi.contrib.apps.public_forms.urls')),
|
||||
]
|
||||
|
|
@ -92,16 +93,16 @@ urlpatterns += i18n_patterns(*url_patterns_args)
|
|||
# Serving media and static in debug/developer mode.
|
||||
if settings.DEBUG:
|
||||
urlpatterns += staticfiles_urlpatterns()
|
||||
urlpatterns += static(settings.MEDIA_URL,
|
||||
document_root=settings.MEDIA_ROOT)
|
||||
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||
|
||||
# Conditionally including FeinCMS URls in case if
|
||||
# FeinCMS in installed apps.
|
||||
if 'feincms' in settings.INSTALLED_APPS:
|
||||
if "feincms" in settings.INSTALLED_APPS:
|
||||
from page.models import Page
|
||||
|
||||
Page
|
||||
url_patterns_args = [
|
||||
url(r'^pages/', include('feincms.urls')),
|
||||
url(r"^pages/", include("feincms.urls")),
|
||||
]
|
||||
urlpatterns += i18n_patterns(*url_patterns_args)
|
||||
|
||||
|
|
@ -112,48 +113,47 @@ if 'feincms' in settings.INSTALLED_APPS:
|
|||
# ]
|
||||
# urlpatterns += list(url_patterns_args)
|
||||
|
||||
if 'ckeditor_uploader' in settings.INSTALLED_APPS:
|
||||
if "ckeditor_uploader" in settings.INSTALLED_APPS:
|
||||
url_patterns_args = [
|
||||
url(r'^ckeditor/', include('ckeditor_uploader.urls')),
|
||||
url(r"^ckeditor/", include("ckeditor_uploader.urls")),
|
||||
]
|
||||
urlpatterns += i18n_patterns(*url_patterns_args)
|
||||
|
||||
# Conditionally including DjangoCMS URls in case if
|
||||
# DjangoCMS in installed apps.
|
||||
if 'cms' in settings.INSTALLED_APPS:
|
||||
if "cms" in settings.INSTALLED_APPS:
|
||||
url_patterns_args = [
|
||||
url(r'^cms-pages/', include('cms.urls')),
|
||||
url(r"^cms-pages/", include("cms.urls")),
|
||||
]
|
||||
urlpatterns += i18n_patterns(*url_patterns_args)
|
||||
|
||||
# Conditionally including Django REST framework integration app
|
||||
if 'fobi.contrib.apps.drf_integration' in settings.INSTALLED_APPS:
|
||||
if "fobi.contrib.apps.drf_integration" in settings.INSTALLED_APPS:
|
||||
from fobi.contrib.apps.drf_integration.urls import fobi_router
|
||||
urlpatterns += [
|
||||
url(r'^api/', include(fobi_router.urls))
|
||||
]
|
||||
|
||||
urlpatterns += [url(r"^api/", include(fobi_router.urls))]
|
||||
|
||||
# Conditionally including Captcha URls in case if
|
||||
# Captcha in installed apps.
|
||||
if getattr(settings, 'ENABLE_CAPTCHA', False):
|
||||
if getattr(settings, "ENABLE_CAPTCHA", False):
|
||||
try:
|
||||
from captcha.fields import ReCaptchaField
|
||||
except ImportError:
|
||||
try:
|
||||
from captcha.fields import CaptchaField
|
||||
if 'captcha' in settings.INSTALLED_APPS:
|
||||
|
||||
if "captcha" in settings.INSTALLED_APPS:
|
||||
urlpatterns += [
|
||||
url(r'^captcha/', include('captcha.urls')),
|
||||
url(r"^captcha/", include("captcha.urls")),
|
||||
]
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
if (
|
||||
getattr(settings, 'DEBUG', False)
|
||||
and getattr(settings, 'DEBUG_TOOLBAR', False)
|
||||
if getattr(settings, "DEBUG", False) and getattr(
|
||||
settings, "DEBUG_TOOLBAR", False
|
||||
):
|
||||
import debug_toolbar
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^__debug__/', include(debug_toolbar.urls)),
|
||||
url(r"^__debug__/", include(debug_toolbar.urls)),
|
||||
] + urlpatterns
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ os.environ.setdefault("DJANGO_SETTINGS_MODULE", "simple.settings")
|
|||
# file. This includes Django's development server, if the WSGI_APPLICATION
|
||||
# setting points here.
|
||||
from django.core.wsgi import get_wsgi_application
|
||||
|
||||
application = get_wsgi_application()
|
||||
|
||||
# Apply WSGI middleware here.
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
from fobi.constants import CALLBACK_FORM_VALID
|
||||
from fobi.base import FormCallback, form_callback_registry
|
||||
from fobi.constants import CALLBACK_FORM_VALID
|
||||
|
||||
|
||||
class SampleFooCallback(FormCallback):
|
||||
|
|
|
|||
|
|
@ -1,34 +1,38 @@
|
|||
import os
|
||||
PROJECT_DIR = lambda base : os.path.abspath(os.path.join(os.path.dirname(__file__), base).replace('\\','/'))
|
||||
|
||||
PROJECT_DIR = lambda base: os.path.abspath(
|
||||
os.path.join(os.path.dirname(__file__), base).replace("\\", "/")
|
||||
)
|
||||
|
||||
DEBUG = True
|
||||
DEBUG_TOOLBAR = not True
|
||||
TEMPLATE_DEBUG = True
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
|
||||
'NAME': PROJECT_DIR('../db/example.db'), # Or path to database file if using sqlite3.
|
||||
|
||||
"default": {
|
||||
"ENGINE": "django.db.backends.sqlite3", # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
|
||||
"NAME": PROJECT_DIR(
|
||||
"../db/example.db"
|
||||
), # Or path to database file if using sqlite3.
|
||||
# The following settings are not used with sqlite3:
|
||||
'USER': '',
|
||||
'PASSWORD': '',
|
||||
'HOST': '', # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP.
|
||||
'PORT': '', # Set to empty string for default.
|
||||
"USER": "",
|
||||
"PASSWORD": "",
|
||||
"HOST": "", # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP.
|
||||
"PORT": "", # Set to empty string for default.
|
||||
}
|
||||
}
|
||||
|
||||
INTERNAL_IPS = ('127.0.0.1',)
|
||||
INTERNAL_IPS = ("127.0.0.1",)
|
||||
|
||||
EMAIL_BACKEND = 'django.core.mail.backends.filebased.EmailBackend'
|
||||
EMAIL_FILE_PATH = PROJECT_DIR('../tmp')
|
||||
EMAIL_BACKEND = "django.core.mail.backends.filebased.EmailBackend"
|
||||
EMAIL_FILE_PATH = PROJECT_DIR("../tmp")
|
||||
|
||||
DEFAULT_FROM_EMAIL = '<no-reply@dev.django-fobi.mail.example.com>'
|
||||
DEFAULT_FROM_EMAIL = "<no-reply@dev.django-fobi.mail.example.com>"
|
||||
|
||||
FOBI_DEBUG = True
|
||||
FOBI_RESTRICT_PLUGIN_ACCESS = False
|
||||
FOBI_RESTRICT_FIELDS_ACCESS = False
|
||||
#FOBI_DEFAULT_THEME = 'foundation5'
|
||||
# FOBI_DEFAULT_THEME = 'foundation5'
|
||||
|
||||
WAIT_BETWEEN_TEST_STEPS = 0
|
||||
FOBI_WAIT_AT_TEST_END = 0
|
||||
|
|
|
|||
|
|
@ -1,17 +1,17 @@
|
|||
from fobi.base import form_element_plugin_widget_registry
|
||||
|
||||
from sample_textarea.widgets import BaseSampleTextareaPluginWidget
|
||||
|
||||
from fobi.base import form_element_plugin_widget_registry
|
||||
|
||||
|
||||
class SampleTextareaPluginWidget(BaseSampleTextareaPluginWidget):
|
||||
"""SampleTextareaPluginWidget."""
|
||||
|
||||
theme_uid = 'sample_layout' # Theme for which the widget is loaded
|
||||
theme_uid = "sample_layout" # Theme for which the widget is loaded
|
||||
media_js = [
|
||||
'sample_layout/js/fobi.plugins.form_elements.sample_textarea.js',
|
||||
"sample_layout/js/fobi.plugins.form_elements.sample_textarea.js",
|
||||
]
|
||||
media_css = [
|
||||
'sample_layout/css/fobi.plugins.form_elements.sample_textarea.css',
|
||||
"sample_layout/css/fobi.plugins.form_elements.sample_textarea.css",
|
||||
]
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
import json
|
||||
|
||||
from django.core.mail import send_mail
|
||||
from sample_mail.forms import SampleMailForm
|
||||
|
||||
from fobi.base import FormHandlerPlugin, form_handler_plugin_registry
|
||||
|
||||
from sample_mail.forms import SampleMailForm
|
||||
|
||||
|
||||
class SampleMailHandlerPlugin(FormHandlerPlugin):
|
||||
"""SampleMailHandlerPlugin."""
|
||||
|
|
@ -20,7 +19,7 @@ class SampleMailHandlerPlugin(FormHandlerPlugin):
|
|||
json.dumps(form.cleaned_data),
|
||||
self.data.from_email,
|
||||
[self.data.to_email],
|
||||
fail_silently=True
|
||||
fail_silently=True,
|
||||
)
|
||||
|
||||
def plugin_data_repr(self):
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
from django import forms
|
||||
|
||||
from fobi.base import FormFieldPlugin, form_element_plugin_registry
|
||||
|
||||
from .forms import SampleTextareaForm
|
||||
|
||||
from fobi.base import FormFieldPlugin, form_element_plugin_registry
|
||||
|
||||
|
||||
class SampleTextareaPlugin(FormFieldPlugin):
|
||||
"""SampleTextareaPlugin."""
|
||||
|
|
@ -13,13 +13,14 @@ class SampleTextareaPlugin(FormFieldPlugin):
|
|||
form = SampleTextareaForm
|
||||
group = "Samples" # Group to which the plugin belongs to
|
||||
|
||||
def get_form_field_instances(self, request=None, form_entry=None,
|
||||
form_element_entries=None, **kwargs):
|
||||
def get_form_field_instances(
|
||||
self, request=None, form_entry=None, form_element_entries=None, **kwargs
|
||||
):
|
||||
field_kwargs = {
|
||||
'required': self.data.required,
|
||||
'label': self.data.label,
|
||||
'initial': self.data.initial,
|
||||
'widget': forms.widgets.Textarea(attrs={})
|
||||
"required": self.data.required,
|
||||
"label": self.data.label,
|
||||
"initial": self.data.initial,
|
||||
"widget": forms.widgets.Textarea(attrs={}),
|
||||
}
|
||||
|
||||
return [(self.data.name, forms.CharField, field_kwargs)]
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ class SampleTextareaForm(forms.Form, BasePluginForm):
|
|||
("name", ""),
|
||||
("label", ""),
|
||||
("initial", ""),
|
||||
("required", False)
|
||||
("required", False),
|
||||
]
|
||||
|
||||
name = forms.CharField(label="Name", required=True)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
# Django settings for example project.
|
||||
import os
|
||||
PROJECT_DIR = lambda base : os.path.abspath(os.path.join(os.path.dirname(__file__), base).replace('\\','/'))
|
||||
|
||||
PROJECT_DIR = lambda base: os.path.abspath(
|
||||
os.path.join(os.path.dirname(__file__), base).replace("\\", "/")
|
||||
)
|
||||
gettext = lambda s: s
|
||||
|
||||
DEBUG = False
|
||||
|
|
@ -14,14 +17,16 @@ ADMINS = (
|
|||
MANAGERS = ADMINS
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
|
||||
'NAME': PROJECT_DIR('../db/example.db'), # Or path to database file if using sqlite3.
|
||||
"default": {
|
||||
"ENGINE": "django.db.backends.sqlite3", # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
|
||||
"NAME": PROJECT_DIR(
|
||||
"../db/example.db"
|
||||
), # Or path to database file if using sqlite3.
|
||||
# The following settings are not used with sqlite3:
|
||||
'USER': '',
|
||||
'PASSWORD': '',
|
||||
'HOST': '', # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP.
|
||||
'PORT': '', # Set to empty string for default.
|
||||
"USER": "",
|
||||
"PASSWORD": "",
|
||||
"HOST": "", # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP.
|
||||
"PORT": "", # Set to empty string for default.
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -33,17 +38,17 @@ ALLOWED_HOSTS = []
|
|||
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
|
||||
# although not all choices may be available on all operating systems.
|
||||
# In a Windows environment this must be set to your system time zone.
|
||||
TIME_ZONE = 'America/Chicago'
|
||||
TIME_ZONE = "America/Chicago"
|
||||
|
||||
# Language code for this installation. All choices can be found here:
|
||||
# http://www.i18nguy.com/unicode/language-identifiers.html
|
||||
#LANGUAGE_CODE = 'en-us'
|
||||
# LANGUAGE_CODE = 'en-us'
|
||||
|
||||
LANGUAGES = (
|
||||
('en', gettext("English")), # Main language!
|
||||
('hy', gettext("Armenian")),
|
||||
('nl', gettext("Dutch")),
|
||||
('ru', gettext("Russian")),
|
||||
("en", gettext("English")), # Main language!
|
||||
("hy", gettext("Armenian")),
|
||||
("nl", gettext("Dutch")),
|
||||
("ru", gettext("Russian")),
|
||||
)
|
||||
|
||||
SITE_ID = 1
|
||||
|
|
@ -61,63 +66,63 @@ USE_TZ = True
|
|||
|
||||
# Absolute filesystem path to the directory that will hold user-uploaded files.
|
||||
# Example: "/var/www/example.com/media/"
|
||||
MEDIA_ROOT = PROJECT_DIR(os.path.join('..', 'media'))
|
||||
MEDIA_ROOT = PROJECT_DIR(os.path.join("..", "media"))
|
||||
|
||||
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
|
||||
# trailing slash.
|
||||
# Examples: "http://example.com/media/", "http://media.example.com/"
|
||||
MEDIA_URL = '/media/'
|
||||
MEDIA_URL = "/media/"
|
||||
|
||||
# Absolute path to the directory static files should be collected to.
|
||||
# Don't put anything in this directory yourself; store your static files
|
||||
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
|
||||
# Example: "/var/www/example.com/static/"
|
||||
STATIC_ROOT = PROJECT_DIR(os.path.join('..', 'static'))
|
||||
STATIC_ROOT = PROJECT_DIR(os.path.join("..", "static"))
|
||||
|
||||
# URL prefix for static files.
|
||||
# Example: "http://example.com/static/", "http://static.example.com/"
|
||||
STATIC_URL = '/static/'
|
||||
STATIC_URL = "/static/"
|
||||
|
||||
# Additional locations of static files
|
||||
STATICFILES_DIRS = (
|
||||
# Put strings here, like "/home/html/static" or "C:/www/django/static".
|
||||
# Always use forward slashes, even on Windows.
|
||||
# Don't forget to use absolute paths, not relative paths.
|
||||
PROJECT_DIR(os.path.join('..', 'media', 'static')),
|
||||
PROJECT_DIR(os.path.join("..", "media", "static")),
|
||||
)
|
||||
|
||||
# List of finder classes that know how to find static files in
|
||||
# various locations.
|
||||
STATICFILES_FINDERS = (
|
||||
'django.contrib.staticfiles.finders.FileSystemFinder',
|
||||
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
|
||||
# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
|
||||
"django.contrib.staticfiles.finders.FileSystemFinder",
|
||||
"django.contrib.staticfiles.finders.AppDirectoriesFinder",
|
||||
# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
|
||||
)
|
||||
|
||||
# Make this unique, and don't share it with anybody.
|
||||
SECRET_KEY = '97818c*w97Zi8a-m^1coRRrmurMI6+q5_kyn*)s@(*_Pk6q423'
|
||||
SECRET_KEY = "97818c*w97Zi8a-m^1coRRrmurMI6+q5_kyn*)s@(*_Pk6q423"
|
||||
|
||||
# List of callables that know how to import templates from various sources.
|
||||
TEMPLATE_LOADERS = (
|
||||
'django.template.loaders.filesystem.Loader',
|
||||
'django.template.loaders.app_directories.Loader',
|
||||
'django.template.loaders.eggs.Loader',
|
||||
"django.template.loaders.filesystem.Loader",
|
||||
"django.template.loaders.app_directories.Loader",
|
||||
"django.template.loaders.eggs.Loader",
|
||||
)
|
||||
|
||||
MIDDLEWARE_CLASSES = (
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
'django.middleware.csrf.CsrfViewMiddleware',
|
||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||
'django.contrib.messages.middleware.MessageMiddleware',
|
||||
"django.contrib.sessions.middleware.SessionMiddleware",
|
||||
"django.middleware.common.CommonMiddleware",
|
||||
"django.middleware.csrf.CsrfViewMiddleware",
|
||||
"django.contrib.auth.middleware.AuthenticationMiddleware",
|
||||
"django.contrib.messages.middleware.MessageMiddleware",
|
||||
# Uncomment the next line for simple clickjacking protection:
|
||||
# 'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||
)
|
||||
|
||||
ROOT_URLCONF = 'urls'
|
||||
ROOT_URLCONF = "urls"
|
||||
|
||||
# Python dotted path to the WSGI application used by Django's runserver.
|
||||
WSGI_APPLICATION = 'wsgi.application'
|
||||
WSGI_APPLICATION = "wsgi.application"
|
||||
|
||||
TEMPLATE_CONTEXT_PROCESSORS = (
|
||||
"django.contrib.auth.context_processors.auth",
|
||||
|
|
@ -128,14 +133,14 @@ TEMPLATE_CONTEXT_PROCESSORS = (
|
|||
"django.core.context_processors.tz",
|
||||
"django.contrib.messages.context_processors.messages",
|
||||
"django.core.context_processors.request",
|
||||
"fobi.context_processors.theme", # Important!
|
||||
"fobi.context_processors.theme", # Important!
|
||||
)
|
||||
|
||||
TEMPLATE_DIRS = (
|
||||
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
|
||||
# Always use forward slashes, even on Windows.
|
||||
# Don't forget to use absolute paths, not relative paths.
|
||||
PROJECT_DIR('templates'),
|
||||
PROJECT_DIR("templates"),
|
||||
)
|
||||
|
||||
INSTALLED_APPS = (
|
||||
|
|
@ -143,31 +148,26 @@ INSTALLED_APPS = (
|
|||
#'admin_tools',
|
||||
#'admin_tools.menu',
|
||||
#'admin_tools.dashboard',
|
||||
|
||||
# Django core and contrib apps
|
||||
'django.contrib.auth',
|
||||
'django.contrib.contenttypes',
|
||||
'django.contrib.sessions',
|
||||
'django.contrib.sites',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
'django.contrib.admin',
|
||||
'django.contrib.sitemaps',
|
||||
|
||||
"django.contrib.auth",
|
||||
"django.contrib.contenttypes",
|
||||
"django.contrib.sessions",
|
||||
"django.contrib.sites",
|
||||
"django.contrib.messages",
|
||||
"django.contrib.staticfiles",
|
||||
"django.contrib.admin",
|
||||
"django.contrib.sitemaps",
|
||||
# Third party apps used in the project
|
||||
'tinymce', # TinyMCE
|
||||
'easy_thumbnails', # Thumbnailer
|
||||
"tinymce", # TinyMCE
|
||||
"easy_thumbnails", # Thumbnailer
|
||||
# Auth views and registration app
|
||||
'django_registration' if DJANGO_GTE_3_0 else 'registration',
|
||||
|
||||
"django_registration" if DJANGO_GTE_3_0 else "registration",
|
||||
# Fobi core
|
||||
'fobi',
|
||||
|
||||
"fobi",
|
||||
# Fobi themes
|
||||
#'fobi.contrib.themes.bootstrap3', # Bootstrap 3 theme
|
||||
#'fobi.contrib.themes.foundation5', # Foundation 5 theme
|
||||
#'fobi.contrib.themes.simple', # Simple theme
|
||||
|
||||
# Fobi form elements - fields
|
||||
#'fobi.contrib.plugins.form_elements.fields.boolean',
|
||||
#'fobi.contrib.plugins.form_elements.fields.email',
|
||||
|
|
@ -180,40 +180,38 @@ INSTALLED_APPS = (
|
|||
#'fobi.contrib.plugins.form_elements.fields.select_multiple_model_objects',
|
||||
#'fobi.contrib.plugins.form_elements.fields.text',
|
||||
#'fobi.contrib.plugins.form_elements.fields.textarea',
|
||||
|
||||
# Fobi form elements - content elements
|
||||
'fobi.contrib.plugins.form_elements.test.dummy',
|
||||
'fobi.contrib.plugins.form_elements.content.content_image',
|
||||
'fobi.contrib.plugins.form_elements.content.content_text',
|
||||
'fobi.contrib.plugins.form_elements.content.content_video',
|
||||
|
||||
"fobi.contrib.plugins.form_elements.test.dummy",
|
||||
"fobi.contrib.plugins.form_elements.content.content_image",
|
||||
"fobi.contrib.plugins.form_elements.content.content_text",
|
||||
"fobi.contrib.plugins.form_elements.content.content_video",
|
||||
# Form handlers
|
||||
#'fobi.contrib.plugins.form_handlers.db_store',
|
||||
#'fobi.contrib.plugins.form_handlers.http_repost',
|
||||
#'fobi.contrib.plugins.form_handlers.mail',
|
||||
|
||||
# Your custom fobi apps
|
||||
'sample_layout', # Sample theme/layout
|
||||
'sample_textarea', # Sample text area form element plugin
|
||||
'sample_mail', # Sample mail form handler plugin
|
||||
|
||||
"sample_layout", # Sample theme/layout
|
||||
"sample_textarea", # Sample text area form element plugin
|
||||
"sample_mail", # Sample mail form handler plugin
|
||||
# Other project specific apps
|
||||
'foo', # Test app
|
||||
"foo", # Test app
|
||||
)
|
||||
|
||||
LOGIN_REDIRECT_URL = '/fobi/' # Important for passing the selenium tests
|
||||
LOGIN_REDIRECT_URL = "/fobi/" # Important for passing the selenium tests
|
||||
|
||||
#LOGIN_URL = '/accounts/login/'
|
||||
#LOGIN_ERROR_URL = '/accounts/login/'
|
||||
#LOGOUT_URL = '/accounts/logout/'
|
||||
# LOGIN_URL = '/accounts/login/'
|
||||
# LOGIN_ERROR_URL = '/accounts/login/'
|
||||
# LOGOUT_URL = '/accounts/logout/'
|
||||
|
||||
# django-admin-tools custom dashboard
|
||||
ADMIN_TOOLS_INDEX_DASHBOARD = 'admin_tools_dashboard.CustomIndexDashboard'
|
||||
ADMIN_TOOLS_APP_INDEX_DASHBOARD = 'admin_tools_dashboard.CustomAppIndexDashboard'
|
||||
ADMIN_TOOLS_MENU = 'admin_tools_dashboard.menu.CustomMenu'
|
||||
ADMIN_TOOLS_INDEX_DASHBOARD = "admin_tools_dashboard.CustomIndexDashboard"
|
||||
ADMIN_TOOLS_APP_INDEX_DASHBOARD = (
|
||||
"admin_tools_dashboard.CustomAppIndexDashboard"
|
||||
)
|
||||
ADMIN_TOOLS_MENU = "admin_tools_dashboard.menu.CustomMenu"
|
||||
|
||||
MIGRATION_MODULES = {
|
||||
'fobi': 'fobi.migrations',
|
||||
"fobi": "fobi.migrations",
|
||||
}
|
||||
|
||||
# A sample logging configuration. The only tangible logging
|
||||
|
|
@ -222,59 +220,55 @@ MIGRATION_MODULES = {
|
|||
# See http://docs.djangoproject.com/en/dev/topics/logging for
|
||||
# more details on how to customize your logging configuration.
|
||||
LOGGING = {
|
||||
'version': 1,
|
||||
'disable_existing_loggers': False,
|
||||
'filters': {
|
||||
'require_debug_false': {
|
||||
'()': 'django.utils.log.RequireDebugFalse'
|
||||
}
|
||||
"version": 1,
|
||||
"disable_existing_loggers": False,
|
||||
"filters": {
|
||||
"require_debug_false": {"()": "django.utils.log.RequireDebugFalse"}
|
||||
},
|
||||
'formatters': {
|
||||
'verbose': {
|
||||
'format': '\n%(levelname)s %(asctime)s [%(pathname)s:%(lineno)s] %(message)s'
|
||||
"formatters": {
|
||||
"verbose": {
|
||||
"format": "\n%(levelname)s %(asctime)s [%(pathname)s:%(lineno)s] %(message)s"
|
||||
},
|
||||
'simple': {
|
||||
'format': '\n%(levelname)s %(message)s'
|
||||
"simple": {"format": "\n%(levelname)s %(message)s"},
|
||||
},
|
||||
"handlers": {
|
||||
"mail_admins": {
|
||||
"level": "ERROR",
|
||||
"filters": ["require_debug_false"],
|
||||
"class": "django.utils.log.AdminEmailHandler",
|
||||
},
|
||||
"console": {
|
||||
"level": "DEBUG",
|
||||
"class": "logging.StreamHandler",
|
||||
"formatter": "verbose",
|
||||
},
|
||||
"django_log": {
|
||||
"level": "DEBUG",
|
||||
"class": "logging.handlers.RotatingFileHandler",
|
||||
"filename": PROJECT_DIR("../logs/django.log"),
|
||||
"maxBytes": 1048576,
|
||||
"backupCount": 99,
|
||||
"formatter": "verbose",
|
||||
},
|
||||
"fobi_log": {
|
||||
"level": "DEBUG",
|
||||
"class": "logging.handlers.RotatingFileHandler",
|
||||
"filename": PROJECT_DIR("../logs/fobi.log"),
|
||||
"maxBytes": 1048576,
|
||||
"backupCount": 99,
|
||||
"formatter": "verbose",
|
||||
},
|
||||
},
|
||||
'handlers': {
|
||||
'mail_admins': {
|
||||
'level': 'ERROR',
|
||||
'filters': ['require_debug_false'],
|
||||
'class': 'django.utils.log.AdminEmailHandler'
|
||||
"loggers": {
|
||||
"django": {
|
||||
"handlers": ["django_log"],
|
||||
"level": "ERROR",
|
||||
"propagate": True,
|
||||
},
|
||||
'console': {
|
||||
'level': 'DEBUG',
|
||||
'class': 'logging.StreamHandler',
|
||||
'formatter': 'verbose'
|
||||
},
|
||||
'django_log': {
|
||||
'level':'DEBUG',
|
||||
'class':'logging.handlers.RotatingFileHandler',
|
||||
'filename': PROJECT_DIR("../logs/django.log"),
|
||||
'maxBytes': 1048576,
|
||||
'backupCount': 99,
|
||||
'formatter': 'verbose',
|
||||
},
|
||||
'fobi_log': {
|
||||
'level':'DEBUG',
|
||||
'class':'logging.handlers.RotatingFileHandler',
|
||||
'filename': PROJECT_DIR("../logs/fobi.log"),
|
||||
'maxBytes': 1048576,
|
||||
'backupCount': 99,
|
||||
'formatter': 'verbose',
|
||||
},
|
||||
},
|
||||
'loggers': {
|
||||
'django': {
|
||||
'handlers': ['django_log'],
|
||||
'level': 'ERROR',
|
||||
'propagate': True,
|
||||
},
|
||||
'fobi': {
|
||||
'handlers': ['console', 'fobi_log'],
|
||||
'level': 'DEBUG',
|
||||
'propagate': True,
|
||||
"fobi": {
|
||||
"handlers": ["console", "fobi_log"],
|
||||
"level": "DEBUG",
|
||||
"propagate": True,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
@ -287,19 +281,13 @@ except:
|
|||
|
||||
if DEBUG and DEBUG_TOOLBAR:
|
||||
# debug_toolbar
|
||||
MIDDLEWARE_CLASSES += (
|
||||
'debug_toolbar.middleware.DebugToolbarMiddleware',
|
||||
)
|
||||
MIDDLEWARE_CLASSES += ("debug_toolbar.middleware.DebugToolbarMiddleware",)
|
||||
|
||||
INSTALLED_APPS += (
|
||||
'debug_toolbar',
|
||||
)
|
||||
INSTALLED_APPS += ("debug_toolbar",)
|
||||
|
||||
DEBUG_TOOLBAR_CONFIG = {
|
||||
'INTERCEPT_REDIRECTS': False,
|
||||
"INTERCEPT_REDIRECTS": False,
|
||||
}
|
||||
|
||||
if DEBUG and TEMPLATE_DEBUG:
|
||||
INSTALLED_APPS += (
|
||||
'template_debug',
|
||||
)
|
||||
INSTALLED_APPS += ("template_debug",)
|
||||
|
|
|
|||
|
|
@ -1,11 +1,9 @@
|
|||
from django.urls import include, re_path as url
|
||||
|
||||
from django.conf import settings
|
||||
from django.conf.urls.static import static
|
||||
from django.contrib import admin
|
||||
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
|
||||
from django.conf.urls.static import static
|
||||
from django.urls import include, re_path as url
|
||||
from django.views.generic import TemplateView
|
||||
|
||||
from django_nine import versions
|
||||
|
||||
from fobi.settings import DEFAULT_THEME
|
||||
|
|
@ -14,39 +12,40 @@ admin.autodiscover()
|
|||
|
||||
# Mapping.
|
||||
fobi_theme_home_template_mapping = {
|
||||
'bootstrap3': 'home/bootstrap3.html',
|
||||
'foundation5': 'home/foundation5.html',
|
||||
"bootstrap3": "home/bootstrap3.html",
|
||||
"foundation5": "home/foundation5.html",
|
||||
}
|
||||
|
||||
# Get the template to be used.
|
||||
fobi_home_template = fobi_theme_home_template_mapping.get(
|
||||
DEFAULT_THEME,
|
||||
'home/base.html'
|
||||
)
|
||||
DEFAULT_THEME, "home/base.html"
|
||||
)
|
||||
|
||||
urlpatterns = [
|
||||
# DB Store plugin URLs
|
||||
url(r'^fobi/plugins/form-handlers/db-store/',
|
||||
include('fobi.contrib.plugins.form_handlers.db_store.urls')),
|
||||
#, namespace='fobi'
|
||||
|
||||
url(
|
||||
r"^fobi/plugins/form-handlers/db-store/",
|
||||
include("fobi.contrib.plugins.form_handlers.db_store.urls"),
|
||||
),
|
||||
# , namespace='fobi'
|
||||
# django-fobi URLs:
|
||||
url(r'^fobi/', include('fobi.urls')), #, namespace='fobi'
|
||||
|
||||
url(r'^admin_tools/', include('admin_tools.urls')),
|
||||
|
||||
url(r'^admin/', include(admin.site.urls)),
|
||||
|
||||
url(r"^fobi/", include("fobi.urls")), # , namespace='fobi'
|
||||
url(r"^admin_tools/", include("admin_tools.urls")),
|
||||
url(r"^admin/", include(admin.site.urls)),
|
||||
# django-registration URLs:
|
||||
url(r'^accounts/', include('django_registration.backends.one_step.urls' if versions.DJANGO_GTE_3_0 else 'registration.backends.simple.urls')),
|
||||
|
||||
url(
|
||||
r"^accounts/",
|
||||
include(
|
||||
"django_registration.backends.one_step.urls"
|
||||
if versions.DJANGO_GTE_3_0
|
||||
else "registration.backends.simple.urls"
|
||||
),
|
||||
),
|
||||
# foo URLs:
|
||||
url(r'^foo/', include('foo.urls')),
|
||||
|
||||
url(r'^$', TemplateView.as_view(template_name=fobi_home_template)),
|
||||
|
||||
url(r"^foo/", include("foo.urls")),
|
||||
url(r"^$", TemplateView.as_view(template_name=fobi_home_template)),
|
||||
# django-fobi public forms contrib app:
|
||||
#url(r'^', include('fobi.contrib.apps.public_forms.urls')),
|
||||
# url(r'^', include('fobi.contrib.apps.public_forms.urls')),
|
||||
]
|
||||
|
||||
# Serving media and static in debug/developer mode.
|
||||
|
|
@ -56,9 +55,10 @@ if settings.DEBUG:
|
|||
|
||||
# Conditionally including FeinCMS URls in case if
|
||||
# FeinCMS in installed apps.
|
||||
if 'feincms' in settings.INSTALLED_APPS:
|
||||
if "feincms" in settings.INSTALLED_APPS:
|
||||
from page.models import Page
|
||||
|
||||
Page
|
||||
urlpatterns += [
|
||||
url(r'', include('feincms.urls')),
|
||||
url(r"", include("feincms.urls")),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ os.environ.setdefault("DJANGO_SETTINGS_MODULE", "example.settings")
|
|||
# file. This includes Django's development server, if the WSGI_APPLICATION
|
||||
# setting points here.
|
||||
from django.core.wsgi import get_wsgi_application
|
||||
|
||||
application = get_wsgi_application()
|
||||
|
||||
# Apply WSGI middleware here.
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#!/usr/bin/env python
|
||||
import os
|
||||
import sys
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
|
|
@ -11,5 +12,5 @@ def main():
|
|||
return pytest.main()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ skip =
|
|||
wsgi.py,
|
||||
./src/fobi/migrations/*.py,
|
||||
./src/fobi/south_migrations/*.py
|
||||
.tox/
|
||||
skip_glob = **/migrations/*.py
|
||||
force_grid_wrap = 0
|
||||
use_parentheses = true
|
||||
|
|
|
|||
189
setup.py
189
setup.py
|
|
@ -3,7 +3,7 @@ import os
|
|||
from distutils.version import LooseVersion
|
||||
from setuptools import setup, find_packages
|
||||
|
||||
version = '0.19.1'
|
||||
version = "0.19.1"
|
||||
|
||||
# ***************************************************************************
|
||||
# ************************** Django version *********************************
|
||||
|
|
@ -11,69 +11,73 @@ version = '0.19.1'
|
|||
DJANGO_INSTALLED = False
|
||||
try:
|
||||
import django
|
||||
|
||||
DJANGO_INSTALLED = True
|
||||
|
||||
LOOSE_DJANGO_VERSION = LooseVersion(django.get_version())
|
||||
LOOSE_DJANGO_MINOR_VERSION = LooseVersion(
|
||||
'.'.join([str(i) for i in LOOSE_DJANGO_VERSION.version[0:2]])
|
||||
".".join([str(i) for i in LOOSE_DJANGO_VERSION.version[0:2]])
|
||||
)
|
||||
|
||||
# Loose versions
|
||||
LOOSE_VERSIONS = (
|
||||
'1.4',
|
||||
'1.5',
|
||||
'1.6',
|
||||
'1.7',
|
||||
'1.8',
|
||||
'1.9',
|
||||
'1.10',
|
||||
'1.11',
|
||||
'2.0',
|
||||
'2.1',
|
||||
'2.2',
|
||||
'3.0',
|
||||
'3.1',
|
||||
'3.2',
|
||||
'4.0',
|
||||
'4.1',
|
||||
'4.2',
|
||||
'5.0',
|
||||
"1.4",
|
||||
"1.5",
|
||||
"1.6",
|
||||
"1.7",
|
||||
"1.8",
|
||||
"1.9",
|
||||
"1.10",
|
||||
"1.11",
|
||||
"2.0",
|
||||
"2.1",
|
||||
"2.2",
|
||||
"3.0",
|
||||
"3.1",
|
||||
"3.2",
|
||||
"4.0",
|
||||
"4.1",
|
||||
"4.2",
|
||||
"5.0",
|
||||
)
|
||||
|
||||
for v in LOOSE_VERSIONS:
|
||||
var_name = 'LOOSE_VERSION_{0}'.format(v.replace('.', '_'))
|
||||
var_name = "LOOSE_VERSION_{0}".format(v.replace(".", "_"))
|
||||
globals()[var_name] = LooseVersion(v)
|
||||
|
||||
# Exact versions
|
||||
EXACT_VERSIONS = LOOSE_VERSIONS[:-1]
|
||||
|
||||
for i, v in enumerate(EXACT_VERSIONS):
|
||||
l_cur = globals()['LOOSE_VERSION_{0}' \
|
||||
''.format(LOOSE_VERSIONS[i].replace('.', '_'))]
|
||||
l_nxt = globals()['LOOSE_VERSION_{0}' \
|
||||
''.format(LOOSE_VERSIONS[i + 1].replace('.', '_'))]
|
||||
var_name = 'DJANGO_{0}'.format(v.replace('.', '_'))
|
||||
globals()[var_name] = (l_cur <= LOOSE_DJANGO_VERSION < l_nxt)
|
||||
l_cur = globals()[
|
||||
"LOOSE_VERSION_{0}" "".format(LOOSE_VERSIONS[i].replace(".", "_"))
|
||||
]
|
||||
l_nxt = globals()[
|
||||
"LOOSE_VERSION_{0}"
|
||||
"".format(LOOSE_VERSIONS[i + 1].replace(".", "_"))
|
||||
]
|
||||
var_name = "DJANGO_{0}".format(v.replace(".", "_"))
|
||||
globals()[var_name] = l_cur <= LOOSE_DJANGO_VERSION < l_nxt
|
||||
|
||||
# LTE list
|
||||
LTE_VERSIONS = LOOSE_VERSIONS[:-1]
|
||||
|
||||
for i, v in enumerate(EXACT_VERSIONS):
|
||||
l_cur = globals()['LOOSE_VERSION_{0}' \
|
||||
''.format(LOOSE_VERSIONS[i].replace('.', '_'))]
|
||||
var_name = 'DJANGO_LTE_{0}'.format(v.replace('.', '_'))
|
||||
globals()[var_name] = (LOOSE_DJANGO_MINOR_VERSION <= l_cur)
|
||||
l_cur = globals()[
|
||||
"LOOSE_VERSION_{0}" "".format(LOOSE_VERSIONS[i].replace(".", "_"))
|
||||
]
|
||||
var_name = "DJANGO_LTE_{0}".format(v.replace(".", "_"))
|
||||
globals()[var_name] = LOOSE_DJANGO_MINOR_VERSION <= l_cur
|
||||
|
||||
# GTE list
|
||||
GTE_VERSIONS = LOOSE_VERSIONS[:-1]
|
||||
|
||||
for i, v in enumerate(EXACT_VERSIONS):
|
||||
l_cur = globals()['LOOSE_VERSION_{0}' \
|
||||
''.format(LOOSE_VERSIONS[i].replace('.', '_'))]
|
||||
var_name = 'DJANGO_GTE_{0}'.format(v.replace('.', '_'))
|
||||
globals()[var_name] = (
|
||||
LOOSE_DJANGO_MINOR_VERSION >= l_cur
|
||||
)
|
||||
l_cur = globals()[
|
||||
"LOOSE_VERSION_{0}" "".format(LOOSE_VERSIONS[i].replace(".", "_"))
|
||||
]
|
||||
var_name = "DJANGO_GTE_{0}".format(v.replace(".", "_"))
|
||||
globals()[var_name] = LOOSE_DJANGO_MINOR_VERSION >= l_cur
|
||||
|
||||
except Exception as err:
|
||||
pass
|
||||
|
|
@ -83,77 +87,61 @@ except Exception as err:
|
|||
# ***************************************************************************
|
||||
|
||||
try:
|
||||
readme = open(os.path.join(os.path.dirname(__file__), 'README.rst')).read()
|
||||
readme = open(os.path.join(os.path.dirname(__file__), "README.rst")).read()
|
||||
screenshots = open(
|
||||
os.path.join(os.path.dirname(__file__), 'docs/screenshots.rst.distrib')
|
||||
os.path.join(os.path.dirname(__file__), "docs/screenshots.rst.distrib")
|
||||
).read()
|
||||
screenshots = screenshots.replace(
|
||||
'.. image:: _static',
|
||||
'.. figure:: https://github.com/barseghyanartur/django-fobi/raw/'
|
||||
'master/docs/_static'
|
||||
".. image:: _static",
|
||||
".. figure:: https://github.com/barseghyanartur/django-fobi/raw/"
|
||||
"master/docs/_static",
|
||||
)
|
||||
except:
|
||||
readme = ''
|
||||
screenshots = ''
|
||||
readme = ""
|
||||
screenshots = ""
|
||||
|
||||
template_dirs = [
|
||||
# Core templates
|
||||
"src/fobi/templates/fobi",
|
||||
|
||||
# Bootstrap 3
|
||||
"src/fobi/contrib/themes/bootstrap3/templates/bootstrap3",
|
||||
|
||||
# Foundation 5
|
||||
"src/fobi/contrib/themes/foundation5/templates/foundation5",
|
||||
|
||||
# DB Store widget for Foundation 5
|
||||
"src/fobi/contrib/themes/foundation5/widgets/form_handlers/"
|
||||
"db_store_foundation5_widget",
|
||||
|
||||
# Simple
|
||||
"src/fobi/contrib/themes/simple/templates/simple",
|
||||
|
||||
# djangocms_admin_style_theme
|
||||
"src/fobi/contrib/themes/djangocms_admin_style_theme/templates/"
|
||||
"djangocms_admin_style_theme",
|
||||
|
||||
# DjangoCMS integration
|
||||
"src/fobi/contrib/apps/djangocms_integration/templates/"
|
||||
"djangocms_integration",
|
||||
|
||||
# FeinCMS integration
|
||||
# "src/fobi/contrib/apps/feincms_integration/templates/"
|
||||
# "feincms_integration",
|
||||
|
||||
# Mezzanine integration
|
||||
"src/fobi/contrib/apps/mezzanine_integration/templates/"
|
||||
"mezzanine_integration",
|
||||
|
||||
# Wagtail integration
|
||||
"src/fobi/contrib/apps/wagtail_integration/templates/"
|
||||
"wagtail_integration",
|
||||
|
||||
# Content image
|
||||
"src/fobi/contrib/plugins/form_elements/content/content_image/"
|
||||
"templates/content_image",
|
||||
|
||||
# Content image URL
|
||||
"src/fobi/contrib/plugins/form_elements/content/content_image_url/"
|
||||
"templates/content_image_url",
|
||||
|
||||
# DB Store
|
||||
"src/fobi/contrib/plugins/form_handlers/db_store/templates/db_store",
|
||||
|
||||
# Mail
|
||||
"src/fobi/contrib/plugins/form_handlers/mail/templates/mail",
|
||||
|
||||
# Mail sender
|
||||
"src/fobi/contrib/plugins/form_handlers/mail_sender/templates/mail_sender",
|
||||
|
||||
# Http re-post
|
||||
"src/fobi/contrib/plugins/form_handlers/http_repost/templates/"
|
||||
"http_repost",
|
||||
|
||||
# MailChimp importer
|
||||
"src/fobi/contrib/plugins/form_importers/mailchimp_importer/templates/"
|
||||
"mailchimp_importer",
|
||||
|
|
@ -162,49 +150,36 @@ template_dirs = [
|
|||
static_dirs = [
|
||||
# Core static
|
||||
"src/fobi/static",
|
||||
|
||||
# Bootstrap3
|
||||
"src/fobi/contrib/themes/bootstrap3/static",
|
||||
|
||||
# Bootstrap3 datetime widget
|
||||
"src/fobi/contrib/themes/bootstrap3/widgets/form_elements/"
|
||||
"datetime_bootstrap3_widget/static",
|
||||
|
||||
# Bootstrap3 date widget
|
||||
"src/fobi/contrib/themes/bootstrap3/widgets/form_elements/"
|
||||
"date_bootstrap3_widget/static",
|
||||
|
||||
# Bootstrap3 slider widget
|
||||
"src/fobi/contrib/themes/bootstrap3/widgets/form_elements/"
|
||||
"slider_bootstrap3_widget/static",
|
||||
|
||||
# Foundation5
|
||||
"src/fobi/contrib/themes/foundation5/static",
|
||||
|
||||
# Foundation5 datetime widget
|
||||
"src/fobi/contrib/themes/foundation5/widgets/form_elements/"
|
||||
"datetime_foundation5_widget/static",
|
||||
|
||||
# Foundation5 date widget
|
||||
"src/fobi/contrib/themes/foundation5/widgets/form_elements/"
|
||||
"date_foundation5_widget/static",
|
||||
|
||||
# Simple
|
||||
"src/fobi/contrib/themes/simple/static",
|
||||
|
||||
# djangocms_admin_style_theme
|
||||
"src/fobi/contrib/themes/djangocms_admin_style_theme/static",
|
||||
|
||||
# DB Store
|
||||
"src/fobi/contrib/plugins/form_handlers/db_store/static",
|
||||
|
||||
# Dummy
|
||||
"src/fobi/contrib/plugins/form_elements/test/dummy/static",
|
||||
|
||||
# Markdown widget
|
||||
"src/fobi/reusable/markdown_widget/static",
|
||||
"src/fobi/contrib/plugins/form_elements/content/content_markdown/static",
|
||||
|
||||
# Invisible reCAPTCHA
|
||||
"src/fobi/contrib/plugins/form_elements/security/invisible_recaptcha/static",
|
||||
]
|
||||
|
|
@ -220,40 +195,40 @@ static_files = []
|
|||
locale_files = []
|
||||
|
||||
for template_dir in template_dirs:
|
||||
templates += [os.path.join(template_dir, f)
|
||||
for f
|
||||
in os.listdir(template_dir)]
|
||||
templates += [
|
||||
os.path.join(template_dir, f) for f in os.listdir(template_dir)
|
||||
]
|
||||
|
||||
for static_dir in static_dirs:
|
||||
static_files += [os.path.join(static_dir, f)
|
||||
for f
|
||||
in os.listdir(static_dir)]
|
||||
static_files += [
|
||||
os.path.join(static_dir, f) for f in os.listdir(static_dir)
|
||||
]
|
||||
|
||||
for locale_dir in locale_dirs:
|
||||
locale_files += [os.path.join(locale_dir, f)
|
||||
for f
|
||||
in os.listdir(locale_dir)]
|
||||
locale_files += [
|
||||
os.path.join(locale_dir, f) for f in os.listdir(locale_dir)
|
||||
]
|
||||
|
||||
dependency_links = []
|
||||
|
||||
# Dependencies
|
||||
install_requires = [
|
||||
'bleach',
|
||||
'django-autoslug>=1.9.4',
|
||||
'django-formtools>=2.0',
|
||||
'django-nine>=0.2.3',
|
||||
'django-nonefield>=0.1',
|
||||
'Pillow>=2.0.0',
|
||||
'requests>=1.0.0',
|
||||
'six>=1.9',
|
||||
'Unidecode>=0.04.1',
|
||||
'vishap>=0.1.5,<2.0',
|
||||
'easy-thumbnails>=2.4.1',
|
||||
"bleach",
|
||||
"django-autoslug>=1.9.4",
|
||||
"django-formtools>=2.0",
|
||||
"django-nine>=0.2.3",
|
||||
"django-nonefield>=0.1",
|
||||
"Pillow>=2.0.0",
|
||||
"requests>=1.0.0",
|
||||
"six>=1.9",
|
||||
"Unidecode>=0.04.1",
|
||||
"vishap>=0.1.5,<2.0",
|
||||
"easy-thumbnails>=2.4.1",
|
||||
]
|
||||
|
||||
tests_require = [
|
||||
'selenium',
|
||||
'Faker',
|
||||
"selenium",
|
||||
"Faker",
|
||||
# 'factory_boy',
|
||||
# 'fake-factory',
|
||||
# 'Pillow',
|
||||
|
|
@ -264,10 +239,10 @@ tests_require = [
|
|||
]
|
||||
|
||||
setup(
|
||||
name='django-fobi',
|
||||
name="django-fobi",
|
||||
version=version,
|
||||
description="Form generator/builder application for Django done right: "
|
||||
"customisable, modular, user- and developer- friendly.",
|
||||
"customisable, modular, user- and developer- friendly.",
|
||||
long_description="{0}{1}".format(readme, screenshots),
|
||||
classifiers=[
|
||||
"Programming Language :: Python :: 3",
|
||||
|
|
@ -290,21 +265,19 @@ setup(
|
|||
"Documentation": "https://django-fobi.readthedocs.io/",
|
||||
"Source Code": "https://github.com/barseghyanartur/django-fobi",
|
||||
"Changelog": "https://django-fobi.readthedocs.io/"
|
||||
"en/latest/changelog.html",
|
||||
"en/latest/changelog.html",
|
||||
},
|
||||
keywords="django, form generator, form builder, visual form designer, "
|
||||
"user generated forms",
|
||||
author='Artur Barseghyan',
|
||||
author_email='artur.barseghyan@gmail.com',
|
||||
url='https://github.com/barseghyanartur/django-fobi/',
|
||||
package_dir={'': 'src'},
|
||||
packages=find_packages(where='./src'),
|
||||
license='GPL-2.0-only OR LGPL-2.1-or-later',
|
||||
"user generated forms",
|
||||
author="Artur Barseghyan",
|
||||
author_email="artur.barseghyan@gmail.com",
|
||||
url="https://github.com/barseghyanartur/django-fobi/",
|
||||
package_dir={"": "src"},
|
||||
packages=find_packages(where="./src"),
|
||||
license="GPL-2.0-only OR LGPL-2.1-or-later",
|
||||
install_requires=install_requires,
|
||||
tests_require=tests_require,
|
||||
dependency_links=dependency_links,
|
||||
package_data={
|
||||
'fobi': templates + static_files + locale_files
|
||||
},
|
||||
package_data={"fobi": templates + static_files + locale_files},
|
||||
include_package_data=True,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
__title__ = 'django-fobi'
|
||||
__version__ = '0.19.1'
|
||||
__author__ = 'Artur Barseghyan <artur.barseghyan@gmail.com>'
|
||||
__copyright__ = '2014-2022 Artur Barseghyan'
|
||||
__license__ = 'GPL 2.0/LGPL 2.1'
|
||||
__title__ = "django-fobi"
|
||||
__version__ = "0.19.1"
|
||||
__author__ = "Artur Barseghyan <artur.barseghyan@gmail.com>"
|
||||
__copyright__ = "2014-2022 Artur Barseghyan"
|
||||
__license__ = "GPL 2.0/LGPL 2.1"
|
||||
|
||||
default_app_config = 'fobi.apps.Config'
|
||||
default_app_config = "fobi.apps.Config"
|
||||
|
|
|
|||
|
|
@ -1,15 +1,12 @@
|
|||
from django.urls import re_path as url
|
||||
from django.contrib import admin
|
||||
from django.contrib import messages
|
||||
from django.contrib import admin, messages
|
||||
from django.contrib.admin import helpers
|
||||
from django.contrib.admin.views.decorators import staff_member_required
|
||||
from django.shortcuts import render
|
||||
from django.shortcuts import redirect
|
||||
from django.shortcuts import redirect, render
|
||||
from django.template import RequestContext
|
||||
from django.urls import re_path as url
|
||||
from django.utils.decorators import method_decorator
|
||||
from django.utils.html import strip_tags
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from django_nine import versions
|
||||
|
||||
from .constants import ACTION_CHOICE_REPLACE
|
||||
|
|
@ -19,7 +16,7 @@ from .forms import (
|
|||
BulkChangeFormWizardHandlerPluginsForm,
|
||||
FormElementEntryForm,
|
||||
FormHandlerEntryForm,
|
||||
FormWizardHandlerEntryForm
|
||||
FormWizardHandlerEntryForm,
|
||||
)
|
||||
from .models import (
|
||||
FormElement,
|
||||
|
|
@ -30,31 +27,31 @@ from .models import (
|
|||
FormWizardEntry,
|
||||
FormWizardFormEntry,
|
||||
FormWizardHandler,
|
||||
FormWizardHandlerEntry
|
||||
FormWizardHandlerEntry,
|
||||
)
|
||||
|
||||
__title__ = 'fobi.admin'
|
||||
__author__ = 'Artur Barseghyan <artur.barseghyan@gmail.com>'
|
||||
__copyright__ = '2014-2019 Artur Barseghyan'
|
||||
__license__ = 'GPL 2.0/LGPL 2.1'
|
||||
__title__ = "fobi.admin"
|
||||
__author__ = "Artur Barseghyan <artur.barseghyan@gmail.com>"
|
||||
__copyright__ = "2014-2019 Artur Barseghyan"
|
||||
__license__ = "GPL 2.0/LGPL 2.1"
|
||||
__all__ = (
|
||||
'base_bulk_change_plugins',
|
||||
'BasePluginModelAdmin',
|
||||
'bulk_change_form_element_plugins',
|
||||
'bulk_change_form_handler_plugins',
|
||||
'bulk_change_form_wizard_handler_plugins',
|
||||
'FormElementAdmin',
|
||||
'FormElementEntryAdmin',
|
||||
'FormElementEntryInlineAdmin',
|
||||
'FormEntryAdmin',
|
||||
'FormFieldsetEntryAdmin',
|
||||
'FormHandlerAdmin',
|
||||
'FormHandlerEntryAdmin',
|
||||
'FormHandlerEntryInlineAdmin',
|
||||
'FormWizardEntryAdmin',
|
||||
'FormWizardFormEntryInlineAdmin',
|
||||
'FormWizardHandlerAdmin',
|
||||
'FormWizardHandlerEntryInlineAdmin',
|
||||
"base_bulk_change_plugins",
|
||||
"BasePluginModelAdmin",
|
||||
"bulk_change_form_element_plugins",
|
||||
"bulk_change_form_handler_plugins",
|
||||
"bulk_change_form_wizard_handler_plugins",
|
||||
"FormElementAdmin",
|
||||
"FormElementEntryAdmin",
|
||||
"FormElementEntryInlineAdmin",
|
||||
"FormEntryAdmin",
|
||||
"FormFieldsetEntryAdmin",
|
||||
"FormHandlerAdmin",
|
||||
"FormHandlerEntryAdmin",
|
||||
"FormHandlerEntryInlineAdmin",
|
||||
"FormWizardEntryAdmin",
|
||||
"FormWizardFormEntryInlineAdmin",
|
||||
"FormWizardHandlerAdmin",
|
||||
"FormWizardHandlerEntryInlineAdmin",
|
||||
)
|
||||
|
||||
staff_member_required_m = method_decorator(staff_member_required)
|
||||
|
|
@ -66,8 +63,9 @@ staff_member_required_m = method_decorator(staff_member_required)
|
|||
# *****************************************************************************
|
||||
|
||||
|
||||
def base_bulk_change_plugins(PluginForm, named_url, modeladmin, request,
|
||||
queryset):
|
||||
def base_bulk_change_plugins(
|
||||
PluginForm, named_url, modeladmin, request, queryset
|
||||
):
|
||||
"""Bulk change of plugins action additional view."""
|
||||
|
||||
opts = modeladmin.model._meta
|
||||
|
|
@ -76,25 +74,25 @@ def base_bulk_change_plugins(PluginForm, named_url, modeladmin, request,
|
|||
selected = request.POST.getlist(admin.ACTION_CHECKBOX_NAME)
|
||||
post = dict(request.POST)
|
||||
if selected:
|
||||
post['selected_plugins'] = ','.join(selected)
|
||||
if request.method == 'POST':
|
||||
post["selected_plugins"] = ",".join(selected)
|
||||
if request.method == "POST":
|
||||
form = PluginForm(
|
||||
data=post,
|
||||
files=request.FILES,
|
||||
initial={'selected_plugins': ','.join(selected)}
|
||||
initial={"selected_plugins": ",".join(selected)},
|
||||
)
|
||||
else:
|
||||
form = PluginForm(initial={'selected_plugins': ','.join(selected)})
|
||||
form = PluginForm(initial={"selected_plugins": ",".join(selected)})
|
||||
|
||||
context = {
|
||||
'form': form,
|
||||
'app_label': app_label,
|
||||
'opts': opts,
|
||||
'action_checkbox_name': helpers.ACTION_CHECKBOX_NAME,
|
||||
'named_url': named_url,
|
||||
"form": form,
|
||||
"app_label": app_label,
|
||||
"opts": opts,
|
||||
"action_checkbox_name": helpers.ACTION_CHECKBOX_NAME,
|
||||
"named_url": named_url,
|
||||
}
|
||||
|
||||
template_name = 'fobi/admin/bulk_change_plugins.html'
|
||||
template_name = "fobi/admin/bulk_change_plugins.html"
|
||||
|
||||
return render(request, template_name, context)
|
||||
|
||||
|
|
@ -103,10 +101,10 @@ def bulk_change_form_element_plugins(modeladmin, request, queryset):
|
|||
"""Bulk change FormElement plugins."""
|
||||
return base_bulk_change_plugins(
|
||||
BulkChangeFormElementPluginsForm,
|
||||
'admin:bulk_change_form_element_plugins',
|
||||
"admin:bulk_change_form_element_plugins",
|
||||
modeladmin,
|
||||
request,
|
||||
queryset
|
||||
queryset,
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -114,10 +112,10 @@ def bulk_change_form_handler_plugins(modeladmin, request, queryset):
|
|||
"""Bulk change FormHandler plugins."""
|
||||
return base_bulk_change_plugins(
|
||||
BulkChangeFormHandlerPluginsForm,
|
||||
'admin:bulk_change_form_handler_plugins',
|
||||
"admin:bulk_change_form_handler_plugins",
|
||||
modeladmin,
|
||||
request,
|
||||
queryset
|
||||
queryset,
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -125,12 +123,13 @@ def bulk_change_form_wizard_handler_plugins(modeladmin, request, queryset):
|
|||
"""Bulk change FormWizardHandler plugins."""
|
||||
return base_bulk_change_plugins(
|
||||
BulkChangeFormWizardHandlerPluginsForm,
|
||||
'admin:bulk_change_form_wizard_handler_plugins',
|
||||
"admin:bulk_change_form_wizard_handler_plugins",
|
||||
modeladmin,
|
||||
request,
|
||||
queryset
|
||||
queryset,
|
||||
)
|
||||
|
||||
|
||||
# *****************************************************************************
|
||||
# *****************************************************************************
|
||||
# ******************************* Entry admin *********************************
|
||||
|
|
@ -147,7 +146,12 @@ class FormElementEntryInlineAdmin(admin.TabularInline):
|
|||
|
||||
model = FormElementEntry
|
||||
form = FormElementEntryForm
|
||||
fields = ('form_entry', 'plugin_uid', 'plugin_data', 'position',)
|
||||
fields = (
|
||||
"form_entry",
|
||||
"plugin_uid",
|
||||
"plugin_data",
|
||||
"position",
|
||||
)
|
||||
extra = 0
|
||||
|
||||
|
||||
|
|
@ -156,7 +160,11 @@ class FormHandlerEntryInlineAdmin(admin.TabularInline):
|
|||
|
||||
model = FormHandlerEntry
|
||||
form = FormHandlerEntryForm
|
||||
fields = ('form_entry', 'plugin_uid', 'plugin_data',)
|
||||
fields = (
|
||||
"form_entry",
|
||||
"plugin_uid",
|
||||
"plugin_data",
|
||||
)
|
||||
extra = 0
|
||||
|
||||
|
||||
|
|
@ -164,54 +172,58 @@ class FormEntryAdmin(admin.ModelAdmin):
|
|||
"""FormEntry admin."""
|
||||
|
||||
list_display = (
|
||||
'name',
|
||||
'slug',
|
||||
'user',
|
||||
'is_public',
|
||||
'is_active',
|
||||
'created',
|
||||
'updated',
|
||||
'is_cloneable',
|
||||
"name",
|
||||
"slug",
|
||||
"user",
|
||||
"is_public",
|
||||
"is_active",
|
||||
"created",
|
||||
"updated",
|
||||
"is_cloneable",
|
||||
)
|
||||
list_editable = ('is_public', 'is_cloneable')
|
||||
list_filter = ('is_public', 'is_cloneable')
|
||||
readonly_fields = ('slug',)
|
||||
list_editable = ("is_public", "is_cloneable")
|
||||
list_filter = ("is_public", "is_cloneable")
|
||||
readonly_fields = ("slug",)
|
||||
radio_fields = {"user": admin.VERTICAL}
|
||||
fieldsets = (
|
||||
(_("Form"), {
|
||||
'fields': (
|
||||
'name',
|
||||
'is_public',
|
||||
'is_cloneable',
|
||||
'active_date_from',
|
||||
'active_date_to',
|
||||
'inactive_page_title',
|
||||
'inactive_page_message',
|
||||
)
|
||||
}),
|
||||
(_("Custom"), {
|
||||
'classes': ('collapse',),
|
||||
'fields': ('success_page_title', 'success_page_message', 'action')
|
||||
}),
|
||||
(
|
||||
_("Form"),
|
||||
{
|
||||
"fields": (
|
||||
"name",
|
||||
"is_public",
|
||||
"is_cloneable",
|
||||
"active_date_from",
|
||||
"active_date_to",
|
||||
"inactive_page_title",
|
||||
"inactive_page_message",
|
||||
)
|
||||
},
|
||||
),
|
||||
(
|
||||
_("Custom"),
|
||||
{
|
||||
"classes": ("collapse",),
|
||||
"fields": (
|
||||
"success_page_title",
|
||||
"success_page_message",
|
||||
"action",
|
||||
),
|
||||
},
|
||||
),
|
||||
# (_("Wizard"), {
|
||||
# 'classes': ('collapse',),
|
||||
# 'fields': ('form_wizard_entry', 'position',)
|
||||
# }),
|
||||
(_("User"), {
|
||||
'classes': ('collapse',),
|
||||
'fields': ('user',)
|
||||
}),
|
||||
(_('Additional'), {
|
||||
'classes': ('collapse',),
|
||||
'fields': ('slug',)
|
||||
}),
|
||||
(_("User"), {"classes": ("collapse",), "fields": ("user",)}),
|
||||
(_("Additional"), {"classes": ("collapse",), "fields": ("slug",)}),
|
||||
)
|
||||
inlines = [FormElementEntryInlineAdmin, FormHandlerEntryInlineAdmin]
|
||||
|
||||
class Meta(object):
|
||||
"""Meta."""
|
||||
|
||||
app_label = _('Fobi')
|
||||
app_label = _("Fobi")
|
||||
|
||||
|
||||
admin.site.register(FormEntry, FormEntryAdmin)
|
||||
|
|
@ -227,7 +239,10 @@ class FormWizardFormEntryInlineAdmin(admin.TabularInline):
|
|||
|
||||
model = FormWizardFormEntry
|
||||
# form = FormElementEntryForm
|
||||
fields = ('form_entry', 'position',)
|
||||
fields = (
|
||||
"form_entry",
|
||||
"position",
|
||||
)
|
||||
extra = 0
|
||||
|
||||
|
||||
|
|
@ -236,47 +251,72 @@ class FormWizardHandlerEntryInlineAdmin(admin.TabularInline):
|
|||
|
||||
model = FormWizardHandlerEntry
|
||||
form = FormWizardHandlerEntryForm
|
||||
fields = ('plugin_uid', 'plugin_data',)
|
||||
fields = (
|
||||
"plugin_uid",
|
||||
"plugin_data",
|
||||
)
|
||||
extra = 0
|
||||
|
||||
|
||||
class FormWizardEntryAdmin(admin.ModelAdmin):
|
||||
"""FormWizardEntry admin."""
|
||||
|
||||
list_display = ('name', 'slug', 'user', 'is_public', 'created', 'updated',
|
||||
'is_cloneable',)
|
||||
list_editable = ('is_public', 'is_cloneable',)
|
||||
list_filter = ('is_public', 'is_cloneable',)
|
||||
readonly_fields = ('slug',)
|
||||
list_display = (
|
||||
"name",
|
||||
"slug",
|
||||
"user",
|
||||
"is_public",
|
||||
"created",
|
||||
"updated",
|
||||
"is_cloneable",
|
||||
)
|
||||
list_editable = (
|
||||
"is_public",
|
||||
"is_cloneable",
|
||||
)
|
||||
list_filter = (
|
||||
"is_public",
|
||||
"is_cloneable",
|
||||
)
|
||||
readonly_fields = ("slug",)
|
||||
radio_fields = {"user": admin.VERTICAL}
|
||||
fieldsets = (
|
||||
(_("Form"), {
|
||||
'fields': ('name', 'is_public', 'is_cloneable',)
|
||||
}),
|
||||
(_("Custom"), {
|
||||
'classes': ('collapse',),
|
||||
'fields': ('success_page_title', 'success_page_message',)
|
||||
}),
|
||||
(
|
||||
_("Form"),
|
||||
{
|
||||
"fields": (
|
||||
"name",
|
||||
"is_public",
|
||||
"is_cloneable",
|
||||
)
|
||||
},
|
||||
),
|
||||
(
|
||||
_("Custom"),
|
||||
{
|
||||
"classes": ("collapse",),
|
||||
"fields": (
|
||||
"success_page_title",
|
||||
"success_page_message",
|
||||
),
|
||||
},
|
||||
),
|
||||
# (_("Wizard"), {
|
||||
# 'classes': ('collapse',),
|
||||
# 'fields': ('form_wizard_entry', 'position',)
|
||||
# }),
|
||||
(_("User"), {
|
||||
'classes': ('collapse',),
|
||||
'fields': ('user',)
|
||||
}),
|
||||
(_('Additional'), {
|
||||
'classes': ('collapse',),
|
||||
'fields': ('slug',)
|
||||
}),
|
||||
(_("User"), {"classes": ("collapse",), "fields": ("user",)}),
|
||||
(_("Additional"), {"classes": ("collapse",), "fields": ("slug",)}),
|
||||
)
|
||||
inlines = [FormWizardFormEntryInlineAdmin,
|
||||
FormWizardHandlerEntryInlineAdmin]
|
||||
inlines = [
|
||||
FormWizardFormEntryInlineAdmin,
|
||||
FormWizardHandlerEntryInlineAdmin,
|
||||
]
|
||||
|
||||
class Meta(object):
|
||||
"""Meta."""
|
||||
|
||||
app_label = _('Fobi')
|
||||
app_label = _("Fobi")
|
||||
|
||||
|
||||
admin.site.register(FormWizardEntry, FormWizardEntryAdmin)
|
||||
|
|
@ -289,20 +329,16 @@ admin.site.register(FormWizardEntry, FormWizardEntryAdmin)
|
|||
class FormFieldsetEntryAdmin(admin.ModelAdmin):
|
||||
"""FormEieldsetEntry admin."""
|
||||
|
||||
list_display = ('form_entry', 'name', 'is_repeatable')
|
||||
list_editable = ('is_repeatable',)
|
||||
list_filter = ('is_repeatable',)
|
||||
list_display = ("form_entry", "name", "is_repeatable")
|
||||
list_editable = ("is_repeatable",)
|
||||
list_filter = ("is_repeatable",)
|
||||
# readonly_fields = ('slug',)
|
||||
fieldsets = (
|
||||
(None, {
|
||||
'fields': ('form_entry', 'name', 'is_repeatable')
|
||||
}),
|
||||
)
|
||||
fieldsets = ((None, {"fields": ("form_entry", "name", "is_repeatable")}),)
|
||||
|
||||
class Meta(object):
|
||||
"""Meta."""
|
||||
|
||||
app_label = _('Fobi')
|
||||
app_label = _("Fobi")
|
||||
|
||||
|
||||
# admin.site.register(FormFieldsetEntry, FormFieldsetEntryAdmin)
|
||||
|
|
@ -311,33 +347,52 @@ class FormFieldsetEntryAdmin(admin.ModelAdmin):
|
|||
# ************************** Form element entry admin *************************
|
||||
# *****************************************************************************
|
||||
|
||||
|
||||
class FormElementEntryAdmin(admin.ModelAdmin):
|
||||
"""FormElementEntry admin."""
|
||||
|
||||
list_display = ('plugin_uid', 'plugin_uid_code', 'plugin_data', 'position',
|
||||
'form_entry',)
|
||||
list_filter = ('form_entry', 'plugin_uid')
|
||||
list_editable = ('position',)
|
||||
readonly_fields = ('plugin_uid_code',)
|
||||
list_display = (
|
||||
"plugin_uid",
|
||||
"plugin_uid_code",
|
||||
"plugin_data",
|
||||
"position",
|
||||
"form_entry",
|
||||
)
|
||||
list_filter = ("form_entry", "plugin_uid")
|
||||
list_editable = ("position",)
|
||||
readonly_fields = ("plugin_uid_code",)
|
||||
fieldsets = (
|
||||
(_("Plugin"), {
|
||||
'fields': ('plugin_uid', 'plugin_data',)
|
||||
}),
|
||||
(_("Form"), {
|
||||
'fields': ('form_entry', 'form_fieldset_entry', 'position',)
|
||||
}),
|
||||
(
|
||||
_("Plugin"),
|
||||
{
|
||||
"fields": (
|
||||
"plugin_uid",
|
||||
"plugin_data",
|
||||
)
|
||||
},
|
||||
),
|
||||
(
|
||||
_("Form"),
|
||||
{
|
||||
"fields": (
|
||||
"form_entry",
|
||||
"form_fieldset_entry",
|
||||
"position",
|
||||
)
|
||||
},
|
||||
),
|
||||
)
|
||||
|
||||
class Meta(object):
|
||||
"""Meta."""
|
||||
|
||||
app_label = _('Fobi')
|
||||
app_label = _("Fobi")
|
||||
|
||||
def get_queryset(self, request):
|
||||
"""Get queryset."""
|
||||
qs = super(FormElementEntryAdmin, self).get_queryset(request)
|
||||
|
||||
qs = qs.select_related('form_entry', 'form_fieldset_entry')
|
||||
qs = qs.select_related("form_entry", "form_fieldset_entry")
|
||||
return qs
|
||||
|
||||
|
||||
|
|
@ -348,32 +403,43 @@ class FormElementEntryAdmin(admin.ModelAdmin):
|
|||
# ************************** Form element entry admin *************************
|
||||
# *****************************************************************************
|
||||
|
||||
|
||||
class FormHandlerEntryAdmin(admin.ModelAdmin):
|
||||
"""FormHandlerEntry admin."""
|
||||
|
||||
list_display = ('plugin_uid', 'plugin_uid_code', 'plugin_data',
|
||||
'form_entry',)
|
||||
list_filter = ('form_entry', 'plugin_uid')
|
||||
readonly_fields = ('plugin_uid_code',)
|
||||
list_display = (
|
||||
"plugin_uid",
|
||||
"plugin_uid_code",
|
||||
"plugin_data",
|
||||
"form_entry",
|
||||
)
|
||||
list_filter = ("form_entry", "plugin_uid")
|
||||
readonly_fields = ("plugin_uid_code",)
|
||||
fieldsets = (
|
||||
(_("Plugin"), {
|
||||
'fields': ('plugin_uid', 'plugin_data',)
|
||||
}),
|
||||
(_("Form"), {
|
||||
'fields': ('form_entry',)
|
||||
}),
|
||||
(
|
||||
_("Plugin"),
|
||||
{
|
||||
"fields": (
|
||||
"plugin_uid",
|
||||
"plugin_data",
|
||||
)
|
||||
},
|
||||
),
|
||||
(_("Form"), {"fields": ("form_entry",)}),
|
||||
)
|
||||
|
||||
class Meta(object):
|
||||
"""Meta."""
|
||||
|
||||
app_label = _('Form handler entry')
|
||||
app_label = _("Form handler entry")
|
||||
|
||||
def get_queryset(self, request):
|
||||
"""Tweak the queryset."""
|
||||
qs = super(FormHandlerEntryAdmin, self).get_queryset(request)
|
||||
|
||||
qs = qs.select_related('form_entry',)
|
||||
qs = qs.select_related(
|
||||
"form_entry",
|
||||
)
|
||||
return qs
|
||||
|
||||
|
||||
|
|
@ -393,19 +459,18 @@ class FormHandlerEntryAdmin(admin.ModelAdmin):
|
|||
class BasePluginModelAdmin(admin.ModelAdmin):
|
||||
"""Base plugin admin."""
|
||||
|
||||
list_display = ('plugin_uid_admin', 'users_list', 'groups_list')
|
||||
readonly_fields = ('plugin_uid', 'plugin_uid_admin')
|
||||
fieldsets = (
|
||||
(None, {
|
||||
'fields': ('plugin_uid', 'users', 'groups')
|
||||
}),
|
||||
list_display = ("plugin_uid_admin", "users_list", "groups_list")
|
||||
readonly_fields = ("plugin_uid", "plugin_uid_admin")
|
||||
fieldsets = ((None, {"fields": ("plugin_uid", "users", "groups")}),)
|
||||
filter_horizontal = (
|
||||
"users",
|
||||
"groups",
|
||||
)
|
||||
filter_horizontal = ('users', 'groups',)
|
||||
|
||||
class Meta(object):
|
||||
"""Meta."""
|
||||
|
||||
app_label = _('Fobi')
|
||||
app_label = _("Fobi")
|
||||
|
||||
def has_add_permission(self, request):
|
||||
"""Has add permissions.
|
||||
|
|
@ -420,7 +485,7 @@ class BasePluginModelAdmin(admin.ModelAdmin):
|
|||
"""Tweak queryset."""
|
||||
qs = super(BasePluginModelAdmin, self).get_queryset(request)
|
||||
|
||||
qs = qs.prefetch_related('users', 'groups')
|
||||
qs = qs.prefetch_related("users", "groups")
|
||||
return qs
|
||||
|
||||
def _get_bulk_change_form_class(self):
|
||||
|
|
@ -446,19 +511,16 @@ class BasePluginModelAdmin(admin.ModelAdmin):
|
|||
This is where the data is actually processed.
|
||||
"""
|
||||
changelist_named_url = self._get_changelist_named_url()
|
||||
if request.method == 'POST':
|
||||
if request.method == "POST":
|
||||
form_cls = self._get_bulk_change_form_class()
|
||||
form = form_cls(
|
||||
data=request.POST,
|
||||
files=request.FILES
|
||||
)
|
||||
form = form_cls(data=request.POST, files=request.FILES)
|
||||
|
||||
if form.is_valid():
|
||||
ids = form.cleaned_data.pop('selected_plugins').split(',')
|
||||
users = form.cleaned_data.pop('users')
|
||||
groups = form.cleaned_data.pop('groups')
|
||||
users_action = form.cleaned_data.pop('users_action')
|
||||
groups_action = form.cleaned_data.pop('groups_action')
|
||||
ids = form.cleaned_data.pop("selected_plugins").split(",")
|
||||
users = form.cleaned_data.pop("users")
|
||||
groups = form.cleaned_data.pop("groups")
|
||||
users_action = form.cleaned_data.pop("users_action")
|
||||
groups_action = form.cleaned_data.pop("groups_action")
|
||||
cleaned_data = dict(
|
||||
(key, val)
|
||||
for (key, val) in form.cleaned_data.items()
|
||||
|
|
@ -489,24 +551,24 @@ class BasePluginModelAdmin(admin.ModelAdmin):
|
|||
|
||||
messages.info(
|
||||
request,
|
||||
_('{0} plugins were changed '
|
||||
'successfully.').format(len(ids))
|
||||
_("{0} plugins were changed " "successfully.").format(
|
||||
len(ids)
|
||||
),
|
||||
)
|
||||
return redirect(changelist_named_url)
|
||||
else:
|
||||
messages.warning(
|
||||
request,
|
||||
_('Form contains '
|
||||
'errors: {}').format(strip_tags(form.errors))
|
||||
_("Form contains " "errors: {}").format(
|
||||
strip_tags(form.errors)
|
||||
),
|
||||
)
|
||||
return redirect(changelist_named_url)
|
||||
else:
|
||||
messages.warning(
|
||||
request,
|
||||
_('POST required when changing in bulk!')
|
||||
)
|
||||
messages.warning(request, _("POST required when changing in bulk!"))
|
||||
return redirect(changelist_named_url)
|
||||
|
||||
|
||||
# *****************************************************************************
|
||||
# ********************************** Form element *****************************
|
||||
# *****************************************************************************
|
||||
|
|
@ -527,15 +589,17 @@ class FormElementAdmin(BasePluginModelAdmin):
|
|||
|
||||
def _get_changelist_named_url(self):
|
||||
"""Get changelist named URL."""
|
||||
return 'admin:fobi_formelement_changelist'
|
||||
return "admin:fobi_formelement_changelist"
|
||||
|
||||
def get_urls(self):
|
||||
"""Get URLs."""
|
||||
my_urls = [
|
||||
# Bulk change plugins
|
||||
url(r'^bulk-change-form-element-plugins/$',
|
||||
url(
|
||||
r"^bulk-change-form-element-plugins/$",
|
||||
self.bulk_change_plugins,
|
||||
name='bulk_change_form_element_plugins'),
|
||||
name="bulk_change_form_element_plugins",
|
||||
),
|
||||
]
|
||||
return my_urls + super(FormElementAdmin, self).get_urls()
|
||||
|
||||
|
|
@ -562,15 +626,17 @@ class FormHandlerAdmin(BasePluginModelAdmin):
|
|||
|
||||
def _get_changelist_named_url(self):
|
||||
"""Get changelist named URL."""
|
||||
return 'admin:fobi_formhandler_changelist'
|
||||
return "admin:fobi_formhandler_changelist"
|
||||
|
||||
def get_urls(self):
|
||||
"""Get URLs."""
|
||||
my_urls = [
|
||||
# Bulk change plugins
|
||||
url(r'^bulk-change-form-handler-plugins/$',
|
||||
url(
|
||||
r"^bulk-change-form-handler-plugins/$",
|
||||
self.bulk_change_plugins,
|
||||
name='bulk_change_form_handler_plugins'),
|
||||
name="bulk_change_form_handler_plugins",
|
||||
),
|
||||
]
|
||||
return my_urls + super(FormHandlerAdmin, self).get_urls()
|
||||
|
||||
|
|
@ -585,7 +651,9 @@ admin.site.register(FormHandler, FormHandlerAdmin)
|
|||
class FormWizardHandlerAdmin(BasePluginModelAdmin):
|
||||
"""FormHandler admin."""
|
||||
|
||||
actions = [bulk_change_form_wizard_handler_plugins] + BasePluginModelAdmin.actions
|
||||
actions = [
|
||||
bulk_change_form_wizard_handler_plugins
|
||||
] + BasePluginModelAdmin.actions
|
||||
|
||||
def _get_bulk_change_form_class(self):
|
||||
"""Get bulk change form class."""
|
||||
|
|
@ -597,15 +665,17 @@ class FormWizardHandlerAdmin(BasePluginModelAdmin):
|
|||
|
||||
def _get_changelist_named_url(self):
|
||||
"""Get changelist named URL."""
|
||||
return 'admin:fobi_formwizardhandler_changelist'
|
||||
return "admin:fobi_formwizardhandler_changelist"
|
||||
|
||||
def get_urls(self):
|
||||
"""Get URLs."""
|
||||
my_urls = [
|
||||
# Bulk change plugins
|
||||
url(r'^bulk-change-form-wizard-handler-plugins/$',
|
||||
url(
|
||||
r"^bulk-change-form-wizard-handler-plugins/$",
|
||||
self.bulk_change_plugins,
|
||||
name='bulk_change_form_wizard_handler_plugins'),
|
||||
name="bulk_change_form_wizard_handler_plugins",
|
||||
),
|
||||
]
|
||||
return my_urls + super(FormWizardHandlerAdmin, self).get_urls()
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,11 @@
|
|||
__title__ = 'fobi.app'
|
||||
__author__ = 'Artur Barseghyan <artur.barseghyan@gmail.com>'
|
||||
__copyright__ = '2014-2019 Artur Barseghyan'
|
||||
__license__ = 'GPL 2.0/LGPL 2.1'
|
||||
__all__ = ('app_name', 'app_config',)
|
||||
__title__ = "fobi.app"
|
||||
__author__ = "Artur Barseghyan <artur.barseghyan@gmail.com>"
|
||||
__copyright__ = "2014-2019 Artur Barseghyan"
|
||||
__license__ = "GPL 2.0/LGPL 2.1"
|
||||
__all__ = (
|
||||
"app_name",
|
||||
"app_config",
|
||||
)
|
||||
|
||||
|
||||
def app_name(path, reduce_depth_by=1):
|
||||
|
|
@ -12,10 +15,10 @@ def app_name(path, reduce_depth_by=1):
|
|||
:param int reduce_depth_by:
|
||||
:return str:
|
||||
"""
|
||||
return '.'.join(path.split('.')[:-reduce_depth_by])
|
||||
return ".".join(path.split(".")[:-reduce_depth_by])
|
||||
|
||||
|
||||
def app_config(path, config_app_path='apps.Config'):
|
||||
def app_config(path, config_app_path="apps.Config"):
|
||||
"""App config.
|
||||
|
||||
:param str path: Absolute app path (from project root).
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
__title__ = 'fobi.apps'
|
||||
__author__ = 'Artur Barseghyan <artur.barseghyan@gmail.com>'
|
||||
__copyright__ = '2014-2019 Artur Barseghyan'
|
||||
__license__ = 'GPL 2.0/LGPL 2.1'
|
||||
__all__ = ('Config',)
|
||||
__title__ = "fobi.apps"
|
||||
__author__ = "Artur Barseghyan <artur.barseghyan@gmail.com>"
|
||||
__copyright__ = "2014-2019 Artur Barseghyan"
|
||||
__license__ = "GPL 2.0/LGPL 2.1"
|
||||
__all__ = ("Config",)
|
||||
|
||||
try:
|
||||
from django.apps import AppConfig
|
||||
|
|
@ -10,7 +10,7 @@ try:
|
|||
class Config(AppConfig):
|
||||
"""Config."""
|
||||
|
||||
name = label = 'fobi'
|
||||
name = label = "fobi"
|
||||
|
||||
except ImportError:
|
||||
pass
|
||||
|
|
|
|||
1013
src/fobi/base.py
1013
src/fobi/base.py
File diff suppressed because it is too large
Load diff
|
|
@ -2,10 +2,10 @@ from django.conf import settings
|
|||
|
||||
from . import defaults
|
||||
|
||||
__author__ = 'Artur Barseghyan <artur.barseghyan@gmail.com>'
|
||||
__copyright__ = '2014-2019 Artur Barseghyan'
|
||||
__license__ = 'GPL 2.0/LGPL 2.1'
|
||||
__all__ = ('get_setting',)
|
||||
__author__ = "Artur Barseghyan <artur.barseghyan@gmail.com>"
|
||||
__copyright__ = "2014-2019 Artur Barseghyan"
|
||||
__license__ = "GPL 2.0/LGPL 2.1"
|
||||
__all__ = ("get_setting",)
|
||||
|
||||
|
||||
def get_setting(setting, override=None):
|
||||
|
|
@ -20,7 +20,7 @@ def get_setting(setting, override=None):
|
|||
None.
|
||||
:return: Setting value.
|
||||
"""
|
||||
attr_name = 'FOBI_{0}'.format(setting)
|
||||
attr_name = "FOBI_{0}".format(setting)
|
||||
if hasattr(settings, attr_name):
|
||||
return getattr(settings, attr_name)
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -1,41 +1,42 @@
|
|||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
__title__ = 'fobi.constants'
|
||||
__author__ = 'Artur Barseghyan <artur.barseghyan@gmail.com>'
|
||||
__copyright__ = '2014-2019 Artur Barseghyan'
|
||||
__license__ = 'GPL 2.0/LGPL 2.1'
|
||||
__title__ = "fobi.constants"
|
||||
__author__ = "Artur Barseghyan <artur.barseghyan@gmail.com>"
|
||||
__copyright__ = "2014-2019 Artur Barseghyan"
|
||||
__license__ = "GPL 2.0/LGPL 2.1"
|
||||
__all__ = (
|
||||
'ACTION_CHOICE_REPLACE',
|
||||
'ACTION_CHOICE_APPEND',
|
||||
'ACTION_CHOICES',
|
||||
'CALLBACK_BEFORE_FORM_VALIDATION',
|
||||
'CALLBACK_FORM_VALID_BEFORE_SUBMIT_PLUGIN_FORM_DATA',
|
||||
'CALLBACK_FORM_VALID',
|
||||
'CALLBACK_FORM_VALID_AFTER_FORM_HANDLERS',
|
||||
'CALLBACK_FORM_INVALID',
|
||||
'CALLBACK_STAGES',
|
||||
'SUBMIT_VALUE_AS_VAL',
|
||||
'SUBMIT_VALUE_AS_REPR',
|
||||
'SUBMIT_VALUE_AS_MIX',
|
||||
'WIZARD_TYPE_SESSION',
|
||||
'WIZARD_TYPE_COOKIE',
|
||||
'WIZARD_TYPES',
|
||||
'DEFAULT_WIZARD_TYPE',
|
||||
"ACTION_CHOICE_REPLACE",
|
||||
"ACTION_CHOICE_APPEND",
|
||||
"ACTION_CHOICES",
|
||||
"CALLBACK_BEFORE_FORM_VALIDATION",
|
||||
"CALLBACK_FORM_VALID_BEFORE_SUBMIT_PLUGIN_FORM_DATA",
|
||||
"CALLBACK_FORM_VALID",
|
||||
"CALLBACK_FORM_VALID_AFTER_FORM_HANDLERS",
|
||||
"CALLBACK_FORM_INVALID",
|
||||
"CALLBACK_STAGES",
|
||||
"SUBMIT_VALUE_AS_VAL",
|
||||
"SUBMIT_VALUE_AS_REPR",
|
||||
"SUBMIT_VALUE_AS_MIX",
|
||||
"WIZARD_TYPE_SESSION",
|
||||
"WIZARD_TYPE_COOKIE",
|
||||
"WIZARD_TYPES",
|
||||
"DEFAULT_WIZARD_TYPE",
|
||||
)
|
||||
|
||||
ACTION_CHOICE_REPLACE = '1'
|
||||
ACTION_CHOICE_APPEND = '2'
|
||||
ACTION_CHOICE_REPLACE = "1"
|
||||
ACTION_CHOICE_APPEND = "2"
|
||||
ACTION_CHOICES = (
|
||||
(ACTION_CHOICE_APPEND, _("Append")),
|
||||
(ACTION_CHOICE_REPLACE, _("Replace")),
|
||||
)
|
||||
|
||||
CALLBACK_BEFORE_FORM_VALIDATION = 'before_form_validation'
|
||||
CALLBACK_FORM_VALID_BEFORE_SUBMIT_PLUGIN_FORM_DATA = \
|
||||
'before_submit_plugin_form_data'
|
||||
CALLBACK_FORM_VALID = 'form_valid'
|
||||
CALLBACK_FORM_VALID_AFTER_FORM_HANDLERS = 'after_form_handlers'
|
||||
CALLBACK_FORM_INVALID = 'form_invalid'
|
||||
CALLBACK_BEFORE_FORM_VALIDATION = "before_form_validation"
|
||||
CALLBACK_FORM_VALID_BEFORE_SUBMIT_PLUGIN_FORM_DATA = (
|
||||
"before_submit_plugin_form_data"
|
||||
)
|
||||
CALLBACK_FORM_VALID = "form_valid"
|
||||
CALLBACK_FORM_VALID_AFTER_FORM_HANDLERS = "after_form_handlers"
|
||||
CALLBACK_FORM_INVALID = "form_invalid"
|
||||
|
||||
CALLBACK_STAGES = (
|
||||
CALLBACK_BEFORE_FORM_VALIDATION,
|
||||
|
|
@ -44,12 +45,12 @@ CALLBACK_STAGES = (
|
|||
CALLBACK_FORM_VALID_AFTER_FORM_HANDLERS,
|
||||
)
|
||||
|
||||
SUBMIT_VALUE_AS_VAL = 'val'
|
||||
SUBMIT_VALUE_AS_REPR = 'repr'
|
||||
SUBMIT_VALUE_AS_MIX = 'mix'
|
||||
SUBMIT_VALUE_AS_VAL = "val"
|
||||
SUBMIT_VALUE_AS_REPR = "repr"
|
||||
SUBMIT_VALUE_AS_MIX = "mix"
|
||||
|
||||
WIZARD_TYPE_SESSION = 'SessionWizardView'
|
||||
WIZARD_TYPE_COOKIE = 'CookieWizardView'
|
||||
WIZARD_TYPE_SESSION = "SessionWizardView"
|
||||
WIZARD_TYPE_COOKIE = "CookieWizardView"
|
||||
DEFAULT_WIZARD_TYPE = WIZARD_TYPE_SESSION
|
||||
WIZARD_TYPES = (
|
||||
(WIZARD_TYPE_SESSION, "Session wizard"),
|
||||
|
|
|
|||
|
|
@ -4,14 +4,14 @@ from .base import get_theme
|
|||
from .form_importers import get_form_importer_plugin_urls
|
||||
from .helpers import StrippedRequest
|
||||
|
||||
__title__ = 'fobi.context_processors'
|
||||
__author__ = 'Artur Barseghyan <artur.barseghyan@gmail.com>'
|
||||
__copyright__ = '2014-2019 Artur Barseghyan'
|
||||
__license__ = 'GPL 2.0/LGPL 2.1'
|
||||
__title__ = "fobi.context_processors"
|
||||
__author__ = "Artur Barseghyan <artur.barseghyan@gmail.com>"
|
||||
__copyright__ = "2014-2019 Artur Barseghyan"
|
||||
__license__ = "GPL 2.0/LGPL 2.1"
|
||||
__all__ = (
|
||||
'dynamic_values',
|
||||
'form_importers',
|
||||
'theme',
|
||||
"dynamic_values",
|
||||
"form_importers",
|
||||
"theme",
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -21,16 +21,16 @@ def theme(request):
|
|||
:param django.http.HttpRequest request:
|
||||
:return fobi.base.BaseTheme: Instance of ``fobi.base.BaseTheme``.
|
||||
"""
|
||||
return {'fobi_theme': get_theme(request, as_instance=True)}
|
||||
return {"fobi_theme": get_theme(request, as_instance=True)}
|
||||
|
||||
|
||||
def dynamic_values(request):
|
||||
"""Dynamic values exposed to public forms."""
|
||||
return {
|
||||
'fobi_dynamic_values': {
|
||||
'request': StrippedRequest(request),
|
||||
'now': datetime.datetime.now(),
|
||||
'today': datetime.date.today(),
|
||||
"fobi_dynamic_values": {
|
||||
"request": StrippedRequest(request),
|
||||
"now": datetime.datetime.now(),
|
||||
"today": datetime.date.today(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -38,5 +38,5 @@ def dynamic_values(request):
|
|||
def form_importers(request):
|
||||
"""Form importers."""
|
||||
return {
|
||||
'form_importers': get_form_importer_plugin_urls(),
|
||||
"form_importers": get_form_importer_plugin_urls(),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
__title__ = 'fobi.contrib.apps.djangocms_integration'
|
||||
__author__ = 'Artur Barseghyan <artur.barseghyan@gmail.com>'
|
||||
__copyright__ = '2014-2019 Artur Barseghyan'
|
||||
__license__ = 'GPL 2.0/LGPL 2.1'
|
||||
__all__ = ('default_app_config',)
|
||||
__title__ = "fobi.contrib.apps.djangocms_integration"
|
||||
__author__ = "Artur Barseghyan <artur.barseghyan@gmail.com>"
|
||||
__copyright__ = "2014-2019 Artur Barseghyan"
|
||||
__license__ = "GPL 2.0/LGPL 2.1"
|
||||
__all__ = ("default_app_config",)
|
||||
|
||||
default_app_config = 'fobi.contrib.apps.djangocms_integration.apps.Config'
|
||||
default_app_config = "fobi.contrib.apps.djangocms_integration.apps.Config"
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
from django.apps import AppConfig
|
||||
|
||||
__title__ = 'fobi.contrib.apps.djangocms_integration.apps'
|
||||
__author__ = 'Artur Barseghyan <artur.barseghyan@gmail.com>'
|
||||
__copyright__ = '2014-2019 Artur Barseghyan'
|
||||
__license__ = 'GPL 2.0/LGPL 2.1'
|
||||
__all__ = ('Config',)
|
||||
__title__ = "fobi.contrib.apps.djangocms_integration.apps"
|
||||
__author__ = "Artur Barseghyan <artur.barseghyan@gmail.com>"
|
||||
__copyright__ = "2014-2019 Artur Barseghyan"
|
||||
__license__ = "GPL 2.0/LGPL 2.1"
|
||||
__all__ = ("Config",)
|
||||
|
||||
|
||||
class Config(AppConfig):
|
||||
"""Config."""
|
||||
|
||||
name = 'fobi.contrib.apps.djangocms_integration'
|
||||
label = 'fobi_contrib_apps_djangocms_integration'
|
||||
name = "fobi.contrib.apps.djangocms_integration"
|
||||
label = "fobi_contrib_apps_djangocms_integration"
|
||||
|
|
|
|||
|
|
@ -1,18 +1,17 @@
|
|||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from cms.plugin_base import CMSPluginBase
|
||||
from cms.plugin_pool import plugin_pool
|
||||
|
||||
from fobi.integration.processors import IntegrationProcessor
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from .models import FobiFormWidget
|
||||
from .settings import WIDGET_FORM_SENT_GET_PARAM
|
||||
|
||||
__title__ = 'fobi.contrib.apps.djangocms_integration.cms_plugins'
|
||||
__author__ = 'Artur Barseghyan <artur.barseghyan@gmail.com>'
|
||||
__copyright__ = '2014-2019 Artur Barseghyan'
|
||||
__license__ = 'GPL 2.0/LGPL 2.1'
|
||||
__all__ = ('FobiFormWidgetPlugin',)
|
||||
from fobi.integration.processors import IntegrationProcessor
|
||||
|
||||
__title__ = "fobi.contrib.apps.djangocms_integration.cms_plugins"
|
||||
__author__ = "Artur Barseghyan <artur.barseghyan@gmail.com>"
|
||||
__copyright__ = "2014-2019 Artur Barseghyan"
|
||||
__license__ = "GPL 2.0/LGPL 2.1"
|
||||
__all__ = ("FobiFormWidgetPlugin",)
|
||||
|
||||
|
||||
class FobiFormWidgetPlugin(CMSPluginBase, IntegrationProcessor):
|
||||
|
|
@ -27,7 +26,7 @@ class FobiFormWidgetPlugin(CMSPluginBase, IntegrationProcessor):
|
|||
# Fobi integration processor configuration
|
||||
form_sent_get_param = WIDGET_FORM_SENT_GET_PARAM
|
||||
can_redirect = False
|
||||
login_required_template_name = 'djangocms_integration/login_required.html'
|
||||
login_required_template_name = "djangocms_integration/login_required.html"
|
||||
|
||||
def process(self, request, instance, **kwargs):
|
||||
"""This is where most of the form handling happens.
|
||||
|
|
@ -39,14 +38,16 @@ class FobiFormWidgetPlugin(CMSPluginBase, IntegrationProcessor):
|
|||
|
||||
def render(self, context, instance, placeholder):
|
||||
"""Render."""
|
||||
self.process(context['request'], instance)
|
||||
rendered_context = getattr(self, 'rendered_output', '')
|
||||
context.update({
|
||||
'object': instance,
|
||||
'instance': instance,
|
||||
'placeholder': placeholder,
|
||||
'rendered_context': rendered_context
|
||||
})
|
||||
self.process(context["request"], instance)
|
||||
rendered_context = getattr(self, "rendered_output", "")
|
||||
context.update(
|
||||
{
|
||||
"object": instance,
|
||||
"instance": instance,
|
||||
"placeholder": placeholder,
|
||||
"rendered_context": rendered_context,
|
||||
}
|
||||
)
|
||||
return context
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,17 +1,18 @@
|
|||
from cms import __version__
|
||||
|
||||
__title__ = 'fobi.contrib.apps.djangocms_integration.cms_version'
|
||||
__author__ = 'Artur Barseghyan <artur.barseghyan@gmail.com>'
|
||||
__copyright__ = '2014-2019 Artur Barseghyan'
|
||||
__license__ = 'GPL 2.0/LGPL 2.1'
|
||||
__title__ = "fobi.contrib.apps.djangocms_integration.cms_version"
|
||||
__author__ = "Artur Barseghyan <artur.barseghyan@gmail.com>"
|
||||
__copyright__ = "2014-2019 Artur Barseghyan"
|
||||
__license__ = "GPL 2.0/LGPL 2.1"
|
||||
__all__ = (
|
||||
'CMS_VERSION',
|
||||
'CMS_VERSION_LTE_3_0',
|
||||
'CMS_VERSION_GT_3_0',
|
||||
"CMS_VERSION",
|
||||
"CMS_VERSION_LTE_3_0",
|
||||
"CMS_VERSION_GT_3_0",
|
||||
)
|
||||
|
||||
CMS_VERSION = [int(__v) for __v in __version__.split('.')]
|
||||
CMS_VERSION = [int(__v) for __v in __version__.split(".")]
|
||||
|
||||
CMS_VERSION_LTE_3_0 = CMS_VERSION[0] <= 2 \
|
||||
or (CMS_VERSION[0] == 3 and CMS_VERSION[1] == 0)
|
||||
CMS_VERSION_LTE_3_0 = CMS_VERSION[0] <= 2 or (
|
||||
CMS_VERSION[0] == 3 and CMS_VERSION[1] == 0
|
||||
)
|
||||
CMS_VERSION_GT_3_0 = not CMS_VERSION_LTE_3_0
|
||||
|
|
|
|||
|
|
@ -2,11 +2,11 @@ from django.conf import settings
|
|||
|
||||
from . import defaults
|
||||
|
||||
__title__ = 'fobi.contrib.apps.djangocms_integration.conf'
|
||||
__author__ = 'Artur Barseghyan <artur.barseghyan@gmail.com>'
|
||||
__copyright__ = '2014-2019 Artur Barseghyan'
|
||||
__license__ = 'GPL 2.0/LGPL 2.1'
|
||||
__all__ = ('get_setting',)
|
||||
__title__ = "fobi.contrib.apps.djangocms_integration.conf"
|
||||
__author__ = "Artur Barseghyan <artur.barseghyan@gmail.com>"
|
||||
__copyright__ = "2014-2019 Artur Barseghyan"
|
||||
__license__ = "GPL 2.0/LGPL 2.1"
|
||||
__all__ = ("get_setting",)
|
||||
|
||||
|
||||
def get_setting(setting, override=None):
|
||||
|
|
@ -24,10 +24,9 @@ def get_setting(setting, override=None):
|
|||
"""
|
||||
if override is not None:
|
||||
return override
|
||||
if hasattr(settings, 'FOBI_DJANGOCMS_INTEGRATION_{0}'.format(setting)):
|
||||
if hasattr(settings, "FOBI_DJANGOCMS_INTEGRATION_{0}".format(setting)):
|
||||
return getattr(
|
||||
settings,
|
||||
'FOBI_DJANGOCMS_INTEGRATION_{0}'.format(setting)
|
||||
settings, "FOBI_DJANGOCMS_INTEGRATION_{0}".format(setting)
|
||||
)
|
||||
else:
|
||||
return getattr(defaults, setting)
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue