auto-search on multiple matches
This commit is contained in:
parent
abb22ab0f8
commit
fa5de8ab39
3 changed files with 12 additions and 5 deletions
3
angular_app/js/controllers.js
vendored
3
angular_app/js/controllers.js
vendored
|
@ -293,6 +293,9 @@ eventManControllers.controller('EventTicketsCtrl', ['$scope', '$state', 'Event',
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (data.error && data.message) {
|
if (data.error && data.message) {
|
||||||
|
if (data.searchFor) {
|
||||||
|
$scope.query = angular.copy(data.searchFor);
|
||||||
|
}
|
||||||
toaster.pop({type: 'error', title: 'Error', body: data.message, timeout: 0, showCloseButton: true});
|
toaster.pop({type: 'error', title: 'Error', body: data.message, timeout: 0, showCloseButton: true});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -799,6 +799,10 @@ class EventsHandler(CollectionHandler):
|
||||||
if '_errorMessage' in arguments:
|
if '_errorMessage' in arguments:
|
||||||
_errorMessage = arguments['_errorMessage']
|
_errorMessage = arguments['_errorMessage']
|
||||||
del arguments['_errorMessage']
|
del arguments['_errorMessage']
|
||||||
|
_searchFor = False
|
||||||
|
if '_searchFor' in arguments:
|
||||||
|
_searchFor = arguments['_searchFor']
|
||||||
|
del arguments['_searchFor']
|
||||||
query = dict([('tickets.%s' % k, v) for k, v in arguments.items()])
|
query = dict([('tickets.%s' % k, v) for k, v in arguments.items()])
|
||||||
query['_id'] = id_
|
query['_id'] = id_
|
||||||
if ticket_id is not None:
|
if ticket_id is not None:
|
||||||
|
@ -818,13 +822,13 @@ class EventsHandler(CollectionHandler):
|
||||||
nr_matches = len(matching_tickets)
|
nr_matches = len(matching_tickets)
|
||||||
if nr_matches > 1:
|
if nr_matches > 1:
|
||||||
ret = {'error': True, 'message': 'more than one ticket matched. %s' % _errorMessage, 'query': query,
|
ret = {'error': True, 'message': 'more than one ticket matched. %s' % _errorMessage, 'query': query,
|
||||||
'uuid': uuid, 'username': self.current_user_info.get('username', '')}
|
'searchFor': _searchFor, 'uuid': uuid, 'username': self.current_user_info.get('username', '')}
|
||||||
self.send_ws_message('event/%s/tickets/updates' % id_, json.dumps(ret))
|
self.send_ws_message('event/%s/tickets/updates' % id_, json.dumps(ret))
|
||||||
self.set_status(400)
|
self.set_status(400)
|
||||||
return ret
|
return ret
|
||||||
elif nr_matches == 0:
|
elif nr_matches == 0:
|
||||||
ret = {'error': True, 'message': 'no ticket matched. %s' % _errorMessage, 'query': query,
|
ret = {'error': True, 'message': 'no ticket matched. %s' % _errorMessage, 'query': query,
|
||||||
'uuid': uuid, 'username': self.current_user_info.get('username', '')}
|
'searchFor': _searchFor, 'uuid': uuid, 'username': self.current_user_info.get('username', '')}
|
||||||
self.send_ws_message('event/%s/tickets/updates' % id_, json.dumps(ret))
|
self.send_ws_message('event/%s/tickets/updates' % id_, json.dumps(ret))
|
||||||
self.set_status(400)
|
self.set_status(400)
|
||||||
return ret
|
return ret
|
||||||
|
|
|
@ -75,7 +75,7 @@ class ImprovedEncoder(json.JSONEncoder):
|
||||||
datetime.time, datetime.timedelta)):
|
datetime.time, datetime.timedelta)):
|
||||||
try:
|
try:
|
||||||
return str(o)
|
return str(o)
|
||||||
except Exception as e:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
elif isinstance(o, set):
|
elif isinstance(o, set):
|
||||||
return list(o)
|
return list(o)
|
||||||
|
@ -127,7 +127,7 @@ class Connector():
|
||||||
pass
|
pass
|
||||||
if limit_field:
|
if limit_field:
|
||||||
code = code[:limit_field]
|
code = code[:limit_field]
|
||||||
params = {cfg['event']['field']: code, '_errorMessage': 'code: %s' % code}
|
params = {cfg['event']['field']: code, '_errorMessage': 'code: %s' % code, '_searchFor': code}
|
||||||
checkin_url = self.checkin_url + '?' + urllib.parse.urlencode(params)
|
checkin_url = self.checkin_url + '?' + urllib.parse.urlencode(params)
|
||||||
json = convert(dict(self.cfg['actions']))
|
json = convert(dict(self.cfg['actions']))
|
||||||
req = self.session.put(checkin_url, json=json, timeout=TIMEOUT)
|
req = self.session.put(checkin_url, json=json, timeout=TIMEOUT)
|
||||||
|
@ -135,7 +135,7 @@ class Connector():
|
||||||
try:
|
try:
|
||||||
req.raise_for_status()
|
req.raise_for_status()
|
||||||
msg += 'ok'
|
msg += 'ok'
|
||||||
except requests.exceptions.HTTPError as ex:
|
except requests.exceptions.HTTPError:
|
||||||
error = True
|
error = True
|
||||||
msg += 'error: %s' % req.json().get('message')
|
msg += 'error: %s' % req.json().get('message')
|
||||||
if not error:
|
if not error:
|
||||||
|
|
Loading…
Reference in a new issue