Skip to content

Commit

Permalink
[FIX #6626] add tinymce editor to resource text areas
Browse files Browse the repository at this point in the history
(cherry picked from commit 45bb0dc)
  • Loading branch information
petrus7 authored and afabiani committed Nov 10, 2020
1 parent 0dfc3ef commit e807d63
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 14 deletions.
8 changes: 7 additions & 1 deletion geonode/base/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import html
import logging

from tinymce.widgets import TinyMCE

from .fields import MultiThesauriField

from dal import autocomplete
Expand Down Expand Up @@ -332,7 +334,11 @@ def build_attrs(self, base_attrs=None, extra_attrs=None, **kwargs):

class ResourceBaseForm(TranslationModelForm):
"""Base form for metadata, should be inherited by childres classes of ResourceBase"""

abstract = forms.CharField(widget=TinyMCE())
purpose = forms.CharField(widget=TinyMCE())
constraints_other = forms.CharField(widget=TinyMCE())
supplemental_information = forms.CharField(widget=TinyMCE())
data_quality_statement = forms.CharField(widget=TinyMCE())
owner = forms.ModelChoiceField(
empty_label="Owner",
label=_("Owner"),
Expand Down
2 changes: 1 addition & 1 deletion geonode/base/templates/base/_resourcebase_info_panel.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

{% if resource.abstract %}
<dt>{% trans "Abstract" %}</dt>
<dd itemprop="description">{{ resource.abstract|escape|urlize|linebreaks|safe|truncatechars:500 }}</dd>
<dd itemprop="description">{{ resource.abstract|safe|escape|urlize|linebreaks|safe|truncatechars:500 }}</dd>
{% endif %}

{% if resource.date %}
Expand Down
1 change: 1 addition & 0 deletions geonode/layers/templates/layers/layer_metadata.html
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ <h2>{% trans "Metadata Provider" %}</h2>
<script type="text/javascript">
{% autoescape off %}
tinyMCE_default_config = {{ TINYMCE_DEFAULT_CONFIG }};
tinyMCE_default_config['selector'] = 'textarea#id_resource-featureinfo_custom_template'
tinyMCE_default_config['file_picker_callback'] = function (callback, value, meta) {
/* Provide file and text for the link dialog */
if (meta.filetype === 'file') {
Expand Down
8 changes: 1 addition & 7 deletions geonode/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -723,12 +723,6 @@
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'django.contrib.auth.context_processors.auth',
# 'django.core.context_processors.debug',
# 'django.core.context_processors.i18n',
# 'django.core.context_processors.tz',
# 'django.core.context_processors.media',
# 'django.core.context_processors.static',
# 'django.core.context_processors.request',
'geonode.context_processors.resource_urls',
'geonode.geoserver.context_processors.geoserver_urls',
'geonode.themes.context_processors.custom_theme'
Expand Down Expand Up @@ -1645,7 +1639,6 @@ def get_geonode_catalogue_service():

# HTML WYSIWYG Editor (TINYMCE) Menu Bar Settings
TINYMCE_DEFAULT_CONFIG = {
"selector": "textarea#id_resource-featureinfo_custom_template",
"theme": "silver",
"height": 500,
"plugins": 'print preview paste importcss searchreplace autolink autosave save directionality code visualblocks visualchars fullscreen image link media template codesample table charmap hr pagebreak nonbreaking anchor toc insertdatetime advlist lists wordcount imagetools textpattern noneditable help charmap quickbars emoticons',
Expand Down Expand Up @@ -2101,3 +2094,4 @@ def get_geonode_catalogue_service():
#This controls if tastypie search on resourches is performed only with titles
SEARCH_RESOURCES_EXTENDED = strtobool(os.getenv('SEARCH_RESOURCES_EXTENDED', 'True'))
# -- END Settings for MONITORING plugin

3 changes: 3 additions & 0 deletions geonode/templates/metadata_base.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
<script src="{% static "lib/js/moment-with-locales.js" %}"></script>
<script src="{% static "lib/js/bootstrap-datetimepicker.js" %}"></script>
<link rel="stylesheet" href="{% static "lib/css/bootstrap-datetimepicker.css" %}" />
<script type="text/javascript" src={% static "tinymce/tinymce.min.js" %}></script>
<script type="text/javascript" src={% static "django_tinymce/init_tinymce.js" %}></script>
<link rel="stylesheet" type="text/css" id="mce-u0" href= {% static "tinymce/skins/ui/oxide/skin.min.css" %}>

<style>
.xxs-font-size{
Expand Down
10 changes: 5 additions & 5 deletions geonode/templates/metadata_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ <h2 class="page-title">{% trans "Metadata" %} : {{ resource.title }}</h2>

{% if resource.abstract %}
<dt>{% trans "Abstract" %}</dt>
<dd>{{ resource.abstract|escape|urlize|linebreaks|safe|truncatechars:1000 }}</dd>
<dd>{{ resource.abstract|safe|escape|urlize|linebreaks|safe|truncatechars:1000 }}</dd>
{% endif %}

</dl>
Expand Down Expand Up @@ -225,7 +225,7 @@ <h2 class="page-title">{% trans "Metadata" %} : {{ resource.title }}</h2>
{% if resource.restriction_code_type or resource.constraints_other %}
<dt>{% trans "Restrictions" %}</dt>
<dd>{% if resource.constraints_other %}
{{ resource.constraints_other }}
{{ resource.constraints_other|safe }}
{% else %}
{{ resource.restriction_code_type }}
{% endif %}</dd>
Expand All @@ -238,7 +238,7 @@ <h2 class="page-title">{% trans "Metadata" %} : {{ resource.title }}</h2>

{% if resource.purpose %}
<dt>{% trans "Purpose" %}</dt>
<dd>{{ resource.purpose|escape|urlize|linebreaks|safe|truncatechars:160 }}</dd>
<dd>{{ resource.purpose|safe|escape|urlize|linebreaks|safe|truncatechars:160 }}</dd>
{% endif %}

{% if resource.language %}
Expand All @@ -253,12 +253,12 @@ <h2 class="page-title">{% trans "Metadata" %} : {{ resource.title }}</h2>

{% if resource.data_quality_statement %}
<dt>{% trans "Data Quality" %}</dt>
<dd>{{ resource.data_quality_statement }}</dd>
<dd>{{ resource.data_quality_statement|safe }}</dd>
{% endif %}

{% if resource.supplemental_information %}
<dt>{% trans "Supplemental Information" %}</dt>
<dd>{{ resource.supplemental_information|truncatechars:160|escape|urlize|linebreaks|safe }}</dd>
<dd>{{ resource.supplemental_information|safe|truncatechars:160|escape|urlize|linebreaks|safe }}</dd>
{% endif %}

{% if resource.spatial_representation_type %}
Expand Down

0 comments on commit e807d63

Please sign in to comment.