Commit f9f707e8dc23d4d9c5f389c680c193ccf4953bf9
1 parent
4e06051e
Exists in
master
and in
5 other branches
Adding WYSIWYG editor Summernote [Issue #232]
Showing
4 changed files
with
74 additions
and
9 deletions
Show diff stats
amadeus/settings.py
| @@ -46,6 +46,7 @@ INSTALLED_APPS = [ | @@ -46,6 +46,7 @@ INSTALLED_APPS = [ | ||
| 46 | 'rest_framework', | 46 | 'rest_framework', |
| 47 | 'django_bootstrap_breadcrumbs', | 47 | 'django_bootstrap_breadcrumbs', |
| 48 | 's3direct', | 48 | 's3direct', |
| 49 | + 'django_summernote', | ||
| 49 | 50 | ||
| 50 | 'users', | 51 | 'users', |
| 51 | 'core', | 52 | 'core', |
| @@ -225,7 +226,59 @@ S3DIRECT_DESTINATIONS = { | @@ -225,7 +226,59 @@ S3DIRECT_DESTINATIONS = { | ||
| 225 | # FILE UPLOAD | 226 | # FILE UPLOAD |
| 226 | MAX_UPLOAD_SIZE = 10485760 | 227 | MAX_UPLOAD_SIZE = 10485760 |
| 227 | 228 | ||
| 229 | +SUMMERNOTE_CONFIG = { | ||
| 230 | + # Using SummernoteWidget - iframe mode | ||
| 231 | + 'iframe': True, # or set False to use SummernoteInplaceWidget - no iframe mode | ||
| 232 | + | ||
| 233 | + # Using Summernote Air-mode | ||
| 234 | + 'airMode': False, | ||
| 235 | + | ||
| 236 | + # Use native HTML tags (`<b>`, `<i>`, ...) instead of style attributes | ||
| 237 | + # (Firefox, Chrome only) | ||
| 238 | + 'styleWithTags': True, | ||
| 239 | + | ||
| 240 | + # Set text direction : 'left to right' is default. | ||
| 241 | + 'direction': 'ltr', | ||
| 242 | + | ||
| 243 | + # Change editor size | ||
| 244 | + 'width': '100%', | ||
| 245 | + 'height': '480', | ||
| 246 | + | ||
| 247 | + # Use proper language setting automatically (default) | ||
| 248 | + 'lang': None, | ||
| 249 | + | ||
| 250 | + # Or, set editor language/locale forcely | ||
| 251 | + 'lang_matches': { | ||
| 252 | + 'pt': 'pt-BR', | ||
| 253 | + }, | ||
| 254 | + | ||
| 255 | + # Customize toolbar buttons | ||
| 256 | + 'toolbar': [ | ||
| 257 | + ['style', ['style']], | ||
| 258 | + ['font', ['bold', 'italic', 'underline', 'superscript', 'subscript', | ||
| 259 | + 'strikethrough', 'clear']], | ||
| 260 | + ['fontname', ['fontname']], | ||
| 261 | + ['fontsize', ['fontsize']], | ||
| 262 | + ['color', ['color']], | ||
| 263 | + ['para', ['ul', 'ol', 'paragraph']], | ||
| 264 | + ['height', ['height']], | ||
| 265 | + ['table', ['table']], | ||
| 266 | + ['insert', ['link', 'picture', 'video', 'hr']], | ||
| 267 | + ['view', ['fullscreen', 'codeview']], | ||
| 268 | + ['help', ['help']], | ||
| 269 | + ], | ||
| 270 | + | ||
| 271 | + # Need authentication while uploading attachments. | ||
| 272 | + 'attachment_require_authentication': True, | ||
| 273 | + | ||
| 274 | + # Set `upload_to` function for attachments. | ||
| 275 | + #'attachment_upload_to': my_custom_upload_to_func(), | ||
| 276 | + | ||
| 277 | + | ||
| 278 | + | ||
| 279 | +} | ||
| 280 | + | ||
| 228 | try: | 281 | try: |
| 229 | from .local_settings import * | 282 | from .local_settings import * |
| 230 | except ImportError: | 283 | except ImportError: |
| 231 | - pass | 284 | - pass |
| 285 | + pass | ||
| 232 | \ No newline at end of file | 286 | \ No newline at end of file |
amadeus/urls.py
| @@ -28,6 +28,7 @@ urlpatterns = [ | @@ -28,6 +28,7 @@ urlpatterns = [ | ||
| 28 | 28 | ||
| 29 | #S3Direct | 29 | #S3Direct |
| 30 | url(r'^s3direct/', include('s3direct.urls')), | 30 | url(r'^s3direct/', include('s3direct.urls')), |
| 31 | + url(r'^summernote/', include('django_summernote.urls')), | ||
| 31 | ] | 32 | ] |
| 32 | 33 | ||
| 33 | urlpatterns += static(settings.MEDIA_URL, document_root = settings.MEDIA_ROOT) | 34 | urlpatterns += static(settings.MEDIA_URL, document_root = settings.MEDIA_ROOT) |
courses/forms.py
| @@ -2,7 +2,7 @@ from django import forms | @@ -2,7 +2,7 @@ from django import forms | ||
| 2 | from django.utils.translation import ugettext_lazy as _ | 2 | from django.utils.translation import ugettext_lazy as _ |
| 3 | from .models import CourseCategory, Course, Subject, Topic, ActivityFile, Activity, FileMaterial, LinkMaterial | 3 | from .models import CourseCategory, Course, Subject, Topic, ActivityFile, Activity, FileMaterial, LinkMaterial |
| 4 | from s3direct.widgets import S3DirectWidget | 4 | from s3direct.widgets import S3DirectWidget |
| 5 | - | 5 | +from django_summernote.widgets import SummernoteWidget |
| 6 | 6 | ||
| 7 | class CategoryCourseForm(forms.ModelForm): | 7 | class CategoryCourseForm(forms.ModelForm): |
| 8 | 8 | ||
| @@ -79,8 +79,8 @@ class CourseForm(forms.ModelForm): | @@ -79,8 +79,8 @@ class CourseForm(forms.ModelForm): | ||
| 79 | 79 | ||
| 80 | widgets = { | 80 | widgets = { |
| 81 | 'categoy': forms.Select(), | 81 | 'categoy': forms.Select(), |
| 82 | - 'objectivies': forms.Textarea(attrs={'cols': 80, 'rows': 5}), | ||
| 83 | - 'content': forms.Textarea(attrs={'cols': 80, 'rows': 5}), | 82 | + 'objectivies': SummernoteWidget(attrs={'cols': 80, 'rows': 5}), |
| 83 | + 'content': SummernoteWidget(attrs={'cols': 80, 'rows': 5}), | ||
| 84 | } | 84 | } |
| 85 | 85 | ||
| 86 | class UpdateCourseForm(CourseForm): | 86 | class UpdateCourseForm(CourseForm): |
| @@ -120,8 +120,8 @@ class UpdateCourseForm(CourseForm): | @@ -120,8 +120,8 @@ class UpdateCourseForm(CourseForm): | ||
| 120 | } | 120 | } |
| 121 | widgets = { | 121 | widgets = { |
| 122 | 'categoy': forms.Select(), | 122 | 'categoy': forms.Select(), |
| 123 | - 'objectivies': forms.Textarea(attrs={'cols': 80, 'rows': 5}), | ||
| 124 | - 'content': forms.Textarea(attrs={'cols': 80, 'rows': 5}), | 123 | + 'objectivies': SummernoteWidget(attrs={'cols': 80, 'rows': 5}), |
| 124 | + 'content': SummernoteWidget(attrs={'cols': 80, 'rows': 5}), | ||
| 125 | } | 125 | } |
| 126 | 126 | ||
| 127 | class SubjectForm(forms.ModelForm): | 127 | class SubjectForm(forms.ModelForm): |
| @@ -143,6 +143,9 @@ class SubjectForm(forms.ModelForm): | @@ -143,6 +143,9 @@ class SubjectForm(forms.ModelForm): | ||
| 143 | 'end_date': _('End date of the subject'), | 143 | 'end_date': _('End date of the subject'), |
| 144 | 'visible': _('Is the subject visible?'), | 144 | 'visible': _('Is the subject visible?'), |
| 145 | } | 145 | } |
| 146 | + widgets = { | ||
| 147 | + 'description':SummernoteWidget(), | ||
| 148 | + } | ||
| 146 | 149 | ||
| 147 | class TopicForm(forms.ModelForm): | 150 | class TopicForm(forms.ModelForm): |
| 148 | 151 | ||
| @@ -157,6 +160,9 @@ class TopicForm(forms.ModelForm): | @@ -157,6 +160,9 @@ class TopicForm(forms.ModelForm): | ||
| 157 | 'name': _("Topic's name"), | 160 | 'name': _("Topic's name"), |
| 158 | 'description': _("Topic's description"), | 161 | 'description': _("Topic's description"), |
| 159 | } | 162 | } |
| 163 | + widgets = { | ||
| 164 | + 'description':SummernoteWidget(), | ||
| 165 | + } | ||
| 160 | 166 | ||
| 161 | class ActivityFileForm(forms.ModelForm): | 167 | class ActivityFileForm(forms.ModelForm): |
| 162 | name = forms.CharField( | 168 | name = forms.CharField( |
requirements.txt
| 1 | +beautifulsoup4==4.5.1 | ||
| 1 | click==6.6 | 2 | click==6.6 |
| 2 | decorator==4.0.10 | 3 | decorator==4.0.10 |
| 3 | deps==0.1.0 | 4 | deps==0.1.0 |
| @@ -10,18 +11,22 @@ django-floppyforms==1.7.0 | @@ -10,18 +11,22 @@ django-floppyforms==1.7.0 | ||
| 10 | django-modalview==0.1.5 | 11 | django-modalview==0.1.5 |
| 11 | django-role-permissions==1.2.1 | 12 | django-role-permissions==1.2.1 |
| 12 | django-s3direct==0.4.2 | 13 | django-s3direct==0.4.2 |
| 14 | +django-summernote==0.8.6 | ||
| 13 | django-widget-tweaks==1.4.1 | 15 | django-widget-tweaks==1.4.1 |
| 16 | +django-wysiwyg==0.8.0 | ||
| 14 | djangorestframework==3.4.6 | 17 | djangorestframework==3.4.6 |
| 15 | gunicorn==19.6.0 | 18 | gunicorn==19.6.0 |
| 19 | +itsdangerous==0.24 | ||
| 16 | Jinja2==2.8 | 20 | Jinja2==2.8 |
| 21 | +lxml==3.6.4 | ||
| 17 | MarkupSafe==0.23 | 22 | MarkupSafe==0.23 |
| 18 | Pillow==3.3.1 | 23 | Pillow==3.3.1 |
| 19 | psycopg2==2.6.2 | 24 | psycopg2==2.6.2 |
| 20 | pycpfcnpj==1.0.2 | 25 | pycpfcnpj==1.0.2 |
| 26 | +requests==2.11.1 | ||
| 21 | six==1.10.0 | 27 | six==1.10.0 |
| 28 | +slugify==0.0.1 | ||
| 22 | validators==0.11.0 | 29 | validators==0.11.0 |
| 30 | +virtualenv==15.0.3 | ||
| 23 | Werkzeug==0.11.11 | 31 | Werkzeug==0.11.11 |
| 24 | whitenoise==3.2.2 | 32 | whitenoise==3.2.2 |
| 25 | -beautifulsoup4==4.5.1 | ||
| 26 | -lxml==3.6.4 | ||
| 27 | -requests==2.11.1 |