BO 1.9.2 ckeditor

This commit is contained in:
Bossanyi Tibor 2021-04-24 19:23:01 +02:00
parent a3418cfd91
commit eacefb27b6
8 changed files with 28 additions and 15 deletions

View File

@ -0,0 +1,6 @@
{% extends "admin/base_site.html" %}
{% block extrahead %}
<script>window.CKEDITOR_BASEPATH = '/static/ckeditor/ckeditor/';</script>
{{ block.super }}
{% endblock %}

View File

@ -1,6 +1,6 @@
from django.db import models from django.db import models
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from froala_editor.fields import FroalaField from ckeditor.fields import RichTextField
from .enums import LanguageTypes from .enums import LanguageTypes
from .exercise_device import ExerciseDevice from .exercise_device import ExerciseDevice
@ -21,7 +21,7 @@ class ExerciseType(models.Model):
exercise_type_id = models.AutoField(primary_key=True) exercise_type_id = models.AutoField(primary_key=True)
name = models.CharField(max_length=100, help_text='The name should be in English here') name = models.CharField(max_length=100, help_text='The name should be in English here')
#description = models.TextField(max_length=1000, blank=True, null=True, help_text='The description should be in English here') #description = models.TextField(max_length=1000, blank=True, null=True, help_text='The description should be in English here')
description = FroalaField() description = RichTextField()
unit = models.CharField(choices=UnitTypes.choices, default=UnitTypes.REPEAT, max_length=50, blank=True, null=True) unit = models.CharField(choices=UnitTypes.choices, default=UnitTypes.REPEAT, max_length=50, blank=True, null=True)
unit_quantity = models.BooleanField(default=0, blank=True, null=True) unit_quantity = models.BooleanField(default=0, blank=True, null=True)
unit_quantity_unit = models.CharField(choices=UnitTypes.choices, default=UnitTypes.KG, max_length=50, blank=True, unit_quantity_unit = models.CharField(choices=UnitTypes.choices, default=UnitTypes.KG, max_length=50, blank=True,
@ -67,7 +67,7 @@ class ExerciseTypeTranslation(models.Model):
language_code = models.CharField(max_length=2, choices=LanguageTypes.choices, default=LanguageTypes.HU) language_code = models.CharField(max_length=2, choices=LanguageTypes.choices, default=LanguageTypes.HU)
name = models.CharField(max_length=100) name = models.CharField(max_length=100)
#description = models.TextField(max_length=1000, blank=True, null=True) #description = models.TextField(max_length=1000, blank=True, null=True)
description = FroalaField(blank=True, null=True) description = RichTextField(blank=True, null=True)
class Meta: class Meta:
db_table = 'exercise_type_translation' db_table = 'exercise_type_translation'

View File

@ -1,6 +1,6 @@
from django.db import models from django.db import models
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from froala_editor.fields import FroalaField from ckeditor.fields import RichTextField
from .enums import LanguageTypes from .enums import LanguageTypes
@ -23,8 +23,8 @@ class TutorialSteps(models.Model):
tutorial_step_id = models.AutoField(primary_key=True) tutorial_step_id = models.AutoField(primary_key=True)
tutorial = models.ForeignKey(Tutorial, on_delete=models.CASCADE) tutorial = models.ForeignKey(Tutorial, on_delete=models.CASCADE)
step = models.IntegerField(help_text="Tutorial Step") step = models.IntegerField(help_text="Tutorial Step")
tutorial_text = FroalaField() tutorial_text = RichTextField()
error_text = FroalaField(blank=True, null=True) error_text = RichTextField(blank=True, null=True)
check_text = models.TextField(max_length=50, blank=True, null=True, help_text="Only for programmers!") check_text = models.TextField(max_length=50, blank=True, null=True, help_text="Only for programmers!")
class Meta: class Meta:
@ -37,8 +37,8 @@ class TutorialTranslation(models.Model):
translation_id = models.AutoField(primary_key=True) translation_id = models.AutoField(primary_key=True)
tutorial_step = models.ForeignKey(TutorialSteps, on_delete=models.CASCADE) tutorial_step = models.ForeignKey(TutorialSteps, on_delete=models.CASCADE)
language_code = models.CharField(max_length=2, choices=LanguageTypes.choices, default=LanguageTypes.HU) language_code = models.CharField(max_length=2, choices=LanguageTypes.choices, default=LanguageTypes.HU)
tutorial_text = FroalaField() tutorial_text = RichTextField()
error_text = FroalaField(blank=True, null=True) error_text = RichTextField(blank=True, null=True)
class Meta: class Meta:
db_table = 'tutorial_translation' db_table = 'tutorial_translation'

View File

@ -44,7 +44,8 @@ INSTALLED_APPS = [
'django.contrib.sessions', 'django.contrib.sessions',
'django.contrib.messages', 'django.contrib.messages',
'django.contrib.staticfiles', 'django.contrib.staticfiles',
'froala_editor' 'ckeditor',
'ckeditor_uploader',
] ]
MIDDLEWARE = [ MIDDLEWARE = [
@ -129,8 +130,10 @@ STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, "static") STATIC_ROOT = os.path.join(BASE_DIR, "static")
STATIC_JS_DIR = os.path.join(STATIC_URL, "js") STATIC_JS_DIR = os.path.join(STATIC_URL, "js")
MEDIA_URL = '/media/' MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media') MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
CKEDITOR_UPLOAD_PATH = MEDIA_URL
LOGGING = { LOGGING = {
'version': 1, 'version': 1,

View File

@ -40,7 +40,8 @@ INSTALLED_APPS = [
'django.contrib.sessions', 'django.contrib.sessions',
'django.contrib.messages', 'django.contrib.messages',
'django.contrib.staticfiles', 'django.contrib.staticfiles',
'froala_editor' 'ckeditor',
'ckeditor_uploader',
] ]
MIDDLEWARE = [ MIDDLEWARE = [
@ -79,8 +80,8 @@ WSGI_APPLICATION = 'aitrainer_backoffice.wsgi.application'
DATABASES = { DATABASES = {
'default': { 'default': {
'ENGINE': 'django.db.backends.mysql', 'ENGINE': 'django.db.backends.mysql',
'NAME': 'aitrainer', 'NAME': 'aitrainer_test',
'USER': 'aitrainer_test', 'USER': 'aitrainer',
'PASSWORD': 'andio2009', 'PASSWORD': 'andio2009',
'HOST': '62.171.188.119', 'HOST': '62.171.188.119',
'PORT': 33060 'PORT': 33060
@ -126,6 +127,7 @@ STATIC_ROOT = os.path.join(BASE_DIR, "static")
MEDIA_URL = '/media/' MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media') MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
CKEDITOR_UPLOAD_PATH = MEDIA_URL
LOGGING = { LOGGING = {
'version': 1, 'version': 1,

View File

@ -20,13 +20,14 @@ from django.conf import settings #
from django.conf.urls.static import static # n from django.conf.urls.static import static # n
from django.contrib import admin from django.contrib import admin
from django.urls import path, include from django.urls import path, include
from froala_editor import views
urlpatterns = [ urlpatterns = [
path('admin/', admin.site.urls), path('admin/', admin.site.urls),
path('froala_editor/',include('froala_editor.urls')) path(r'^ckeditor/', include('ckeditor_uploader.urls')),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
admin.site.site_header = 'WorkoutTest Admin' admin.site.site_header = 'WorkoutTest Admin'

View File

@ -0,0 +1 @@
python manage.py collectstatic --settings aitrainer_backoffice.settings.dev

View File

@ -1,5 +1,5 @@
django==3.2 django==3.2
django-froala-editor=3.2.6-1 django-ckeditor==6.0.0
asgiref==3.3.4 asgiref==3.3.4
certifi==2020.6.20 certifi==2020.6.20
chardet==3.0.4 chardet==3.0.4