Skip to content

Commit

Permalink
Release v2.1 (#136)
Browse files Browse the repository at this point in the history
* Update metadata to 2.1

* result_selector, control inserting of add_element | add_file if element_id | doc_id are null

* Set missing headers
Remove unused imports
Remove TODO's
  • Loading branch information
daviderill authored Feb 16, 2017
1 parent b2daeea commit 4966064
Show file tree
Hide file tree
Showing 22 changed files with 110 additions and 545 deletions.
26 changes: 19 additions & 7 deletions actions/ed.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
'''

# -*- coding: utf-8 -*-

from PyQt4.QtGui import QCompleter, QLineEdit, QStringListModel, QDateTimeEdit, QFileDialog, QPushButton
from qgis.gui import QgsMessageBar
from qgis.core import QgsExpression

import os
import sys
Expand Down Expand Up @@ -113,7 +111,7 @@ def ed_search_plus(self):
try:
if self.search_plus is not None:
self.search_plus.dlg.setVisible(True)
except RuntimeError as e:
except RuntimeError:
pass


Expand Down Expand Up @@ -256,9 +254,9 @@ def get_date(self):

# Check if interval is valid
if (date_from < date_to):
expr = QgsExpression('format_date("date",\'yyyyMMdd\') > ' + self.date_document_from.date().toString('yyyyMMdd')+'AND format_date("date",\'yyyyMMdd\') < ' + self.date_document_to.date().toString('yyyyMMdd')+ ' AND "arc_id" ='+ self.arc_id_selected+'' )
pass
else :
message="Valid interval!"
message = "Date interval not valid!"
self.iface.messageBar().pushMessage(message, QgsMessageBar.WARNING, 5)
return

Expand Down Expand Up @@ -302,7 +300,13 @@ def ed_add_element_accept(self):
rotation = utils_giswater.getWidgetText("rotation")
link = utils_giswater.getWidgetText("link")
verified = utils_giswater.getWidgetText("verified")


if element_id == 'null':
# Show warning message
message = "You need to insert element_id"
self.controller.show_warning(message, context_name='ui_message')
return

# Check if we already have data with selected element_id
sql = "SELECT DISTINCT(element_id) FROM "+self.schema_name+".element WHERE element_id = '"+element_id+"'"
row = self.dao.get_row(sql)
Expand Down Expand Up @@ -567,6 +571,12 @@ def ed_add_file_accept(self):
observ = utils_giswater.getWidgetText("observ")
path = utils_giswater.getWidgetText("path")


if doc_id == 'null':
# Show warning message
message = "You need to insert doc_id"
self.controller.show_warning(message, context_name='ui_message' )
return
# Check if this document already exists
sql = "SELECT DISTINCT(id) FROM "+self.schema_name+".doc WHERE id = '"+doc_id+"'"
row = self.dao.get_row(sql)
Expand Down Expand Up @@ -641,4 +651,6 @@ def open_web_browser(self, widget):
url = 'www.giswater.org'
webbrowser.open(url)
else :
webbrowser.open(url)
webbrowser.open(url)


44 changes: 17 additions & 27 deletions actions/mg.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
'''
This file is part of Giswater 2.0
The program is free software: you can redistribute it and/or modify it under the terms of the GNU
General Public License as published by the Free Software Foundation, either version 3 of the License,
or (at your option) any later version.
'''

# -*- coding: utf-8 -*-
from PyQt4.QtCore import Qt, QSettings
from PyQt4.QtGui import QFileDialog, QMessageBox, QCheckBox, QLineEdit, QCommandLinkButton, QTableView, QMenu, QPushButton
from qgis.gui import QgsMessageBar
from PyQt4.QtGui import QFileDialog, QMessageBox, QCheckBox, QLineEdit, QTableView, QMenu, QPushButton
from PyQt4.QtSql import QSqlTableModel

import os
Expand Down Expand Up @@ -101,9 +107,7 @@ def mg_arc_topo_repair_accept(self):
sql = "SELECT "+self.schema_name+".gw_fct_anl_node_sink();"
self.controller.execute_sql(sql)

# Show message and close the dialog
#message = "Selected functions have been executed"
#self.controller.show_info(message, context_name='ui_message')
# Close the dialog
self.close_dialog()

# Refresh map canvas
Expand Down Expand Up @@ -329,9 +333,7 @@ def mg_go2epa_accept(self):
self.gsw_settings.setValue('FILE_RPT', self.file_rpt)
self.gsw_settings.setValue('PROJECT_NAME', self.project_name)

# Show message and close form
# message = "Values has been updated"
# self.controller.show_info(message, context_name='ui_message')
# Close form
self.close_dialog(self.dlg)


Expand Down Expand Up @@ -418,21 +420,18 @@ def mg_result_selector_accept(self):
rpt_selector_result_id = utils_giswater.getWidgetText("rpt_selector_result_id")
rpt_selector_compare_id = utils_giswater.getWidgetText("rpt_selector_compare_id")

# Set project user
user = self.controller.set_project_user()

# Delete previous values
# Set new values to tables 'rpt_selector_result' and 'rpt_selector_compare'
sql = "DELETE FROM "+self.schema_name+".rpt_selector_result"
self.controller.execute_sql(sql)
sql = "DELETE FROM "+self.schema_name+".rpt_selector_compare"
self.controller.execute_sql(sql)

# Set new values to tables 'rpt_selector_result' and 'rpt_selector_compare'
sql = "INSERT INTO "+self.schema_name+".rpt_selector_result (result_id, cur_user)"
sql+= " VALUES ('"+rpt_selector_result_id+"', '"+user+"')"
sql+= " VALUES ('"+rpt_selector_result_id+"', '"+rpt_selector_compare_id+"')"
self.controller.execute_sql(sql)
#sql = "INSERT INTO "+self.schema_name+".rpt_selector_compare VALUES ('"+rpt_selector_compare_id+"');"
sql = "INSERT INTO "+self.schema_name+".rpt_selector_compare (result_id, cur_user)"
sql+= " VALUES ('"+rpt_selector_compare_id+"', '"+user+"')"
sql+= " VALUES ('"+rpt_selector_compare_id+"', '"+rpt_selector_compare_id+"')"
self.controller.execute_sql(sql)

# Show message to user
Expand All @@ -458,7 +457,6 @@ def mg_change_elem_type(self):
Combo to select new node_type.type
Combo to select new node_type.id
Combo to select new cat_node.id
TODO: Trigger 'gw_trg_edit_node' has to be disabled temporarily
'''

# Uncheck all actions (buttons) except this one
Expand Down Expand Up @@ -561,7 +559,7 @@ def mg_change_elem_type_accept(self):
message = "Node type has been update!"
self.controller.show_info(message, context_name='ui_message' )

# Close dialog
# Close form
self.close_dialog()


Expand Down Expand Up @@ -589,8 +587,6 @@ def mg_config(self):

self.om_visit_absolute_path = self.dlg.findChild(QLineEdit, "om_visit_absolute_path")
self.doc_absolute_path = self.dlg.findChild(QLineEdit, "doc_absolute_path")


self.om_visit_path = self.dlg.findChild(QLineEdit, "om_visit_absolute_path")
self.doc_path = self.dlg.findChild(QLineEdit, "doc_absolute_path")

Expand All @@ -605,17 +601,14 @@ def mg_config(self):
row = self.dao.get_row(sql)
if row :
path = str(row['value'])
self.om_visit_absolute_path.setText(path)
#self.om_visit_absolute_path.clicked.connect(partial(self.geth_path, path))
self.om_visit_absolute_path.setText(path)

sql = "SELECT value FROM "+self.schema_name+".config_param_text"
sql +=" WHERE id = 'doc_absolute_path'"
row = self.dao.get_row(sql)
if row :
path = str(row['value'])
self.doc_absolute_path.setText(path)
#self.doc_absolute_path.clicked.connect(partial(self.geth_path, path))


# Set values from widgets of type QComboBox
sql = "SELECT DISTINCT(type) FROM "+self.schema_name+".node_type ORDER BY type"
Expand Down Expand Up @@ -785,17 +778,14 @@ def fill_insert_menu(self,table):
if row == None:
self.menu.addAction(elem,partial(self.insert, elem,table))

#self.menu.activated.connect(self.insert)


def insert(self,id_action,table):
def insert(self, id_action, table):
''' On action(select value from menu) execute SQL '''

# Insert value into database
sql = "INSERT INTO "+self.schema_name+"."+table+" (id) "
sql+= " VALUES ('"+id_action+"')"
self.controller.execute_sql(sql)

self.fill_table(self.tbl, self.schema_name+"."+table)


Expand Down
17 changes: 7 additions & 10 deletions dao/controller.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
'''
This file is part of Giswater 2.0
The program is free software: you can redistribute it and/or modify it under the terms of the GNU
General Public License as published by the Free Software Foundation, either version 3 of the License,
or (at your option) any later version.
'''

# -*- coding: utf-8 -*-
from PyQt4.QtCore import QCoreApplication, QSettings
from PyQt4.QtGui import QCheckBox, QLabel, QMessageBox, QPushButton
Expand Down Expand Up @@ -358,15 +365,5 @@ def get_layer_source_key(self):

return uri_schema


def set_project_user(self):
# TODO: Set user
pass
'''
sql = "UPDATE "+self.schema_name+".rpt_selector_result"
sql+= " SET cur_user = '"+self.user+"'"
sql+= " WHERE id = '1'"
self.dao.execute_sql(sql)
'''


1 change: 0 additions & 1 deletion giswater.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
'''

# -*- coding: utf-8 -*-

from PyQt4.QtCore import QCoreApplication, QObject, QSettings, QTranslator
from PyQt4.QtGui import QAction, QActionGroup, QIcon

Expand Down
7 changes: 7 additions & 0 deletions init/ud_arc_init.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
'''
This file is part of Giswater 2.0
The program is free software: you can redistribute it and/or modify it under the terms of the GNU
General Public License as published by the Free Software Foundation, either version 3 of the License,
or (at your option) any later version.
'''

# -*- coding: utf-8 -*-
from PyQt4.QtGui import QPushButton, QTableView, QTabWidget

Expand Down
7 changes: 7 additions & 0 deletions init/ud_connec_init.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
'''
This file is part of Giswater 2.0
The program is free software: you can redistribute it and/or modify it under the terms of the GNU
General Public License as published by the Free Software Foundation, either version 3 of the License,
or (at your option) any later version.
'''

# -*- coding: utf-8 -*-
from PyQt4.QtGui import QPushButton, QTableView, QTabWidget

Expand Down
7 changes: 7 additions & 0 deletions init/ud_gully_init.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
'''
This file is part of Giswater 2.0
The program is free software: you can redistribute it and/or modify it under the terms of the GNU
General Public License as published by the Free Software Foundation, either version 3 of the License,
or (at your option) any later version.
'''

# -*- coding: utf-8 -*-
from PyQt4.QtGui import QPushButton, QTableView, QTabWidget

Expand Down
4 changes: 0 additions & 4 deletions init/ud_man_arc_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
'''

# -*- coding: utf-8 -*-

from PyQt4.QtGui import QPushButton, QTableView, QTabWidget, QLineEdit
from PyQt4.QtCore import Qt
from functools import partial
Expand Down Expand Up @@ -77,9 +76,6 @@ def init_config_form(self):
# Load data from related tables
self.load_data()

# Set layer in editing mode
# self.layer.startEditing()

# Manage tab visibility
self.set_tabs_visibility(4)

Expand Down
16 changes: 2 additions & 14 deletions init/ud_man_connec_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,12 @@
'''

# -*- coding: utf-8 -*-

from PyQt4.QtGui import QComboBox, QDateEdit, QPushButton, QTableView, QTabWidget, QLineEdit
from PyQt4.QtGui import QPushButton, QTableView, QTabWidget

from functools import partial

import utils_giswater
from parent_init import ParentDialog
from ui.add_sum import Add_sum # @UnresolvedImport
from PyQt4.Qt import QDialogButtonBox


def formOpen(dialog, layer, feature):
Expand Down Expand Up @@ -56,7 +53,6 @@ def init_config_form(self):

table_element = "v_ui_element_x_connec"
table_document = "v_ui_doc_x_connec"
#table_event_connec = "v_ui_doc_x_connec"
table_event_connec = "v_ui_om_visit_x_connec"
table_hydrometer = "v_rtc_hydrometer"
table_hydrometer_value = "v_edit_rtc_hydro_data_x_connec"
Expand All @@ -80,9 +76,6 @@ def init_config_form(self):
# Load data from related tables
self.load_data()

# Set layer in editing mode
#self.layer.startEditing()

# Fill the info table
self.fill_table(self.tbl_info, self.schema_name+"."+table_element, self.filter)

Expand Down Expand Up @@ -114,15 +107,10 @@ def init_config_form(self):
# Configuration of table hydrometer | hydrometer value
self.set_configuration(self.tbl_hydrometer_value, table_hydrometer_value)


# Set signals
self.dialog.findChild(QPushButton, "btn_doc_delete").clicked.connect(partial(self.delete_records, self.tbl_document, table_document))
self.dialog.findChild(QPushButton, "delete_row_info").clicked.connect(partial(self.delete_records, self.tbl_info, table_element))
self.dialog.findChild(QPushButton, "btn_delete_hydrometer").clicked.connect(partial(self.delete_records_hydro, self.tbl_hydrometer))
self.dialog.findChild(QPushButton, "btn_add_hydrometer").clicked.connect(self.insert_records)


#self.dialog.findChild(QPushButton, "buttonBox").clicked.connect(self.save)




1 change: 0 additions & 1 deletion init/ud_man_gully_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
'''

# -*- coding: utf-8 -*-

from PyQt4.QtGui import QPushButton, QTableView, QTabWidget

from functools import partial
Expand Down
2 changes: 0 additions & 2 deletions init/ud_man_node_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
'''

# -*- coding: utf-8 -*-

from PyQt4.QtGui import QPushButton, QTableView, QTabWidget

from functools import partial
Expand Down Expand Up @@ -52,7 +51,6 @@ def init_config_form(self):
table_event_node = "v_ui_om_visit_x_node"
table_scada = "v_rtc_scada"
table_scada_value = "v_rtc_scada_value"

table_price_node = "v_price_x_node"

self.table_chamber = self.schema_name+'."v_edit_man_chamber"'
Expand Down
7 changes: 7 additions & 0 deletions init/ud_node_init.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
'''
This file is part of Giswater 2.0
The program is free software: you can redistribute it and/or modify it under the terms of the GNU
General Public License as published by the Free Software Foundation, either version 3 of the License,
or (at your option) any later version.
'''

# -*- coding: utf-8 -*-
from PyQt4.QtGui import QPushButton, QTableView, QTabWidget

Expand Down
10 changes: 9 additions & 1 deletion init/ws_arc_init.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
'''
This file is part of Giswater 2.0
The program is free software: you can redistribute it and/or modify it under the terms of the GNU
General Public License as published by the Free Software Foundation, either version 3 of the License,
or (at your option) any later version.
'''

# -*- coding: utf-8 -*-
from PyQt4.QtGui import QComboBox, QPushButton, QTableView, QTabWidget

from functools import partial

import utils_giswater
from parent_init import ParentDialog

Expand Down Expand Up @@ -97,7 +106,6 @@ def init_config_form(self):
# Set signals
btn_element_delete = self.dialog.findChild(QPushButton, "btn_element_delete")
btn_doc_delete = self.dialog.findChild(QPushButton, "btn_doc_delete")
# TODO
if btn_element_delete:
btn_element_delete.clicked.connect(partial(self.delete_records, self.tbl_info, table_element))
if btn_doc_delete:
Expand Down
Loading

0 comments on commit 4966064

Please sign in to comment.