Skip to content

Commit a106481

Browse files
committed
make rouxcode/django-text-ckeditor optional
1 parent 4526ba4 commit a106481

File tree

9 files changed

+41
-9
lines changed

9 files changed

+41
-9
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Simple terms and condition notify app
55

66
## Install
77
```shell
8-
$ pip install -e git+https://github.com/rouxcode/django-tac@0.0.6#egg=django-tac
8+
$ pip install -e git+https://github.com/rouxcode/django-tac@0.0.7#egg=django-tac
99
```
1010

1111
## Usage
@@ -39,6 +39,10 @@ use the template tag:
3939
```html
4040
{% tac_popup %}
4141
```
42+
or if rouxcode/django-text-ckeditor is not installed
43+
```html
44+
{% tac_popup_no_ckeditor %}
45+
```
4246

4347
### javascript
4448
jquery needs to be loaded before:

tac/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from __future__ import unicode_literals
22

33

4-
__version__ = '0.0.6'
4+
__version__ = '0.0.7'
55
default_app_config = 'tac.apps.TACConfig'

tac/admin/__init__.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
from django.contrib import admin
44

5-
from .link import PopupLink, PopupLinkAdmin
6-
from .popup import PopupContent, PopupContentAdmin
7-
5+
try:
6+
from .link import PopupLink, PopupLinkAdmin
7+
admin.site.register(PopupLink, PopupLinkAdmin)
8+
except Exception:
9+
pass
810

11+
from .popup import PopupContent, PopupContentAdmin
912
admin.site.register(PopupContent, PopupContentAdmin)
10-
admin.site.register(PopupLink, PopupLinkAdmin)

tac/admin/popup.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
from django import forms
44
from django.contrib import admin
55

6-
from text_ckeditor.widgets import CKEditorWidget
6+
try:
7+
from text_ckeditor.widgets import CKEditorWidget
8+
except Exception:
9+
from .widgets import CKEditorWidget
710

811
from .. import conf
912
from ..models import PopupContent

tac/admin/widgets.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from __future__ import unicode_literals
2+
3+
from django import forms
4+
5+
6+
class CKEditorWidget(forms.Textarea):
7+
8+
def __init__(self, *args, **kwargs):
9+
try:
10+
kwargs.popu('conf')
11+
except Exception:
12+
pass
13+
14+
super(CKEditorWidget, self).__init__(*args, **kwargs)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{% if show %}<div class="tac-popup tac-popup-no-ckeditor">
2+
<div class="tac-popup-text">{{ object.text|safe }}</div>
3+
<a class="tac-popup-button" href="{{ url }}" data-apiurl="{{ apiurl }}">{{ object.get_button_label }}</a>
4+
</div>{% endif %}

tac/templatetags/tac_tags.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,8 @@ def tac_popup(context):
3535
'url': './?tac=accepted',
3636
'apiurl': reverse('tac-api-accept'),
3737
}
38+
39+
40+
@register.inclusion_tag('tac/tags/popup_no_ckeditor.html', takes_context=True)
41+
def tac_popup_no_ckeditor(context):
42+
return tac_popup(context)

testproject/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
'testproject',
4444
'tac',
4545
'compressor',
46-
'text_ckeditor',
46+
# 'text_ckeditor',
4747

4848
'django.contrib.redirects',
4949
'django.contrib.admin',

testproject/templates/base.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
{% placeholder 'body' %}
1414
{% endblock %}
1515
</div>
16-
{% tac_popup %}
16+
{% tac_popup_no_ckeditor %}
1717
{% compress js %}
1818
<script src="{{ STATIC_URL }}js/jquery.js"></script>
1919
<script src="{{ STATIC_URL }}tac/js/tac.accept.js"></script>

0 commit comments

Comments
 (0)