diff --git a/arches/app/media/js/viewmodels/file-widget.js b/arches/app/media/js/viewmodels/file-widget.js index 3c197c75009..71e3dc9ea24 100644 --- a/arches/app/media/js/viewmodels/file-widget.js +++ b/arches/app/media/js/viewmodels/file-widget.js @@ -9,7 +9,7 @@ define([ 'bindings/dropzone' ], function($, ko, _, arches, Dropzone, uuid, WidgetViewModel) { /** - * A viewmodel used for domain widgets + * A viewmodel used for file widgets * * @constructor * @name FileWidgetViewModel diff --git a/arches/app/models/migrations/10150_add_default_value_file_list.py b/arches/app/models/migrations/10150_add_default_value_file_list.py new file mode 100644 index 00000000000..390d107fc14 --- /dev/null +++ b/arches/app/models/migrations/10150_add_default_value_file_list.py @@ -0,0 +1,52 @@ +# Generated by Django 4.2.4 on 2023-10-23 13:50 + +from django.db import migrations + +from arches.app.models.graph import Graph + + +def using_custom_file_widgets(apps, schema_editor): + CardXNodeXWidget = apps.get_model("models", "CardXNodeXWidget") + return ( + CardXNodeXWidget.objects.filter(widget_id="10000000-0000-0000-0000-000000000019").values_list("node__graph", flat=True).distinct() + ) + + +def publish_graph(apps, schema_editor): + for graph in Graph.objects.filter(pk__in=using_custom_file_widgets(apps, schema_editor)): + graph.publish(user=None) + + +def unpublish_graph(apps, schema_editor): + for graph in Graph.objects.filter(pk__in=using_custom_file_widgets(apps, schema_editor)): + graph.unpublish() + + +class Migration(migrations.Migration): + dependencies = [ + ("models", "10149_add_workflow_name_to_workflow_history"), + ] + + operations = [ + # Changes to cards_x_nodes_x_widgets have no effect without republishing graph. + migrations.RunPython(unpublish_graph, publish_graph), + migrations.RunSQL( + sql=""" + UPDATE widgets + SET defaultconfig = jsonb_set(defaultconfig, '{defaultValue}', '[]') + WHERE name = 'file-widget'; + UPDATE cards_x_nodes_x_widgets + SET config = jsonb_set(config, '{defaultValue}', '[]') + WHERE widgetid = '10000000-0000-0000-0000-000000000019'; + """, + reverse_sql=""" + UPDATE widgets + SET defaultconfig = defaultconfig - 'defaultValue' + WHERE name = 'file-widget'; + UPDATE cards_x_nodes_x_widgets + SET config = config - 'defaultValue' + WHERE widgetid = '10000000-0000-0000-0000-000000000019'; + """, + ), + migrations.RunPython(publish_graph, unpublish_graph), + ]