g3w-admin-processing 1.2.1b1.dev1__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 (80) hide show
  1. g3w_admin_processing-1.2.1b1.dev1.dist-info/METADATA +258 -0
  2. g3w_admin_processing-1.2.1b1.dev1.dist-info/RECORD +80 -0
  3. g3w_admin_processing-1.2.1b1.dev1.dist-info/WHEEL +5 -0
  4. g3w_admin_processing-1.2.1b1.dev1.dist-info/licenses/LICENSE +373 -0
  5. g3w_admin_processing-1.2.1b1.dev1.dist-info/top_level.txt +1 -0
  6. qprocessing/__init__.py +7 -0
  7. qprocessing/admin.py +21 -0
  8. qprocessing/api/__init__.py +0 -0
  9. qprocessing/api/permissions.py +41 -0
  10. qprocessing/api/views/__init__.py +4 -0
  11. qprocessing/api/views/actions.py +84 -0
  12. qprocessing/api/views/admin.py +76 -0
  13. qprocessing/api/views/models.py +219 -0
  14. qprocessing/api/views/upload.py +177 -0
  15. qprocessing/apiurls.py +64 -0
  16. qprocessing/apps.py +38 -0
  17. qprocessing/configs.py +131 -0
  18. qprocessing/forms.py +133 -0
  19. qprocessing/migrations/0001_initial.py +24 -0
  20. qprocessing/migrations/0002_auto_20230615_1609.py +23 -0
  21. qprocessing/migrations/0003_qprocessinginputupload.py +32 -0
  22. qprocessing/migrations/0004_auto_20230809_0920.py +26 -0
  23. qprocessing/migrations/0005_alter_qprocessinginputupload_user.py +21 -0
  24. qprocessing/migrations/__init__.py +0 -0
  25. qprocessing/models.py +143 -0
  26. qprocessing/receivers.py +100 -0
  27. qprocessing/sitetrees.py +31 -0
  28. qprocessing/static/qprocessing/js/components/DrawInputVectorFeatures.js +180 -0
  29. qprocessing/static/qprocessing/js/components/InputFieldChooser.js +226 -0
  30. qprocessing/static/qprocessing/js/components/InputPrjRasterLayer.js +135 -0
  31. qprocessing/static/qprocessing/js/components/InputPrjVectorLayer.js +415 -0
  32. qprocessing/static/qprocessing/js/components/ModelPanel.js +496 -0
  33. qprocessing/static/qprocessing/js/components/ModelResults.js +73 -0
  34. qprocessing/static/qprocessing/js/components/OutputFile.js +63 -0
  35. qprocessing/static/qprocessing/js/components/OutputRasterLayer.js +63 -0
  36. qprocessing/static/qprocessing/js/components/OutputVectorLayer.js +115 -0
  37. qprocessing/static/qprocessing/js/components/UploadVectorFile.js +53 -0
  38. qprocessing/static/qprocessing/js/i18n/en.js +33 -0
  39. qprocessing/static/qprocessing/js/i18n/index.js +7 -0
  40. qprocessing/static/qprocessing/js/i18n/it.js +33 -0
  41. qprocessing/static/qprocessing/js/plugin.js +122 -0
  42. qprocessing/tasks.py +136 -0
  43. qprocessing/templates/qprocessing/project_form.html +70 -0
  44. qprocessing/templates/qprocessing/projects_list.html +72 -0
  45. qprocessing/tests/__init__.py +0 -0
  46. qprocessing/tests/base.py +104 -0
  47. qprocessing/tests/data/models/qbuffer.model3 +233 -0
  48. qprocessing/tests/data/models/qintersection.model3 +288 -0
  49. qprocessing/tests/data/models/qpointspolygons.model3 +222 -0
  50. qprocessing/tests/data/models/test.model3 +321 -0
  51. qprocessing/tests/data/models/test_buffer_all_inputs.model3 +269 -0
  52. qprocessing/tests/data/models/test_buffer_layer1.model3 +201 -0
  53. qprocessing/tests/data/project_data/buildings.geojson +15 -0
  54. qprocessing/tests/data/project_data/qprocessing.gpkg +0 -0
  55. qprocessing/tests/data/qprocessing_qprocessing.qgs +2813 -0
  56. qprocessing/tests/data/qprocessing_qprocessing_attachments.zip +0 -0
  57. qprocessing/tests/data/test_qgis_328.qgs +954 -0
  58. qprocessing/tests/data/test_qgis_328_attachments.zip +0 -0
  59. qprocessing/tests/data/upload/fail_shp_to_upload.zip +0 -0
  60. qprocessing/tests/data/upload/linestring_to_upload.geojson +9 -0
  61. qprocessing/tests/data/upload/point_to_upload.geojson +10 -0
  62. qprocessing/tests/data/upload/point_to_upload_espg4326.geojson +10 -0
  63. qprocessing/tests/data/upload/point_to_upload_espg4326.qmd +26 -0
  64. qprocessing/tests/data/upload/polygon_to_upload.geojson +9 -0
  65. qprocessing/tests/data/upload/shp_to_upload.cpg +1 -0
  66. qprocessing/tests/data/upload/shp_to_upload.dbf +0 -0
  67. qprocessing/tests/data/upload/shp_to_upload.prj +1 -0
  68. qprocessing/tests/data/upload/shp_to_upload.qix +0 -0
  69. qprocessing/tests/data/upload/shp_to_upload.shp +0 -0
  70. qprocessing/tests/data/upload/shp_to_upload.shx +0 -0
  71. qprocessing/tests/data/upload/shp_to_upload.zip +0 -0
  72. qprocessing/tests/test_algorithm.py +52 -0
  73. qprocessing/tests/test_api.py +173 -0
  74. qprocessing/tests/test_api_models.py +459 -0
  75. qprocessing/urls.py +33 -0
  76. qprocessing/utils/__init__.py +0 -0
  77. qprocessing/utils/data.py +283 -0
  78. qprocessing/utils/exceptions.py +20 -0
  79. qprocessing/utils/formtypes.py +521 -0
  80. qprocessing/views.py +96 -0
@@ -0,0 +1,115 @@
1
+ const { GUI } = g3wsdk.gui;
2
+ const { uniqueId } = g3wsdk.core.utils;
3
+ const { createVectorLayerFromFile } = g3wsdk.core.geoutils;
4
+
5
+ export default ({
6
+
7
+ // language=html
8
+ template: /* html */ `
9
+ <div
10
+ v-t-tooltip:top.create = "state.description"
11
+ class = "form-group">
12
+ <label
13
+ style = "color:#fff !important;"
14
+ :for = "state.name"
15
+ class = "col-sm-12">{{ state.label }}
16
+ </label>
17
+ <div class="col-sm-12">
18
+ <select
19
+ :id = "state.name"
20
+ v-select2 = "'type'"
21
+ ref = "select2"
22
+ class = "form-control qprocessing-output-vectorlayer-select"
23
+ >
24
+ <option
25
+ v-for = "({key, value}) in state.input.options.values"
26
+ :key = "key"
27
+ :value = "value">{{key}}
28
+ </option>
29
+ </select>
30
+ <input
31
+ style = "width:100%;"
32
+ class = "magic-checkbox"
33
+ v-model = "checked"
34
+ type = "checkbox"
35
+ :id = "state.name + '_checkbox'"
36
+ ><label
37
+ style = "margin-top: 10px;"
38
+ :for = "state.name + '_checkbox'"
39
+ v-t-plugin = "'qprocessing.outputs.outputvector.open_file_on_map'"
40
+ ></label>
41
+ </div>
42
+ </div>`,
43
+
44
+ name: "OutputVectorLayer",
45
+ props: {
46
+ state: {
47
+ type: Object,
48
+ required: true
49
+ },
50
+ task: {
51
+ required: true
52
+ }
53
+ },
54
+ data() {
55
+ this.state.value = this.state.input.options.values[0].value;
56
+ return {
57
+ checked: true,
58
+ type: this.state.value,
59
+ }
60
+ },
61
+ methods: {
62
+ changeSelect(value) {
63
+ this.state.value = value;
64
+ }
65
+ },
66
+ watch: {
67
+ type(value) {
68
+ this.changeSelect(value)
69
+ },
70
+ async task(res={}) {
71
+ const {task_result={}} = res;
72
+ //get value from name of the output
73
+ const downloadUrl = task_result[this.state.name];
74
+
75
+ //add to map
76
+ if (this.checked) {
77
+ let name = `${uniqueId()}_${this.type}`, crs = GUI.getService('map').getEpsg();
78
+ // convert shp → zip
79
+ const type = 'shp' !== this.type ? this.type : 'zip';
80
+ const response = await fetch(downloadUrl);
81
+ try {
82
+ name = response.headers.get("content-disposition").split('filename=')[1].replace(/"/g,'');
83
+ } catch(e) {
84
+ console.warn(e);
85
+ }
86
+ let data = await response.blob();
87
+
88
+ // skip adding csv file to map
89
+ if ('csv' === type) {
90
+ return;
91
+ }
92
+
93
+ // ie. geojson, kml
94
+ if (!['zip', 'kmz'].includes(type)) {
95
+ data = await (new Promise(resolve => {
96
+ const reader = new FileReader();
97
+ reader.addEventListener("load", () => { resolve(reader.result) }, false);
98
+ reader.readAsText(data);
99
+ }));
100
+ }
101
+
102
+ GUI.getService('map').addExternalLayer(
103
+ await createVectorLayerFromFile({ name, data, crs, mapCrs: crs, type }),
104
+ { type, downloadUrl, color: `#${((1<<24)*Math.random() | 0).toString(16)}` });
105
+ }
106
+
107
+ //always add to results
108
+ this.$emit('add-result-to-model-results', {
109
+ output: this.state,
110
+ result: task_result
111
+ })
112
+
113
+ }
114
+ },
115
+ });
@@ -0,0 +1,53 @@
1
+ export default ({
2
+
3
+ // language=html
4
+ template: /* html */ `
5
+ <div
6
+ class = "qprocessing-upload-vector-file"
7
+ style = "flex-grow: 2"
8
+ >
9
+ <section class="upload-file-content">
10
+ <form
11
+ class = "addlayer skin-border-color"
12
+ v-t-tooltip:top.create = "'mapcontrols.add_layer_control.drag_layer'"
13
+ >
14
+ <input
15
+ ref = "file"
16
+ type = "file"
17
+ title = " "
18
+ @change = "$emit('add-layer', { file: $refs.file.files[0], type: 'upload' })"
19
+ accept = ".zip,.geojson,.GEOJSON,.kml,.kmz,.KMZ,.KML,.json,.gpx,.gml,.csv"
20
+ />
21
+ <div class="drag_and_drop">
22
+ <i :class="g3wtemplate.getFontClass('cloud-upload')" class="fa-2x" aria-hidden="true"></i>
23
+ </div>
24
+ </form>
25
+ </section>
26
+ </div>`,
27
+
28
+ name: "UploadVectorFile",
29
+ props: {
30
+ upload: {
31
+ type: Boolean,
32
+ }
33
+ },
34
+ data() {
35
+ return {
36
+ layer: {
37
+ name: null,
38
+ id: null
39
+ }
40
+ }
41
+ },
42
+ })
43
+
44
+
45
+ document.head.insertAdjacentHTML(
46
+ 'beforeend',
47
+ /* css */`
48
+ <style>
49
+ .qprocessing-upload-vector-file form.addlayer { position: relative; border: 2px dashed; text-align: center; border-radius: 3px; }
50
+ .qprocessing-upload-vector-file .addlayer input { position: absolute; margin: 0; padding: 0; width: 100%; height: 100%; outline: 0; opacity: 0; cursor: pointer; display: block; }
51
+ .qprocessing-upload-vector-file .drag_and_drop { line-height: 20px; padding: 5px; color: #fff; }
52
+ </style>`,
53
+ );
@@ -0,0 +1,33 @@
1
+ export default {
2
+ title: 'Geoprocessing',
3
+ inputs: {
4
+ prjvectorlayerfeature: {
5
+ selected_features: "Only selected features"
6
+ },
7
+ fieldchooser: {
8
+ validate: {
9
+ message: {
10
+ multiple: "Select at least a field",
11
+ single: "Select at least a field"
12
+ }
13
+ }
14
+ }
15
+ },
16
+ outputs: {
17
+ outputvector: {
18
+ open_file_on_map: "Open output file after running algorithm"
19
+ }
20
+ },
21
+ run :{
22
+ messages: {
23
+ success: "Model run successfully",
24
+ error: "An Error occur on model"
25
+ }
26
+ },
27
+ draw_types: {
28
+ 'Polygon': "Polygon",
29
+ 'LineString': "Line",
30
+ 'Point': "Point",
31
+ },
32
+ draw_filename: 'Draw layer',
33
+ }
@@ -0,0 +1,7 @@
1
+ import it from './it';
2
+ import en from './en';
3
+
4
+ export default {
5
+ it,
6
+ en,
7
+ }
@@ -0,0 +1,33 @@
1
+ export default {
2
+ title: 'Geoprocessing',
3
+ inputs: {
4
+ prjvectorlayerfeature: {
5
+ selected_features: "Solo features selezionate",
6
+ },
7
+ fieldchooser: {
8
+ validate: {
9
+ message: {
10
+ multiple: "Seleziona almeno un campo",
11
+ single: "Seleziona un campo"
12
+ }
13
+ }
14
+ }
15
+ },
16
+ outputs: {
17
+ outputvector: {
18
+ open_file_on_map: "Apri il file sulla mappa"
19
+ }
20
+ },
21
+ run :{
22
+ messages: {
23
+ success: "Modello eseguito con successo",
24
+ error: "Errore durante l'esecuzione del modello"
25
+ }
26
+ },
27
+ draw_types: {
28
+ 'Polygon': "Poligono",
29
+ 'LineString': "Linea",
30
+ 'Point': "Punto",
31
+ },
32
+ draw_filename: 'Layer disegnato',
33
+ }
@@ -0,0 +1,122 @@
1
+ (async function() { try {
2
+
3
+ const BASE_URL = `${initConfig.group.plugins.qprocessing.baseUrl}qprocessing/js`;
4
+
5
+ const { ApplicationState } = g3wsdk.core;
6
+ const { Plugin } = g3wsdk.core.plugin;
7
+ const { ProjectsRegistry } = g3wsdk.core.project;
8
+ const { GUI, Panel } = g3wsdk.gui;
9
+
10
+ new class extends Plugin {
11
+ constructor() {
12
+ super({ name: 'qprocessing' });
13
+
14
+ // i18n
15
+ const VM = new Vue();
16
+ const i18n = async lang => {
17
+ this.setLocale({ [lang]: (await import(`${BASE_URL}/i18n/${lang}.js`)).default });
18
+ };
19
+
20
+ VM.$watch(() => ApplicationState.language, i18n);
21
+
22
+ // Show loading plugin icon
23
+ this.setHookLoading({ loading: true });
24
+
25
+ GUI.isReady().then(async() => {
26
+
27
+ if (!this.registerPlugin(this.config.gid)) {
28
+ return;
29
+ }
30
+
31
+ await i18n(ApplicationState.language);
32
+
33
+ this.emitChangeSelectedFeatures = () => this.emit('change-selected-features');
34
+ this.registersSelectedFeatureLayersEvent = this.registersSelectedFeatureLayersEvent.bind(this);
35
+ this.unregistersSelectedFeatureLayersEvent = this.unregistersSelectedFeatureLayersEvent.bind(this);
36
+
37
+ // layer fields based on layerId and datatype
38
+ this.layerFields = {};
39
+
40
+ this.createSideBarComponent({
41
+ data: () => ({ models: this.config.models, service: this }),
42
+ template: /* html */`
43
+ <ul
44
+ id = "g3w-client-plugin-qprocessing"
45
+ class = "treeview-menu g3w-tools menu-items"
46
+ >
47
+ <li
48
+ v-for = "model in models"
49
+ :key = "model.id"
50
+ @click.stop = "service.showPanel(model)"
51
+ >
52
+ <i :class="g3wtemplate.getFontClass('tool')"></i>
53
+ <span>{{ model.display_name }}</span>
54
+ </li>
55
+ </ul>
56
+ `,
57
+ }, this.config.sidebar);
58
+
59
+ this.setHookLoading({loading: false});
60
+
61
+ this.setReady(true);
62
+ });
63
+ }
64
+
65
+ async showPanel(model) {
66
+ new Panel({
67
+ id: 'qprocessing-panel',
68
+ title: 'plugins.qprocessing.title',
69
+ internalPanel: new (Vue.extend((await import(BASE_URL + '/components/ModelPanel.js')).default))({
70
+ propsData: { model },
71
+ }),
72
+ show: true,
73
+ });
74
+ }
75
+
76
+ registersSelectedFeatureLayersEvent() {
77
+ GUI.getService('map').defaultsLayers.selectionLayer.getSource().on('addfeature', this.emitChangeSelectedFeatures);
78
+ GUI.getService('map').defaultsLayers.selectionLayer.getSource().on('removefeature', this.emitChangeSelectedFeatures);
79
+ }
80
+
81
+ unregistersSelectedFeatureLayersEvent() {
82
+ GUI.getService('map').defaultsLayers.selectionLayer.getSource().un('addfeature', this.emitChangeSelectedFeatures);
83
+ GUI.getService('map').defaultsLayers.selectionLayer.getSource().un('removefeature', this.emitChangeSelectedFeatures);
84
+ }
85
+
86
+ createGeoJSONFile({features=[], name, crs}={}) {
87
+ return new File(
88
+ [JSON.stringify(Object.assign(
89
+ (new ol.format.GeoJSON()).writeFeaturesObject(features), {
90
+ crs: {
91
+ type: "name",
92
+ properties: {
93
+ "name": crs || GUI.getService('map').getCrs() //add crs to geojsonObject
94
+ }
95
+ }
96
+ }))],
97
+ `${name}.geojson`,
98
+ {
99
+ type: "application/geo+json",
100
+ }
101
+ );
102
+ }
103
+
104
+ async uploadFile({modelId, inputName, file}) {
105
+ const data = new FormData();
106
+ data.append('file', file);
107
+ const response = await fetch(`${this.config.urls.upload}${modelId}/${ProjectsRegistry.getCurrentProject().getId()}/${inputName}/`, {
108
+ method: 'POST',
109
+ body: data,
110
+ });
111
+ const json = await response.json();
112
+ if (json.result) {
113
+ return {
114
+ key: file.name,
115
+ value: `file:${json.data.file}`
116
+ }
117
+ }
118
+ }
119
+
120
+ }
121
+
122
+ } catch (e) { console.error(e); } })();
qprocessing/tasks.py ADDED
@@ -0,0 +1,136 @@
1
+ # coding=utf-8
2
+ """" Module for async scripting
3
+ .. note:: This program is free software; you can redistribute it and/or modify
4
+ it under the terms of the Mozilla Public License 2.0.
5
+
6
+ """
7
+
8
+ __author__ = 'lorenzetti@gis3w.it'
9
+ __date__ = '2023-05-23'
10
+ __copyright__ = 'Copyright 2015 - 2023, Gis3w'
11
+ __license__ = 'MPL 2.0'
12
+
13
+ from functools import wraps
14
+
15
+ from django.db import close_old_connections
16
+ from django.contrib.auth.models import User
17
+ from django.conf import settings
18
+ from huey.contrib.djhuey import HUEY
19
+ from huey_monitor.tqdm import ProcessInfo
20
+ from celery import shared_task, current_task
21
+ from celery.utils.log import get_task_logger
22
+ from .models import QProcessingProject
23
+ from .utils.data import QProcessingModel
24
+ from qgis.core import QgsProcessingContext, QgsProcessingFeedback, QgsProject, Qgis
25
+
26
+
27
+ import logging
28
+
29
+ logger = logging.getLogger('qprocessing')
30
+
31
+ task = HUEY.task
32
+
33
+ celery_logger = get_task_logger(__name__)
34
+
35
+ def run_model_test(qprocessing_project_pk, project_pk, params):
36
+
37
+
38
+ print(qprocessing_project_pk)
39
+ qpp = QProcessingProject.objects.get(pk=qprocessing_project_pk)
40
+ prj = qpp.projects.get(pk=project_pk)
41
+ print(prj)
42
+ print(prj.qgis_project)
43
+
44
+
45
+ return True
46
+
47
+ def run_model(url_params, form_data, **kwargs):
48
+ """
49
+ Run processing model
50
+ """
51
+
52
+ qpp = QProcessingProject.objects.get(pk=url_params['qprocessingproject_pk'])
53
+ qpm = QProcessingModel(str(qpp.model.file))
54
+
55
+ prj_instance = qpp.projects.get(pk=url_params['project_pk'])
56
+ # prj = prj_instance.qgis_project
57
+ # prj = QgsProject()
58
+ # flags = Qgis.ProjectReadFlags()
59
+ # flags |= Qgis.ProjectReadFlag.DontLoadLayouts
60
+ # # flags |= Qgis.ProjectReadFlag.DontResolveLayers
61
+ # prj.read(str(prj_instance.qgis_file.path), flags)
62
+
63
+ prj, params = qpm.make_model_params(form_data=form_data, qproject=prj_instance, **kwargs)
64
+
65
+ qpm = QProcessingModel(str(qpp.model.file))
66
+
67
+ ctx = QgsProcessingContext()
68
+ if settings.DEBUG and Qgis.QGIS_VERSION_INT >= 33400:
69
+ ctx.setLogLevel(QgsProcessingContext.LogLevel.ModelDebug)
70
+ ctf = QgsProcessingFeedback()
71
+
72
+ ctx.setProject(prj)
73
+ res = qpm.process_algorithm(params, ctx, ctf)
74
+
75
+ # Replace outputs
76
+ res = qpm.make_outputs(res, url_params['qprocessingproject_pk'], url_params['project_pk'])
77
+
78
+ return res
79
+
80
+ def close_db(fn):
81
+ """Decorator called by db_task() to be used with tasks that may operate
82
+ on the database.
83
+
84
+ This implementation is a copy of djhuey implementation but it falls
85
+ back to noop when HUEY.testing is True.
86
+
87
+ Set HUEY.testing to True to skip DB connection close.
88
+
89
+ """
90
+
91
+ @wraps(fn)
92
+ def inner(*args, **kwargs):
93
+ try:
94
+ return fn(*args, **kwargs)
95
+ finally:
96
+ if not HUEY.immediate and not getattr(HUEY, 'testing', False):
97
+ close_old_connections()
98
+ return inner
99
+
100
+
101
+ def db_task(*args, **kwargs):
102
+ """Decorator to be used with tasks that may operate on the database.
103
+
104
+ This implementation is a copy of djhuey implementation but it falls
105
+ back to noop when HUEY.testing is True.
106
+
107
+ Set HUEY.testing to True to skip DB connection close.
108
+
109
+ """
110
+
111
+ def decorator(fn):
112
+ ret = task(*args, **kwargs)(close_db(fn))
113
+ ret.call_local = fn
114
+ return ret
115
+ return decorator
116
+
117
+ @db_task(context=True)
118
+ def run_model_task(url_params, form_data, task, **kwargs):
119
+ """
120
+ Run processing model
121
+ """
122
+
123
+ process_info = ProcessInfo(
124
+ task,
125
+ desc='Run Processing Model'
126
+ )
127
+
128
+ #return run_model(qpp.pk, url_params['project_pk'], params)
129
+ return run_model(url_params, form_data, **kwargs)
130
+
131
+ @shared_task(name='run_model_celery', bind=True)
132
+ def run_model_celery_task(self, url_params, form_data, **kwargs):
133
+
134
+
135
+ model = run_model(url_params, form_data, **{'user': User.objects.get(pk=kwargs['user_pk'])})
136
+ return {}
@@ -0,0 +1,70 @@
1
+ {% extends "base.html" %}
2
+ {% load static %}
3
+ {% load g3wadmin_tags %}
4
+ {% load crispy_forms_tags %}
5
+ {% load i18n %}
6
+
7
+
8
+ {% block custom_js_links_page %}
9
+ <script>
10
+ const QPROCESSINGPROJECT_ID = {% if form.instance.pk %} {{ form.instance.pk }} {% else %} -1 {% endif %};
11
+ $(document).ready(function(){
12
+ ga.$projectSelect = $('#id_projects');
13
+ ga.$projectSelect.on('change', function(e){
14
+
15
+ var value = $(this).val();
16
+ var $viewers_select = $("#id_viewer_users");
17
+ var $viewer_groups_select = $("#id_viewer_user_groups");
18
+ if (value) {
19
+ $.ajax({
20
+ url: '{% url 'qprocessing-viewer-users' %}' + '?project_id='+value+'&qpp_id='+QPROCESSINGPROJECT_ID,
21
+ success:function(res){
22
+ $viewers_select.html('');
23
+ $viewers_select.select2({data: res.viewer_users});
24
+ $viewer_groups_select.html('');
25
+ $viewer_groups_select.select2({data: res.group_viewers});
26
+ }
27
+
28
+ });
29
+ } else {
30
+ $("#id_viewer_users").select2('val', '');
31
+ $("#id_viewer_user_groups").select2('val', '');
32
+ }
33
+
34
+ });
35
+ // to start
36
+ ga.$projectSelect.trigger('change');
37
+ });
38
+ </script>
39
+ {% endblock %}
40
+
41
+
42
+ {% block page_header %}
43
+ <h1>
44
+ {% if form.instance.pk %}
45
+ {% trans 'QProcessing Project' %}
46
+ <small>{{ form.instance.project.title }}</small>
47
+ {% else %}
48
+ {% trans 'New' %} {% trans 'QProcessing Project' %}
49
+ {% endif %}
50
+
51
+ </h1>
52
+ {% endblock %}
53
+
54
+ {% block main_content %}
55
+
56
+ <form method="post" id="project-form" data-widget-type="ajaxUpload" enctype="multipart/form-data">
57
+ {% if form.errors %}
58
+ <div class="row">
59
+ <div class="col-md-12">
60
+ <div class="alert alert-danger alert-dismissable">
61
+ <h4><i class="icon fa fa-ban"></i> {% trans 'Alert' %}!</h4>
62
+ {% trans 'Some errors on form. Check it and send again.' %}
63
+ </div>
64
+ </div>
65
+ </div>
66
+ {% endif %}
67
+ {% crispy form %}
68
+ {% g3wadmin_add_button_form %}
69
+ </form>
70
+ {% endblock %}
@@ -0,0 +1,72 @@
1
+ {% extends "base.html" %}
2
+ {% load static %}
3
+ {% load crispy_forms_tags %}
4
+ {% load guardian_tags %}
5
+ {% load i18n %}
6
+
7
+ {% block page_header %}
8
+ <h1>
9
+ {% trans 'QProcessing Projects' %}
10
+ </h1>
11
+ {% endblock %}
12
+
13
+ {% block main_content %}
14
+ <div class="row">
15
+ <div class="col-md-12 col-xs-12">
16
+ <div class="box">
17
+ <div class="box-header">
18
+ {% if perms.auth.add_simplereopoproject %}
19
+ <a href="{% url 'qprocessing-project-add' %}" class="btn btn-info" id="btn-add-project"><i class="ion ion-plus-circled"></i> {% trans 'Project' %}</a>
20
+ {% endif %}
21
+ </div>
22
+ <div class="box-body">
23
+ <table id="qprocessingprojects_table" class="table table-hover table-striped" data-widget-type="dataTable">
24
+ <thead>
25
+ <tr>
26
+ <th style="width:120px">{% trans 'Actions' %}</th>
27
+ <th>{% trans 'Projects' %}</th>
28
+ <th>{% trans 'Model' %}</th>
29
+ <th>{% trans 'Note' %}</th>
30
+ </tr>
31
+ </thead>
32
+ {% for object in object_list %}
33
+ <tr id="qprocessing_project_{{ object.pk }}">
34
+ <td>
35
+
36
+ <span class="col-xs-4 icon">
37
+ <a href="{% url 'qprocessing-project-update' object.id %}" data-toggle="tooltip" data-placement="top" title="{% trans 'Edit' %}" ><i class="ion ion-edit"></i></a>
38
+ </span>
39
+ <span class="col-xs-4 icon">
40
+ <a href="#" data-toggle="tooltip" data-placement="top" title="{% trans 'Delete' %}" data-widget-type="deleteItem" data-delete-url="{% url 'qprocessing-project-delete' object.pk %}" data-item-selector="#qprocessing_project_{{ object.pk }}"><i class="ion ion-trash-b"></i></a>
41
+ </span>
42
+ </td>
43
+ <td>
44
+ {% for o in object.projects.all %}
45
+ {% get_obj_perms user for o as "userObj_perms" %}
46
+ {{ o }}
47
+ {% if "view_project" in userObj_perms %}
48
+ <a href="{% url 'group-project-map' o.group.slug 'qdjango' o.pk %}" data-toggle="tooltip" data-placement="top" title="{% trans 'Show map' %}" target="_blank"><i class="ion ion-map"></i></a>
49
+ {% endif %}
50
+ {% if "change_project" in userObj_perms %}
51
+ <a href="{% url 'qdjango-project-update' o.group.slug o.slug %}" data-toggle="tooltip" data-placement="top" title="{% trans 'Edit' %}" target="_blank"><i class="ion ion-edit"></i></a>
52
+ {% endif %}
53
+ {% if not forloop.last %}
54
+ |
55
+ {% endif %}
56
+
57
+ {% endfor %}
58
+ </td>
59
+ <td>
60
+ <a href="{{ SETTINGS.MEDIA_URL }}{{ object.model }}">{{ object.model }}</a>
61
+ </td>
62
+ <td>{{ object.note|safe }}</td>
63
+ </tr>
64
+ {% endfor %}
65
+ <tbody></tbody>
66
+ </table>
67
+ </div>
68
+ </div>
69
+ </div>
70
+
71
+ </div>
72
+ {% endblock %}
File without changes