-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 42ced3c
Showing
37 changed files
with
1,024 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
*.log | ||
*.pot | ||
*.pyc | ||
*.egg-info | ||
*.sqlite | ||
*.coverage | ||
*~ | ||
.DS_Store | ||
.tmp* | ||
local_settings.py | ||
build | ||
storage | ||
docs/_build | ||
dist | ||
data | ||
htmlcov | ||
.idea | ||
.tox | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2015 Alaric Mägerle | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# django-tac | ||
|
||
Simple terms and condition notify app | ||
|
||
|
||
## Install | ||
```shell | ||
$ pip install -e git+https://github.com/rouxcode/[email protected]#egg=django-tac | ||
``` | ||
|
||
## Usage | ||
add tac to your installed apps: | ||
```python | ||
INSTALLED_APPS = ( | ||
'tac', | ||
'...' | ||
) | ||
``` | ||
|
||
add the middleware: | ||
```python | ||
MIDDLEWARE = [ | ||
'tac.middleware.TACMiddleware', | ||
'...' | ||
] | ||
```` | ||
|
||
if desired load initial data | ||
```shell | ||
$ ./manage.py tac_load_inital | ||
``` | ||
or create at least one popupcontent entry | ||
|
||
use the template tag: | ||
```html | ||
{% tac_popup %} | ||
``` | ||
|
||
if desired js (jquery needs to be loaded before): | ||
```html | ||
<script src="{{ STATIC_URL }}tac/js/tac.accept.js"></script> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/usr/bin/env python | ||
import os | ||
import sys | ||
|
||
if __name__ == "__main__": | ||
os.environ.setdefault( | ||
"DJANGO_SETTINGS_MODULE", | ||
"testproject.settings" | ||
) | ||
try: | ||
from django.core.management import execute_from_command_line | ||
except ImportError: | ||
# The above import may fail for some other reason. Ensure that the | ||
# issue is really that Django is missing to avoid masking other | ||
# exceptions on Python 2. | ||
try: | ||
import django # NOQA | ||
except ImportError: | ||
raise ImportError( | ||
"Couldn't import Django. Are you sure it's installed and " | ||
"available on your PYTHONPATH environment variable? Did you " | ||
"forget to activate a virtual environment?" | ||
) | ||
raise | ||
execute_from_command_line(sys.argv) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
|
||
# dont change any files besides CHANGELOG.txt and __init__.py during procedure. | ||
|
||
git flow release start xxxx | ||
version bump in admin_sort/__init__.py | ||
last chance to update CHANGELOG! | ||
git commit -am'version bump / changelog' | ||
git flow release finish xxxx | ||
git push --all; git push --tags | ||
# upstream: depends | ||
git push upstream --all; git push upstream --tags | ||
python setup.py sdist && python setup.py bdist_wheel --universal | ||
python setup.py register -r pypitest && twine upload dist/* -r pypitest | ||
python setup.py register -r pypi && twine upload dist/* -r pypi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
from setuptools import setup, find_packages | ||
from admin_sort import __version__ | ||
|
||
try: | ||
from pypandoc import convert | ||
except ImportError: | ||
def convert(filename, fmt): | ||
with open(filename) as fd: | ||
return fd.read() | ||
|
||
|
||
DESCRIPTION = 'Django tac' | ||
|
||
CLASSIFIERS = [ | ||
'Environment :: Web Environment', | ||
'Framework :: Django', | ||
'Intended Audience :: Developers', | ||
'License :: OSI Approved :: MIT License', | ||
'Operating System :: OS Independent', | ||
'Programming Language :: Python', | ||
'Topic :: Software Development :: Libraries :: Python Modules', | ||
'Development Status :: 3 - Alpha', | ||
] | ||
|
||
|
||
setup( | ||
name='django-tac', | ||
version=__version__, | ||
author='Alaric Mägerle', | ||
author_email='[email protected]', | ||
description=DESCRIPTION, | ||
long_description=convert('README.md', 'rst', format='md'), | ||
url='https://github.com/rouxcode/django-tac', | ||
license='MIT', | ||
keywords=['django'], | ||
platforms=['OS Independent'], | ||
classifiers=CLASSIFIERS, | ||
install_requires=[], | ||
packages=find_packages(exclude=['example', 'docs']), | ||
include_package_data=True, | ||
zip_safe=False, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from __future__ import unicode_literals | ||
|
||
|
||
__version__ = '0.0.1' | ||
default_app_config = 'tac.apps.TACConfig' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from __future__ import unicode_literals | ||
|
||
from django.contrib import admin | ||
|
||
from .link import PopupLink, PopupLinkAdmin | ||
from .popup import PopupContent, PopupContentAdmin | ||
|
||
|
||
admin.site.register(PopupContent, PopupContentAdmin) | ||
admin.site.register(PopupLink, PopupLinkAdmin) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from __future__ import unicode_literals | ||
|
||
from django import forms | ||
|
||
from text_ckeditor.admin import DjangoLinkAdmin | ||
|
||
from .. import conf | ||
from ..models import PopupLink | ||
|
||
|
||
class PopupLinkAdminForm(forms.ModelForm): | ||
|
||
class Meta: | ||
fields = '__all__' | ||
model = PopupLink | ||
widgets = {} | ||
|
||
|
||
class PopupLinkAdmin(DjangoLinkAdmin): | ||
|
||
fieldsets = conf.LINK_FIELDSETS | ||
form = PopupLinkAdminForm | ||
|
||
class Media: | ||
css = { | ||
'all': ['admin/links/css/link.ckeditor.css'] | ||
} | ||
js = ( | ||
'admin/links/js/link.type.js', | ||
) | ||
|
||
def formfield_for_dbfield(self, db_field, **kwargs): | ||
if db_field.name == "link_type": | ||
# add link_type choices defined by the actual model | ||
db_field.choices = self.model.link_type_choices | ||
db_field.widget = forms.Select | ||
return super(PopupLinkAdmin, self).formfield_for_dbfield( | ||
db_field, | ||
**kwargs | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from __future__ import unicode_literals | ||
|
||
from django import forms | ||
from django.contrib import admin | ||
|
||
from text_ckeditor.widgets import CKEditorWidget | ||
|
||
from .. import conf | ||
from ..models import PopupContent | ||
|
||
|
||
class PopupContentAdminForm(forms.ModelForm): | ||
|
||
class Meta: | ||
fields = '__all__' | ||
model = PopupContent | ||
widgets = { | ||
'text': CKEditorWidget(conf.CKEDITOR_CONF) | ||
} | ||
|
||
|
||
class PopupContentAdmin(admin.ModelAdmin): | ||
|
||
form = PopupContentAdminForm | ||
list_display = [ | ||
'get_admin_title', | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from __future__ import unicode_literals | ||
|
||
from django.apps import AppConfig | ||
from django.utils.translation import ugettext_lazy as _ | ||
|
||
|
||
class TACConfig(AppConfig): | ||
name = 'tac' | ||
verbose_name = _('Datenschutz') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from __future__ import unicode_literals | ||
|
||
from django.utils.translation import ugettext_lazy as _ | ||
|
||
|
||
TAC_ACCEPTED_SESSION_KEY = 'tac_accepted' | ||
|
||
LANGUAGES = [ | ||
('de', 'De'), | ||
('en', 'En'), | ||
('fr', 'Fr'), | ||
('it', 'It'), | ||
('es', 'Es'), | ||
] | ||
|
||
CKEDITOR_CONF = { | ||
'height': 100, | ||
'width': '100%', | ||
'skin': 'moono-lisa', | ||
'uiColor': '#ffffff', | ||
'extraPlugins': 'djangolink', | ||
'toolbar': [ | ||
['Bold'], | ||
['DjangoLink', 'Unlink'], | ||
], | ||
} | ||
|
||
|
||
LINK_FIELDSETS = [ | ||
(_('Target'), { | ||
'classes': [ | ||
'section', | ||
'link', | ||
'page-anchors-js', | ||
], | ||
'fields': [ | ||
'link_type', | ||
'link_cms_page', | ||
'link_url', | ||
], | ||
}), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[{"model": "tac.popupcontent", "pk": 1, "fields": {"name": "Text Deutsch 1", "language": "de", "text": "<p>beispiel.ch benutzt Cookies, um seinen Lesern das beste Webseiten-Erlebnis zu ermöglichen. Außerdem werden teilweise auch Cookies von Diensten Dritter gesetzt. Weiterführende Informationen erhalten Sie in der <a data-djangolink=\"true\" data-link_cms_page=\"3\" data-link_url=\"\" data-link_type=\"link_cms_page\" href=\"/de/datenschutz/\">Datenschutzerklärung</a> von beispiel.ch.</p>", "button_label": "Ich habe verstanden!"}}] |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import os | ||
|
||
from django.core import management | ||
from django.core.management.base import BaseCommand | ||
|
||
from tac.models import PopupContent | ||
|
||
|
||
class Command(BaseCommand): | ||
|
||
def handle(self, *args, **options): | ||
if PopupContent.objects.all().count() > 0: | ||
print('nothing loaded: there is allready content') | ||
return | ||
file = os.path.abspath( | ||
os.path.join( | ||
os.path.dirname(__file__), | ||
'..', | ||
'..', | ||
'fixtures', | ||
'tac.popupcontent.json', | ||
) | ||
) | ||
if os.path.isfile(file): | ||
management.call_command('loaddata', file, verbosity=0) | ||
else: | ||
print('fixture file missing') | ||
print('tac initial data imported') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from __future__ import unicode_literals | ||
|
||
from django import forms | ||
|
||
from . import conf | ||
|
||
|
||
class TACAcceptedForm(forms.Form): | ||
tac = forms.ChoiceField( | ||
choices=[ | ||
('accepted', 'accepted'), | ||
] | ||
) | ||
|
||
|
||
class TACMiddleware(object): | ||
|
||
def __init__(self, get_response): | ||
self.get_response = get_response | ||
|
||
def __call__(self, request): | ||
request = self.process_request(request) | ||
response = self.process_response(request) | ||
return response | ||
|
||
def process_request(self, request): | ||
form = TACAcceptedForm(request.GET) | ||
if form.is_valid(): | ||
request.session[conf.TAC_ACCEPTED_SESSION_KEY] = True | ||
return request | ||
|
||
def process_response(self, request): | ||
response = self.get_response(request) | ||
return response |
Oops, something went wrong.