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.
Files changed (139) hide show
  1. g3w_admin_qplotly-0.0.1.dist-info/METADATA +52 -0
  2. g3w_admin_qplotly-0.0.1.dist-info/RECORD +139 -0
  3. g3w_admin_qplotly-0.0.1.dist-info/WHEEL +5 -0
  4. g3w_admin_qplotly-0.0.1.dist-info/licenses/LICENSE +373 -0
  5. g3w_admin_qplotly-0.0.1.dist-info/top_level.txt +1 -0
  6. qplotly/__init__.py +1 -0
  7. qplotly/admin.py +34 -0
  8. qplotly/api/__init__.py +0 -0
  9. qplotly/api/plots/__init__.py +0 -0
  10. qplotly/api/plots/views.py +211 -0
  11. qplotly/api/widgets/__init__.py +0 -0
  12. qplotly/api/widgets/permissions.py +79 -0
  13. qplotly/api/widgets/serializers.py +109 -0
  14. qplotly/api/widgets/views.py +287 -0
  15. qplotly/apiurls.py +132 -0
  16. qplotly/apps.py +11 -0
  17. qplotly/locale/bg/LC_MESSAGES/django.mo +0 -0
  18. qplotly/locale/bg/LC_MESSAGES/django.po +162 -0
  19. qplotly/locale/de/LC_MESSAGES/django.mo +0 -0
  20. qplotly/locale/de/LC_MESSAGES/django.po +126 -0
  21. qplotly/locale/de/LC_MESSAGES/djangojs.mo +0 -0
  22. qplotly/locale/de/LC_MESSAGES/djangojs.po +221 -0
  23. qplotly/locale/es/LC_MESSAGES/django.mo +0 -0
  24. qplotly/locale/es/LC_MESSAGES/django.po +151 -0
  25. qplotly/locale/es/LC_MESSAGES/djangojs.mo +0 -0
  26. qplotly/locale/es/LC_MESSAGES/djangojs.po +232 -0
  27. qplotly/locale/fi/LC_MESSAGES/django.mo +0 -0
  28. qplotly/locale/fi/LC_MESSAGES/django.po +126 -0
  29. qplotly/locale/fi/LC_MESSAGES/djangojs.mo +0 -0
  30. qplotly/locale/fi/LC_MESSAGES/djangojs.po +222 -0
  31. qplotly/locale/fr/LC_MESSAGES/django.mo +0 -0
  32. qplotly/locale/fr/LC_MESSAGES/django.po +160 -0
  33. qplotly/locale/fr/LC_MESSAGES/djangojs.mo +0 -0
  34. qplotly/locale/fr/LC_MESSAGES/djangojs.po +222 -0
  35. qplotly/locale/it/LC_MESSAGES/django.mo +0 -0
  36. qplotly/locale/it/LC_MESSAGES/django.po +163 -0
  37. qplotly/locale/it/LC_MESSAGES/djangojs.mo +0 -0
  38. qplotly/locale/it/LC_MESSAGES/djangojs.po +220 -0
  39. qplotly/locale/pl/LC_MESSAGES/django.mo +0 -0
  40. qplotly/locale/pl/LC_MESSAGES/django.po +129 -0
  41. qplotly/locale/pl/LC_MESSAGES/djangojs.mo +0 -0
  42. qplotly/locale/pl/LC_MESSAGES/djangojs.po +217 -0
  43. qplotly/locale/pt/LC_MESSAGES/django.mo +0 -0
  44. qplotly/locale/pt/LC_MESSAGES/django.po +160 -0
  45. qplotly/locale/ro/LC_MESSAGES/django.mo +0 -0
  46. qplotly/locale/ro/LC_MESSAGES/django.po +128 -0
  47. qplotly/locale/ro/LC_MESSAGES/djangojs.mo +0 -0
  48. qplotly/locale/ro/LC_MESSAGES/djangojs.po +222 -0
  49. qplotly/locale/se/LC_MESSAGES/django.mo +0 -0
  50. qplotly/locale/se/LC_MESSAGES/django.po +126 -0
  51. qplotly/locale/se/LC_MESSAGES/djangojs.mo +0 -0
  52. qplotly/locale/se/LC_MESSAGES/djangojs.po +222 -0
  53. qplotly/migrations/0001_initial.py +26 -0
  54. qplotly/migrations/0002_qplotlywidget_type.py +18 -0
  55. qplotly/migrations/0003_auto_20200925_0838.py +18 -0
  56. qplotly/migrations/0004_auto_20200925_1535.py +25 -0
  57. qplotly/migrations/0005_qplotlywidget_show_on_start_client.py +18 -0
  58. qplotly/migrations/0006_alter_qplotlywidget_options_qplotlywidget_order.py +23 -0
  59. qplotly/migrations/0007_alter_qplotlywidget_options_and_more.py +22 -0
  60. qplotly/migrations/0008_alter_qplotlywidget_order.py +18 -0
  61. qplotly/migrations/0009_qplotlywidget_show_in_sidebar.py +18 -0
  62. qplotly/migrations/0010_remove_qplotlywidget_show_in_sidebar_and_more.py +22 -0
  63. qplotly/migrations/0011_rename_show_poistion_qplotlywidget_show_position.py +18 -0
  64. qplotly/migrations/0012_qplotlywidgetrelation_qplotlywidget_related_widgets.py +34 -0
  65. qplotly/migrations/0013_alter_qplotlywidgetrelation_source_and_more.py +24 -0
  66. qplotly/migrations/0014_alter_qplotlywidgetrelation_source_and_more.py +24 -0
  67. qplotly/migrations/0015_qplotlywidgetrelation_project.py +34 -0
  68. qplotly/migrations/0016_remove_qplotlywidget_project.py +17 -0
  69. qplotly/migrations/__init__.py +0 -0
  70. qplotly/models.py +142 -0
  71. qplotly/receivers.py +356 -0
  72. qplotly/requirements.txt +1 -0
  73. qplotly/server_filters/__init__.py +1 -0
  74. qplotly/server_filters/relations.py +32 -0
  75. qplotly/static/qplotly/icons/2dhistogram.svg +2048 -0
  76. qplotly/static/qplotly/icons/barplot.svg +2048 -0
  77. qplotly/static/qplotly/icons/boxplot.svg +2048 -0
  78. qplotly/static/qplotly/icons/contour.svg +2056 -0
  79. qplotly/static/qplotly/icons/histogram.svg +2048 -0
  80. qplotly/static/qplotly/icons/pie.svg +2048 -0
  81. qplotly/static/qplotly/icons/polar.svg +2055 -0
  82. qplotly/static/qplotly/icons/scatterplot.svg +2048 -0
  83. qplotly/static/qplotly/icons/scatterternary.svg +2055 -0
  84. qplotly/static/qplotly/icons/violin.svg +2878 -0
  85. qplotly/static/qplotly/js/data-widget-qplotlyWidgetList.js +373 -0
  86. qplotly/static/qplotly/js/i18n/bg.js +19 -0
  87. qplotly/static/qplotly/js/i18n/de.js +19 -0
  88. qplotly/static/qplotly/js/i18n/en.js +19 -0
  89. qplotly/static/qplotly/js/i18n/fi.js +19 -0
  90. qplotly/static/qplotly/js/i18n/fr.js +19 -0
  91. qplotly/static/qplotly/js/i18n/index.js +19 -0
  92. qplotly/static/qplotly/js/i18n/it.js +19 -0
  93. qplotly/static/qplotly/js/i18n/ro.js +19 -0
  94. qplotly/static/qplotly/js/i18n/se.js +19 -0
  95. qplotly/static/qplotly/js/i18n/uk.js +19 -0
  96. qplotly/static/qplotly/js/plugin.js +927 -0
  97. qplotly/static/qplotly/js/sidebar.js +373 -0
  98. qplotly/static/qplotly/js/widget.js +9 -0
  99. qplotly/static/qplotly/plotly-1.52.2.min.js +7 -0
  100. qplotly/static/qplotly/polyfill.min.js +3 -0
  101. qplotly/templates/qplotly/include/plot_type_icon.html +52 -0
  102. qplotly/templates/qplotly/layer_action.html +13 -0
  103. qplotly/templates/qplotly/plots_list_order.html +68 -0
  104. qplotly/templates/qplotly/plots_list_order_action.html +14 -0
  105. qplotly/templatetags/__init__.py +0 -0
  106. qplotly/templatetags/qplotly_tags.py +28 -0
  107. qplotly/urls.py +52 -0
  108. qplotly/utils/__init__.py +13 -0
  109. qplotly/utils/models.py +86 -0
  110. qplotly/utils/qplotly_factory.py +699 -0
  111. qplotly/utils/qplotly_settings.py +37 -0
  112. qplotly/vendor/DataPlotly/__init__.py +0 -0
  113. qplotly/vendor/DataPlotly/core/__init__.py +0 -0
  114. qplotly/vendor/DataPlotly/core/plot_factory.py +843 -0
  115. qplotly/vendor/DataPlotly/core/plot_settings.py +322 -0
  116. qplotly/vendor/DataPlotly/core/plot_types/__init__.py +20 -0
  117. qplotly/vendor/DataPlotly/core/plot_types/bar_plot.py +83 -0
  118. qplotly/vendor/DataPlotly/core/plot_types/box.py +56 -0
  119. qplotly/vendor/DataPlotly/core/plot_types/contour.py +43 -0
  120. qplotly/vendor/DataPlotly/core/plot_types/histogram.py +66 -0
  121. qplotly/vendor/DataPlotly/core/plot_types/histogram2d.py +39 -0
  122. qplotly/vendor/DataPlotly/core/plot_types/icons/2dhistogram.svg +2048 -0
  123. qplotly/vendor/DataPlotly/core/plot_types/icons/barplot.svg +2048 -0
  124. qplotly/vendor/DataPlotly/core/plot_types/icons/boxplot.svg +2048 -0
  125. qplotly/vendor/DataPlotly/core/plot_types/icons/contour.svg +2056 -0
  126. qplotly/vendor/DataPlotly/core/plot_types/icons/histogram.svg +2048 -0
  127. qplotly/vendor/DataPlotly/core/plot_types/icons/pie.svg +2048 -0
  128. qplotly/vendor/DataPlotly/core/plot_types/icons/polar.svg +2055 -0
  129. qplotly/vendor/DataPlotly/core/plot_types/icons/scatterplot.svg +2048 -0
  130. qplotly/vendor/DataPlotly/core/plot_types/icons/scatterternary.svg +2055 -0
  131. qplotly/vendor/DataPlotly/core/plot_types/icons/violin.svg +2878 -0
  132. qplotly/vendor/DataPlotly/core/plot_types/pie.py +60 -0
  133. qplotly/vendor/DataPlotly/core/plot_types/plot_type.py +170 -0
  134. qplotly/vendor/DataPlotly/core/plot_types/polar.py +63 -0
  135. qplotly/vendor/DataPlotly/core/plot_types/scatter.py +74 -0
  136. qplotly/vendor/DataPlotly/core/plot_types/ternary.py +129 -0
  137. qplotly/vendor/DataPlotly/core/plot_types/violin.py +62 -0
  138. qplotly/vendor/__init__.py +0 -0
  139. 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'})