Esempio n. 1
0
 def media(self):
     shared = super(SortableInlineAdminMixin, self).media + widgets.Media(
         js=('adminsortable2/js/inline-sortable.js', ))
     if isinstance(self, admin.StackedInline):
         return shared + widgets.Media(
             js=('adminsortable2/js/inline-stacked.js', ))
     if isinstance(self, admin.TabularInline):
         return shared + widgets.Media(
             js=('adminsortable2/js/inline-tabular.js', ))
Esempio n. 2
0
 def media(self):
     shared = (super(SortableInlineAdminMixin, self).media + widgets.Media(
         js=('adminsortable2/js/libs/jquery.ui.sortable-1.11.4.js',
             'adminsortable2/js/inline-sortable.js')))
     if isinstance(self, admin.StackedInline):
         return shared + widgets.Media(
             js=('adminsortable2/js/inline-sortable.js',
                 'adminsortable2/js/inline-stacked.js'))
     if isinstance(self, admin.TabularInline):
         return shared + widgets.Media(
             js=('adminsortable2/js/inline-sortable.js',
                 'adminsortable2/js/inline-tabular.js'))
Esempio n. 3
0
 def media(self):
     shared = (super().media + widgets.Media(
         js=('adminsortable2/js/libs/jquery.ui.sortable-1.11.4.js',
             'adminsortable2/js/inline-sortable.js')))
     if isinstance(self, admin.StackedInline):
         return shared + widgets.Media(
             js=('adminsortable2/js/inline-sortable.js',
                 'adminsortable2/js/inline-stacked.js'))
     else:
         # assume TabularInline (don't return None in any case)
         return shared + widgets.Media(
             js=('adminsortable2/js/inline-sortable.js',
                 'adminsortable2/js/inline-tabular.js'))
Esempio n. 4
0
 def media(self):
     shared = (
         super(SortableInlineAdminMixin, self).media
         + widgets.Media(js=('adminsortable2/js/libs/jquery.ui.sortable-1.11.4.js',
                             'adminsortable2/js/inline-sortable.js')))
     if self.is_stacked:
         return shared + widgets.Media(
             js=('adminsortable2/js/inline-sortable.js',
                 'adminsortable2/js/inline-stacked.js'))
     else:
         # assume TabularInline (don't return None in any case)
         return shared + widgets.Media(
             js=('adminsortable2/js/inline-sortable.js',
                 'adminsortable2/js/inline-tabular.js'))
Esempio n. 5
0
 def media(self):
     if not self.is_localized:
         return self._media
     lang = get_language()
     if not lang or lang.startswith("en"):
         return self._media
     lang = lang.replace("-", "_")
     return widgets.Media(
         css={
             'all': [
                 'node_modules/trumbowyg/dist/ui/trumbowyg.min.css',
                 'node_modules/trumbowyg/dist/plugins/emoji/ui/trumbowyg.emoji.css',  # noqa: E501
                 'node_modules/trumbowyg/dist/plugins/colors/ui/trumbowyg.colors.css',  # noqa: E501
                 # 'node_modules/trumbowyg/dist/plugins/history/ui/trumbowyg.history.css'  # noqa: E501
                 # 'node_modules/jquery-resizable/resizable.css',
             ]
         },
         js=[
             'node_modules/jquery/dist/jquery%s.js' % _extra,
             # 'node_modules/jquery-resizable/resizable.js',
             'node_modules/trumbowyg/dist/trumbowyg%s.js' % _extra,
             'node_modules/trumbowyg/dist/plugins/emoji/trumbowyg.emoji.min.js',  # noqa: E501
             'node_modules/trumbowyg/dist/plugins/preformatted/trumbowyg.preformatted.min.js',  # noqa: E501
             'node_modules/trumbowyg/dist/plugins/insertaudio/trumbowyg.insertaudio.min.js',  # noqa: E501
             'node_modules/trumbowyg/dist/plugins/pasteimage/trumbowyg.pasteimage.min.js',  # noqa: E501
             'node_modules/trumbowyg/dist/plugins/lineheight/trumbowyg.lineheight.min.js',  # noqa: E501
             'node_modules/trumbowyg/dist/plugins/base64/trumbowyg.base64.min.js',  # noqa: E501
             'node_modules/trumbowyg/dist/plugins/history/trumbowyg.history.min.js',  # noqa: E501
             'node_modules/trumbowyg/dist/plugins/colors/trumbowyg.colors.min.js',  # noqa: E501
             # 'node_modules/trumbowyg/dist/plugins/resizimg/trumbowyg.resizimg.js',  # noqa: E501
             'node_modules/trumbowyg/dist/plugins/table/trumbowyg.table.min.js',  # noqa: E501
             'spider_base/trumbowygWidget.js',
             'node_modules/trumbowyg/dist/langs/{}.min.js'.format(lang)
         ])
 def media(self):
     m = super(SortableAdminMixin, self).media
     if self.enable_sorting:
         m = m + widgets.Media(
             js=('adminsortable2/js/libs/jquery.ui.sortable-1.11.4.js',
                 'adminsortable2/js/list-sortable.js'))
     return m
Esempio n. 7
0
    def media(self):
        """Media needed for the widget.

        This is used by the form to return all CSS/JavaScript media that the
        page will need in order to render this widget and any widgets used
        in the condition value fields.

        Returns:
            django.forms.widgets.Media:
            The media to include on the path.
        """
        media = (widgets.Media() + self.choice_widget.media +
                 self.operator_widget.media)

        choices = self.choices.get_choices(choice_kwargs=self.choice_kwargs)

        for choice in choices:
            default_value_field = choice.default_value_field

            if callable(default_value_field):
                default_value_field = default_value_field()

            if hasattr(default_value_field, 'widget'):
                media += default_value_field.widget.media

            for operator in choice.get_operators():
                if operator.has_custom_value_field:
                    if (operator.value_field
                            and hasattr(operator.value_field, 'widget')):
                        media += operator.value_field.widget.media

        return media
Esempio n. 8
0
    def _media(self):
        js = ["js/bootstrap-datetimepicker.js"]
        if self.language != 'en':
            js.append("js/locales/bootstrap-datetimepicker.%s.js" %
                      self.language)

        return widgets.Media(css={'all': ('css/datetimepicker.css', )}, js=js)
Esempio n. 9
0
 def media(self):
     css = {'all': ('adminsortable2/css/sortable.css', )}
     if VERSION[:2] <= (1, 5):
         js = (
             'adminsortable2/js/plugins/admincompat.js',
             'adminsortable2/js/libs/jquery.ui.core-1.7.1.js',
             'adminsortable2/js/libs/jquery.ui.sortable-1.7.1.js',
         )
     else:
         js = (
             'adminsortable2/js/plugins/admincompat.js',
             'adminsortable2/js/libs/jquery.ui.core-1.11.4.js',
             'adminsortable2/js/libs/jquery.ui.widget-1.11.4.js',
             'adminsortable2/js/libs/jquery.ui.mouse-1.11.4.js',
             'adminsortable2/js/libs/jquery.ui.sortable-1.11.4.js',
         )
     if 'cms' in settings.INSTALLED_APPS:
         try:
             # for DjangoCMS < 3, override jQuery files for inclusion from the CMS
             from cms import __version__
             cms_version = __version__.split('.')
             if int(cms_version[0]) < 3:
                 js = (
                     'cms/js/plugins/admincompat.js',
                     'cms/js/libs/jquery.query.js',
                     'cms/js/libs/jquery.ui.core.js',
                     'cms/js/libs/jquery.ui.sortable.js',
                 )
         except ImportError:
             # other packages may pollute the import search path with 'cms'
             pass
     return super(SortableAdminBase, self).media + widgets.Media(css=css,
                                                                 js=js)
Esempio n. 10
0
 def media(self):
     return (
         super(SortableInlineAdminMixin, self).media + widgets.Media(js=(
             'adminsortable2/js/libs/jquery.ui.sortable-1.11.4.js',
             'admin/training/inline-sortable.js',
             'adminsortable2/js/inline-tabular.js')
         )
     )
Esempio n. 11
0
 def media(self):
     original_media = super(DjangoLinkAdmin, self).media
     css = {
         'all':
         (settings.STATIC_URL + 'admin/ckeditor_link/css/link_admin.css', )
     }
     new_media = widgets.Media(css=css)
     return original_media + new_media
Esempio n. 12
0
    def _media(self):

        js = ["js/bootstrap-datetimepicker.js"]

        language = get_supported_language(get_language())
        if language != 'en':
            js.append("js/locales/bootstrap-datetimepicker.%s.js" % language)

        return widgets.Media(css={'all': ('css/datetimepicker.css', )}, js=js)
Esempio n. 13
0
    def _media(self):

        js = ["js/bootstrap-datetimepicker.js"]

        language = self.options.get('language', 'en')
        if language != 'en':
            js.append("js/locales/bootstrap-datetimepicker.%s.js" % language)

        return widgets.Media(css={'all': ('css/datetimepicker.css', )}, js=js)
Esempio n. 14
0
 def _get_media(self):
     # The "core.js" file is required by the Admin Date widget, yet for
     # some reason, isn't included in the widgets media definition.
     # We override "_get_media" because core.js needs to appear BEFORE
     # the widget's JS files, and the default order puts the form's
     # media AFTER that of its fields.
     media = widgets.Media(js=('%sjs/core.js' %
                               settings.ADMIN_MEDIA_PREFIX, ))
     media += super(EventForm, self).media
     return media
Esempio n. 15
0
 def media(self):
     css = {'all': ('adminsortable2/css/sortable.css',)}
     js = (
         'adminsortable2/js/plugins/admincompat.js',
         'adminsortable2/js/libs/jquery.ui.core-1.11.4.js',
         'adminsortable2/js/libs/jquery.ui.widget-1.11.4.js',
         'adminsortable2/js/libs/jquery.ui.mouse-1.11.4.js',
         'adminsortable2/js/libs/jquery.ui.sortable-1.11.4.js',
     )
     return super(SortableAdminBase, self).media + widgets.Media(css=css, js=js)
Esempio n. 16
0
 def media(self):  # pylint: disable=missing-docstring
     return widgets.Media(
         css={
             'all': (
                 MATERIAL_CSS,
                 'material_widgets/css/material_error.css',
             )
         },
         js=(MATERIAL_JS, ),
     )
Esempio n. 17
0
 def _media(self):
     return widgets.Media(
         css={
             'all': ('eonasdan-bootstrap-datetimepicker/build/css/bootstrap-datetimepicker.css',)
             },
         js=[
             "moment/moment.js",
             "eonasdan-bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min.js",
         ]
     )
Esempio n. 18
0
 def media(self):
     js = (
         'admin/js/jquery.init.js',
         'formfield_stash/formfield_stash.js',
     )
     css = {}
     #     'all': ('formfield_stash/adjust-divers.css', ),
     # }
     original_media = super(FormFieldStashMixin, self).media
     return original_media + widgets.Media(css=css, js=js)
Esempio n. 19
0
    def media(self):
        extra = "" if settings.DEBUG else ".min"
        i18n_name = self._get_language_code()
        i18n_file = ("%s%s.js" % (I18N_PATH, i18n_name),) if i18n_name else ()

        return widgets.Media(
            js=(
                   "autocomplete_light/autocomplete_light%s.js" % extra,
                   "autocomplete_light/select2%s.js" % extra,
               ) + i18n_file,
        )
Esempio n. 20
0
 def media(self):
     js = (
         'inline_addons/js/popup_inline_handling.js',
     )
     css = {
         'all': (
             'inline_addons/css/popup_inline.css',
         )
     }
     original_media = super(PopupInline, self).media
     return original_media + widgets.Media(js=js, css=css)
Esempio n. 21
0
 def media(self):
     extra = '' if settings.DEBUG else '.min'
     return widgets.Media(
         js=(
             'admin/js/vendor/jquery/jquery%s.js' % extra,
             'admin/js/jquery.init.js',
             'prettyjson/prettyjson.js',
         ),
         css={
             'all': ('prettyjson/prettyjson.css', )
         },
     )
Esempio n. 22
0
 def media(self):
     css = {'all': ['adminsortable2/css/sortable.css']}
     js = [
         'admin/js/jquery.init.js',
         'adminsortable2/js/plugins/admincompat.js',
         'adminsortable2/js/libs/jquery.ui.core-1.11.4.js',
         'adminsortable2/js/libs/jquery.ui.widget-1.11.4.js',
         'adminsortable2/js/libs/jquery.ui.mouse-1.11.4.js',
         'adminsortable2/js/libs/jquery.ui.touch-punch-0.2.3.js',
         'adminsortable2/js/libs/jquery.ui.sortable-1.11.4.js',
     ]
     return super(SortableAdminBase, self).media + widgets.Media(css=css, js=js)
 def media(self):
     original_media = super(FilerMultiUploadInlineMixin, self).media
     js = (
         settings.STATIC_URL + 'filer/js/libs/dropzone.min.js',
         settings.STATIC_URL + 'admin/filer_gui/js/multiupload_inline.js',
     )
     css = {
         'all': (settings.STATIC_URL +
                 'admin/filer_gui/css/multiupload_base.css', )
     }
     new_media = widgets.Media(js=js, css=css)
     return original_media + new_media
Esempio n. 24
0
 def media(self):
     original_media = super(UploadInlineMixin, self).media
     js = (
         settings.STATIC_URL + 'admin/filer_gui/js/dropzone.js',
         settings.STATIC_URL + 'admin/filer_gui/js/inline.upload.js',
     )
     css = {
         'all':
         (settings.STATIC_URL + 'admin/filer_gui/css/filer_gui.css', )
     }
     new_media = widgets.Media(js=js, css=css)
     return original_media + new_media
 def media(self):
     original_media = super(UploadPluginMixin, self).media
     js = (
         # settings.STATIC_URL + 'filer/js/libs/dropzone.min.js',
         # settings.STATIC_URL + 'filer/js/addons/dropzone.init.js',
         settings.STATIC_URL + 'admin/filer_gui/js/multiupload_plugin.js', )
     css = {
         'all': [
             settings.STATIC_URL +
             'admin/filer_gui/css/multiupload_base.css',
         ]
     }
     new_media = widgets.Media(js=js, css=css)
     return original_media + new_media
Esempio n. 26
0
 def media(self):
     share = super(GenericStackedPolymorphicInline, self).media
     sortable_media = super(SortableInlineAdminMixin, self).media
     add_media(
         sortable_media,
         widgets.Media(
             js=(
                 'admin/js/jquery.init.js',
                 'adminsortable2/js/inline-sortable.js',
                 'adminsortable2/js/inline-stacked.js',
             )
         ),
     )
     add_media(share, sortable_media)
     return share
Esempio n. 27
0
 def media(self):
     js_files = ["codemirror2/lib/codemirror.js"]
     js_files += ["codemirror2/addon/mode/overlay.js"]
     js_files += [("codemirror2/mode/%s/%s.js" % (mode, mode))
                  for mode in self.modes]
     css_files = ["codemirror2/lib/codemirror.css"]
     css_files += [("codemirror2/theme/%s.css" % theme)
                   for theme in self.themes if theme != "default"
                   ]  # default theme is included in codemirror.css
     # some modes have extra css files, too:
     # TODO: autodetect
     need_css = ["tiki", "tiddlywiki"]
     for mode in need_css:
         if mode in self.modes:
             css_files.append("codemirror2/mode/%s/%s.css" % (mode, mode))
     return widgets.Media(js=js_files, css={'screen': css_files})
Esempio n. 28
0
    def _media(self):

        js = ["js/bootstrap-datetimepicker.js"]

        #language = self.options.get('language', 'en')
        language = get_supported_language(get_language())
        self.options['language'] = language

        if language != 'en':
            js.append("js/locales/bootstrap-datetimepicker.%s.js" % language)

        self.options['format'] = toJavascript_re.sub(
            lambda x: dateConversiontoJavascript[x.group()],
            get_format(self.format_name)[0])

        return widgets.Media(css={'all': ('css/datetimepicker.css', )}, js=js)
Esempio n. 29
0
    def media(self):
        """Media needed for the widget.

        This is used by the form to return all CSS/JavaScript media that the
        page will need in order to render the widget.
        """
        media = (widgets.Media() + self.choice_widget.media +
                 self.operator_widget.media)

        choices = self.choices.get_choices(choice_kwargs=self.choice_kwargs)

        for choice in choices:
            media += choice.default_value_field.widget.media

            for operator in choice.get_operators():
                if operator.has_custom_value_field:
                    media += operator.value_field.widget.media

        return media
Esempio n. 30
0
    def _media(self):

        js = ["js/bootstrap-datetimepicker.js"]

        language = self.options.get('language', 'en')
        if language != 'en':
            js.append("js/locales/bootstrap-datetimepicker.%s.js" % language)

        options_list = []
        for key, value in iter(self.options.items()):
            options_list.append("%s: %s" % (key, quote(key, value)))
        js_options = ",\n".join(options_list)

        js.append(emb.JS(SCRIPT_TEMPLATE[self.bootstrap_version] % dict(
            id=self.id,
            options=js_options
        )))

        return widgets.Media(
            css={
                'all': ('css/datetimepicker.css',)
                },
            js=js
            )