mirror of
https://github.com/Hopiu/django-fobi.git
synced 2026-03-16 22:10:28 +00:00
more on django 2.0
This commit is contained in:
parent
c0acaf1d43
commit
b960f8cb01
10 changed files with 77 additions and 21 deletions
|
|
@ -8,6 +8,7 @@ docopt==0.4.0
|
|||
docutils==0.12
|
||||
Jinja2==2.8
|
||||
mailchimp==2.0.9
|
||||
markdown
|
||||
MarkupSafe==0.23
|
||||
#MySQL-python
|
||||
ordereddict==1.1
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ django-ckeditor>=5.4.0
|
|||
django-debug-toolbar>=1.6
|
||||
django-formtools>=2.0
|
||||
django-registration-redux>=1.4
|
||||
django-simple-captcha>=0.5.5
|
||||
django-simple-captcha>=0.5.6
|
||||
djangorestframework==3.7.7
|
||||
easy-thumbnails>=2.4.1
|
||||
sqlparse>=0.2.2
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@ if DJANGO_GTE_1_10:
|
|||
'loaders': [
|
||||
'django.template.loaders.filesystem.Loader',
|
||||
'django.template.loaders.app_directories.Loader',
|
||||
'django.template.loaders.eggs.Loader',
|
||||
# 'django.template.loaders.eggs.Loader',
|
||||
'admin_tools.template_loaders.Loader',
|
||||
],
|
||||
'debug': DEBUG_TEMPLATE,
|
||||
|
|
|
|||
|
|
@ -48,9 +48,18 @@ url_patterns_args = [
|
|||
include('fobi.urls.edit')),
|
||||
|
||||
url(r'^admin_tools/', include('admin_tools.urls')),
|
||||
]
|
||||
|
||||
url(r'^admin/', include(admin.site.urls)),
|
||||
if versions.DJANGO_GTE_2_0:
|
||||
url_patterns_args += [
|
||||
url(r'^admin/', admin.site.urls),
|
||||
]
|
||||
else:
|
||||
url_patterns_args += [
|
||||
url(r'^admin/', include(admin.site.urls)),
|
||||
]
|
||||
|
||||
url_patterns_args += [
|
||||
# django-registration URLs:
|
||||
url(r'^accounts/', include('registration.backends.simple.urls')),
|
||||
|
||||
|
|
@ -120,9 +129,14 @@ if 'cms' in settings.INSTALLED_APPS:
|
|||
# Conditionally including Django REST framework integration app
|
||||
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))
|
||||
]
|
||||
if versions.DJANGO_GTE_2_0:
|
||||
urlpatterns += [
|
||||
url(r'^api/', include(fobi_router.urls))
|
||||
]
|
||||
else:
|
||||
urlpatterns += [
|
||||
url(r'^api/', include(fobi_router.urls))
|
||||
]
|
||||
|
||||
# Conditionally including Captcha URls in case if
|
||||
# Captcha in installed apps.
|
||||
|
|
@ -141,6 +155,12 @@ if getattr(settings, 'ENABLE_CAPTCHA', False):
|
|||
|
||||
if getattr(settings, 'DEBUG', False) and getattr(settings, 'DEBUG_TOOLBAR', False):
|
||||
import debug_toolbar
|
||||
urlpatterns = [
|
||||
url(r'^__debug__/', include(debug_toolbar.urls)),
|
||||
] + urlpatterns
|
||||
|
||||
if versions.DJANGO_GTE_2_0:
|
||||
urlpatterns = [
|
||||
url(r'^__debug__/', debug_toolbar.urls),
|
||||
] + urlpatterns
|
||||
else:
|
||||
urlpatterns = [
|
||||
url(r'^__debug__/', include(debug_toolbar.urls)),
|
||||
] + urlpatterns
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
django-autoslug==1.9.3
|
||||
django-autoslug-iplweb
|
||||
django-formtools>=2.0
|
||||
django-nine>=0.1.13
|
||||
django-nonefield>=0.1
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ from django.contrib import messages
|
|||
from django.http import HttpRequest
|
||||
from django.utils.translation import ugettext
|
||||
|
||||
from nine import versions
|
||||
|
||||
from rest_framework import mixins, permissions
|
||||
from rest_framework.response import Response
|
||||
from rest_framework.viewsets import GenericViewSet
|
||||
|
|
@ -64,8 +66,12 @@ class FobiFormEntryViewSet(
|
|||
We show all forms to authenticated users and show only public forms
|
||||
to non-authenticated users.
|
||||
"""
|
||||
if versions.DJANGO_GTE_1_10:
|
||||
user_is_authenticated = self.request.user.is_authenticated
|
||||
else:
|
||||
user_is_authenticated = self.request.user.is_authenticated()
|
||||
kwargs = {}
|
||||
if not self.request.user.is_authenticated():
|
||||
if not user_is_authenticated:
|
||||
kwargs.update({'is_public': True})
|
||||
return FormEntry.objects.select_related('user').filter(**kwargs)
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ from django.template import RequestContext
|
|||
from django.template.loader import render_to_string
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from nine.versions import DJANGO_GTE_1_8
|
||||
from nine.versions import DJANGO_GTE_1_8, DJANGO_GTE_1_10
|
||||
|
||||
from ..base import (
|
||||
fire_form_callbacks,
|
||||
|
|
@ -107,10 +107,15 @@ class IntegrationProcessor(object):
|
|||
"""
|
||||
template_name = self.get_form_template_name(request, instance)
|
||||
|
||||
if DJANGO_GTE_1_10:
|
||||
user_is_authenticated = request.user.is_authenticated
|
||||
else:
|
||||
user_is_authenticated = request.user.is_authenticated()
|
||||
|
||||
# Handle public/non-public forms. If form requires user authentication
|
||||
# redirect to login form with next parameter set to current request
|
||||
# path.
|
||||
if not request.user.is_authenticated() \
|
||||
if not user_is_authenticated \
|
||||
and not instance.form_entry.is_public:
|
||||
if self.can_redirect:
|
||||
return redirect(
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ from django.conf import settings
|
|||
from django.template import Library, TemplateSyntaxError, Node
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from nine.versions import DJANGO_GTE_1_7
|
||||
from nine.versions import DJANGO_GTE_1_7, DJANGO_GTE_1_10
|
||||
|
||||
from ..base import get_theme
|
||||
from ..settings import DISPLAY_AUTH_LINK
|
||||
|
|
@ -249,7 +249,11 @@ def render_auth_link(context):
|
|||
return {}
|
||||
|
||||
request = context.get('request', None)
|
||||
if request and request.user.is_authenticated():
|
||||
if DJANGO_GTE_1_10:
|
||||
user_is_authenticated = request.user.is_authenticated
|
||||
else:
|
||||
user_is_authenticated = request.user.is_authenticated()
|
||||
if request and user_is_authenticated:
|
||||
try:
|
||||
auth_url = settings.LOGOUT_URL
|
||||
auth_icon_class = 'icon-signout'
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ try:
|
|||
# We're using the Django 1.6 admin templates, that make use of new
|
||||
# things. One of the new additions (changed) was the ``firstof``
|
||||
# template tag. If we can't import it, we simply define it ourselves.
|
||||
from django.template.deafulttags import firstof
|
||||
from django.template.defaulttags import firstof
|
||||
except ImportError:
|
||||
import warnings
|
||||
|
||||
|
|
|
|||
|
|
@ -1456,9 +1456,13 @@ class FormWizardView(DynamicSessionWizardView):
|
|||
|
||||
def get_initial_wizard_data(self, request, *args, **kwargs):
|
||||
"""Get initial wizard data."""
|
||||
if versions.DJANGO_GTE_1_10:
|
||||
user_is_authenticated = request.user.is_authenticated
|
||||
else:
|
||||
user_is_authenticated = request.user.is_authenticated()
|
||||
try:
|
||||
qs_kwargs = {'slug': kwargs.get('form_wizard_entry_slug')}
|
||||
if not request.user.is_authenticated():
|
||||
if not user_is_authenticated:
|
||||
kwargs.update({'is_public': True})
|
||||
form_wizard_entry = FormWizardEntry.objects \
|
||||
.select_related('user') \
|
||||
|
|
@ -1682,9 +1686,13 @@ class FormWizardView(DynamicSessionWizardView):
|
|||
|
||||
def done(self, form_list, **kwargs):
|
||||
"""Done."""
|
||||
if versions.DJANGO_GTE_1_10:
|
||||
user_is_authenticated = self.request.user.is_authenticated
|
||||
else:
|
||||
user_is_authenticated = self.request.user.is_authenticated()
|
||||
try:
|
||||
qs_kwargs = {'slug': kwargs.get('form_wizard_entry_slug')}
|
||||
if not self.request.user.is_authenticated():
|
||||
if not user_is_authenticated:
|
||||
kwargs.update({'is_public': True})
|
||||
form_wizard_entry = FormWizardEntry.objects \
|
||||
.select_related('user') \
|
||||
|
|
@ -1720,9 +1728,13 @@ def form_wizard_entry_submitted(request, form_wizard_entry_slug=None,
|
|||
:param string template_name:
|
||||
:return django.http.HttpResponse:
|
||||
"""
|
||||
if versions.DJANGO_GTE_1_10:
|
||||
user_is_authenticated = request.user.is_authenticated
|
||||
else:
|
||||
user_is_authenticated = request.user.is_authenticated()
|
||||
try:
|
||||
kwargs = {'slug': form_wizard_entry_slug}
|
||||
if not request.user.is_authenticated():
|
||||
if not user_is_authenticated:
|
||||
kwargs.update({'is_public': True})
|
||||
form_wizard_entry = FormWizardEntry._default_manager \
|
||||
.select_related('user') \
|
||||
|
|
@ -2178,9 +2190,13 @@ def view_form_entry(request, form_entry_slug, theme=None, template_name=None):
|
|||
:param string template_name:
|
||||
:return django.http.HttpResponse:
|
||||
"""
|
||||
if versions.DJANGO_GTE_1_10:
|
||||
user_is_authenticated = request.user.is_authenticated
|
||||
else:
|
||||
user_is_authenticated = request.user.is_authenticated()
|
||||
try:
|
||||
kwargs = {'slug': form_entry_slug}
|
||||
if not request.user.is_authenticated():
|
||||
if not user.is_authenticated:
|
||||
kwargs.update({'is_public': True})
|
||||
form_entry = FormEntry._default_manager.select_related('user') \
|
||||
.get(**kwargs)
|
||||
|
|
@ -2315,9 +2331,13 @@ def form_entry_submitted(request, form_entry_slug=None, template_name=None):
|
|||
:param string template_name:
|
||||
:return django.http.HttpResponse:
|
||||
"""
|
||||
if versions.DJANGO_GTE_1_10:
|
||||
user_is_authenticated = request.user.is_authenticated
|
||||
else:
|
||||
user_is_authenticated = request.user.is_authenticated()
|
||||
try:
|
||||
kwargs = {'slug': form_entry_slug}
|
||||
if not request.user.is_authenticated():
|
||||
if not user_is_authenticated:
|
||||
kwargs.update({'is_public': True})
|
||||
form_entry = FormEntry._default_manager \
|
||||
.select_related('user') \
|
||||
|
|
|
|||
Loading…
Reference in a new issue