Type für Participant, Content-Type in responses korrigiert

This commit is contained in:
Daniel Schick 2023-08-07 12:19:20 +02:00
parent d44dbcc437
commit 6b93f0ac3f
18 changed files with 120 additions and 65 deletions

View File

@ -14,7 +14,9 @@
"listen": "test", "listen": "test",
"script": { "script": {
"exec": [ "exec": [
"pm.environment.set(\"LOGON_TOKEN\", responseBody)" "let responseData = pm.response.json();\r",
"pm.environment.set(\"LOGON_TOKEN\", responseData.token)\r",
"console.log(\"Id: \" + responseData.id)"
], ],
"type": "text/javascript" "type": "text/javascript"
} }
@ -63,18 +65,12 @@
"method": "GET", "method": "GET",
"header": [], "header": [],
"url": { "url": {
"raw": "{{SCHEMA}}{{PATH}}/participant?user_id=1", "raw": "{{SCHEMA}}{{PATH}}/participants",
"host": [ "host": [
"{{SCHEMA}}{{PATH}}" "{{SCHEMA}}{{PATH}}"
], ],
"path": [ "path": [
"participant" "participants"
],
"query": [
{
"key": "user_id",
"value": "1"
}
] ]
} }
}, },
@ -282,7 +278,7 @@
"method": "GET", "method": "GET",
"header": [], "header": [],
"url": { "url": {
"raw": "{{SCHEMA}}{{PATH}}/times?shipcall_id=1", "raw": "{{SCHEMA}}{{PATH}}/times?shipcall_id=3",
"host": [ "host": [
"{{SCHEMA}}{{PATH}}" "{{SCHEMA}}{{PATH}}"
], ],
@ -292,7 +288,7 @@
"query": [ "query": [
{ {
"key": "shipcall_id", "key": "shipcall_id",
"value": "1" "value": "3"
} }
] ]
} }

View File

@ -8,6 +8,7 @@ CREATE TABLE `participant` (
`street` varchar(128) DEFAULT NULL, `street` varchar(128) DEFAULT NULL,
`postal_code` varchar(5) DEFAULT NULL, `postal_code` varchar(5) DEFAULT NULL,
`city` varchar(64) DEFAULT NULL, `city` varchar(64) DEFAULT NULL,
`type` int(10) DEFAULT NULL,
`flags` int(10) unsigned DEFAULT NULL, `flags` int(10) unsigned DEFAULT NULL,
`created` DATETIME NULL DEFAULT current_timestamp(), `created` DATETIME NULL DEFAULT current_timestamp(),
`modified` DATETIME NULL DEFAULT NULL ON UPDATE current_timestamp(), `modified` DATETIME NULL DEFAULT NULL ON UPDATE current_timestamp(),

View File

@ -41,7 +41,7 @@ UNLOCK TABLES;
LOCK TABLES `participant` WRITE; LOCK TABLES `participant` WRITE;
/*!40000 ALTER TABLE `participant` DISABLE KEYS */; /*!40000 ALTER TABLE `participant` DISABLE KEYS */;
INSERT INTO `participant` (`id`, `name`, `street`, `postal_code`, `city`, `flags`, `created`, `modified`) VALUES (1,'Schick Informatik','Gottlieb-Daimler-Str. 8','73614','Schorndorf',42,'2023-04-17 07:18:19',NULL); INSERT INTO `participant` (`id`, `name`, `street`, `postal_code`, `city`, `type`, `flags`, `created`, `modified`) VALUES (1,'Schick Informatik','Gottlieb-Daimler-Str. 8','73614','Schorndorf',1,42,'2023-04-17 07:18:19',NULL);
/*!40000 ALTER TABLE `participant` ENABLE KEYS */; /*!40000 ALTER TABLE `participant` ENABLE KEYS */;
UNLOCK TABLES; UNLOCK TABLES;

View File

@ -5,7 +5,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:RoleEditor" xmlns:local="clr-namespace:RoleEditor"
mc:Ignorable="d" mc:Ignorable="d"
Title="Bremen calling admin editor" Height="600" Width="800" Icon="Resources/lock_preferences.ico" Loaded="Window_Loaded"> Title="Bremen calling admin editor" Height="650" Width="800" Icon="Resources/lock_preferences.ico" Loaded="Window_Loaded">
<Grid> <Grid>
<TabControl> <TabControl>
<TabItem Header="Participant, users and roles"> <TabItem Header="Participant, users and roles">
@ -29,6 +29,7 @@
<RowDefinition Height="28"/> <RowDefinition Height="28"/>
<RowDefinition Height="28"/> <RowDefinition Height="28"/>
<RowDefinition Height="28"/> <RowDefinition Height="28"/>
<RowDefinition Height="28"/>
<RowDefinition Height="*"/> <RowDefinition Height="*"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
@ -57,16 +58,18 @@
<Label Content="Postal code" Grid.Row="2" Grid.Column="1" HorizontalAlignment="Right"/> <Label Content="Postal code" Grid.Row="2" Grid.Column="1" HorizontalAlignment="Right"/>
<Label Content="City" Grid.Row="3" Grid.Column="1" HorizontalAlignment="Right"/> <Label Content="City" Grid.Row="3" Grid.Column="1" HorizontalAlignment="Right"/>
<Label Content="Active" Grid.Row="4" Grid.Column="1" HorizontalAlignment="Right"/> <Label Content="Active" Grid.Row="4" Grid.Column="1" HorizontalAlignment="Right"/>
<Label Content="Created" Grid.Row="5" Grid.Column="1" HorizontalAlignment="Right"/> <Label Content="Type" Grid.Row="5" Grid.Column="1" HorizontalAlignment="Right"/>
<Label Content="Modified" Grid.Row="6" Grid.Column="1" HorizontalAlignment="Right"/> <Label Content="Created" Grid.Row="6" Grid.Column="1" HorizontalAlignment="Right"/>
<Label Content="Modified" Grid.Row="7" Grid.Column="1" HorizontalAlignment="Right"/>
<TextBox x:Name="textBoxParticipantName" Grid.Row="0" Grid.Column="2" Margin="2" VerticalContentAlignment="Center" /> <TextBox x:Name="textBoxParticipantName" Grid.Row="0" Grid.Column="2" Margin="2" VerticalContentAlignment="Center" />
<TextBox x:Name="textBoxParticipantStreet" Grid.Row="1" Grid.Column="2" Margin="2" VerticalContentAlignment="Center" /> <TextBox x:Name="textBoxParticipantStreet" Grid.Row="1" Grid.Column="2" Margin="2" VerticalContentAlignment="Center" />
<TextBox x:Name="textBoxParticipantPostalCode" Grid.Row="2" Grid.Column="2" Margin="2" VerticalContentAlignment="Center" /> <TextBox x:Name="textBoxParticipantPostalCode" Grid.Row="2" Grid.Column="2" Margin="2" VerticalContentAlignment="Center" />
<TextBox x:Name="textBoxParticipantCity" Grid.Row="3" Grid.Column="2" Margin="2" VerticalContentAlignment="Center" /> <TextBox x:Name="textBoxParticipantCity" Grid.Row="3" Grid.Column="2" Margin="2" VerticalContentAlignment="Center" />
<CheckBox x:Name="checkboxParticipantActive" Grid.Row="4" Grid.Column="2" VerticalAlignment="Center" /> <CheckBox x:Name="checkboxParticipantActive" Grid.Row="4" Grid.Column="2" VerticalAlignment="Center" />
<TextBox x:Name="textBoxParticipantCreated" Grid.Row="5" IsReadOnly="True" IsEnabled="False" Grid.Column="2" Margin="2" VerticalContentAlignment="Center" /> <ComboBox x:Name="comboBoxParticipantType" Grid.Row="5" Grid.Column="2" Margin="2" SelectedValuePath="Key" DisplayMemberPath="Value" />
<TextBox x:Name="textBoxParticipantModified" Grid.Row="6" IsReadOnly="True" IsEnabled="False" Grid.Column="2" Margin="2" VerticalContentAlignment="Center" /> <TextBox x:Name="textBoxParticipantCreated" Grid.Row="6" IsReadOnly="True" IsEnabled="False" Grid.Column="2" Margin="2" VerticalContentAlignment="Center" />
<Button x:Name="buttonParticipantSave" Grid.Row="7" Grid.Column="2" Click="buttonParticipantSave_Click" Margin="2"> <TextBox x:Name="textBoxParticipantModified" Grid.Row="7" IsReadOnly="True" IsEnabled="False" Grid.Column="2" Margin="2" VerticalContentAlignment="Center" />
<Button x:Name="buttonParticipantSave" Grid.Row="8" Grid.Column="2" Click="buttonParticipantSave_Click" Margin="2">
<DockPanel> <DockPanel>
<Image Source="./Resources/disk_blue.png" Margin="0,0,5,0" Height="24" DockPanel.Dock="Left" Width="16"/> <Image Source="./Resources/disk_blue.png" Margin="0,0,5,0" Height="24" DockPanel.Dock="Left" Width="16"/>
<TextBlock Text="Save" VerticalAlignment="Center" DockPanel.Dock="Right"/> <TextBlock Text="Save" VerticalAlignment="Center" DockPanel.Dock="Right"/>

View File

@ -103,6 +103,9 @@ namespace RoleEditor
this.listBoxUser.ItemsSource = _users; this.listBoxUser.ItemsSource = _users;
this.listBoxRoleSecurables.ItemsSource = _assignedSecurables; this.listBoxRoleSecurables.ItemsSource = _assignedSecurables;
this.listBoxUserRoles.ItemsSource = _assignedRoles; this.listBoxUserRoles.ItemsSource = _assignedRoles;
this.comboBoxParticipantType.ItemsSource = EnumHelper.GetAllValuesAndDescription(typeof(Participant.ParticipantType));
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -206,9 +209,10 @@ namespace RoleEditor
p.Street = this.textBoxParticipantStreet.Text.Trim(); p.Street = this.textBoxParticipantStreet.Text.Trim();
p.PostalCode = this.textBoxParticipantPostalCode.Text.Trim(); p.PostalCode = this.textBoxParticipantPostalCode.Text.Trim();
p.City = this.textBoxParticipantCity.Text.Trim(); p.City = this.textBoxParticipantCity.Text.Trim();
p.Type = (Participant.ParticipantType) Enum.Parse(typeof(Participant.ParticipantType), (string) this.comboBoxParticipantType.SelectedValue);
await p.Save(_dbManager); await p.Save(_dbManager);
this.listBoxParticipant.ItemsSource = null; this.listBoxParticipant.ItemsSource = null;
this.listBoxParticipant.ItemsSource = _users; this.listBoxParticipant.ItemsSource = _participants;
this.listBoxParticipant.SelectedItem = p; this.listBoxParticipant.SelectedItem = p;
} }
} }
@ -362,11 +366,15 @@ namespace RoleEditor
// this.checkboxParticipantActive.Checked = (p != null) ? p. // this.checkboxParticipantActive.Checked = (p != null) ? p.
this.textBoxParticipantCreated.Text = (p != null) ? p.Created.ToString() : string.Empty; this.textBoxParticipantCreated.Text = (p != null) ? p.Created.ToString() : string.Empty;
this.textBoxParticipantModified.Text = (p != null) ? p.Modified.ToString() : string.Empty; this.textBoxParticipantModified.Text = (p != null) ? p.Modified.ToString() : string.Empty;
this.comboBoxParticipantType.SelectedValue = (p != null) ? p.Type : 0;
// -> load users for this participant selection // -> load users for this participant selection
this._users.Clear(); this._users.Clear();
foreach (User u in await User.LoadForParticipant(p, _dbManager)) if (p != null)
_users.Add(u); {
foreach (User u in await User.LoadForParticipant(p, _dbManager))
_users.Add(u);
}
} }
private async void listBoxRoles_SelectionChanged(object sender, SelectionChangedEventArgs e) private async void listBoxRoles_SelectionChanged(object sender, SelectionChangedEventArgs e)

View File

@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
namespace brecal.model
{
public static class EnumHelper
{
public static string Description(this Enum eValue)
{
var nAttributes = eValue.GetType().GetField(eValue.ToString()).GetCustomAttributes(typeof(DescriptionAttribute), false);
if (nAttributes.Any())
return (nAttributes.First() as DescriptionAttribute).Description;
return eValue.ToString();
}
public static IEnumerable<KeyValuePair<string, string>> GetAllValuesAndDescription(Type t)
{
if (!t.IsEnum)
throw new ArgumentException("t must be an enum");
return from e in Enum.GetValues(t).Cast<Enum>()
select new KeyValuePair<string, string>(e.ToString(), e.Description());
}
}
}

View File

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel;
using System.Data; using System.Data;
using System.Linq; using System.Linq;
using System.Reflection.PortableExecutable; using System.Reflection.PortableExecutable;
@ -15,13 +16,22 @@ namespace brecal.model
[Flags] [Flags]
public enum ParticipantType public enum ParticipantType
{ {
[Description("not assigned")]
NONE = 0, NONE = 0,
[Description("BSMD")]
BSMD = 1, BSMD = 1,
[Description("Terminal")]
TERMINAL = 2, TERMINAL = 2,
[Description("Lotsen")]
PILOT = 4, PILOT = 4,
[Description("Agentur")]
AGENCY = 8, AGENCY = 8,
[Description("Festmacher")]
MOORING = 16, MOORING = 16,
[Description("Hafenamt")]
PORT_ADMINISTRATION = 32, PORT_ADMINISTRATION = 32,
[Description("Schlepper")]
TUG = 64,
} }
#endregion #endregion
@ -36,9 +46,11 @@ namespace brecal.model
public string? City { get; set; } public string? City { get; set; }
public ParticipantType Type { get; set;}
public uint Flags { get; set; } public uint Flags { get; set; }
#endregion #endregion
#region public static methods #region public static methods
@ -49,7 +61,7 @@ namespace brecal.model
foreach (Participant p in loadResultList.Cast<Participant>()) foreach (Participant p in loadResultList.Cast<Participant>())
result.Add(p); result.Add(p);
return result; return result;
} }
public static List<DbEntity> LoadElems(IDataReader reader) public static List<DbEntity> LoadElems(IDataReader reader)
{ {
@ -62,9 +74,10 @@ namespace brecal.model
if (!reader.IsDBNull(2)) p.Street = reader.GetString(2); if (!reader.IsDBNull(2)) p.Street = reader.GetString(2);
if (!reader.IsDBNull(3)) p.PostalCode = reader.GetString(3); if (!reader.IsDBNull(3)) p.PostalCode = reader.GetString(3);
if (!reader.IsDBNull(4)) p.City = reader.GetString(4); if (!reader.IsDBNull(4)) p.City = reader.GetString(4);
if (!reader.IsDBNull(5)) p.Flags = (uint)reader.GetInt32(5); if (!reader.IsDBNull(5)) p.Type = (ParticipantType) reader.GetInt32(5);
if (!reader.IsDBNull(6)) p.Created = reader.GetDateTime(6); if (!reader.IsDBNull(6)) p.Flags = (uint)reader.GetInt32(6);
if (!reader.IsDBNull(7)) p.Modified = reader.GetDateTime(7); if (!reader.IsDBNull(7)) p.Created = reader.GetDateTime(7);
if (!reader.IsDBNull(8)) p.Modified = reader.GetDateTime(8);
result.Add(p); result.Add(p);
} }
return result; return result;
@ -72,7 +85,7 @@ namespace brecal.model
public static void SetLoadQuery(IDbCommand cmd, params object?[] list) public static void SetLoadQuery(IDbCommand cmd, params object?[] list)
{ {
cmd.CommandText = "SELECT id, name, street, postal_code, city, flags, created, modified FROM participant"; cmd.CommandText = "SELECT id, name, street, postal_code, city, type, flags, created, modified FROM participant";
} }
#endregion #endregion
@ -81,14 +94,14 @@ namespace brecal.model
public override void SetUpdate(IDbCommand cmd) public override void SetUpdate(IDbCommand cmd)
{ {
cmd.CommandText = "UPDATE participant set name = @NAME, street = @STREET, postal_code = @POSTAL_CODE, city = @CITY, flags = @FLAGS WHERE id = @ID"; cmd.CommandText = "UPDATE participant set name = @NAME, street = @STREET, postal_code = @POSTAL_CODE, type = @TYPE, city = @CITY, flags = @FLAGS WHERE id = @ID";
this.SetParameters(cmd); this.SetParameters(cmd);
} }
public override void SetCreate(IDbCommand cmd) public override void SetCreate(IDbCommand cmd)
{ {
cmd.CommandText = "INSERT INTO participant (name, street, postal_code, city, flags) VALUES ( @NAME, @STREET, @POSTAL_CODE, @CITY, @FLAGS)"; cmd.CommandText = "INSERT INTO participant (name, street, postal_code, city, flags) VALUES ( @NAME, @STREET, @POSTAL_CODE, @CITY, @TYPE, @FLAGS)";
this.SetParameters(cmd); this.SetParameters(cmd);
} }
public override void SetDelete(IDbCommand cmd) public override void SetDelete(IDbCommand cmd)
@ -99,7 +112,7 @@ namespace brecal.model
idParam.ParameterName = "ID"; idParam.ParameterName = "ID";
idParam.Value = this.Id; idParam.Value = this.Id;
cmd.Parameters.Add(idParam); cmd.Parameters.Add(idParam);
} }
#endregion #endregion
@ -136,6 +149,11 @@ namespace brecal.model
idParam.ParameterName = "ID"; idParam.ParameterName = "ID";
idParam.Value = this.Id; idParam.Value = this.Id;
cmd.Parameters.Add(idParam); cmd.Parameters.Add(idParam);
IDataParameter typeParam = cmd.CreateParameter();
typeParam.ParameterName = "TYPE";
typeParam.Value = (int) this.Type;
cmd.Parameters.Add(typeParam);
} }
#endregion #endregion

View File

@ -9,7 +9,7 @@ namespace brecal.mysql
public class DBManager : IDBManager public class DBManager : IDBManager
{ {
// TODO: remove this and use external configuration // TODO: remove this and use external configuration
private static readonly string _connectionString = "Server=lager;User ID=ds;Password=HalloWach23;Database=bremen_calling"; private static readonly string _connectionString = "Server=localhost;User ID=ds;Password=HalloWach_2323XXL!!;Database=bremen_calling;Port=33306";
public async Task<List<DbEntity>> Load(QueryFunc prepareAction, LoadFunc<IDataReader> loadAction, params object?[] args) public async Task<List<DbEntity>> Load(QueryFunc prepareAction, LoadFunc<IDataReader> loadAction, params object?[] args)
{ {

View File

@ -40,6 +40,7 @@ def create_app(test_config=None):
app.register_blueprint(ships.bp) app.register_blueprint(ships.bp)
app.register_blueprint(login.bp) app.register_blueprint(login.bp)
logging.basicConfig(filename='brecal.log', level=logging.DEBUG, format='%(asctime)s | %(name)s | %(levelname)s | %(message)s') logging.basicConfig(filename='brecal.log', level=logging.DEBUG, format='%(asctime)s | %(name)s | %(levelname)s | %(message)s')
local_db.initPool() local_db.initPool()
logging.info('App started') logging.info('App started')

View File

@ -3,14 +3,14 @@ from .. import impl
from ..services.auth_guard import auth_guard from ..services.auth_guard import auth_guard
import json import json
bp = Blueprint('participant', __name__) bp = Blueprint('participants', __name__)
@bp.route('/participant', methods=['get']) @bp.route('/participants', methods=['get'])
@auth_guard() # no restriction by role @auth_guard() # no restriction by role
def GetParticipant(): def GetParticipant():
if 'Authorization' in request.headers: if 'Authorization' in request.headers:
token = request.headers.get('Authorization') token = request.headers.get('Authorization')
options = {} options = {}
options["user_id"] = request.args.get("user_id") options["user_id"] = request.args.get("user_id")
return impl.participant.GetParticipant(options) return impl.participant.GetParticipant(options)

View File

@ -17,7 +17,7 @@ def GetBerths(token):
commands = pydapper.using(pooledConnection) commands = pydapper.using(pooledConnection)
data = commands.query("SELECT id, name, participant_id, `lock`, created, modified FROM berth ORDER BY name", model=model.Berth) data = commands.query("SELECT id, name, participant_id, `lock`, created, modified FROM berth ORDER BY name", model=model.Berth)
pooledConnection.close() pooledConnection.close()
except Exception as ex: except Exception as ex:
logging.error(ex) logging.error(ex)
print(ex) print(ex)
@ -25,7 +25,7 @@ def GetBerths(token):
result["message"] = "call failed" result["message"] = "call failed"
return json.dumps(result), 500 return json.dumps(result), 500
return json.dumps(data, default=model.obj_dict), 200 return json.dumps(data, default=model.obj_dict), 200, {'Content-Type': 'application/json; charset=utf-8'}

View File

@ -30,23 +30,23 @@ def GetUser(options):
} }
token = jwt_handler.generate_jwt(payload=result, lifetime=60) # generate token valid 60 mins token = jwt_handler.generate_jwt(payload=result, lifetime=60) # generate token valid 60 mins
result["token"] = token # add token to user data result["token"] = token # add token to user data
return json.dumps(result), 200 return json.dumps(result), 200, {'Content-Type': 'application/json; charset=utf-8'}
if len(data) > 1: if len(data) > 1:
result = {} result = {}
result["message"] = "credential lookup mismatch" result["message"] = "credential lookup mismatch"
return json.dumps(result), 500 return json.dumps(result), 500, {'Content-Type': 'application/json; charset=utf-8'}
result = {} result = {}
result["message"] = "invalid credentials" result["message"] = "invalid credentials"
return json.dumps(result), 403 return json.dumps(result), 403, {'Content-Type': 'application/json; charset=utf-8'}
except Exception as ex: except Exception as ex:
logging.error(ex) logging.error(ex)
print(ex) print(ex)
result = {} result = {}
result["message"] = "call failed: " + str(ex) result["message"] = "call failed: " + str(ex)
return json.dumps(result), 500 return json.dumps(result), 500, {'Content-Type': 'application/json; charset=utf-8'}
# $2b$12$uWLE0r32IrtCV30WkMbVwOdltgeibymZyYAf4ZnQb2Bip8hrkGGwG # $2b$12$uWLE0r32IrtCV30WkMbVwOdltgeibymZyYAf4ZnQb2Bip8hrkGGwG
# $2b$12$.vEapj9xU8z0RK0IpIGeYuRIl0ktdMt4XdJQBhVn.3K2hmvm7qD3y # $2b$12$.vEapj9xU8z0RK0IpIGeYuRIl0ktdMt4XdJQBhVn.3K2hmvm7qD3y

View File

@ -23,7 +23,7 @@ def GetNotifications(options):
"participant_id": "<integer>", "participant_id": "<integer>",
"times_id": "<integer>", "times_id": "<integer>",
"timestamp": "<date-time>", "timestamp": "<date-time>",
}), 200 }), 200, {'Content-Type': 'application/json; charset=utf-8'}

View File

@ -17,11 +17,11 @@ def GetParticipant(options):
pooledConnection = local_db.getPoolConnection() pooledConnection = local_db.getPoolConnection()
commands = pydapper.using(pooledConnection) commands = pydapper.using(pooledConnection)
if "user_id" in options and options["user_id"]: if "user_id" in options and options["user_id"]:
data = commands.query("SELECT p.id as id, p.name as name, p.street as street, p.postal_code as postal_code, p.city as city, p.flags as flags, p.created as created, p.modified as modified FROM p INNER JOIN user u WHERE u.participant_id = p.id and u.id = ?userid?", model=model.Participant, param={"userid" : options["user_id"]}) data = commands.query("SELECT p.id as id, p.name as name, p.street as street, p.postal_code as postal_code, p.city as city, p.type as type, p.flags as flags, p.created as created, p.modified as modified FROM p INNER JOIN user u WHERE u.participant_id = p.id and u.id = ?userid?", model=model.Participant, param={"userid" : options["user_id"]})
else: else:
data = commands.query("SELECT p.id as id, p.name as name, p.street as street, p.postal_code as postal_code, p.city as city, p.flags as flags, p.created as created, p.modified as modified FROM participant p ORDER BY p.name", model=model.Participant) data = commands.query("SELECT p.id as id, p.name as name, p.street as street, p.postal_code as postal_code, p.city as city, p.type as type, p.flags as flags, p.created as created, p.modified as modified FROM participant p ORDER BY p.name", model=model.Participant)
pooledConnection.close() pooledConnection.close()
except Exception as ex: except Exception as ex:
logging.error(ex) logging.error(ex)
print(ex) print(ex)
@ -29,5 +29,5 @@ def GetParticipant(options):
result["message"] = "call failed" result["message"] = "call failed"
return json.dumps("call failed"), 500 return json.dumps("call failed"), 500
return json.dumps(data, default=model.obj_dict), 200 return json.dumps(data, default=model.obj_dict), 200, {'Content-Type': 'application/json; charset=utf-8'}

View File

@ -28,9 +28,9 @@ def GetShipcalls(options):
print(ex) print(ex)
result = {} result = {}
result["message"] = "call failed" result["message"] = "call failed"
return json.dumps(result), 500 return json.dumps(result), 500, {'Content-Type': 'application/json; charset=utf-8'}
return json.dumps(data, default=model.obj_dict), 200 return json.dumps(data, default=model.obj_dict), 200, {'Content-Type': 'application/json; charset=utf-8'}
def PostShipcalls(schemaModel): def PostShipcalls(schemaModel):
@ -72,14 +72,14 @@ def PostShipcalls(schemaModel):
pooledConnection.close() pooledConnection.close()
return json.dumps({"id" : new_id}), 201 return json.dumps({"id" : new_id}), 201, {'Content-Type': 'application/json; charset=utf-8'}
except Exception as ex: except Exception as ex:
logging.error(ex) logging.error(ex)
print(ex) print(ex)
result = {} result = {}
result["message"] = "call failed" result["message"] = "call failed"
return json.dumps(result), 500 return json.dumps(result), 500, {'Content-Type': 'application/json; charset=utf-8'}
def PutShipcalls(schemaModel): def PutShipcalls(schemaModel):
@ -113,14 +113,14 @@ def PutShipcalls(schemaModel):
if affected_rows == 1: if affected_rows == 1:
return json.dumps({"id" : schemaModel["id"]}), 200 return json.dumps({"id" : schemaModel["id"]}), 200
return json.dumps("no such record"), 404 return json.dumps("no such record"), 404, {'Content-Type': 'application/json; charset=utf-8'}
except Exception as ex: except Exception as ex:
logging.error(ex) logging.error(ex)
print(ex) print(ex)
result = {} result = {}
result["message"] = "call failed" result["message"] = "call failed"
return json.dumps(result), 500 return json.dumps(result), 500, {'Content-Type': 'application/json; charset=utf-8'}

View File

@ -24,9 +24,9 @@ def GetShips(token):
print(ex) print(ex)
result = {} result = {}
result["message"] = "call failed" result["message"] = "call failed"
return json.dumps(result), 500 return json.dumps(result), 500, {'Content-Type': 'application/json; charset=utf-8'}
return json.dumps(data, default=model.obj_dict), 200 return json.dumps(data, default=model.obj_dict), 200, {'Content-Type': 'application/json; charset=utf-8'}

View File

@ -27,9 +27,9 @@ def GetTimes(options):
print(ex) print(ex)
result = {} result = {}
result["message"] = "call failed" result["message"] = "call failed"
return json.dumps(result), 500 return json.dumps(result), 500, {'Content-Type': 'application/json; charset=utf-8'}
return json.dumps(data, default=model.obj_dict), 200 return json.dumps(data, default=model.obj_dict), 200, {'Content-Type': 'application/json; charset=utf-8'}
@ -72,14 +72,14 @@ def PostTimes(schemaModel):
pooledConnection.close() pooledConnection.close()
return json.dumps({"id" : new_id}), 201 return json.dumps({"id" : new_id}), 201, {'Content-Type': 'application/json; charset=utf-8'}
except Exception as ex: except Exception as ex:
logging.error(ex) logging.error(ex)
print(ex) print(ex)
result = {} result = {}
result["message"] = "call failed" result["message"] = "call failed"
return json.dumps(result), 500 return json.dumps(result), 500, {'Content-Type': 'application/json; charset=utf-8'}
def PutTimes(schemaModel): def PutTimes(schemaModel):
@ -111,16 +111,16 @@ def PutTimes(schemaModel):
pooledConnection.close() pooledConnection.close()
if affected_rows == 1: if affected_rows == 1:
return json.dumps({"id" : schemaModel["id"]}), 200 return json.dumps({"id" : schemaModel["id"]}), 200, {'Content-Type': 'application/json; charset=utf-8'}
return json.dumps("no such record"), 404 return json.dumps("no such record"), 404, {'Content-Type': 'application/json; charset=utf-8'}
except Exception as ex: except Exception as ex:
logging.error(ex) logging.error(ex)
print(ex) print(ex)
result = {} result = {}
result["message"] = "call failed" result["message"] = "call failed"
return json.dumps(result), 500 return json.dumps(result), 500, {'Content-Type': 'application/json; charset=utf-8'}
def DeleteTimes(options): def DeleteTimes(options):
""" """
@ -136,15 +136,15 @@ def DeleteTimes(options):
pooledConnection.close() pooledConnection.close()
if affected_rows == 1: if affected_rows == 1:
return json.dumps({"id" : options["id"]}), 200 return json.dumps({"id" : options["id"]}), 200, {'Content-Type': 'application/json; charset=utf-8'}
result = {} result = {}
result["message"] = "no such record" result["message"] = "no such record"
return json.dumps(result), 404 return json.dumps(result), 404, {'Content-Type': 'application/json; charset=utf-8'}
except Exception as ex: except Exception as ex:
logging.error(ex) logging.error(ex)
print(ex) print(ex)
result = {} result = {}
result["message"] = "call failed" result["message"] = "call failed"
return json.dumps(result), 500 return json.dumps(result), 500, {'Content-Type': 'application/json; charset=utf-8'}

View File

@ -44,6 +44,7 @@ class Participant(Schema):
street: str street: str
postal_code: str postal_code: str
city: str city: str
type: int
flags: int flags: int
created: datetime created: datetime
modified: datetime modified: datetime