g3w-admin-qplotly 0.0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- g3w_admin_qplotly-0.0.1.dist-info/METADATA +52 -0
- g3w_admin_qplotly-0.0.1.dist-info/RECORD +139 -0
- g3w_admin_qplotly-0.0.1.dist-info/WHEEL +5 -0
- g3w_admin_qplotly-0.0.1.dist-info/licenses/LICENSE +373 -0
- g3w_admin_qplotly-0.0.1.dist-info/top_level.txt +1 -0
- qplotly/__init__.py +1 -0
- qplotly/admin.py +34 -0
- qplotly/api/__init__.py +0 -0
- qplotly/api/plots/__init__.py +0 -0
- qplotly/api/plots/views.py +211 -0
- qplotly/api/widgets/__init__.py +0 -0
- qplotly/api/widgets/permissions.py +79 -0
- qplotly/api/widgets/serializers.py +109 -0
- qplotly/api/widgets/views.py +287 -0
- qplotly/apiurls.py +132 -0
- qplotly/apps.py +11 -0
- qplotly/locale/bg/LC_MESSAGES/django.mo +0 -0
- qplotly/locale/bg/LC_MESSAGES/django.po +162 -0
- qplotly/locale/de/LC_MESSAGES/django.mo +0 -0
- qplotly/locale/de/LC_MESSAGES/django.po +126 -0
- qplotly/locale/de/LC_MESSAGES/djangojs.mo +0 -0
- qplotly/locale/de/LC_MESSAGES/djangojs.po +221 -0
- qplotly/locale/es/LC_MESSAGES/django.mo +0 -0
- qplotly/locale/es/LC_MESSAGES/django.po +151 -0
- qplotly/locale/es/LC_MESSAGES/djangojs.mo +0 -0
- qplotly/locale/es/LC_MESSAGES/djangojs.po +232 -0
- qplotly/locale/fi/LC_MESSAGES/django.mo +0 -0
- qplotly/locale/fi/LC_MESSAGES/django.po +126 -0
- qplotly/locale/fi/LC_MESSAGES/djangojs.mo +0 -0
- qplotly/locale/fi/LC_MESSAGES/djangojs.po +222 -0
- qplotly/locale/fr/LC_MESSAGES/django.mo +0 -0
- qplotly/locale/fr/LC_MESSAGES/django.po +160 -0
- qplotly/locale/fr/LC_MESSAGES/djangojs.mo +0 -0
- qplotly/locale/fr/LC_MESSAGES/djangojs.po +222 -0
- qplotly/locale/it/LC_MESSAGES/django.mo +0 -0
- qplotly/locale/it/LC_MESSAGES/django.po +163 -0
- qplotly/locale/it/LC_MESSAGES/djangojs.mo +0 -0
- qplotly/locale/it/LC_MESSAGES/djangojs.po +220 -0
- qplotly/locale/pl/LC_MESSAGES/django.mo +0 -0
- qplotly/locale/pl/LC_MESSAGES/django.po +129 -0
- qplotly/locale/pl/LC_MESSAGES/djangojs.mo +0 -0
- qplotly/locale/pl/LC_MESSAGES/djangojs.po +217 -0
- qplotly/locale/pt/LC_MESSAGES/django.mo +0 -0
- qplotly/locale/pt/LC_MESSAGES/django.po +160 -0
- qplotly/locale/ro/LC_MESSAGES/django.mo +0 -0
- qplotly/locale/ro/LC_MESSAGES/django.po +128 -0
- qplotly/locale/ro/LC_MESSAGES/djangojs.mo +0 -0
- qplotly/locale/ro/LC_MESSAGES/djangojs.po +222 -0
- qplotly/locale/se/LC_MESSAGES/django.mo +0 -0
- qplotly/locale/se/LC_MESSAGES/django.po +126 -0
- qplotly/locale/se/LC_MESSAGES/djangojs.mo +0 -0
- qplotly/locale/se/LC_MESSAGES/djangojs.po +222 -0
- qplotly/migrations/0001_initial.py +26 -0
- qplotly/migrations/0002_qplotlywidget_type.py +18 -0
- qplotly/migrations/0003_auto_20200925_0838.py +18 -0
- qplotly/migrations/0004_auto_20200925_1535.py +25 -0
- qplotly/migrations/0005_qplotlywidget_show_on_start_client.py +18 -0
- qplotly/migrations/0006_alter_qplotlywidget_options_qplotlywidget_order.py +23 -0
- qplotly/migrations/0007_alter_qplotlywidget_options_and_more.py +22 -0
- qplotly/migrations/0008_alter_qplotlywidget_order.py +18 -0
- qplotly/migrations/0009_qplotlywidget_show_in_sidebar.py +18 -0
- qplotly/migrations/0010_remove_qplotlywidget_show_in_sidebar_and_more.py +22 -0
- qplotly/migrations/0011_rename_show_poistion_qplotlywidget_show_position.py +18 -0
- qplotly/migrations/0012_qplotlywidgetrelation_qplotlywidget_related_widgets.py +34 -0
- qplotly/migrations/0013_alter_qplotlywidgetrelation_source_and_more.py +24 -0
- qplotly/migrations/0014_alter_qplotlywidgetrelation_source_and_more.py +24 -0
- qplotly/migrations/0015_qplotlywidgetrelation_project.py +34 -0
- qplotly/migrations/0016_remove_qplotlywidget_project.py +17 -0
- qplotly/migrations/__init__.py +0 -0
- qplotly/models.py +142 -0
- qplotly/receivers.py +356 -0
- qplotly/requirements.txt +1 -0
- qplotly/server_filters/__init__.py +1 -0
- qplotly/server_filters/relations.py +32 -0
- qplotly/static/qplotly/icons/2dhistogram.svg +2048 -0
- qplotly/static/qplotly/icons/barplot.svg +2048 -0
- qplotly/static/qplotly/icons/boxplot.svg +2048 -0
- qplotly/static/qplotly/icons/contour.svg +2056 -0
- qplotly/static/qplotly/icons/histogram.svg +2048 -0
- qplotly/static/qplotly/icons/pie.svg +2048 -0
- qplotly/static/qplotly/icons/polar.svg +2055 -0
- qplotly/static/qplotly/icons/scatterplot.svg +2048 -0
- qplotly/static/qplotly/icons/scatterternary.svg +2055 -0
- qplotly/static/qplotly/icons/violin.svg +2878 -0
- qplotly/static/qplotly/js/data-widget-qplotlyWidgetList.js +373 -0
- qplotly/static/qplotly/js/i18n/bg.js +19 -0
- qplotly/static/qplotly/js/i18n/de.js +19 -0
- qplotly/static/qplotly/js/i18n/en.js +19 -0
- qplotly/static/qplotly/js/i18n/fi.js +19 -0
- qplotly/static/qplotly/js/i18n/fr.js +19 -0
- qplotly/static/qplotly/js/i18n/index.js +19 -0
- qplotly/static/qplotly/js/i18n/it.js +19 -0
- qplotly/static/qplotly/js/i18n/ro.js +19 -0
- qplotly/static/qplotly/js/i18n/se.js +19 -0
- qplotly/static/qplotly/js/i18n/uk.js +19 -0
- qplotly/static/qplotly/js/plugin.js +927 -0
- qplotly/static/qplotly/js/sidebar.js +373 -0
- qplotly/static/qplotly/js/widget.js +9 -0
- qplotly/static/qplotly/plotly-1.52.2.min.js +7 -0
- qplotly/static/qplotly/polyfill.min.js +3 -0
- qplotly/templates/qplotly/include/plot_type_icon.html +52 -0
- qplotly/templates/qplotly/layer_action.html +13 -0
- qplotly/templates/qplotly/plots_list_order.html +68 -0
- qplotly/templates/qplotly/plots_list_order_action.html +14 -0
- qplotly/templatetags/__init__.py +0 -0
- qplotly/templatetags/qplotly_tags.py +28 -0
- qplotly/urls.py +52 -0
- qplotly/utils/__init__.py +13 -0
- qplotly/utils/models.py +86 -0
- qplotly/utils/qplotly_factory.py +699 -0
- qplotly/utils/qplotly_settings.py +37 -0
- qplotly/vendor/DataPlotly/__init__.py +0 -0
- qplotly/vendor/DataPlotly/core/__init__.py +0 -0
- qplotly/vendor/DataPlotly/core/plot_factory.py +843 -0
- qplotly/vendor/DataPlotly/core/plot_settings.py +322 -0
- qplotly/vendor/DataPlotly/core/plot_types/__init__.py +20 -0
- qplotly/vendor/DataPlotly/core/plot_types/bar_plot.py +83 -0
- qplotly/vendor/DataPlotly/core/plot_types/box.py +56 -0
- qplotly/vendor/DataPlotly/core/plot_types/contour.py +43 -0
- qplotly/vendor/DataPlotly/core/plot_types/histogram.py +66 -0
- qplotly/vendor/DataPlotly/core/plot_types/histogram2d.py +39 -0
- qplotly/vendor/DataPlotly/core/plot_types/icons/2dhistogram.svg +2048 -0
- qplotly/vendor/DataPlotly/core/plot_types/icons/barplot.svg +2048 -0
- qplotly/vendor/DataPlotly/core/plot_types/icons/boxplot.svg +2048 -0
- qplotly/vendor/DataPlotly/core/plot_types/icons/contour.svg +2056 -0
- qplotly/vendor/DataPlotly/core/plot_types/icons/histogram.svg +2048 -0
- qplotly/vendor/DataPlotly/core/plot_types/icons/pie.svg +2048 -0
- qplotly/vendor/DataPlotly/core/plot_types/icons/polar.svg +2055 -0
- qplotly/vendor/DataPlotly/core/plot_types/icons/scatterplot.svg +2048 -0
- qplotly/vendor/DataPlotly/core/plot_types/icons/scatterternary.svg +2055 -0
- qplotly/vendor/DataPlotly/core/plot_types/icons/violin.svg +2878 -0
- qplotly/vendor/DataPlotly/core/plot_types/pie.py +60 -0
- qplotly/vendor/DataPlotly/core/plot_types/plot_type.py +170 -0
- qplotly/vendor/DataPlotly/core/plot_types/polar.py +63 -0
- qplotly/vendor/DataPlotly/core/plot_types/scatter.py +74 -0
- qplotly/vendor/DataPlotly/core/plot_types/ternary.py +129 -0
- qplotly/vendor/DataPlotly/core/plot_types/violin.py +62 -0
- qplotly/vendor/__init__.py +0 -0
- qplotly/views.py +148 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Generated by Django 4.2.18 on 2025-05-15 10:07
|
|
2
|
+
|
|
3
|
+
from django.db import migrations, models
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Migration(migrations.Migration):
|
|
7
|
+
|
|
8
|
+
dependencies = [
|
|
9
|
+
('qplotly', '0005_qplotlywidget_show_on_start_client'),
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
operations = [
|
|
13
|
+
migrations.AlterModelOptions(
|
|
14
|
+
name='qplotlywidget',
|
|
15
|
+
options={'ordering': ('-order',)},
|
|
16
|
+
),
|
|
17
|
+
migrations.AddField(
|
|
18
|
+
model_name='qplotlywidget',
|
|
19
|
+
name='order',
|
|
20
|
+
field=models.PositiveIntegerField(db_index=True, default=0, editable=False, verbose_name='order'),
|
|
21
|
+
preserve_default=False,
|
|
22
|
+
),
|
|
23
|
+
]
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Generated by Django 4.2.18 on 2025-05-15 10:16
|
|
2
|
+
|
|
3
|
+
from django.db import migrations, models
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Migration(migrations.Migration):
|
|
7
|
+
|
|
8
|
+
dependencies = [
|
|
9
|
+
('qplotly', '0006_alter_qplotlywidget_options_qplotlywidget_order'),
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
operations = [
|
|
13
|
+
migrations.AlterModelOptions(
|
|
14
|
+
name='qplotlywidget',
|
|
15
|
+
options={},
|
|
16
|
+
),
|
|
17
|
+
migrations.AlterField(
|
|
18
|
+
model_name='qplotlywidget',
|
|
19
|
+
name='order',
|
|
20
|
+
field=models.PositiveIntegerField(blank=True, default=0, null=True, verbose_name='Fields order'),
|
|
21
|
+
),
|
|
22
|
+
]
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Generated by Django 4.2.18 on 2025-05-15 13:37
|
|
2
|
+
|
|
3
|
+
from django.db import migrations, models
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Migration(migrations.Migration):
|
|
7
|
+
|
|
8
|
+
dependencies = [
|
|
9
|
+
('qplotly', '0007_alter_qplotlywidget_options_and_more'),
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
operations = [
|
|
13
|
+
migrations.AlterField(
|
|
14
|
+
model_name='qplotlywidget',
|
|
15
|
+
name='order',
|
|
16
|
+
field=models.PositiveIntegerField(blank=True, default=0, null=True, verbose_name='Order'),
|
|
17
|
+
),
|
|
18
|
+
]
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Generated by Django 4.2.22 on 2025-06-16 09:39
|
|
2
|
+
|
|
3
|
+
from django.db import migrations, models
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Migration(migrations.Migration):
|
|
7
|
+
|
|
8
|
+
dependencies = [
|
|
9
|
+
('qplotly', '0008_alter_qplotlywidget_order'),
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
operations = [
|
|
13
|
+
migrations.AddField(
|
|
14
|
+
model_name='qplotlywidget',
|
|
15
|
+
name='show_in_sidebar',
|
|
16
|
+
field=models.BooleanField(default=True, help_text='Show this plot in the sidebar. If not checked, it will be shown only on results of a query.', verbose_name='Show in sidebar'),
|
|
17
|
+
),
|
|
18
|
+
]
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Generated by Django 4.2.22 on 2025-06-23 15:03
|
|
2
|
+
|
|
3
|
+
from django.db import migrations, models
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Migration(migrations.Migration):
|
|
7
|
+
|
|
8
|
+
dependencies = [
|
|
9
|
+
('qplotly', '0009_qplotlywidget_show_in_sidebar'),
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
operations = [
|
|
13
|
+
migrations.RemoveField(
|
|
14
|
+
model_name='qplotlywidget',
|
|
15
|
+
name='show_in_sidebar',
|
|
16
|
+
),
|
|
17
|
+
migrations.AddField(
|
|
18
|
+
model_name='qplotlywidget',
|
|
19
|
+
name='show_poistion',
|
|
20
|
+
field=models.CharField(blank=True, default='sidebarquery', max_length=100, null=True, verbose_name='SChart show position'),
|
|
21
|
+
),
|
|
22
|
+
]
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Generated by Django 4.2.22 on 2025-06-24 08:58
|
|
2
|
+
|
|
3
|
+
from django.db import migrations
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Migration(migrations.Migration):
|
|
7
|
+
|
|
8
|
+
dependencies = [
|
|
9
|
+
('qplotly', '0010_remove_qplotlywidget_show_in_sidebar_and_more'),
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
operations = [
|
|
13
|
+
migrations.RenameField(
|
|
14
|
+
model_name='qplotlywidget',
|
|
15
|
+
old_name='show_poistion',
|
|
16
|
+
new_name='show_position',
|
|
17
|
+
),
|
|
18
|
+
]
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Generated by Django 4.2.27 on 2026-03-17 10:36
|
|
2
|
+
|
|
3
|
+
from django.db import migrations, models
|
|
4
|
+
import django.db.models.deletion
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class Migration(migrations.Migration):
|
|
8
|
+
|
|
9
|
+
dependencies = [
|
|
10
|
+
('qplotly', '0011_rename_show_poistion_qplotlywidget_show_position'),
|
|
11
|
+
]
|
|
12
|
+
|
|
13
|
+
operations = [
|
|
14
|
+
migrations.CreateModel(
|
|
15
|
+
name='QplotlyWidgetRelation',
|
|
16
|
+
fields=[
|
|
17
|
+
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
18
|
+
('order', models.PositiveIntegerField(default=0, verbose_name='Order')),
|
|
19
|
+
('source', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='widget_relations', to='qplotly.qplotlywidget', verbose_name='Source widget')),
|
|
20
|
+
('target', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='widget_related_by', to='qplotly.qplotlywidget', verbose_name='Target widget')),
|
|
21
|
+
],
|
|
22
|
+
options={
|
|
23
|
+
'verbose_name': 'QPlotly Widget relation',
|
|
24
|
+
'verbose_name_plural': 'QPlotly Widget relations',
|
|
25
|
+
'ordering': ['order'],
|
|
26
|
+
'unique_together': {('source', 'target')},
|
|
27
|
+
},
|
|
28
|
+
),
|
|
29
|
+
migrations.AddField(
|
|
30
|
+
model_name='qplotlywidget',
|
|
31
|
+
name='related_widgets',
|
|
32
|
+
field=models.ManyToManyField(blank=True, related_name='associated_by', through='qplotly.QplotlyWidgetRelation', to='qplotly.qplotlywidget', verbose_name='Related widgets'),
|
|
33
|
+
),
|
|
34
|
+
]
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Generated by Django 4.2.27 on 2026-03-17 14:09
|
|
2
|
+
|
|
3
|
+
from django.db import migrations, models
|
|
4
|
+
import django.db.models.deletion
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class Migration(migrations.Migration):
|
|
8
|
+
|
|
9
|
+
dependencies = [
|
|
10
|
+
('qplotly', '0012_qplotlywidgetrelation_qplotlywidget_related_widgets'),
|
|
11
|
+
]
|
|
12
|
+
|
|
13
|
+
operations = [
|
|
14
|
+
migrations.AlterField(
|
|
15
|
+
model_name='qplotlywidgetrelation',
|
|
16
|
+
name='source',
|
|
17
|
+
field=models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, related_name='widget_relations', to='qplotly.qplotlywidget', verbose_name='Source widget'),
|
|
18
|
+
),
|
|
19
|
+
migrations.AlterField(
|
|
20
|
+
model_name='qplotlywidgetrelation',
|
|
21
|
+
name='target',
|
|
22
|
+
field=models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, related_name='widget_related_by', to='qplotly.qplotlywidget', verbose_name='Target widget'),
|
|
23
|
+
),
|
|
24
|
+
]
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Generated by Django 4.2.27 on 2026-03-17 15:15
|
|
2
|
+
|
|
3
|
+
from django.db import migrations, models
|
|
4
|
+
import django.db.models.deletion
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class Migration(migrations.Migration):
|
|
8
|
+
|
|
9
|
+
dependencies = [
|
|
10
|
+
('qplotly', '0013_alter_qplotlywidgetrelation_source_and_more'),
|
|
11
|
+
]
|
|
12
|
+
|
|
13
|
+
operations = [
|
|
14
|
+
migrations.AlterField(
|
|
15
|
+
model_name='qplotlywidgetrelation',
|
|
16
|
+
name='source',
|
|
17
|
+
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='widget_relations', to='qplotly.qplotlywidget', verbose_name='Source widget'),
|
|
18
|
+
),
|
|
19
|
+
migrations.AlterField(
|
|
20
|
+
model_name='qplotlywidgetrelation',
|
|
21
|
+
name='target',
|
|
22
|
+
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='widget_related_by', to='qplotly.qplotlywidget', verbose_name='Target widget'),
|
|
23
|
+
),
|
|
24
|
+
]
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Generated by Django 4.2.27 on 2026-03-18 00:00
|
|
2
|
+
|
|
3
|
+
from django.db import migrations, models
|
|
4
|
+
import django.db.models.deletion
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def fill_relation_project(apps, schema_editor):
|
|
8
|
+
QplotlyWidgetRelation = apps.get_model('qplotly', 'QplotlyWidgetRelation')
|
|
9
|
+
|
|
10
|
+
for relation in QplotlyWidgetRelation.objects.select_related('source', 'target').all().iterator():
|
|
11
|
+
project_id = relation.source.project_id or relation.target.project_id
|
|
12
|
+
if relation.project_id != project_id:
|
|
13
|
+
relation.project_id = project_id
|
|
14
|
+
relation.save(update_fields=['project'])
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class Migration(migrations.Migration):
|
|
18
|
+
|
|
19
|
+
dependencies = [
|
|
20
|
+
('qplotly', '0014_alter_qplotlywidgetrelation_source_and_more'),
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
operations = [
|
|
24
|
+
migrations.AddField(
|
|
25
|
+
model_name='qplotlywidgetrelation',
|
|
26
|
+
name='project',
|
|
27
|
+
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='qplotly_widget_relations', to='qdjango.project', verbose_name='Project'),
|
|
28
|
+
),
|
|
29
|
+
migrations.RunPython(fill_relation_project, migrations.RunPython.noop),
|
|
30
|
+
migrations.AlterUniqueTogether(
|
|
31
|
+
name='qplotlywidgetrelation',
|
|
32
|
+
unique_together={('project', 'source', 'target')},
|
|
33
|
+
),
|
|
34
|
+
]
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Generated by Django 4.2.27 on 2026-03-19 00:00
|
|
2
|
+
|
|
3
|
+
from django.db import migrations
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Migration(migrations.Migration):
|
|
7
|
+
|
|
8
|
+
dependencies = [
|
|
9
|
+
('qplotly', '0015_qplotlywidgetrelation_project'),
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
operations = [
|
|
13
|
+
migrations.RemoveField(
|
|
14
|
+
model_name='qplotlywidget',
|
|
15
|
+
name='project',
|
|
16
|
+
),
|
|
17
|
+
]
|
|
File without changes
|
qplotly/models.py
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
from django.db import models
|
|
2
|
+
from django.core.exceptions import ValidationError
|
|
3
|
+
from django.utils.translation import gettext_lazy as _
|
|
4
|
+
from qdjango.models import Layer, Project
|
|
5
|
+
from .utils.qplotly_settings import QplotlySettings
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class QplotlyWidget(models.Model):
|
|
9
|
+
"""
|
|
10
|
+
Layer Qplotly Widget
|
|
11
|
+
"""
|
|
12
|
+
xml = models.TextField(_('XML original settings'))
|
|
13
|
+
datasource = models.TextField(_('Layer datasource'), null=True)
|
|
14
|
+
selected_features_only = models.BooleanField(_('Use selected features only'), default=False)
|
|
15
|
+
visible_features_only = models.BooleanField(_('Use visible features only'), default=False)
|
|
16
|
+
type = models.CharField(_('Plot type'), max_length=50, null=True)
|
|
17
|
+
title = models.CharField(_('Plot title'), max_length=255, null=True)
|
|
18
|
+
show_on_start_client = models.BooleanField(_('Set as default plot on starting map'), null=True, default=False)
|
|
19
|
+
|
|
20
|
+
layers = models.ManyToManyField(Layer)
|
|
21
|
+
|
|
22
|
+
related_widgets = models.ManyToManyField(
|
|
23
|
+
'self',
|
|
24
|
+
through='QplotlyWidgetRelation',
|
|
25
|
+
symmetrical=False,
|
|
26
|
+
blank=True,
|
|
27
|
+
related_name='associated_by',
|
|
28
|
+
verbose_name=_('Related widgets'),
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
order = models.PositiveIntegerField(
|
|
32
|
+
_('Order'),
|
|
33
|
+
default=0,
|
|
34
|
+
blank=True,
|
|
35
|
+
null=True,
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
show_position = models.CharField(
|
|
39
|
+
_('SChart show position'),
|
|
40
|
+
max_length=100,
|
|
41
|
+
blank=True,
|
|
42
|
+
null=True,
|
|
43
|
+
default='sidebarquery'
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
def __str__(self):
|
|
47
|
+
return self.title if self.title else self.datasource if self.datasource else str(self.pk)
|
|
48
|
+
|
|
49
|
+
def clean(self):
|
|
50
|
+
"""Check by DataPlotly API"""
|
|
51
|
+
|
|
52
|
+
# check if is a good xml DataPlotly settings
|
|
53
|
+
settings = QplotlySettings()
|
|
54
|
+
|
|
55
|
+
if not settings.read_from_model(self):
|
|
56
|
+
print('XML is not a DataPlotly settings.')
|
|
57
|
+
raise ValidationError(_('XML is not a DataPlotly settings.'))
|
|
58
|
+
|
|
59
|
+
# check for souce_layerd_id inside project and datasource into values
|
|
60
|
+
try:
|
|
61
|
+
layer = Layer.objects.filter(qgs_layer_id=settings.source_layer_id)[0]
|
|
62
|
+
except IndexError:
|
|
63
|
+
print(f'Layer with qgs_layer_id={settings.source_layer_id} is not present into DB')
|
|
64
|
+
raise ValidationError(_(f'Layer with qgs_layer_id={settings.source_layer_id} is not present into DB'))
|
|
65
|
+
|
|
66
|
+
# compare datasources
|
|
67
|
+
if self.datasource and layer.datasource != self.datasource:
|
|
68
|
+
raise ValidationError(_(f'Layer DataPlotly settings layer datasource is not equal to datasource into values.'))
|
|
69
|
+
|
|
70
|
+
def related(self, project: Project = None, order='asc'):
|
|
71
|
+
"""Return related widgets ordered by 'order' field, excluding self-relation"""
|
|
72
|
+
|
|
73
|
+
relations = QplotlyWidgetRelation.objects.filter(source=self)
|
|
74
|
+
|
|
75
|
+
if project:
|
|
76
|
+
relations = relations.filter(project=project)
|
|
77
|
+
|
|
78
|
+
if order == 'asc':
|
|
79
|
+
order = 'order'
|
|
80
|
+
elif order == 'desc':
|
|
81
|
+
order = '-order'
|
|
82
|
+
else:
|
|
83
|
+
raise ValueError(_('Order must be "asc" or "desc".'))
|
|
84
|
+
|
|
85
|
+
target_ids = list(relations.order_by(order).values_list('target_id', flat=True))
|
|
86
|
+
|
|
87
|
+
widgets = {w.pk: w for w in QplotlyWidget.objects.filter(pk__in=target_ids)}
|
|
88
|
+
return [widgets[pk] for pk in target_ids if pk in widgets]
|
|
89
|
+
|
|
90
|
+
def has_related(self, project: Project = None):
|
|
91
|
+
"""Return True if the widget has related widgets"""
|
|
92
|
+
|
|
93
|
+
relations = QplotlyWidgetRelation.objects.filter(source=self)
|
|
94
|
+
|
|
95
|
+
if project:
|
|
96
|
+
relations = relations.filter(project=project)
|
|
97
|
+
|
|
98
|
+
return relations.exists()
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
class QplotlyWidgetRelation(models.Model):
|
|
102
|
+
"""
|
|
103
|
+
Intermediate model for the many-to-many relation between QplotlyWidgets.
|
|
104
|
+
Stores metadata such as ordering on the relation.
|
|
105
|
+
"""
|
|
106
|
+
source = models.ForeignKey(
|
|
107
|
+
QplotlyWidget,
|
|
108
|
+
on_delete=models.CASCADE,
|
|
109
|
+
related_name='widget_relations',
|
|
110
|
+
verbose_name=_('Source widget'),
|
|
111
|
+
)
|
|
112
|
+
target = models.ForeignKey(
|
|
113
|
+
QplotlyWidget,
|
|
114
|
+
on_delete=models.CASCADE,
|
|
115
|
+
related_name='widget_related_by',
|
|
116
|
+
verbose_name=_('Target widget'),
|
|
117
|
+
)
|
|
118
|
+
project = models.ForeignKey(
|
|
119
|
+
Project,
|
|
120
|
+
on_delete=models.CASCADE,
|
|
121
|
+
related_name='qplotly_widget_relations',
|
|
122
|
+
verbose_name=_('Project'),
|
|
123
|
+
null=True,
|
|
124
|
+
blank=True,
|
|
125
|
+
)
|
|
126
|
+
order = models.PositiveIntegerField(
|
|
127
|
+
_('Order'),
|
|
128
|
+
default=0,
|
|
129
|
+
)
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
class Meta:
|
|
133
|
+
unique_together = ('project', 'source', 'target')
|
|
134
|
+
ordering = ['order']
|
|
135
|
+
verbose_name = _('QPlotly Widget relation')
|
|
136
|
+
verbose_name_plural = _('QPlotly Widget relations')
|
|
137
|
+
|
|
138
|
+
def __str__(self):
|
|
139
|
+
return f'{self.source} → {self.target} (order: {self.order})'
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
|