Skip to content

Commit

Permalink
Merge pull request #1113 from uktrade/chore/remove-custom-markdown-field
Browse files Browse the repository at this point in the history
Remove custom markdown field
  • Loading branch information
Miriam Forner authored Jul 20, 2023
2 parents 1833d76 + 018ef89 commit 6cbd6b5
Show file tree
Hide file tree
Showing 63 changed files with 2,474 additions and 2,652 deletions.
24 changes: 12 additions & 12 deletions components/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Generated by Django 1.11.15 on 2018-10-24 11:54
from __future__ import unicode_literals

import core.model_fields
import wagtailmarkdown.fields
import core.models
import core.validators
from django.db import migrations, models
Expand All @@ -23,17 +23,17 @@ class Migration(migrations.Migration):
fields=[
('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.Page')),
('service_name', models.CharField(choices=[('FIND_A_SUPPLIER', 'Find a Supplier'), ('EXPORT_READINESS', 'Export Readiness'), ('INVEST', 'Invest'), ('COMPONENTS', 'Components')], db_index=True, max_length=100, null=True)),
('banner_content', core.model_fields.MarkdownField(validators=[core.validators.slug_hyperlinks])),
('banner_content_en_gb', core.model_fields.MarkdownField(null=True, validators=[core.validators.slug_hyperlinks])),
('banner_content_de', core.model_fields.MarkdownField(null=True, validators=[core.validators.slug_hyperlinks])),
('banner_content_ja', core.model_fields.MarkdownField(null=True, validators=[core.validators.slug_hyperlinks])),
('banner_content_ru', core.model_fields.MarkdownField(null=True, validators=[core.validators.slug_hyperlinks])),
('banner_content_zh_hans', core.model_fields.MarkdownField(null=True, validators=[core.validators.slug_hyperlinks])),
('banner_content_fr', core.model_fields.MarkdownField(null=True, validators=[core.validators.slug_hyperlinks])),
('banner_content_es', core.model_fields.MarkdownField(null=True, validators=[core.validators.slug_hyperlinks])),
('banner_content_pt', core.model_fields.MarkdownField(null=True, validators=[core.validators.slug_hyperlinks])),
('banner_content_pt_br', core.model_fields.MarkdownField(null=True, validators=[core.validators.slug_hyperlinks])),
('banner_content_ar', core.model_fields.MarkdownField(null=True, validators=[core.validators.slug_hyperlinks])),
('banner_content', wagtailmarkdown.fields.MarkdownField(validators=[core.validators.slug_hyperlinks])),
('banner_content_en_gb', wagtailmarkdown.fields.MarkdownField(null=True, validators=[core.validators.slug_hyperlinks])),
('banner_content_de', wagtailmarkdown.fields.MarkdownField(null=True, validators=[core.validators.slug_hyperlinks])),
('banner_content_ja', wagtailmarkdown.fields.MarkdownField(null=True, validators=[core.validators.slug_hyperlinks])),
('banner_content_ru', wagtailmarkdown.fields.MarkdownField(null=True, validators=[core.validators.slug_hyperlinks])),
('banner_content_zh_hans', wagtailmarkdown.fields.MarkdownField(null=True, validators=[core.validators.slug_hyperlinks])),
('banner_content_fr', wagtailmarkdown.fields.MarkdownField(null=True, validators=[core.validators.slug_hyperlinks])),
('banner_content_es', wagtailmarkdown.fields.MarkdownField(null=True, validators=[core.validators.slug_hyperlinks])),
('banner_content_pt', wagtailmarkdown.fields.MarkdownField(null=True, validators=[core.validators.slug_hyperlinks])),
('banner_content_pt_br', wagtailmarkdown.fields.MarkdownField(null=True, validators=[core.validators.slug_hyperlinks])),
('banner_content_ar', wagtailmarkdown.fields.MarkdownField(null=True, validators=[core.validators.slug_hyperlinks])),
('banner_label', models.CharField(blank=True, max_length=50, null=True)),
('banner_label_en_gb', models.CharField(blank=True, max_length=50, null=True)),
('banner_label_de', models.CharField(blank=True, max_length=50, null=True)),
Expand Down
20 changes: 10 additions & 10 deletions components/migrations/0005_auto_20190823_1036.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Generated by Django 2.2.4 on 2019-08-23 10:36

import core.model_fields
import wagtailmarkdown.fields
from django.db import migrations


Expand All @@ -14,46 +14,46 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='bannercomponent',
name='banner_content',
field=core.model_fields.MarkdownField(),
field=wagtailmarkdown.fields.MarkdownField(),
),
migrations.AlterField(
model_name='bannercomponent',
name='banner_content_ar',
field=core.model_fields.MarkdownField(null=True),
field=wagtailmarkdown.fields.MarkdownField(null=True),
),
migrations.AlterField(
model_name='bannercomponent',
name='banner_content_de',
field=core.model_fields.MarkdownField(null=True),
field=wagtailmarkdown.fields.MarkdownField(null=True),
),
migrations.AlterField(
model_name='bannercomponent',
name='banner_content_en_gb',
field=core.model_fields.MarkdownField(null=True),
field=wagtailmarkdown.fields.MarkdownField(null=True),
),
migrations.AlterField(
model_name='bannercomponent',
name='banner_content_es',
field=core.model_fields.MarkdownField(null=True),
field=wagtailmarkdown.fields.MarkdownField(null=True),
),
migrations.AlterField(
model_name='bannercomponent',
name='banner_content_fr',
field=core.model_fields.MarkdownField(null=True),
field=wagtailmarkdown.fields.MarkdownField(null=True),
),
migrations.AlterField(
model_name='bannercomponent',
name='banner_content_ja',
field=core.model_fields.MarkdownField(null=True),
field=wagtailmarkdown.fields.MarkdownField(null=True),
),
migrations.AlterField(
model_name='bannercomponent',
name='banner_content_pt',
field=core.model_fields.MarkdownField(null=True),
field=wagtailmarkdown.fields.MarkdownField(null=True),
),
migrations.AlterField(
model_name='bannercomponent',
name='banner_content_zh_hans',
field=core.model_fields.MarkdownField(null=True),
field=wagtailmarkdown.fields.MarkdownField(null=True),
),
]
12 changes: 0 additions & 12 deletions core/model_fields.py

This file was deleted.

134 changes: 0 additions & 134 deletions core/static/core/js/refresh_codemirror.js

This file was deleted.

64 changes: 15 additions & 49 deletions core/widgets.py
Original file line number Diff line number Diff line change
@@ -1,73 +1,39 @@
import json
from django import forms

from django import forms
from django.utils.safestring import mark_safe
from wagtail.utils.widgets import WidgetWithScript


class MarkdownTextarea(WidgetWithScript, forms.widgets.Textarea):
def __init__(self, **kwargs):
super(MarkdownTextarea, self).__init__(**kwargs)

def render_js_init(self, id_, name, value):
return 'simplemdeAttach("{0}");'.format(id_)

@property
def media(self):
return forms.Media(
css={
'all': (
'https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.css', # NOQA
)
},
js=(
'https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.js',
'core/js/refresh_codemirror.js',
'wagtailadmin/js/page-chooser-modal.js',
)
)


class Select2WidgetMediaMixin:
class Media:
css = {
'all': (
'core/js/select2/select2.css',
'core/js/select2/select2-wagtailadmin.css'
)
}
css = {'all': ('core/js/select2/select2.css', 'core/js/select2/select2-wagtailadmin.css')}
js = ('core/js/select2/select2.min.js',)


class Select2RenderWithOptionsMixin:

def __init__(self, *args, select2_options={}, **kwargs):
super().__init__(*args, **kwargs)
self.select2_options = select2_options

def render(self, name, value, attrs=None, renderer=None):
html = super().render(name, value, attrs, renderer)
extra = mark_safe('\n'.join((
"<script>$(function () {",
" $('select[name=\"{field_name}\"]').select2({options});".format(
field_name=name, options=json.dumps(self.select2_options)
),
"});</script>"
)))
extra = mark_safe(
'\n'.join(
(
"<script>$(function () {",
" $('select[name=\"{field_name}\"]').select2({options});".format(
field_name=name, options=json.dumps(self.select2_options)
),
"});</script>",
)
)
)
return html + extra


class Select2Widget(
Select2WidgetMediaMixin,
Select2RenderWithOptionsMixin,
forms.Select
):
class Select2Widget(Select2WidgetMediaMixin, Select2RenderWithOptionsMixin, forms.Select):
pass


class Select2MultipleWidget(
Select2WidgetMediaMixin,
Select2RenderWithOptionsMixin,
forms.SelectMultiple
):
class Select2MultipleWidget(Select2WidgetMediaMixin, Select2RenderWithOptionsMixin, forms.SelectMultiple):
pass
6 changes: 3 additions & 3 deletions great_international/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Generated by Django 1.11.18 on 2019-02-05 13:06
from __future__ import unicode_literals

import core.model_fields
import wagtailmarkdown.fields
import core.models
import core.validators
from django.db import migrations, models
Expand Down Expand Up @@ -37,7 +37,7 @@ class Migration(migrations.Migration):
('service_name', models.CharField(choices=[('FIND_A_SUPPLIER', 'Find a Supplier'), ('EXPORT_READINESS', 'Export Readiness'), ('INVEST', 'Invest'), ('COMPONENTS', 'Components')], db_index=True, max_length=100, null=True)),
('article_title', models.CharField(max_length=255)),
('article_teaser', models.CharField(max_length=255)),
('article_body_text', core.model_fields.MarkdownField(validators=[core.validators.slug_hyperlinks])),
('article_body_text', wagtailmarkdown.fields.MarkdownField(validators=[core.validators.slug_hyperlinks])),
('article_image', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailimages.Image')),
('related_page_one', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='great_international.InternationalArticlePage')),
('related_page_three', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='great_international.InternationalArticlePage')),
Expand All @@ -54,7 +54,7 @@ class Migration(migrations.Migration):
('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.Page')),
('service_name', models.CharField(choices=[('FIND_A_SUPPLIER', 'Find a Supplier'), ('EXPORT_READINESS', 'Export Readiness'), ('INVEST', 'Invest'), ('COMPONENTS', 'Components')], db_index=True, max_length=100, null=True)),
('tariffs_title', models.CharField(max_length=255)),
('tariffs_description', core.model_fields.MarkdownField(validators=[core.validators.slug_hyperlinks])),
('tariffs_description', wagtailmarkdown.fields.MarkdownField(validators=[core.validators.slug_hyperlinks])),
('tariffs_link', models.URLField()),
('news_title', models.CharField(max_length=255)),
('tariffs_image', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailimages.Image')),
Expand Down
Loading

0 comments on commit 6cbd6b5

Please sign in to comment.