mezzanine_integration pep8

This commit is contained in:
Artur Barseghyan 2016-09-20 11:28:05 +02:00
parent 4d83194d7f
commit c5c3a8e789
9 changed files with 75 additions and 63 deletions

View file

@ -1,8 +1,7 @@
__title__ = 'fobi.contrib.apps.mezzanine_integration'
__author__ = 'Artur Barseghyan <artur.barseghyan@gmail.com>'
__copyright__ = 'Copyright (c) 2014 Artur Barseghyan'
__copyright__ = '2014-2016 Artur Barseghyan'
__license__ = 'GPL 2.0/LGPL 2.1'
__all__ = ('default_app_config',)
default_app_config = 'fobi.contrib.apps.mezzanine_integration.apps.Config'

View file

@ -1,13 +1,13 @@
__title__ = 'fobi.contrib.apps.mezzanine_integration.admin'
__author__ = 'Artur Barseghyan <artur.barseghyan@gmail.com>'
__copyright__ = 'Copyright (c) 2014 Artur Barseghyan'
__license__ = 'GPL 2.0/LGPL 2.1'
#__all__ = ('FobiFormPage',)
from django.contrib import admin
from mezzanine.pages.admin import PageAdmin
from .models import FobiFormPage
__title__ = 'fobi.contrib.apps.mezzanine_integration.admin'
__author__ = 'Artur Barseghyan <artur.barseghyan@gmail.com>'
__copyright__ = '2014-2016 Artur Barseghyan'
__license__ = 'GPL 2.0/LGPL 2.1'
admin.site.register(FobiFormPage, PageAdmin)

View file

@ -1,6 +1,6 @@
__title__ = 'fobi.contrib.apps.mezzanine_integration.apps'
__author__ = 'Artur Barseghyan <artur.barseghyan@gmail.com>'
__copyright__ = 'Copyright (c) 2014-2015 Artur Barseghyan'
__copyright__ = '2014-2016 Artur Barseghyan'
__license__ = 'GPL 2.0/LGPL 2.1'
__all__ = ('Config',)
@ -8,6 +8,8 @@ try:
from django.apps import AppConfig
class Config(AppConfig):
"""Config."""
name = 'fobi.contrib.apps.mezzanine_integration'
label = 'fobi_contrib_apps_mezzanine_integration'

View file

@ -1,15 +1,17 @@
from django.conf import settings
from . import defaults
__title__ = 'fobi.contrib.apps.mezzanine_integration.conf'
__author__ = 'Artur Barseghyan <artur.barseghyan@gmail.com>'
__copyright__ = 'Copyright (c) 2014-2015 Artur Barseghyan'
__license__ = 'GPL 2.0/LGPL 2.1'
__all__ = ('get_setting',)
from django.conf import settings
from . import defaults
def get_setting(setting, override=None):
"""
"""Get setting.
Get a setting from ``fobi.contrib.apps.mezzanine_integration`` conf module,
falling back to the default.
@ -23,6 +25,9 @@ def get_setting(setting, override=None):
if override is not None:
return override
if hasattr(settings, 'FOBI_MEZZANINE_INTEGRATION_{0}'.format(setting)):
return getattr(settings, 'FOBI_MEZZANINE_INTEGRATION_{0}'.format(setting))
return getattr(
settings,
'FOBI_MEZZANINE_INTEGRATION_{0}'.format(setting)
)
else:
return getattr(defaults, setting)

View file

@ -1,6 +1,6 @@
__title__ = 'fobi.contrib.apps.mezzanine_integration.defaults'
__author__ = 'Artur Barseghyan <artur.barseghyan@gmail.com>'
__copyright__ = 'Copyright (c) 2014 Artur Barseghyan'
__copyright__ = '2014-2016 Artur Barseghyan'
__license__ = 'GPL 2.0/LGPL 2.1'
__all__ = (
'WIDGET_FORM_SENT_GET_PARAM', 'FORM_TEMPLATE_CHOICES',

View file

@ -1,17 +1,18 @@
__title__ = 'fobi.contrib.apps.mezzanine_integration.helpers'
__author__ = 'Artur Barseghyan <artur.barseghyan@gmail.com>'
__copyright__ = 'Copyright (c) 2014-2015 Artur Barseghyan'
__license__ = 'GPL 2.0/LGPL 2.1'
__all__ = ('get_form_template_choices', 'get_success_page_template_choices',)
from fobi.integration.helpers import get_template_choices
from .settings import FORM_TEMPLATE_CHOICES, SUCCESS_PAGE_TEMPLATE_CHOICES
__title__ = 'fobi.contrib.apps.mezzanine_integration.helpers'
__author__ = 'Artur Barseghyan <artur.barseghyan@gmail.com>'
__copyright__ = '2014-2016 Artur Barseghyan'
__license__ = 'GPL 2.0/LGPL 2.1'
__all__ = ('get_form_template_choices', 'get_success_page_template_choices',)
def get_form_template_choices():
"""
Gets the form template choices. It's possible to provide theme templates
per theme or just per project.
"""Gets the form template choices.
It's possible to provide theme templates per theme or just per project.
:return list:
"""
@ -19,14 +20,16 @@ def get_form_template_choices():
'mezzanine_integration',
FORM_TEMPLATE_CHOICES,
'form_template_choices'
)
)
def get_success_page_template_choices():
"""
"""Get success page template choices.
:return list:
"""
return get_template_choices(
'mezzanine_integration',
SUCCESS_PAGE_TEMPLATE_CHOICES,
'success_page_template_choices'
)
)

View file

@ -1,9 +1,3 @@
__title__ = 'fobi.contrib.apps.mezzanine_integration.models'
__author__ = 'Artur Barseghyan <artur.barseghyan@gmail.com>'
__copyright__ = 'Copyright (c) 2014-2015 Artur Barseghyan'
__license__ = 'GPL 2.0/LGPL 2.1'
__all__ = ('FobiFormPage',)
from django.db import models
from django.utils.translation import ugettext_lazy as _
@ -12,64 +6,73 @@ from mezzanine.pages.models import Page
from .helpers import (
get_form_template_choices, get_success_page_template_choices
)
)
__title__ = 'fobi.contrib.apps.mezzanine_integration.models'
__author__ = 'Artur Barseghyan <artur.barseghyan@gmail.com>'
__copyright__ = '2014-2016 Artur Barseghyan'
__license__ = 'GPL 2.0/LGPL 2.1'
__all__ = ('FobiFormPage',)
class FobiFormPage(Page, RichText):
"""
Widget for to Mezzanine.
"""Widget for to Mezzanine.
:property fobi.models.FormEntry form_entry: Form entry to be rendered.
:property str template: If given used for rendering the form.
"""
form_entry = models.ForeignKey('fobi.FormEntry', verbose_name=_("Form"))
form_template_name = models.CharField(
_("Form template name"), max_length=255, null=True, blank=True,
choices=get_form_template_choices(),
help_text=_("Template to render the form with.")
)
)
hide_form_title = models.BooleanField(
_("Hide form title"), default=False,
help_text=_("If checked, no form title is shown.")
)
)
form_title = models.CharField(
_("Form title"), max_length=255, null=True, blank=True,
help_text=_("Overrides the default form title.")
)
)
form_submit_button_text = models.CharField(
_("Submit button text"), max_length=255, null=True, blank=True,
help_text=_("Overrides the default form submit button text.")
)
)
success_page_template_name = models.CharField(
_("Success page template name"), max_length=255, null=True, blank=True,
choices=get_success_page_template_choices(),
help_text=_("Template to render the success page with.")
)
)
hide_success_page_title = models.BooleanField(
_("Hide success page title"), default=False,
help_text=_("If checked, no success page title is shown.")
)
)
success_page_title = models.CharField(
_("Succes page title"), max_length=255, null=True, blank=True,
help_text=_("Overrides the default success page title.")
)
)
success_page_text = models.TextField(
_("Succes page text"), null=True, blank=True,
help_text=_("Overrides the default success page text.")
)
)
class Meta:
"""Meta class."""
app_label = 'fobi'
verbose_name = _("Fobi form")
verbose_name_plural = _("Fobi forms")
#db_table = 'fobi_fobiformpage'
# db_table = 'fobi_fobiformpage'
def __unicode__(self):
return _('Fobi form')

View file

@ -1,23 +1,25 @@
__title__ = 'fobi.contrib.apps.mezzanine_integration.page_processors'
__author__ = 'Artur Barseghyan <artur.barseghyan@gmail.com>'
__copyright__ = 'Copyright (c) 2014-2015 Artur Barseghyan'
__license__ = 'GPL 2.0/LGPL 2.1'
__all__ = ('FobiFormProcessor', 'process_fobi_form',)
#from mezzanine.conf import settings
# from mezzanine.conf import settings
from mezzanine.pages.page_processors import processor_for
from fobi.integration.processors import IntegrationProcessor
from .settings import WIDGET_FORM_SENT_GET_PARAM
from .models import FobiFormPage
from .settings import WIDGET_FORM_SENT_GET_PARAM
__title__ = 'fobi.contrib.apps.mezzanine_integration.page_processors'
__author__ = 'Artur Barseghyan <artur.barseghyan@gmail.com>'
__copyright__ = '2014-2016 Artur Barseghyan'
__license__ = 'GPL 2.0/LGPL 2.1'
__all__ = ('FobiFormProcessor', 'process_fobi_form',)
class FobiFormProcessor(IntegrationProcessor):
"""Form processor."""
form_sent_get_param = WIDGET_FORM_SENT_GET_PARAM
def process(self, request, instance, **kwargs):
"""
This is where most of the form handling happens.
"""This is where most of the form handling happens.
:param django.http.HttpRequest request:
:return django.http.HttpResponse | str:
@ -27,13 +29,11 @@ class FobiFormProcessor(IntegrationProcessor):
@processor_for(FobiFormPage)
def process_fobi_form(request, page):
"""
Process the ``FobiFormPage``.
"""
"""Process the ``FobiFormPage``."""
fobi_form_processor = FobiFormProcessor()
response = fobi_form_processor.process(
request, instance=page.get_content_model()
)
)
if response:
return response

View file

@ -1,18 +1,18 @@
"""
- `WIDGET_FORM_SENT_GET_PARAM` (str): Name of the GET param indicating that
- `WIDGET_FORM_SENT_GET_PARAM` (str): Name of the GET param indicating that
form has been successfully sent.
"""
from .conf import get_setting
__title__ = 'fobi.contrib.apps.mezzanine_integration.settings'
__author__ = 'Artur Barseghyan <artur.barseghyan@gmail.com>'
__copyright__ = 'Copyright (c) 2014 Artur Barseghyan'
__copyright__ = '2014-2016 Artur Barseghyan'
__license__ = 'GPL 2.0/LGPL 2.1'
__all__ = (
'WIDGET_FORM_SENT_GET_PARAM', 'FORM_TEMPLATE_CHOICES',
'SUCCESS_PAGE_TEMPLATE_CHOICES',
)
from .conf import get_setting
# **************************************************************
# **************************************************************
# *************************** Core *****************************