""" Optional integration with django-any-Imagefield """ from __future__ import absolute_import from django.db import models from fluent_utils.django_compat import is_installed if is_installed('any_imagefield'): from any_imagefield.models import AnyFileField as BaseFileField, AnyImageField as BaseImageField else: BaseFileField = models.FileField BaseImageField = models.ImageField # subclassing here so South or Django migrations detect a single class. class AnyFileField(BaseFileField): """ A FileField that can refer to an uploaded file. If *django-any-imagefield* is not installed, the filebrowser link will not be displayed. """ def south_field_triple(self): # Masquerade as normal FileField, so the soft-dependency also exists in the migrations. from south.modelsinspector import introspector path = "{0}.{1}".format(models.FileField.__module__, models.FileField.__name__) args, kwargs = introspector(self) return (path, args, kwargs)
Optional integration with django-taggit. """ from __future__ import absolute_import from django.contrib.contenttypes.models import ContentType from django.db import models from django.db.models import Field from fluent_utils.django_compat import is_installed __all__ = ( 'TaggableManager', 'TagsMixin', ) if is_installed('taggit_selectize'): from taggit_selectize.managers import TaggableManager as BaseTaggableManager elif is_installed('taggit_autosuggest'): from taggit_autosuggest.managers import TaggableManager as BaseTaggableManager elif is_installed('taggit_autocomplete_modified'): from taggit_autocomplete_modified.managers import TaggableManagerAutocomplete as BaseTaggableManager elif is_installed('taggit'): from taggit.managers import TaggableManager as BaseTaggableManager else: BaseTaggableManager = None # Make sure the 'tags' field is ignored by old versions of South try: from south.modelsinspector import add_ignored_fields except ImportError:
""" Optional integration with fluent-pages features """ from __future__ import absolute_import from django.utils.functional import lazy from fluent_utils.django_compat import is_installed __all__ = ( 'CurrentPageMixin', 'mixed_reverse', 'mixed_reverse_lazy', 'HAS_APP_URLS', ) if is_installed('fluent_pages'): # Use the real code. from fluent_pages.views import CurrentPageMixin from fluent_pages.urlresolvers import mixed_reverse # app_reverse == hard dependency, no need to import here. try: from fluent_pages.urlresolvers import mixed_reverse_lazy # added after v1.0b4 except ImportError: mixed_reverse_lazy = lazy(mixed_reverse, str) HAS_APP_URLS = True else: # Use the stubs from django.core.urlresolvers import reverse from fluent_utils.django_compat import is_installed from parler.views import ViewUrlMixin
""" A simple wrapper library, that makes sure that the template ``fluent_blogs/entry_detail/comments.html`` can still be rendered when ``django.contrib.comments`` is not included in the site. This way, project authors can easily use an online commenting system (such as DISQUS or Facebook comments) instead. """ from django.template import Library from fluent_utils.django_compat import is_installed # Expose the tag library in the site. # If `django.contrib.comments` is not used, this library can provide stubs instead. # Currently, the real tags are exposed as the template already checks for `object.comments_are_open`. # When a custom template is used, authors likely choose the desired commenting library instead. if is_installed('django.contrib.comments'): from django.contrib.comments.templatetags.comments import register elif is_installed('django_comments'): from django_comments.templatetags.comments import register else: register = Library()
Optional integration with django-taggit. """ from __future__ import absolute_import from django.contrib.contenttypes.models import ContentType from django.db import models from django.db.models import Field from fluent_utils.django_compat import is_installed __all__ = ( 'TaggableManager', 'TagsMixin', ) if is_installed('taggit_selectize'): from taggit_selectize.managers import TaggableManager as BaseTaggableManager elif is_installed('taggit_autosuggest'): from taggit_autosuggest.managers import TaggableManager as BaseTaggableManager elif is_installed('taggit_autocomplete_modified'): from taggit_autocomplete_modified.managers import TaggableManagerAutocomplete as BaseTaggableManager elif is_installed('taggit'): from taggit.managers import TaggableManager as BaseTaggableManager else: BaseTaggableManager = None # Make sure the 'tags' field is ignored by old versions of South try: from south.modelsinspector import add_ignored_fields except ImportError: pass
""" A proxy to automatically switch to the right comments app that is available. """ import warnings from django.template import Library from django.utils.safestring import mark_safe from fluent_utils.django_compat import is_installed from fluent_contents.plugins.commentsarea import appsettings if is_installed("threadedcomments" ) and appsettings.FLUENT_COMMENTSAREA_THREADEDCOMMENTS: from threadedcomments.templatetags.threadedcomments_tags import register elif is_installed("django.contrib.comments"): from django.contrib.comments.templatetags.comments import register elif is_installed("django_comments"): from django_comments.templatetags.comments import register else: register = Library() @register.simple_tag def render_comment_list(for_, object): warnings.warn( "Can't render comments list: no comment app installed!\n" "Make sure either 'django.contrib.comments' or 'django_comments' is in INSTALLED_APPS" ) return mark_safe( "<!-- Can't render comments list: no comment plugin installed! -->" )
This way, project authors can easily use an online commenting system (such as DISQUS or Facebook comments) instead. """ import warnings from django.conf import settings from django.template import Library from django.utils.safestring import mark_safe from fluent_utils.django_compat import is_installed # Expose the tag library in the site. # If `django.contrib.comments` is not used, this library can provide stubs instead. # Currently, the real tags are exposed as the template already checks for `object.comments_are_open`. # When a custom template is used, authors likely choose the desired commenting library instead. if is_installed('threadedcomments') and getattr(settings, 'COMMENTS_APP', None): from threadedcomments.templatetags.threadedcomments_tags import register elif is_installed('django.contrib.comments'): from django.contrib.comments.templatetags.comments import register elif is_installed('django_comments'): from django_comments.templatetags.comments import register else: register = Library() @register.simple_tag def render_comment_list(for_, object): warnings.warn( "Can't render comments list: no comment app installed!\n" "Make sure either 'django.contrib.comments' or 'django_comments' is in INSTALLED_APPS" )
""" A proxy to automatically switch to the right comments app that is available. """ import warnings from django.template import Library from django.utils.safestring import mark_safe from fluent_utils.django_compat import is_installed from fluent_contents.plugins.commentsarea import appsettings if ( is_installed("threadedcomments") and appsettings.FLUENT_COMMENTSAREA_THREADEDCOMMENTS ): from threadedcomments.templatetags.threadedcomments_tags import register elif is_installed("django.contrib.comments"): from django.contrib.comments.templatetags.comments import register elif is_installed("django_comments"): from django_comments.templatetags.comments import register else: register = Library() @register.simple_tag def render_comment_list(for_, object): warnings.warn( "Can't render comments list: no comment app installed!\n" "Make sure either 'django.contrib.comments' or 'django_comments' is in INSTALLED_APPS" ) return mark_safe( "<!-- Can't render comments list: no comment plugin installed! -->"
""" Optional integration with django-any-urlfield """ from __future__ import absolute_import from django.db import models from fluent_utils.django_compat import is_installed if is_installed('any_urlfield'): from any_urlfield.models import AnyUrlField as BaseUrlField else: BaseUrlField = models.URLField # subclassing here so South or Django migrations detect a single class. class AnyUrlField(BaseUrlField): """ A CharField that can either refer to a CMS page ID, or external URL. If *django-any-urlfield* is not installed, only regular URLs can be used. """ def __init__(self, *args, **kwargs): if 'max_length' not in kwargs: kwargs['max_length'] = 300 # Standardize super(AnyUrlField, self).__init__(*args, **kwargs) def south_field_triple(self): # Masquerade as normal URLField, so the soft-dependency also exists in the migrations. from south.modelsinspector import introspector path = "{0}.{1}".format(models.URLField.__module__,
This way, project authors can easily use an online commenting system (such as DISQUS or Facebook comments) instead. """ import warnings from django.conf import settings from django.template import Library from django.utils.safestring import mark_safe from fluent_utils.django_compat import is_installed # Expose the tag library in the site. # If `django.contrib.comments` is not used, this library can provide stubs instead. # Currently, the real tags are exposed as the template already checks for `object.comments_are_open`. # When a custom template is used, authors likely choose the desired commenting library instead. if is_installed('threadedcomments') and getattr(settings, 'COMMENTS_APP', None): from threadedcomments.templatetags.threadedcomments_tags import register elif is_installed('django.contrib.comments'): from django.contrib.comments.templatetags.comments import register elif is_installed('django_comments'): from django_comments.templatetags.comments import register else: register = Library() @register.simple_tag def render_comment_list(for_, object): warnings.warn( "Can't render comments list: no comment app installed!\n" "Make sure either 'django.contrib.comments' or 'django_comments' is in INSTALLED_APPS" ) return mark_safe("<!-- Can't render comments list: no comment plugin installed! -->")
Optional integration with fluent-pages features """ from __future__ import absolute_import from django.utils.functional import lazy from fluent_utils.django_compat import is_installed __all__ = ( 'CurrentPageMixin', 'mixed_reverse', 'mixed_reverse_lazy', 'HAS_APP_URLS', ) if is_installed('fluent_pages'): # Use the real code. from fluent_pages.views import CurrentPageMixin from fluent_pages.urlresolvers import mixed_reverse # app_reverse == hard dependency, no need to import here. try: from fluent_pages.urlresolvers import mixed_reverse_lazy # added after v1.0b4 except ImportError: mixed_reverse_lazy = lazy(mixed_reverse, str) HAS_APP_URLS = True else: # Use the stubs from fluent_utils.django_compat import is_installed, reverse try:
""" A proxy to automatically switch to the right comments app that is available. """ import warnings from django.template import Library from django.utils.safestring import mark_safe from fluent_contents.plugins.commentsarea import appsettings from fluent_utils.django_compat import is_installed if is_installed('threadedcomments') and appsettings.FLUENT_COMMENTSAREA_THREADEDCOMMENTS: from threadedcomments.templatetags.threadedcomments_tags import register elif is_installed('django.contrib.comments'): from django.contrib.comments.templatetags.comments import register elif is_installed('django_comments'): from django_comments.templatetags.comments import register else: register = Library() @register.simple_tag def render_comment_list(for_, object): warnings.warn( "Can't render comments list: no comment app installed!\n" "Make sure either 'django.contrib.comments' or 'django_comments' is in INSTALLED_APPS" ) return mark_safe("<!-- Can't render comments list: no comment plugin installed! -->") @register.simple_tag def render_comment_form(for_, object):
""" Optional integration with django-any-Imagefield """ from __future__ import absolute_import from django.db import models from fluent_utils.django_compat import is_installed if is_installed('any_imagefield'): from any_imagefield.models import AnyFileField as BaseFileField, AnyImageField as BaseImageField else: BaseFileField = models.FileField BaseImageField = models.ImageField # subclassing here so South or Django migrations detect a single class. class AnyFileField(BaseFileField): """ A FileField that can refer to an uploaded file. If *django-any-imagefield* is not installed, the filebrowser link will not be displayed. """ def deconstruct(self): # For Django migrations, masquerade as normal FileField too name, path, args, kwargs = super(AnyFileField, self).deconstruct() # FileField behavior if kwargs.get("max_length") == 100: del kwargs["max_length"]
""" Optional integration with django-any-urlfield """ from __future__ import absolute_import from django.db import models from fluent_utils.django_compat import is_installed if is_installed('any_urlfield'): from any_urlfield.models import AnyUrlField as BaseUrlField else: BaseUrlField = models.URLField # subclassing here so South or Django migrations detect a single class. class AnyUrlField(BaseUrlField): """ A CharField that can either refer to a CMS page ID, or external URL. If *django-any-urlfield* is not installed, only regular URLs can be used. """ def __init__(self, *args, **kwargs): if 'max_length' not in kwargs: kwargs['max_length'] = 300 # Standardize super(AnyUrlField, self).__init__(*args, **kwargs) def south_field_triple(self): # Masquerade as normal URLField, so the soft-dependency also exists in the migrations. from south.modelsinspector import introspector