diff --git a/src/fobi/contrib/apps/mezzanine_integration/__init__.py b/src/fobi/contrib/apps/mezzanine_integration/__init__.py index 91d8903d..1f648f63 100644 --- a/src/fobi/contrib/apps/mezzanine_integration/__init__.py +++ b/src/fobi/contrib/apps/mezzanine_integration/__init__.py @@ -1,8 +1,7 @@ __title__ = 'fobi.contrib.apps.mezzanine_integration' __author__ = 'Artur Barseghyan ' -__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' - diff --git a/src/fobi/contrib/apps/mezzanine_integration/admin.py b/src/fobi/contrib/apps/mezzanine_integration/admin.py index 92a37dc6..54919286 100644 --- a/src/fobi/contrib/apps/mezzanine_integration/admin.py +++ b/src/fobi/contrib/apps/mezzanine_integration/admin.py @@ -1,13 +1,13 @@ -__title__ = 'fobi.contrib.apps.mezzanine_integration.admin' -__author__ = 'Artur Barseghyan ' -__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 ' +__copyright__ = '2014-2016 Artur Barseghyan' +__license__ = 'GPL 2.0/LGPL 2.1' + + admin.site.register(FobiFormPage, PageAdmin) diff --git a/src/fobi/contrib/apps/mezzanine_integration/apps.py b/src/fobi/contrib/apps/mezzanine_integration/apps.py index c2859e62..2ecba18e 100644 --- a/src/fobi/contrib/apps/mezzanine_integration/apps.py +++ b/src/fobi/contrib/apps/mezzanine_integration/apps.py @@ -1,6 +1,6 @@ __title__ = 'fobi.contrib.apps.mezzanine_integration.apps' __author__ = 'Artur Barseghyan ' -__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' diff --git a/src/fobi/contrib/apps/mezzanine_integration/conf.py b/src/fobi/contrib/apps/mezzanine_integration/conf.py index 50c5e600..0630ca41 100644 --- a/src/fobi/contrib/apps/mezzanine_integration/conf.py +++ b/src/fobi/contrib/apps/mezzanine_integration/conf.py @@ -1,15 +1,17 @@ +from django.conf import settings + +from . import defaults + __title__ = 'fobi.contrib.apps.mezzanine_integration.conf' __author__ = 'Artur Barseghyan ' __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) diff --git a/src/fobi/contrib/apps/mezzanine_integration/defaults.py b/src/fobi/contrib/apps/mezzanine_integration/defaults.py index f5f4cdb2..382b68da 100644 --- a/src/fobi/contrib/apps/mezzanine_integration/defaults.py +++ b/src/fobi/contrib/apps/mezzanine_integration/defaults.py @@ -1,6 +1,6 @@ __title__ = 'fobi.contrib.apps.mezzanine_integration.defaults' __author__ = 'Artur Barseghyan ' -__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', diff --git a/src/fobi/contrib/apps/mezzanine_integration/helpers.py b/src/fobi/contrib/apps/mezzanine_integration/helpers.py index 19cdeb94..0b38cc2a 100644 --- a/src/fobi/contrib/apps/mezzanine_integration/helpers.py +++ b/src/fobi/contrib/apps/mezzanine_integration/helpers.py @@ -1,17 +1,18 @@ -__title__ = 'fobi.contrib.apps.mezzanine_integration.helpers' -__author__ = 'Artur Barseghyan ' -__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 ' +__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' - ) + ) diff --git a/src/fobi/contrib/apps/mezzanine_integration/models.py b/src/fobi/contrib/apps/mezzanine_integration/models.py index 6173583e..a8ad1212 100644 --- a/src/fobi/contrib/apps/mezzanine_integration/models.py +++ b/src/fobi/contrib/apps/mezzanine_integration/models.py @@ -1,9 +1,3 @@ -__title__ = 'fobi.contrib.apps.mezzanine_integration.models' -__author__ = 'Artur Barseghyan ' -__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 ' +__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') diff --git a/src/fobi/contrib/apps/mezzanine_integration/page_processors.py b/src/fobi/contrib/apps/mezzanine_integration/page_processors.py index 371395c2..5540c0cd 100644 --- a/src/fobi/contrib/apps/mezzanine_integration/page_processors.py +++ b/src/fobi/contrib/apps/mezzanine_integration/page_processors.py @@ -1,23 +1,25 @@ -__title__ = 'fobi.contrib.apps.mezzanine_integration.page_processors' -__author__ = 'Artur Barseghyan ' -__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 ' +__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 diff --git a/src/fobi/contrib/apps/mezzanine_integration/settings.py b/src/fobi/contrib/apps/mezzanine_integration/settings.py index 183445a7..0f487e63 100644 --- a/src/fobi/contrib/apps/mezzanine_integration/settings.py +++ b/src/fobi/contrib/apps/mezzanine_integration/settings.py @@ -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 ' -__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 *****************************