コード例 #1
0
ファイル: test_stork.py プロジェクト: tonomuniz/tiger
def test_compresses_css():
    theme = Theme.objects.create(name='test')
    panels = Stork(theme, config_path='stork/tests/fixtures/valid.yml')
    panels.save()
    css = panels.css()
    compressed = panels.compressed_css()
    assert len(css) > len(compressed)
コード例 #2
0
ファイル: import_theme.py プロジェクト: tonomuniz/tiger
def import_theme(theme_dir, name=None):
    try:
        shutil.rmtree('tmp')
    except OSError:
        pass
    shutil.copytree(theme_dir, 'tmp')
    theme_dir = os.path.abspath('tmp')

    manifest = yaml.load(open(os.path.join(theme_dir, 'manifest.yaml')).read())

    asset_dir = os.path.join(theme_dir, 'assets')

    try:
        screenshot = os.path.join(asset_dir, manifest.pop('screenshot'))
    except:
        raise KeyError("Screenshot file missing or improperly specified.")
    try:
        description = manifest.pop('description')
    except:
        raise KeyError("No description provided.")
    try:
        target = manifest.pop('dirname')
    except:
        raise KeyError("No dirname provided for theme assets.")
    asset_target = os.path.join(settings.MEDIA_ROOT, 'theme-assets', target)
    notes = manifest.pop('notes', '')
    theme, created = Theme.objects.get_or_create(name=manifest.pop('name'),
                                                 defaults=dict(
                                                     private=False,
                                                     description=description))
    theme.screenshot.save(
        screenshot.rsplit('/', 1)[1], ContentFile(open(screenshot).read()))
    os.remove(screenshot)

    stork = Stork(theme)
    stork.save()

    switch = {
        Html: set_html,
        Image: set_image,
        CSS: set_css,
        Swatch: set_swatch,
        Font: set_font
    }

    for name, panel in manifest.items():
        for component_id, values in panel.items():
            component = stork[component_id]
            instance = component.instance
            switch[component.model](instance, asset_dir, values)

    try:
        os.makedirs(asset_target)
    except:
        pass

    for f in os.listdir(asset_dir):
        shutil.move(os.path.join(asset_dir, f), os.path.join(asset_target, f))
    shutil.rmtree(theme_dir)
コード例 #3
0
ファイル: test_stork.py プロジェクト: tonomuniz/tiger
def test_outputs_swatch_json():
    theme = Theme.objects.create(name='test')
    panels = Stork(theme, config_path='stork/tests/fixtures/valid.yml')
    panels.save()
    swatch_json_as_list = json.loads(panels.swatch_json())
    assert swatch_json_as_list == [
        s.for_json()
        for s in panels.swatches
    ]
コード例 #4
0
ファイル: models.py プロジェクト: VinceRafale/tiger
def new_site_setup(sender, instance, created, **kwargs):
    if created:
        schedule = Schedule.objects.create(site=instance, master=True)
        Location.objects.create(site=instance, schedule=schedule)
        theme = Theme.objects.create(name=instance.name)
        sms = SmsSettings.objects.create(reseller_network=instance.reseller_network)
        instance.sms = sms
        stork = Stork(theme)
        stork.save()
        instance.theme = theme
        instance.save()
コード例 #5
0
def new_site_setup(sender, instance, created, **kwargs):
    if created:
        schedule = Schedule.objects.create(site=instance, master=True)
        Location.objects.create(site=instance, schedule=schedule)
        theme = Theme.objects.create(name=instance.name)
        sms = SmsSettings.objects.create(
            reseller_network=instance.reseller_network)
        instance.sms = sms
        stork = Stork(theme)
        stork.save()
        instance.theme = theme
        instance.save()
コード例 #6
0
ファイル: test_stork.py プロジェクト: tonomuniz/tiger
def test_outputs_valid_css():
    theme = Theme.objects.create(name='test')
    panels = Stork(theme, config_path='stork/tests/fixtures/valid.yml')
    panels.save()
    css = panels.css()
    parsed = cssutils.parseString(css)
    rule_count = 0
    for component in panels.component_cache:
        if hasattr(component, 'properties'):
            rule_count += len(component.properties)
        else:
            rule_count += 1
    assert len(parsed.cssRules) == rule_count
コード例 #7
0
def save(request, redirect_to, callback=None):
    stork = Stork(request.site.theme)
    stork.save(request.POST, request.FILES)
    return HttpResponse("OK")
コード例 #8
0
ファイル: views.py プロジェクト: VinceRafale/tiger
def save(request, redirect_to, callback=None):
    stork = Stork(request.site.theme)
    stork.save(request.POST, request.FILES)
    return HttpResponse("OK")