forked from bnzk/django-separate-users
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
33 changed files
with
1,267 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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,11 @@ | ||
|
||
==== 0.xxx (not yet) === | ||
|
||
- fix for djangocms-admin-styles | ||
|
||
|
||
==== 0.0.1 (not yet) === | ||
|
||
- support for django 1.9 | ||
- refactored tests, to use default manage.py test command | ||
|
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,7 @@ | ||
include LICENSES | ||
include README.rst | ||
global-exclude *.orig *.pyc *.log *.swp | ||
|
||
recursive-include separate_users/templates * | ||
recursive-include separate_users/static * | ||
recursive-include separate_users/locale * |
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,4 @@ | ||
|
||
cd separate_users | ||
django-admin.py compilemessages | ||
cd .. |
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 @@ | ||
|
||
|
||
cd separate_users | ||
django-admin.py makemessages -l en | ||
cd .. |
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,11 @@ | ||
#!/usr/bin/env python | ||
import os | ||
import sys | ||
|
||
if __name__ == "__main__": | ||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', | ||
'separate_users.tests.settings_runtestapp') | ||
|
||
from django.core.management import execute_from_command_line | ||
|
||
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,12 @@ | ||
|
||
|
||
git flow release start 0.xxx | ||
version bump in separate_users/__init__.py | ||
git flow release finish 0.xxx | ||
git push --all; git push --tags | ||
python setup.py sdist | ||
# no wheel for now?! 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/* |
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,2 @@ | ||
__version__ = '0.1.2' | ||
__author__ = 'benzkji' |
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,61 @@ | ||
from django.conf.urls import url | ||
from django.contrib import admin | ||
from django.db import models | ||
from django.http import JsonResponse | ||
|
||
|
||
class DjangoLinkAdmin(admin.ModelAdmin): | ||
|
||
def get_model_perms(self, request): | ||
""" | ||
http://stackoverflow.com/questions/2431727/django-admin-hide-a-model | ||
Return empty perms dict thus hiding the model from admin index. | ||
""" | ||
return {} | ||
|
||
def get_urls(self): | ||
""" | ||
add verify url. | ||
""" | ||
my_urls = [ | ||
url( | ||
r'^verify/$', | ||
self.admin_site.admin_view(self.verify), | ||
name=self._get_verify_url_name() | ||
), | ||
] | ||
return my_urls + super(DjangoLinkAdmin, self).get_urls() | ||
|
||
def _get_verify_url_name(self): | ||
return '{0}_{1}_verify'.format(self.model._meta.app_label, | ||
self.model._meta.model_name) | ||
|
||
def verify(self, request): | ||
""" | ||
verify data with modelform, send through data. | ||
:param request: | ||
:return: | ||
""" | ||
form = self.get_form(request, )(request.POST) | ||
if form.is_valid(): | ||
verified_data = form.cleaned_data | ||
obj = self.model(**verified_data) | ||
link_value = '' | ||
# prepopulate href | ||
if (getattr(obj, 'get_link', None)): | ||
link_value = obj.get_link() | ||
# basic serialize only | ||
for key, value in verified_data.items(): | ||
if isinstance(value, models.Model): | ||
verified_data[key] = value.id | ||
return_data = {"valid": 'true', 'data': verified_data, 'link_value': link_value} | ||
else: | ||
errors = form.errors | ||
return_data = {"valid": 'false', 'errors': errors} | ||
return JsonResponse(return_data) | ||
|
||
def save_model(self, request, obj, form, change): | ||
""" | ||
no save! | ||
""" | ||
return False |
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 @@ | ||
__author__ = 'benzkji' |
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,13 @@ | ||
""" | ||
These settings are used by the ``manage.py`` command. | ||
""" | ||
|
||
from .settings_test import * # NOQA | ||
|
||
|
||
DATABASES = { | ||
'default': { | ||
'ENGINE': 'django.db.backends.sqlite3', | ||
'NAME': 'db.sqlite', | ||
} | ||
} |
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,151 @@ | ||
"""Settings that need to be set in order to run the tests.""" | ||
import os | ||
import sys | ||
import tempfile | ||
import logging | ||
|
||
from django.core.urlresolvers import reverse_lazy | ||
|
||
|
||
DEBUG = True | ||
|
||
logging.getLogger("factory").setLevel(logging.WARN) | ||
|
||
# from selenium.webdriver.firefox import webdriver | ||
from selenium.webdriver.phantomjs import webdriver | ||
SELENIUM_WEBDRIVER = webdriver | ||
|
||
|
||
separate_users_MODEL = 'separate_users.tests.test_app.models.LinkModel' | ||
separate_users_IFRAME_URL = reverse_lazy('admin:test_app_linkmodel_add') | ||
separate_users_VERIFY_URL = reverse_lazy('admin:test_app_linkmodel_verify') | ||
|
||
CKEDITOR_CONFIGS = { | ||
'default': { | ||
'djangolinkIframeURL': separate_users_IFRAME_URL, | ||
'djangolinkVerifyURL': separate_users_VERIFY_URL, | ||
'linkShowAdvancedTab': False, | ||
'extraPlugins': ','.join( | ||
[ | ||
# your extra plugins here | ||
'djangolink', | ||
'autolink', | ||
'autoembed', | ||
'embedsemantic', | ||
'autogrow', | ||
'devtools', | ||
'widget', | ||
'lineutils', | ||
'clipboard', | ||
'dialog', | ||
'dialogui', | ||
'elementspath' | ||
]), | ||
'toolbar': 'Custom', | ||
'toolbar_Custom': [ | ||
['Bold', 'Underline'], | ||
['DjangoLink', 'Unlink'], | ||
['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'], | ||
['Link', 'Unlink'], | ||
['RemoveFormat', 'Source'] | ||
] | ||
} | ||
} | ||
|
||
SITE_ID = 1 | ||
|
||
APP_ROOT = os.path.abspath( | ||
os.path.join(os.path.dirname(__file__), "..")) | ||
|
||
DATABASES = { | ||
'default': { | ||
'ENGINE': 'django.db.backends.sqlite3', | ||
'NAME': ':memory:', | ||
} | ||
} | ||
|
||
LANGUAGE_CODE = 'en' | ||
LANGUAGES = ( | ||
('en', 'ENGLISHS' ), | ||
) | ||
|
||
ROOT_URLCONF = 'separate_users.tests.urls' | ||
|
||
# media root is overridden when needed in tests | ||
MEDIA_ROOT = tempfile.mkdtemp(suffix='ckeditor_media_root') | ||
MEDIA_URL = "/media/" | ||
STATIC_URL = '/static/' | ||
STATIC_ROOT = os.path.join(APP_ROOT, '../test_app_static') | ||
STATICFILES_DIRS = ( | ||
os.path.join(APP_ROOT, 'static'), | ||
) | ||
|
||
# TEMPLATE_DIRS = ( | ||
# os.path.join(APP_ROOT, 'tests/test_app/templates'), | ||
# ) | ||
|
||
COVERAGE_REPORT_HTML_OUTPUT_DIR = os.path.join( | ||
os.path.join(APP_ROOT, 'tests/coverage')) | ||
COVERAGE_MODULE_EXCLUDES = [ | ||
'tests$', 'settings$', 'urls$', 'locale$', | ||
'migrations', 'fixtures', 'admin$', 'django_extensions', | ||
] | ||
|
||
EXTERNAL_APPS = ( | ||
'django.contrib.admin', | ||
# 'django.contrib.admindocs', | ||
'django.contrib.auth', | ||
'django.contrib.contenttypes', | ||
'django.contrib.messages', | ||
'django.contrib.sessions', | ||
'django.contrib.staticfiles', | ||
'django.contrib.sitemaps', | ||
'django.contrib.sites', | ||
'ckeditor', | ||
# 'djangocms_text_ckeditor', | ||
# 'cms', | ||
# 'treebeard', | ||
# 'menus', | ||
) | ||
|
||
TEMPLATES = [ | ||
{ | ||
'BACKEND': 'django.template.backends.django.DjangoTemplates', | ||
'OPTIONS': { | ||
'context_processors': [ | ||
'django.template.context_processors.debug', | ||
'django.contrib.auth.context_processors.auth', | ||
'django.contrib.messages.context_processors.messages', | ||
'django.template.context_processors.i18n', | ||
'django.template.context_processors.request', | ||
'django.template.context_processors.media', | ||
'django.template.context_processors.static', | ||
], | ||
'loaders': [ | ||
'django.template.loaders.filesystem.Loader', | ||
'django.template.loaders.app_directories.Loader', | ||
# 'django.template.loaders.eggs.Loader', | ||
], | ||
} | ||
}, | ||
] | ||
|
||
|
||
INTERNAL_APPS = ( | ||
'separate_users', | ||
'separate_users.tests.test_app', | ||
) | ||
|
||
MIDDLEWARE_CLASSES = ( | ||
'django.contrib.sessions.middleware.SessionMiddleware', | ||
'django.contrib.auth.middleware.AuthenticationMiddleware', | ||
'django.contrib.messages.middleware.MessageMiddleware', | ||
# Uncomment the next line for simple clickjacking protection: | ||
'django.middleware.clickjacking.XFrameOptionsMiddleware', | ||
'django.middleware.locale.LocaleMiddleware', | ||
) | ||
|
||
INSTALLED_APPS = EXTERNAL_APPS + INTERNAL_APPS | ||
COVERAGE_MODULE_EXCLUDES += EXTERNAL_APPS | ||
|
||
SECRET_KEY = 'foobarXXXxxsvXY' |
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,18 @@ | ||
from django import forms | ||
from django.contrib import admin | ||
from django.forms.extras.widgets import SelectDateWidget | ||
|
||
from separate_users.admin import DjangoLinkAdmin | ||
|
||
from .models import TestModel, LinkModel | ||
|
||
|
||
class LinkModelForm(forms.ModelForm): | ||
when = forms.DateField(widget=SelectDateWidget, required=False) | ||
|
||
|
||
class CKLinkModelAdmin(DjangoLinkAdmin): | ||
form = LinkModelForm | ||
|
||
admin.site.register(TestModel) | ||
admin.site.register(LinkModel, CKLinkModelAdmin) |
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": "test_app.testmodel", "pk": 1, "fields": {"title": "Test 2", "richtext": "<p>None</p>", "richtext_second": ""}}, {"model": "test_app.testmodel", "pk": 2, "fields": {"title": "Testing different Link Form Widgets", "richtext": "<p>One Two <a data-ckeditor-link=\"true\" data-email=\"\" data-external_url=\"\" data-target=\"_blank\" data-when=\"2018-02-03\" href=\"http://no-link-given.com/\">Link One (Date Link, haha)</a></p>\r\n\r\n<p><a data-ckeditor-link=\"true\" data-email=\"\" data-external_url=\"\" data-target=\"\" data-testmodel=\"1\" href=\"http://no-link-given.com/\">Link Two (Foreign Key)</a></p>\r\n\r\n<p>what</p>", "richtext_second": "<p><a data-ckeditor-link=\"true\" data-email=\"\" data-external_url=\"\" data-target=\"asdvads\" data-testmodel=\"2\" href=\"http://no-link-given.com/\">sdvasdva</a> <a data-ckeditor-link=\"true\" data-email=\"\" data-external_url=\"sadv\" data-target=\"sdvatest\" data-testmodel=\"1\" href=\"sadv\">link</a></p>"}}] |
Oops, something went wrong.