Fix role valid until date handling. Fixes #1107

This commit is contained in:
Murtuza Zabuawala 2016-06-10 16:12:51 +01:00 committed by Dave Page
parent d5a91c969c
commit fcd33162a9
2 changed files with 16 additions and 2 deletions

View File

@ -133,6 +133,20 @@ class RoleView(PGChildNodeView):
_("Name must be specified.")
)
if u'rolvaliduntil' in data:
# Make date explicit so that it works with every
# postgres database datestyle format
try:
if data[u'rolvaliduntil'] is not None:
date = datetime.datetime.strptime(
data[u'rolvaliduntil'], '%m/%d/%Y'
)
data[u'rolvaliduntil'] = date.strftime("%d-%B-%Y")
except Exception as e:
return precondition_required(
_("Date format is invalid.")
)
if u'rolconnlimit' in data:
if data[u'rolconnlimit'] is not None:
data[u'rolconnlimit'] = int(data[u'rolconnlimit'])

View File

@ -403,10 +403,10 @@ function($, _, S, pgAdmin, pgBrowser, alertify, Backform) {
return false;
}
},{
id: 'rolvaliduntil', disabled: 'readonly', type: 'date',
id: 'rolvaliduntil', disabled: 'readonly', type: 'text',
group: '{{ _('Definition') }}', label: '{{ _('Account Expires') }}',
cell: 'string', mode: ['properties', 'edit', 'create'], retype: true,
deps: ['rolcanlogin'], options: {}
deps: ['rolcanlogin'], options: {}, control: 'datepicker'
},{
id: 'rolconnlimit', type: 'int', group: '{{ _('Definition') }}',
label: '{{ _('Connection Limit') }}', cell: 'number',