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
qplotly/views.py
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
# coding=utf-8
|
|
2
|
+
"""" Qplotly main views module.
|
|
3
|
+
|
|
4
|
+
.. note:: This program is free software; you can redistribute it and/or modify
|
|
5
|
+
it under the terms of the Mozilla Public License 2.0.
|
|
6
|
+
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
__author__ = 'lorenzetti@gis3w.it'
|
|
10
|
+
__date__ = '2020-09-22'
|
|
11
|
+
__copyright__ = 'Copyright 2015 - 2020, Gis3w'
|
|
12
|
+
|
|
13
|
+
from django.views.generic import View, TemplateView
|
|
14
|
+
from django.shortcuts import get_object_or_404
|
|
15
|
+
from django.utils.decorators import method_decorator
|
|
16
|
+
from django.views.decorators.csrf import csrf_exempt
|
|
17
|
+
from qdjango.mixins.views import QdjangoProjectViewMixin, QdjangoLayerViewMixin
|
|
18
|
+
from django.core.files.base import ContentFile
|
|
19
|
+
from django.http.response import JsonResponse
|
|
20
|
+
from django_downloadview import VirtualDownloadView
|
|
21
|
+
from qdjango.utils.models import comparedbdatasource
|
|
22
|
+
from qdjango.models import Project
|
|
23
|
+
from core.utils.slugify import slugify
|
|
24
|
+
from .models import QplotlyWidget
|
|
25
|
+
from .utils.models import get_qplotlywidgets4project
|
|
26
|
+
import json
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class QplotlyLinkWidget2LayerView(QdjangoLayerViewMixin, View):
|
|
30
|
+
"""
|
|
31
|
+
Activate or deactivate widget for layer.
|
|
32
|
+
"""
|
|
33
|
+
def get(self, *args, **kwargs):
|
|
34
|
+
self.widget = get_object_or_404(QplotlyWidget, pk=kwargs['pk'])
|
|
35
|
+
try:
|
|
36
|
+
self.linkUnlinkWidget(link=(not 'unlink' in self.request.GET))
|
|
37
|
+
return JsonResponse({'status': 'ok'})
|
|
38
|
+
except Exception as e:
|
|
39
|
+
return JsonResponse({'status': 'error', 'errors_form': e.message})
|
|
40
|
+
|
|
41
|
+
def linkUnlinkWidget(self, link=True):
|
|
42
|
+
|
|
43
|
+
# apply check datasourc only for postgres and spatialite
|
|
44
|
+
if self.layer.layer_type in ('postgres', 'spatialite') \
|
|
45
|
+
and not comparedbdatasource(self.layer.datasource, self.widget.datasource, self.layer.layer_type):
|
|
46
|
+
raise Exception('Datasource of widget is different from layer datasource')
|
|
47
|
+
if link:
|
|
48
|
+
self.widget.layers.add(self.layer)
|
|
49
|
+
else:
|
|
50
|
+
self.widget.layers.remove(self.layer)
|
|
51
|
+
|
|
52
|
+
@method_decorator(csrf_exempt, name='dispatch')
|
|
53
|
+
class QplotlyWidgetChangeActionView(View):
|
|
54
|
+
"""
|
|
55
|
+
Set on true or false show_on_start_client model property or value for other property.
|
|
56
|
+
"""
|
|
57
|
+
|
|
58
|
+
_actions_map = {
|
|
59
|
+
'showonstartclient': 'show_on_start_client',
|
|
60
|
+
'showposition': 'show_position',
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
def dispatch(self, request, *args, **kwargs):
|
|
64
|
+
|
|
65
|
+
self.widget = get_object_or_404(QplotlyWidget, pk=kwargs['pk'])
|
|
66
|
+
|
|
67
|
+
return super().dispatch(request, *args, **kwargs)
|
|
68
|
+
|
|
69
|
+
def get(self, *args, **kwargs):
|
|
70
|
+
|
|
71
|
+
try:
|
|
72
|
+
self.change_status(action=kwargs['action'], value=(not 'show' in self.request.GET))
|
|
73
|
+
return JsonResponse({'status': 'ok'})
|
|
74
|
+
except Exception as e:
|
|
75
|
+
return JsonResponse({'status': 'error', 'errors_form': e})
|
|
76
|
+
|
|
77
|
+
def post(self, *args, **kwargs):
|
|
78
|
+
|
|
79
|
+
try:
|
|
80
|
+
if self.request.content_type == 'application/json':
|
|
81
|
+
data = json.loads(self.request.body)
|
|
82
|
+
else:
|
|
83
|
+
data = self.request.POST
|
|
84
|
+
self.change_status(action=kwargs['action'], value=data.get('value', None))
|
|
85
|
+
return JsonResponse({'status': 'ok'})
|
|
86
|
+
except Exception as e:
|
|
87
|
+
return JsonResponse({'status': 'error', 'errors_form': e})
|
|
88
|
+
|
|
89
|
+
def change_status(self, action='show_on_start_client',value=True):
|
|
90
|
+
|
|
91
|
+
if value is not None:
|
|
92
|
+
setattr(self.widget, self._actions_map[action], value)
|
|
93
|
+
self.widget.save()
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
class QplotlyDownloadView(VirtualDownloadView):
|
|
99
|
+
"""Download of xml qplotly file config"""
|
|
100
|
+
|
|
101
|
+
def get(self, request, *args, **kwargs):
|
|
102
|
+
self.widget = get_object_or_404(QplotlyWidget, pk=kwargs['pk'])
|
|
103
|
+
|
|
104
|
+
return super().get(request, *args, **kwargs)
|
|
105
|
+
|
|
106
|
+
def get_file(self):
|
|
107
|
+
"""Return :class:`django.core.files.base.ContentFile` object."""
|
|
108
|
+
|
|
109
|
+
title = slugify(self.widget.title)
|
|
110
|
+
return ContentFile(self.widget.xml, name=f"qplotly_{title}.xml")
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
class QplotlyProjectPlotsListView(TemplateView):
|
|
114
|
+
"""
|
|
115
|
+
View to show in a table the list of plots by project
|
|
116
|
+
"""
|
|
117
|
+
|
|
118
|
+
template_name = 'qplotly/plots_list_order.html'
|
|
119
|
+
|
|
120
|
+
def get_context_data(self, **kwargs):
|
|
121
|
+
ctx = super().get_context_data(**kwargs)
|
|
122
|
+
|
|
123
|
+
# Get every qplotly plots for the project
|
|
124
|
+
ctx['project'] = Project.objects.get(pk=kwargs['project_id'])
|
|
125
|
+
ctx['plots'] = get_qplotlywidgets4project(ctx['project'], ctx='free+related')
|
|
126
|
+
|
|
127
|
+
return ctx
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
class QploltyWidgetSetOrderView(View):
|
|
131
|
+
'''
|
|
132
|
+
Set order view list widgets
|
|
133
|
+
'''
|
|
134
|
+
|
|
135
|
+
# only user with change_group for this group can change overview map.
|
|
136
|
+
# @method_decorator(user_passes_test_or_403(lambda u: u.is_superuser))
|
|
137
|
+
# def dispatch(self, *args, **kwargs):
|
|
138
|
+
# return super().dispatch(*args, **kwargs)
|
|
139
|
+
|
|
140
|
+
def post(self, *args, **kwargs):
|
|
141
|
+
# get new order save value for group
|
|
142
|
+
new_order = self.request.POST.getlist('new_order[]')
|
|
143
|
+
for oindex, gid in enumerate(new_order):
|
|
144
|
+
p = QplotlyWidget.objects.get(pk=gid.split('_')[1])
|
|
145
|
+
p.order = oindex
|
|
146
|
+
p.save()
|
|
147
|
+
|
|
148
|
+
return JsonResponse({'Saved': 'ok'})
|