Type für Participant, Content-Type in responses korrigiert
This commit is contained in:
parent
d44dbcc437
commit
6b93f0ac3f
@ -14,7 +14,9 @@
|
||||
"listen": "test",
|
||||
"script": {
|
||||
"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"
|
||||
}
|
||||
@ -63,18 +65,12 @@
|
||||
"method": "GET",
|
||||
"header": [],
|
||||
"url": {
|
||||
"raw": "{{SCHEMA}}{{PATH}}/participant?user_id=1",
|
||||
"raw": "{{SCHEMA}}{{PATH}}/participants",
|
||||
"host": [
|
||||
"{{SCHEMA}}{{PATH}}"
|
||||
],
|
||||
"path": [
|
||||
"participant"
|
||||
],
|
||||
"query": [
|
||||
{
|
||||
"key": "user_id",
|
||||
"value": "1"
|
||||
}
|
||||
"participants"
|
||||
]
|
||||
}
|
||||
},
|
||||
@ -282,7 +278,7 @@
|
||||
"method": "GET",
|
||||
"header": [],
|
||||
"url": {
|
||||
"raw": "{{SCHEMA}}{{PATH}}/times?shipcall_id=1",
|
||||
"raw": "{{SCHEMA}}{{PATH}}/times?shipcall_id=3",
|
||||
"host": [
|
||||
"{{SCHEMA}}{{PATH}}"
|
||||
],
|
||||
@ -292,7 +288,7 @@
|
||||
"query": [
|
||||
{
|
||||
"key": "shipcall_id",
|
||||
"value": "1"
|
||||
"value": "3"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@ -8,6 +8,7 @@ CREATE TABLE `participant` (
|
||||
`street` varchar(128) DEFAULT NULL,
|
||||
`postal_code` varchar(5) DEFAULT NULL,
|
||||
`city` varchar(64) DEFAULT NULL,
|
||||
`type` int(10) DEFAULT NULL,
|
||||
`flags` int(10) unsigned DEFAULT NULL,
|
||||
`created` DATETIME NULL DEFAULT current_timestamp(),
|
||||
`modified` DATETIME NULL DEFAULT NULL ON UPDATE current_timestamp(),
|
||||
|
||||
@ -41,7 +41,7 @@ UNLOCK TABLES;
|
||||
|
||||
LOCK TABLES `participant` WRITE;
|
||||
/*!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 */;
|
||||
UNLOCK TABLES;
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:RoleEditor"
|
||||
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>
|
||||
<TabControl>
|
||||
<TabItem Header="Participant, users and roles">
|
||||
@ -29,6 +29,7 @@
|
||||
<RowDefinition Height="28"/>
|
||||
<RowDefinition Height="28"/>
|
||||
<RowDefinition Height="28"/>
|
||||
<RowDefinition Height="28"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
@ -57,16 +58,18 @@
|
||||
<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="Active" Grid.Row="4" Grid.Column="1" HorizontalAlignment="Right"/>
|
||||
<Label Content="Created" Grid.Row="5" Grid.Column="1" HorizontalAlignment="Right"/>
|
||||
<Label Content="Modified" Grid.Row="6" Grid.Column="1" HorizontalAlignment="Right"/>
|
||||
<Label Content="Type" Grid.Row="5" 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="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="textBoxParticipantCity" Grid.Row="3" Grid.Column="2" Margin="2" VerticalContentAlignment="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" />
|
||||
<TextBox x:Name="textBoxParticipantModified" 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">
|
||||
<ComboBox x:Name="comboBoxParticipantType" Grid.Row="5" Grid.Column="2" Margin="2" SelectedValuePath="Key" DisplayMemberPath="Value" />
|
||||
<TextBox x:Name="textBoxParticipantCreated" Grid.Row="6" IsReadOnly="True" IsEnabled="False" Grid.Column="2" Margin="2" VerticalContentAlignment="Center" />
|
||||
<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>
|
||||
<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"/>
|
||||
|
||||
@ -103,6 +103,9 @@ namespace RoleEditor
|
||||
this.listBoxUser.ItemsSource = _users;
|
||||
this.listBoxRoleSecurables.ItemsSource = _assignedSecurables;
|
||||
this.listBoxUserRoles.ItemsSource = _assignedRoles;
|
||||
|
||||
this.comboBoxParticipantType.ItemsSource = EnumHelper.GetAllValuesAndDescription(typeof(Participant.ParticipantType));
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -206,9 +209,10 @@ namespace RoleEditor
|
||||
p.Street = this.textBoxParticipantStreet.Text.Trim();
|
||||
p.PostalCode = this.textBoxParticipantPostalCode.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);
|
||||
this.listBoxParticipant.ItemsSource = null;
|
||||
this.listBoxParticipant.ItemsSource = _users;
|
||||
this.listBoxParticipant.ItemsSource = _participants;
|
||||
this.listBoxParticipant.SelectedItem = p;
|
||||
}
|
||||
}
|
||||
@ -362,11 +366,15 @@ namespace RoleEditor
|
||||
// this.checkboxParticipantActive.Checked = (p != null) ? p.
|
||||
this.textBoxParticipantCreated.Text = (p != null) ? p.Created.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
|
||||
this._users.Clear();
|
||||
foreach (User u in await User.LoadForParticipant(p, _dbManager))
|
||||
_users.Add(u);
|
||||
if (p != null)
|
||||
{
|
||||
foreach (User u in await User.LoadForParticipant(p, _dbManager))
|
||||
_users.Add(u);
|
||||
}
|
||||
}
|
||||
|
||||
private async void listBoxRoles_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
|
||||
27
src/brecal.model/EnumHelper.cs
Normal file
27
src/brecal.model/EnumHelper.cs
Normal 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());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Reflection.PortableExecutable;
|
||||
@ -15,13 +16,22 @@ namespace brecal.model
|
||||
[Flags]
|
||||
public enum ParticipantType
|
||||
{
|
||||
[Description("not assigned")]
|
||||
NONE = 0,
|
||||
[Description("BSMD")]
|
||||
BSMD = 1,
|
||||
[Description("Terminal")]
|
||||
TERMINAL = 2,
|
||||
[Description("Lotsen")]
|
||||
PILOT = 4,
|
||||
[Description("Agentur")]
|
||||
AGENCY = 8,
|
||||
[Description("Festmacher")]
|
||||
MOORING = 16,
|
||||
[Description("Hafenamt")]
|
||||
PORT_ADMINISTRATION = 32,
|
||||
[Description("Schlepper")]
|
||||
TUG = 64,
|
||||
}
|
||||
|
||||
#endregion
|
||||
@ -36,6 +46,8 @@ namespace brecal.model
|
||||
|
||||
public string? City { get; set; }
|
||||
|
||||
public ParticipantType Type { get; set;}
|
||||
|
||||
public uint Flags { get; set; }
|
||||
|
||||
#endregion
|
||||
@ -62,9 +74,10 @@ namespace brecal.model
|
||||
if (!reader.IsDBNull(2)) p.Street = reader.GetString(2);
|
||||
if (!reader.IsDBNull(3)) p.PostalCode = reader.GetString(3);
|
||||
if (!reader.IsDBNull(4)) p.City = reader.GetString(4);
|
||||
if (!reader.IsDBNull(5)) p.Flags = (uint)reader.GetInt32(5);
|
||||
if (!reader.IsDBNull(6)) p.Created = reader.GetDateTime(6);
|
||||
if (!reader.IsDBNull(7)) p.Modified = reader.GetDateTime(7);
|
||||
if (!reader.IsDBNull(5)) p.Type = (ParticipantType) reader.GetInt32(5);
|
||||
if (!reader.IsDBNull(6)) p.Flags = (uint)reader.GetInt32(6);
|
||||
if (!reader.IsDBNull(7)) p.Created = reader.GetDateTime(7);
|
||||
if (!reader.IsDBNull(8)) p.Modified = reader.GetDateTime(8);
|
||||
result.Add(p);
|
||||
}
|
||||
return result;
|
||||
@ -72,7 +85,7 @@ namespace brecal.model
|
||||
|
||||
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
|
||||
@ -81,13 +94,13 @@ namespace brecal.model
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@ -136,6 +149,11 @@ namespace brecal.model
|
||||
idParam.ParameterName = "ID";
|
||||
idParam.Value = this.Id;
|
||||
cmd.Parameters.Add(idParam);
|
||||
|
||||
IDataParameter typeParam = cmd.CreateParameter();
|
||||
typeParam.ParameterName = "TYPE";
|
||||
typeParam.Value = (int) this.Type;
|
||||
cmd.Parameters.Add(typeParam);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@ -9,7 +9,7 @@ namespace brecal.mysql
|
||||
public class DBManager : IDBManager
|
||||
{
|
||||
// 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)
|
||||
{
|
||||
|
||||
@ -40,6 +40,7 @@ def create_app(test_config=None):
|
||||
app.register_blueprint(ships.bp)
|
||||
app.register_blueprint(login.bp)
|
||||
|
||||
|
||||
logging.basicConfig(filename='brecal.log', level=logging.DEBUG, format='%(asctime)s | %(name)s | %(levelname)s | %(message)s')
|
||||
local_db.initPool()
|
||||
logging.info('App started')
|
||||
|
||||
@ -3,9 +3,9 @@ from .. import impl
|
||||
from ..services.auth_guard import auth_guard
|
||||
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
|
||||
def GetParticipant():
|
||||
|
||||
|
||||
@ -25,7 +25,7 @@ def GetBerths(token):
|
||||
result["message"] = "call failed"
|
||||
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'}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -30,23 +30,23 @@ def GetUser(options):
|
||||
}
|
||||
token = jwt_handler.generate_jwt(payload=result, lifetime=60) # generate token valid 60 mins
|
||||
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:
|
||||
result = {}
|
||||
result["message"] = "credential lookup mismatch"
|
||||
return json.dumps(result), 500
|
||||
return json.dumps(result), 500, {'Content-Type': 'application/json; charset=utf-8'}
|
||||
|
||||
result = {}
|
||||
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:
|
||||
logging.error(ex)
|
||||
print(ex)
|
||||
result = {}
|
||||
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$.vEapj9xU8z0RK0IpIGeYuRIl0ktdMt4XdJQBhVn.3K2hmvm7qD3y
|
||||
|
||||
@ -23,7 +23,7 @@ def GetNotifications(options):
|
||||
"participant_id": "<integer>",
|
||||
"times_id": "<integer>",
|
||||
"timestamp": "<date-time>",
|
||||
}), 200
|
||||
}), 200, {'Content-Type': 'application/json; charset=utf-8'}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -17,9 +17,9 @@ def GetParticipant(options):
|
||||
pooledConnection = local_db.getPoolConnection()
|
||||
commands = pydapper.using(pooledConnection)
|
||||
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:
|
||||
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()
|
||||
|
||||
except Exception as ex:
|
||||
@ -29,5 +29,5 @@ def GetParticipant(options):
|
||||
result["message"] = "call failed"
|
||||
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'}
|
||||
|
||||
|
||||
@ -28,9 +28,9 @@ def GetShipcalls(options):
|
||||
print(ex)
|
||||
result = {}
|
||||
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):
|
||||
@ -72,14 +72,14 @@ def PostShipcalls(schemaModel):
|
||||
|
||||
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:
|
||||
logging.error(ex)
|
||||
print(ex)
|
||||
result = {}
|
||||
result["message"] = "call failed"
|
||||
return json.dumps(result), 500
|
||||
return json.dumps(result), 500, {'Content-Type': 'application/json; charset=utf-8'}
|
||||
|
||||
|
||||
def PutShipcalls(schemaModel):
|
||||
@ -113,14 +113,14 @@ def PutShipcalls(schemaModel):
|
||||
if affected_rows == 1:
|
||||
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:
|
||||
logging.error(ex)
|
||||
print(ex)
|
||||
result = {}
|
||||
result["message"] = "call failed"
|
||||
return json.dumps(result), 500
|
||||
return json.dumps(result), 500, {'Content-Type': 'application/json; charset=utf-8'}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -24,9 +24,9 @@ def GetShips(token):
|
||||
print(ex)
|
||||
result = {}
|
||||
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'}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -27,9 +27,9 @@ def GetTimes(options):
|
||||
print(ex)
|
||||
result = {}
|
||||
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()
|
||||
|
||||
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:
|
||||
logging.error(ex)
|
||||
print(ex)
|
||||
result = {}
|
||||
result["message"] = "call failed"
|
||||
return json.dumps(result), 500
|
||||
return json.dumps(result), 500, {'Content-Type': 'application/json; charset=utf-8'}
|
||||
|
||||
|
||||
def PutTimes(schemaModel):
|
||||
@ -111,16 +111,16 @@ def PutTimes(schemaModel):
|
||||
pooledConnection.close()
|
||||
|
||||
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:
|
||||
logging.error(ex)
|
||||
print(ex)
|
||||
result = {}
|
||||
result["message"] = "call failed"
|
||||
return json.dumps(result), 500
|
||||
return json.dumps(result), 500, {'Content-Type': 'application/json; charset=utf-8'}
|
||||
|
||||
def DeleteTimes(options):
|
||||
"""
|
||||
@ -136,15 +136,15 @@ def DeleteTimes(options):
|
||||
pooledConnection.close()
|
||||
|
||||
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["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:
|
||||
logging.error(ex)
|
||||
print(ex)
|
||||
result = {}
|
||||
result["message"] = "call failed"
|
||||
return json.dumps(result), 500
|
||||
return json.dumps(result), 500, {'Content-Type': 'application/json; charset=utf-8'}
|
||||
@ -44,6 +44,7 @@ class Participant(Schema):
|
||||
street: str
|
||||
postal_code: str
|
||||
city: str
|
||||
type: int
|
||||
flags: int
|
||||
created: datetime
|
||||
modified: datetime
|
||||
|
||||
Reference in New Issue
Block a user