Skip to content

Commit

Permalink
Update resource description field to a WYSIWYG editor in the admin. (#…
Browse files Browse the repository at this point in the history
…241)

* Update resource admin form description widget

* Test static files is configured for ckeditor

* remove branch from github workflows
  • Loading branch information
Afani97 authored Nov 17, 2023
1 parent 89c910e commit 6087289
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: deploy

on:
push:
branches: [main, develop, 112-deploy-fix]
branches: [main, develop]

jobs:
deploy:
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/Components/ResourcePage/ResourcePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function Resource({ resource }) {
<div>
<H2>{resource.title} </H2>
{resource.publication_date && <P size={14}>{resourcePublicationDate}</P>}
<P size={18}>{resource.description}</P>
<P size={18} dangerouslySetInnerHTML={{ __html: resource.description }} />
<div style={{ display: 'flex', flexWrap: 'wrap', gap: '5px' }}>
{resource.agencies_list.map((a) => (
<S.ResourceTag href={`/agencies/${a.id}`}>{a.name}</S.ResourceTag>
Expand Down
12 changes: 12 additions & 0 deletions nc/admin.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from ckeditor.widgets import CKEditorWidget
from django import forms
from django.contrib import admin

from nc.models import Agency, Resource, ResourceFile, StopSummary
Expand Down Expand Up @@ -52,6 +54,15 @@ class InlineResourceFile(admin.StackedInline):
extra = 0


class ResourceForm(forms.ModelForm):
# https://django-ckeditor.readthedocs.io/en/latest/#widget
description = forms.CharField(widget=CKEditorWidget())

class Meta:
model = Resource
fields = "__all__"


class ResourceAdmin(admin.ModelAdmin):
fields = (
"agencies",
Expand All @@ -70,6 +81,7 @@ class ResourceAdmin(admin.ModelAdmin):
filter_horizontal = ("agencies",)
inlines = [InlineResourceFile]
readonly_fields = ("created_date",)
form = ResourceForm

def save_model(self, request, obj, form, change):
super().save_model(request, obj, form, change)
Expand Down
1 change: 1 addition & 0 deletions requirements/base/base.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ boto3==1.26.87
botocore==1.29.109
click==8.1.3
django-cache-machine==1.2.0
django-ckeditor==6.7.0
django-click==2.3.0
django-crispy-forms
django-dotenv
Expand Down
8 changes: 7 additions & 1 deletion requirements/base/base.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# This file is autogenerated by pip-compile with Python 3.8
# This file is autogenerated by pip-compile with Python 3.9
# by the following command:
#
# pip-compile --output-file=requirements/base/base.txt requirements/base/base.in
Expand Down Expand Up @@ -38,13 +38,17 @@ dj-database-url==0.5.0
django==3.2.14
# via
# -r requirements/base/base.in
# django-ckeditor
# django-filter
# django-js-asset
# django-memoize
# django-redis
# django-storages
# djangorestframework
django-cache-machine==1.2.0
# via -r requirements/base/base.in
django-ckeditor==6.7.0
# via -r requirements/base/base.in
django-click==2.3.0
# via -r requirements/base/base.in
django-crispy-forms==1.10.0
Expand All @@ -55,6 +59,8 @@ django-extensions==3.0.1
# via -r requirements/base/base.in
django-filter==2.4.0
# via -r requirements/base/base.in
django-js-asset==2.1.0
# via django-ckeditor
django-memoize==2.3.1
# via -r requirements/base/base.in
django-pgviews-redux==0.8.0
Expand Down
2 changes: 1 addition & 1 deletion requirements/deploy/deploy.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# This file is autogenerated by pip-compile with Python 3.8
# This file is autogenerated by pip-compile with Python 3.9
# by the following command:
#
# pip-compile --output-file=requirements/deploy/deploy.txt requirements/deploy/deploy.in
Expand Down
10 changes: 5 additions & 5 deletions requirements/dev/dev.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# This file is autogenerated by pip-compile with Python 3.8
# This file is autogenerated by pip-compile with Python 3.9
# by the following command:
#
# pip-compile --output-file=requirements/dev/dev.txt requirements/dev/dev.in
Expand All @@ -13,7 +13,9 @@ ansible==5.9.0
ansible-core==2.12.7
# via ansible
appnope==0.1.0
# via -r requirements/dev/dev.in
# via
# -r requirements/dev/dev.in
# ipython
argh==0.26.2
# via sphinx-autobuild
asgiref==3.5.2
Expand Down Expand Up @@ -128,7 +130,7 @@ markupsafe==2.1.1
# via jinja2
oauthlib==3.1.0
# via requests-oauthlib
openshift==0.12
openshift==0.12.0
# via -r requirements/dev/dev.in
packaging==20.3
# via
Expand Down Expand Up @@ -212,8 +214,6 @@ rstcheck==3.3.1
# via -r requirements/dev/dev.in
ruamel-yaml==0.16.10
# via openshift
ruamel-yaml-clib==0.2.6
# via ruamel-yaml
s3transfer==0.6.0
# via
# -c requirements/dev/../base/base.txt
Expand Down
2 changes: 1 addition & 1 deletion requirements/test/test.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# This file is autogenerated by pip-compile with Python 3.8
# This file is autogenerated by pip-compile with Python 3.9
# by the following command:
#
# pip-compile --output-file=requirements/test/test.txt requirements/test/test.in
Expand Down
3 changes: 3 additions & 0 deletions traffic_stops/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ def __init__(self, tz_name=None):
"django_filters",
"rest_framework",
"django_pgviews",
"ckeditor",
# Custom apps
"tsdata",
"nc",
Expand Down Expand Up @@ -357,3 +358,5 @@ def __init__(self, tz_name=None):

# Contact us Email
CONTACT_US_EMAILS = os.getenv("CONTACT_US_EMAILS", "forwardjustice-team@caktusgroup.com").split(":")

CKEDITOR_BASEPATH = "/static/ckeditor/ckeditor/"

0 comments on commit 6087289

Please sign in to comment.