Beispiel #1
0
        class Media:
            css = {
                'all': [
                    'css/pygment-github.css',
                    sass_processor('scss/table.scss'),
                    sass_processor('scss/ranks.scss'),
                ]
            }

            js = [
                'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML'
            ]
Beispiel #2
0
        class Media:
            css = {
                'all': [
                    sass_processor('scss/content-description.scss'),
                    'admin/css/pagedown.css',
                ],
            }

            js = ['admin/js/pagedown.js']
    def test_sass_processor(self):
        from sass_processor.processor import sass_processor

        css_file = sass_processor('tests/css/bluebox.scss')
        self.assertEqual('/static/tests/css/bluebox.css', css_file)
        css_file = os.path.join(settings.STATIC_ROOT, 'tests/css/bluebox.css')
        self.assertTrue(os.path.exists(css_file))
        with open(css_file, 'r') as f:
            output = f.read()
        expected = '.bluebox{background-color:#0000ff}\n\n/*# sourceMappingURL=../../../../../../../../../static/tests/css/bluebox.css.map */'
        self.assertEqual(expected, output)
    def test_sass_processor(self):
        from sass_processor.processor import sass_processor

        css_file = sass_processor('tests/css/bluebox.scss')
        self.assertEqual('/static/tests/css/bluebox.css', css_file)
        css_file = os.path.join(settings.STATIC_ROOT, 'tests/css/bluebox.css')
        self.assertTrue(os.path.exists(css_file))
        with open(css_file, 'r') as f:
            output = f.read()
        expected = '.bluebox{background-color:#0000ff;margin:10.0px 5.0px 20.0px 15.0px;color:#fa0a78}\n\n/*# sourceMappingURL=bluebox.css.map */'
        self.assertEqual(expected, output)
from core.constants.environments import Environments
from core.fields import HistoricDateTimeField, JSONField
from core.forms import HistoricDateWidget
from core.models import Model
from core.widgets.json_editor_widget import JSONEditorWidget

AdminListFilter = Union[str, Type[ListFilter]]


FORM_FIELD_OVERRIDES = {
    HistoricDateTimeField: {'widget': HistoricDateWidget},
    JSONField: {'widget': JSONEditorWidget()},
}

if settings.ENVIRONMENT == Environments.DEV:
    BASE_CSS = sass_processor('styles/base.scss')
    MCE_CSS = sass_processor('styles/mce.scss')
    ADMIN_CSS = sass_processor('styles/admin.scss')
else:
    BASE_CSS = 'styles/base.css'
    MCE_CSS = 'styles/mce.css'
    ADMIN_CSS = 'styles/admin.css'


class ModelAdmin(NestedPolymorphicInlineSupportMixin, NestedModelAdmin):
    """
    Base admin class for ModularHistory's models.

    Uses the NestedPolymorphicInlineSupportMixin as instructed in
    https://django-nested-admin.readthedocs.io/en/latest/integrations.html.
    """
Beispiel #6
0
 def media(self):
     return Media(css={'all': [sass_processor('shop/css/customer.scss')]})
Beispiel #7
0
 def media(self):
     return Media(css={'all': [sass_processor('shop/css/address.scss')]})
Beispiel #8
0
 class Media:
     css = {'all': [sass_processor('scss/admin.scss'),]}
Beispiel #9
0
import os
from django.template import loader, Context
from django.conf import settings
from weasyprint import HTML, CSS
from weasyprint.fonts import FontConfiguration
from sass_processor.processor import sass_processor

font_config = FontConfiguration()
css_path = settings.RUN_DIR + sass_processor('scss/pdf.scss')
css = CSS(filename=css_path, font_config=font_config)


def render_request(form):
    tmpl = loader.get_template('request/ams_request.html')
    rendered = tmpl.render({
        'name': form.full_name,
        'address': form.cleaned_data['address'],
        'zipcode': form.cleaned_data['zipcode'],
        'municipality': form.cleaned_data['municipality'],
        'email': form.cleaned_data['email'],
    })

    doc = HTML(string=rendered)
    return doc.write_pdf(stylesheets=[css], font_config=font_config)
Beispiel #10
0
 def media(self):
     return Media(css={'all': [sass_processor('shop/css/customer.scss')]})
Beispiel #11
0
 def media(self):
     return Media(css={'all': [sass_processor('shop/css/address.scss')]})
Beispiel #12
0
 class Media:
     css = {'all': [sass_processor('sass/range_widget.sass')]}