- Timestamp:
- Apr 26, 2020, 5:02:25 PM (7 years ago)
- Branches:
- debian/bullseye, master
- Children:
- 62569d9
- Parents:
- 691c4ca
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/gnuboat/mapservice_impl/controllers/LogsController.py
r691c4ca rf9321aa 21 21 Water, Device, Gauge, ProcessingStatus, Queue, db 22 22 ) 23 from gnuboat. mapservice_impl.HttpErrors import (24 MapserviceBadRequest, MapserviceUnauthorized, MapserviceNotFound23 from gnuboat.common.webservice.HttpErrors import ( 24 GnuboatBadRequest, GnuboatUnauthorized, GnuboatNotFound 25 25 ) 26 26 from gnuboat.mapservice_impl.tasks.tasks import log_process … … 33 33 submitter = User.query.filter_by(username=submitter).all() 34 34 if len(submitter) != 1: 35 raise MapserviceNotFound(35 raise GnuboatNotFound( 36 36 detail="Could not find the submitter with id {}". 37 37 format(submitter) … … 55 55 log = Log.query.filter_by(id=id).all() 56 56 if len(log) != 1: 57 raise MapserviceNotFound57 raise GnuboatNotFound 58 58 if connexion.request.headers['Accept'] == "application/geo+json": 59 59 return log[0].to_geojson(), 200, { … … 66 66 user = User.loggedin_user() 67 67 if user is None: 68 raise MapserviceUnauthorized68 raise GnuboatUnauthorized 69 69 70 70 water = Water.query.filter_by(id=log_creation.water).all() 71 71 if len(water) != 1: 72 raise MapserviceBadRequest(72 raise GnuboatBadRequest( 73 73 detail='Water {} not found database'.format(log_creation.water) 74 74 ) … … 77 77 device = Device.query.filter_by(id=log_creation.device).all() 78 78 if len(device) != 1: 79 raise MapserviceBadRequest(79 raise GnuboatBadRequest( 80 80 detail='Device {} not found in database'. 81 81 format(log_creation.device) … … 85 85 gauge = Gauge.query.filter_by(id=log_creation.gauge).all() 86 86 if len(gauge) != 1: 87 raise MapserviceBadRequest(87 raise GnuboatBadRequest( 88 88 detail='Gauge {} not found in database'.format(log_creation.gauge) 89 89 ) … … 91 91 92 92 if log_creation.gauge_height is None: 93 raise MapserviceBadRequest(detail='Gauge Height (Stage) missing')93 raise GnuboatBadRequest(detail='Gauge Height (Stage) missing') 94 94 else: 95 95 try: 96 96 float(log_creation.gauge_height) 97 97 except ValueError: 98 raise MapserviceBadRequest(98 raise GnuboatBadRequest( 99 99 detail='Gauge Height (Stage) {} is no number'. 100 100 format(log_creation.gauge_height) … … 122 122 user = User.loggedin_user() 123 123 if user is None: 124 raise MapserviceUnauthorized124 raise GnuboatUnauthorized 125 125 126 126 if body is None or not body: 127 raise MapserviceBadRequest(detail='No log data')127 raise GnuboatBadRequest(detail='No log data') 128 128 129 129 processing_state = ProcessingStatus.query.filter_by( … … 131 131 ).all() 132 132 if len(processing_state) != 1: 133 raise MapserviceBadRequest(133 raise GnuboatBadRequest( 134 134 detail='Processing status Queued for Parsing not found database' 135 135 ) … … 138 138 log = Log.query.filter_by(id=log_id).all() 139 139 if len(log) != 1: 140 raise MapserviceBadRequest(140 raise GnuboatBadRequest( 141 141 detail='Log {} not found database'.format(log_id) 142 142 ) … … 145 145 # check if Log has already log entries 146 146 if LogEntry.query.filter_by(log=log).count() > 0: 147 raise MapserviceBadRequest(147 raise GnuboatBadRequest( 148 148 detail='Log {} has already log entries. Aborting'.format(log_id) 149 149 ) … … 164 164 user = User.loggedin_user() 165 165 if user is None: 166 raise MapserviceUnauthorized166 raise GnuboatUnauthorized 167 167 168 168 if not Log.query.filter_by(submitter=user).filter_by(id=id).delete(): 169 raise MapserviceBadRequest(169 raise GnuboatBadRequest( 170 170 detail="Could not delete log with id {}".format(id) 171 171 )
Note:
See TracChangeset
for help on using the changeset viewer.
