Skip to content

Commit

Permalink
black and isort
Browse files Browse the repository at this point in the history
  • Loading branch information
vdboor committed Nov 16, 2021
1 parent 260a579 commit d951fff
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 67 deletions.
6 changes: 3 additions & 3 deletions fluentcms_cookielaw/appsettings.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.conf import settings

_default_js = ('fluentcms_cookielaw/js/cookielaw.js',)
_default_js = ("fluentcms_cookielaw/js/cookielaw.js",)

# Allow overriding the complete FrontendMedia definition
FLUENTCMS_COOKIELAW_JS = getattr(settings, 'FLUENTCMS_COOKIELAW_JS', _default_js)
FLUENTCMS_COOKIELAW_CSS = getattr(settings, 'FLUENTCMS_COOKIELAW_CSS', {})
FLUENTCMS_COOKIELAW_JS = getattr(settings, "FLUENTCMS_COOKIELAW_JS", _default_js)
FLUENTCMS_COOKIELAW_CSS = getattr(settings, "FLUENTCMS_COOKIELAW_CSS", {})
4 changes: 3 additions & 1 deletion fluentcms_cookielaw/content_plugins.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django.utils.translation import gettext_lazy as _
from fluent_contents.extensions import plugin_pool, ContentPlugin
from fluent_contents.extensions import ContentPlugin, plugin_pool

from . import appsettings
from .models import CookieLawItem

Expand All @@ -9,6 +10,7 @@ class CookieLawPlugin(ContentPlugin):
"""
Showing a cookie law notification
"""

model = CookieLawItem
category = _("Footer")
render_template = "fluentcms_cookielaw/banner.html"
Expand Down
36 changes: 26 additions & 10 deletions fluentcms_cookielaw/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,42 @@
from django.db import models, migrations
import fluent_contents.extensions
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('fluent_contents', '0001_initial'),
("fluent_contents", "0001_initial"),
]

operations = [
migrations.CreateModel(
name='CookieLawItem',
name="CookieLawItem",
fields=[
('contentitem_ptr', models.OneToOneField(parent_link=True, auto_created=True, primary_key=True, serialize=False, to='fluent_contents.ContentItem', on_delete=models.CASCADE)),
('text', fluent_contents.extensions.PluginHtmlField(help_text="For example: 'We use cookies to ensure you get the best experience on our website'", verbose_name='Text')),
('button_text', models.CharField(max_length=100, verbose_name='Button text')),
(
"contentitem_ptr",
models.OneToOneField(
parent_link=True,
auto_created=True,
primary_key=True,
serialize=False,
to="fluent_contents.ContentItem",
on_delete=models.CASCADE,
),
),
(
"text",
fluent_contents.extensions.PluginHtmlField(
help_text="For example: 'We use cookies to ensure you get the best experience on our website'",
verbose_name="Text",
),
),
("button_text", models.CharField(max_length=100, verbose_name="Button text")),
],
options={
'db_table': 'contentitem_fluentcms_cookielaw_cookielawitem',
'verbose_name': 'Cookie notification',
'verbose_name_plural': 'Cookie notifications',
"db_table": "contentitem_fluentcms_cookielaw_cookielawitem",
"verbose_name": "Cookie notification",
"verbose_name_plural": "Cookie notifications",
},
bases=('fluent_contents.contentitem',),
bases=("fluent_contents.contentitem",),
),
]
8 changes: 7 additions & 1 deletion fluentcms_cookielaw/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@ class CookieLawItem(ContentItem):
"""
Cookie law item
"""
text = PluginHtmlField(_("Text"), help_text=_("For example: 'We use cookies to ensure you get the best experience on our website'"))

text = PluginHtmlField(
_("Text"),
help_text=_(
"For example: 'We use cookies to ensure you get the best experience on our website'"
),
)
button_text = models.CharField(_("Button text"), max_length=100) # e.g. "Close" or "Accept"

class Meta:
Expand Down
20 changes: 14 additions & 6 deletions fluentcms_cookielaw/tests.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from django.test import TestCase
from fluent_contents.tests.factories import create_content_item
from fluent_contents.tests.utils import render_content_items

from fluentcms_cookielaw.models import CookieLawItem


Expand All @@ -13,16 +14,23 @@ def test_rendering(self):
"""
Test the standard button
"""
item = create_content_item(CookieLawItem, text="Do you like cookies?", button_text="Jummie!")
item = create_content_item(
CookieLawItem, text="Do you like cookies?", button_text="Jummie!"
)
output = render_content_items([item])

self.assertHTMLEqual(output.html,
'''<div id="cookielaw-banner">
self.assertHTMLEqual(
output.html,
"""<div id="cookielaw-banner">
<div class="container">
<a class="btn" href="javascript:Cookielaw.accept();">Jummie!</a>
Do you like cookies?
</div>
</div>''')
self.assertHTMLEqual(str(output.media), '<script type="text/javascript" src="/static/fluentcms_cookielaw/js/cookielaw.js"></script>')
</div>""",
)
self.assertHTMLEqual(
str(output.media),
'<script type="text/javascript" src="/static/fluentcms_cookielaw/js/cookielaw.js"></script>',
)

self.assertEqual(str(item), 'Do you like cookies?')
self.assertEqual(str(item), "Do you like cookies?")
14 changes: 14 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[tool.isort]
profile = "black"
line_length = 99

[tool.black]
line-length = 99
exclude = '''
/(
\.git
| \.venv
| \.tox
| dist
)/
'''
87 changes: 41 additions & 46 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
#!/usr/bin/env python
from setuptools import setup, find_packages
from os import path
import codecs
import os
import re
import sys
from os import path

from setuptools import find_packages, setup

# When creating the sdist, make sure the django.mo file also exists:
if 'sdist' in sys.argv or 'develop' in sys.argv:
os.chdir('fluentcms_cookielaw')
if "sdist" in sys.argv or "develop" in sys.argv:
os.chdir("fluentcms_cookielaw")
try:
from django.core import management
management.call_command('compilemessages', stdout=sys.stderr, verbosity=1)

management.call_command("compilemessages", stdout=sys.stderr, verbosity=1)
except ImportError:
if 'sdist' in sys.argv:
if "sdist" in sys.argv:
raise
finally:
os.chdir('..')
os.chdir("..")


def read(*parts):
file_path = path.join(path.dirname(__file__), *parts)
return codecs.open(file_path, encoding='utf-8').read()
return codecs.open(file_path, encoding="utf-8").read()


def find_version(*parts):
Expand All @@ -34,49 +35,43 @@ def find_version(*parts):


setup(
name='fluentcms-cookielaw',
version=find_version('fluentcms_cookielaw', '__init__.py'),
license='Apache 2.0',

name="fluentcms-cookielaw",
version=find_version("fluentcms_cookielaw", "__init__.py"),
license="Apache 2.0",
install_requires=[
'django-fluent-contents>=2.0', # Need frontend_media support.
"django-fluent-contents>=2.0", # Need frontend_media support.
],
requires=[
'Django (>=1.10)',
"Django (>=1.10)",
],

description='A cookie notification banner for django-fluent-contents',
long_description=read('README.rst'),

author='Diederik van der Boor',
author_email='[email protected]',

url='https://github.com/edoburu/fluentcms-cookielaw',
download_url='https://github.com/edoburu/fluentcms-cookielaw/zipball/master',

packages=find_packages(exclude=('example*',)),
description="A cookie notification banner for django-fluent-contents",
long_description=read("README.rst"),
author="Diederik van der Boor",
author_email="[email protected]",
url="https://github.com/edoburu/fluentcms-cookielaw",
download_url="https://github.com/edoburu/fluentcms-cookielaw/zipball/master",
packages=find_packages(exclude=("example*",)),
include_package_data=True,

zip_safe=False,
classifiers=[
'Development Status :: 5 - Production/Stable',
'Environment :: Web Environment',
'Framework :: Django',
'Intended Audience :: Developers',
'License :: OSI Approved :: Apache Software License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.6',
'Framework :: Django',
'Framework :: Django :: 1.10',
'Framework :: Django :: 1.11',
'Framework :: Django :: 2.0',
'Topic :: Internet :: WWW/HTTP',
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
'Topic :: Software Development :: Libraries :: Python Modules',
]
"Development Status :: 5 - Production/Stable",
"Environment :: Web Environment",
"Framework :: Django",
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.6",
"Framework :: Django",
"Framework :: Django :: 1.10",
"Framework :: Django :: 1.11",
"Framework :: Django :: 2.0",
"Topic :: Internet :: WWW/HTTP",
"Topic :: Internet :: WWW/HTTP :: Dynamic Content",
"Topic :: Software Development :: Libraries :: Python Modules",
],
)

0 comments on commit d951fff

Please sign in to comment.