Skip to content

Commit

Permalink
Added registry STDM version to show changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
wondie committed Jan 6, 2018
1 parent 2ff2cb1 commit e365f4d
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 27 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ All notable changes of the Social Tenure Domain Model(STDM) is documented in thi
- **Designer**: Added three sample templates.
- **Designer**: Added the ability to add HTML in data labels.
- **Designer**: Added the ability to add inline text in data label items.
- **Documents Generator**: Added Open output folder to open the output folder.
- **Documents Generator**: Added Open output folder to open the output folder.
- **STDM Mobile**: Added mobile form export and mobile data import using GeoODK apps.
- **Styling Lookups**: Added conversion of lookup IDs to values in QGIS attribute table for styling.
- **Registry**: Added registry STDM version that is the same as metadata version.

### Fixed
- **Export Data**: Fixed encoding issues when exporting data.
Expand Down
97 changes: 71 additions & 26 deletions plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
from stdm.settings.registryconfig import (
RegistryConfig,
WIZARD_RUN,
STDM_VERSION,
CONFIG_UPDATED,
HOST,
composer_template_path
Expand Down Expand Up @@ -148,7 +149,7 @@ def __init__(self, iface):
self.stdmTables = []

self.stdm_config = StdmConfiguration.instance()

self.reg_config = RegistryConfig()
self.spatialLayerMangerDockWidget = None

self._user_logged_in = False
Expand Down Expand Up @@ -332,7 +333,7 @@ def login(self):
return

try:

self.show_change_log()
#Set current profile
self.current_profile = current_profile()

Expand Down Expand Up @@ -429,16 +430,14 @@ def run_wizard(self):
:return:
:rtype:
"""
reg_config = RegistryConfig()

host = reg_config.read([HOST])
host = self.reg_config.read([HOST])
host_val = host[HOST]

if host_val != u'localhost':
if host_val != u'127.0.0.1':
return

wizard_key = reg_config.read(
wizard_key = self.reg_config.read(
[WIZARD_RUN]
)

Expand Down Expand Up @@ -557,11 +556,11 @@ def on_update_complete(self, document):
"""
# TODO remove this line below when schema updater is refactored
self.config_serializer.on_version_updated(document)
registry_config = RegistryConfig()
registry_config.write(

self.reg_config.write(
{WIZARD_RUN: 1}
)
self.show_change_log()

self.progress.hide()
self.progress.cancel()

Expand Down Expand Up @@ -601,30 +600,76 @@ def load_configuration_to_serializer(self):

return False

def stdm_reg_version(self, metadata_version):
"""
Checks and set STDM registry version using metadata version.
:param metadata_version: The metadata version
:type metadata_version: String
:return: Result of the check or update.
If reg_version is not set, it returns 'new'
If reg_version is different from metadata returns 'updated'
If reg_version is same as metadata returns 'non-updated'
:rtype: String
"""
reg_version_dict = self.reg_config.read(
[STDM_VERSION]
)

if STDM_VERSION in reg_version_dict.keys():
reg_version = reg_version_dict[STDM_VERSION]

else:
reg_version = None

if reg_version is None:
self.reg_config.write(
{STDM_VERSION: metadata_version}
)
return 'new'
elif metadata_version != reg_version:
self.reg_config.write(
{STDM_VERSION: metadata_version}
)
# compare major versions and mark it return 'updated' if major update.
md_major_version = metadata_version.rsplit('.', 1)[0]
reg_major_version = reg_version.rsplit('.', 1)[0]

if md_major_version !=reg_major_version:
return 'updated'
else:
return 'non-updated'
elif metadata_version == reg_version:
return 'non-updated'

def show_change_log(self):
"""
Shows the change log the new version of STDM.
"""
version = version_from_metadata()
title = QApplication.translate(
'ConfigurationFileUpdater',
'Upgrade Information'
)
# Get the big releases only not minor ones.
major_version = version.rsplit('.', 1)[0]
result = self.stdm_reg_version(version)

message = QApplication.translate(
'ConfigurationFileUpdater',
'Would you like to view the '
'new features and changes of STDM {}?'.format(version)
)
if result == 'updated':
title = QApplication.translate(
'ConfigurationFileUpdater',
'Upgrade Information'
)

result, checkbox_result = simple_dialog(
self.iface.mainWindow(),
title,
message
)
if result:
change_log = ChangeLog(self.iface.mainWindow())
change_log.show_change_log(self.plugin_dir)
message = QApplication.translate(
'ConfigurationFileUpdater',
'Would you like to view the '
'new features and changes of STDM {}?'.format(major_version)
)

result, checkbox_result = simple_dialog(
self.iface.mainWindow(),
title,
message
)
if result:
change_log = ChangeLog(self.iface.mainWindow())
change_log.show_change_log(self.plugin_dir)

def copy_designer_template(self):
"""
Expand Down
2 changes: 2 additions & 0 deletions settings/registryconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"""
from PyQt4.QtCore import QSettings
from PyQt4.QtGui import QColor

#Names of registry keys
NETWORK_DOC_RESOURCE = 'NetDocumentResource'
PATHKEYS = ['Config','NetDocumentResource','ComposerOutputs','ComposerTemplates']
Expand All @@ -38,6 +39,7 @@
HOST = 'Host'
FIRST_LOGIN = 'FirstLogin'
STDM_PLUGIN = 'stdm'
STDM_VERSION = 'STDMVersion'

def registry_value(key_name):
"""
Expand Down

0 comments on commit e365f4d

Please sign in to comment.