Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix datetime validator with timezone and milliseconds #487

Merged
merged 1 commit into from
Mar 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions g3w-admin/qdjango/utils/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ def _set_error(field_name, error):
request.setFilterExpression('to_date("%s") = \'%s\'' % (
field.name().replace('"', '\\"'), value.toString(Qt.ISODate)))
elif field.type() == QVariant.DateTime:
request.setFilterExpression('to_datetime("{field_name}") = \'{date_time_string}\' OR to_datetime("{field_name}") = \'{date_time_string}.000\''.format(
field_name=field.name().replace('"', '\\"'), date_time_string=value.toString(Qt.ISODate)))
request.setFilterExpression('to_datetime("{field_name}") = \'{date_time_string}\' OR to_datetime("{field_name}") = \'{date_time_string_ms}\''.format(
field_name=field.name().replace('"', '\\"'), date_time_string=value.toString(Qt.ISODate), date_time_string_ms=value.toString(Qt.ISODateWithMs)))
elif field.type() == QVariant.Bool: # This does not make any sense, but still
request.setFilterExpression('"%s" = %s' % (
field.name().replace('"', '\\"'), 'true' if value else 'false'))
Expand Down Expand Up @@ -252,7 +252,7 @@ def clean(self):
#else:
# new project: skip because we cannot have any embedded layer to be checked
# pass


class ProjectExists(QgisProjectValidator):
"""
Expand Down Expand Up @@ -393,7 +393,7 @@ def clean(self):
err += ugettext('which should be located at {}'.format(
self.qgisProjectLayer.datasource))
raise QgisProjectLayerException(err)

else:
if not os.path.exists(self.qgisProjectLayer.datasource.split('|')[0]):
err = ugettext('Missing data file for layer {} '.format(
Expand Down