Skip to content
Snippets Groups Projects

Convert HTML metadatas as markdown

Merged Manon Blanco requested to merge convert-html-metadata-as-markdown into master
All threads resolved!
8 files
+ 149
5
Compare changes
  • Side-by-side
  • Inline
Files
8
# Generated by Django 3.1.7 on 2021-03-17 08:26
from django.db import migrations
from arkindex.documents.models import MetaType
def convert_html_metadata_to_markdown(apps, schema_editor):
MetaData = apps.get_model('documents', 'MetaData')
AllowedMetaData = apps.get_model('documents', 'AllowedMetaData')
MetaData.objects.exclude(type__in=[mt.value for mt in MetaType]).update(type=MetaType.Markdown)
AllowedMetaData.objects.exclude(type__in=[mt.value for mt in MetaType]).update(type=MetaType.Markdown)
def convert_markdown_metadata_to_html(apps, schema_editor):
MetaData = apps.get_model('documents', 'MetaData')
AllowedMetaData = apps.get_model('documents', 'AllowedMetaData')
MetaData.objects.exclude(type__in=[mt.value for mt in MetaType]).update(type=MetaType.HTML)
AllowedMetaData.objects.exclude(type__in=[mt.value for mt in MetaType]).update(type=MetaType.HTML)
class Migration(migrations.Migration):
dependencies = [
('documents', '0029_corpus_top_level_type'),
]
operations = [
migrations.RunPython(
convert_html_metadata_to_markdown,
reverse_code=convert_markdown_metadata_to_html,
elidable=True,
),
]
Loading