add address validation in Company URL field
authorSurkov Sergey <surkovsv93@gmail.com>
Mon, 19 Feb 2018 19:02:25 +0300
changeset 1970 b524b356aa58
parent 1969 0607c382d73f
child 1971 62403f9b6ca9
add address validation in Company URL field
controls/ProjectPropertiesPanel.py
--- a/controls/ProjectPropertiesPanel.py	Fri Feb 02 17:16:04 2018 +0300
+++ b/controls/ProjectPropertiesPanel.py	Mon Feb 19 19:02:25 2018 +0300
@@ -26,6 +26,8 @@
 from __future__ import absolute_import
 import wx
 
+from xmlclass.xmlclass import URI_model
+
 # -------------------------------------------------------------------------------
 #                                 Helpers
 # -------------------------------------------------------------------------------
@@ -285,6 +287,14 @@
                 new_value = textctrl.GetValue()
                 if name not in REQUIRED_PARAMS and new_value == "":
                     new_value = None
+                if name == 'companyURL':
+                    if not URI_model.match(new_value):
+                        new_value = None
+                        dialog = wx.MessageDialog(self, _('Invalid URL!\n'
+                                                          'Please enter correct URL address.'),
+                                                  _("Error"), wx.OK | wx.ICON_ERROR)
+                        dialog.ShowModal()
+                        dialog.Destroy()
                 if old_value != new_value:
                     self.Controller.SetProjectProperties(properties={name: new_value})
                     self.ParentWindow._Refresh(TITLE, FILEMENU, EDITMENU,