From 49a8498bbe2fcfba07f778e395e5dda4d9ebed10 Mon Sep 17 00:00:00 2001 From: Daniel Schick Date: Tue, 21 Jan 2025 13:47:52 +0100 Subject: [PATCH 01/23] Changed settings for test version --- misc/BreCalApi.cs | 6 +-- misc/BreCalApi.yaml | 2 +- src/BreCalClient/App.config | 4 +- src/BreCalClient/BreCalClient.csproj | 2 +- .../ClickOnceTestProfile.pubxml | 3 +- .../Properties/Settings.Designer.cs | 54 +++++++++---------- src/BreCalClient/Properties/Settings.settings | 4 +- src/BreCalClient/ShipcallControl.xaml | 2 +- src/BreCalClient/ShipcallControl.xaml.cs | 12 ++--- src/RoleEditor/App.config | 2 +- .../Properties/Settings.Designer.cs | 12 ++--- src/RoleEditor/Properties/Settings.settings | 2 +- src/server/BreCal/__init__.py | 2 +- src/server/BreCal/local_db.py | 6 +-- 14 files changed, 57 insertions(+), 56 deletions(-) diff --git a/misc/BreCalApi.cs b/misc/BreCalApi.cs index 5b792dd..69da75b 100644 --- a/misc/BreCalApi.cs +++ b/misc/BreCalApi.cs @@ -4983,7 +4983,7 @@ namespace BreCalClient.misc.Client { Proxy = null; UserAgent = WebUtility.UrlEncode("OpenAPI-Generator/1.0.0/csharp"); - BasePath = "https://brecaldevel.bsmd-emswe.eu"; + BasePath = "https://brecaltest.bsmd-emswe.eu"; DefaultHeaders = new ConcurrentDictionary(); ApiKey = new ConcurrentDictionary(); ApiKeyPrefix = new ConcurrentDictionary(); @@ -4991,7 +4991,7 @@ namespace BreCalClient.misc.Client { { new Dictionary { - {"url", "https://brecaldevel.bsmd-emswe.eu"}, + {"url", "https://brecaltest.bsmd-emswe.eu"}, {"description", "Development server hosted on vcup"}, } } @@ -5010,7 +5010,7 @@ namespace BreCalClient.misc.Client IDictionary defaultHeaders, IDictionary apiKey, IDictionary apiKeyPrefix, - string basePath = "https://brecaldevel.bsmd-emswe.eu") : this() + string basePath = "https://brecaltest.bsmd-emswe.eu") : this() { if (string.IsNullOrWhiteSpace(basePath)) throw new ArgumentException("The provided basePath is invalid.", "basePath"); diff --git a/misc/BreCalApi.yaml b/misc/BreCalApi.yaml index 41db732..8ca5689 100644 --- a/misc/BreCalApi.yaml +++ b/misc/BreCalApi.yaml @@ -14,7 +14,7 @@ info: name: Use at your own risk url: 'https://www.bsmd.de/license' servers: - - url: 'https://brecaldevel.bsmd-emswe.eu' + - url: 'https://brecaltest.bsmd-emswe.eu' description: Development server hosted on vcup tags: - name: user diff --git a/src/BreCalClient/App.config b/src/BreCalClient/App.config index 31f6f0a..8ff9c1b 100644 --- a/src/BreCalClient/App.config +++ b/src/BreCalClient/App.config @@ -29,7 +29,7 @@ - #1D751F + #751D1F !!Bremen calling Testversion!! @@ -38,7 +38,7 @@ https://www.textbausteine.net/ - https://brecaldevel.bsmd-emswe.eu + https://brecaltest.bsmd-emswe.eu diff --git a/src/BreCalClient/BreCalClient.csproj b/src/BreCalClient/BreCalClient.csproj index 080b62e..eb88220 100644 --- a/src/BreCalClient/BreCalClient.csproj +++ b/src/BreCalClient/BreCalClient.csproj @@ -13,7 +13,7 @@ Bremen calling client A Windows WPF client for the Bremen calling API. containership.ico - BreCalDevelClient + BreCalTestClient diff --git a/src/BreCalClient/Properties/PublishProfiles/ClickOnceTestProfile.pubxml b/src/BreCalClient/Properties/PublishProfiles/ClickOnceTestProfile.pubxml index ba852d6..25d2641 100644 --- a/src/BreCalClient/Properties/PublishProfiles/ClickOnceTestProfile.pubxml +++ b/src/BreCalClient/Properties/PublishProfiles/ClickOnceTestProfile.pubxml @@ -5,7 +5,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121. 0 - 1.6.0.3 + 1.7.0.5 True Debug True @@ -39,6 +39,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121. Bremen Calling http://www.textbausteine.net/ bin\Debug\net6.0-windows\win-x64\app.publish\ + 1.7.0.5 win-x64 diff --git a/src/BreCalClient/Properties/Settings.Designer.cs b/src/BreCalClient/Properties/Settings.Designer.cs index c5b234b..60f862a 100644 --- a/src/BreCalClient/Properties/Settings.Designer.cs +++ b/src/BreCalClient/Properties/Settings.Designer.cs @@ -9,29 +9,29 @@ //------------------------------------------------------------------------------ namespace BreCalClient.Properties { - - + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.10.0.0")] internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { - + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - + public static Settings Default { get { return defaultInstance; } } - + [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("#1D751F")] + [global::System.Configuration.DefaultSettingValueAttribute("#751D1F")] public string BG_COLOR { get { return ((string)(this["BG_COLOR"])); } } - + [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("!!Bremen calling Testversion!!")] @@ -40,7 +40,7 @@ namespace BreCalClient.Properties { return ((string)(this["APP_TITLE"])); } } - + [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("https://www.textbausteine.net/")] @@ -49,7 +49,7 @@ namespace BreCalClient.Properties { return ((string)(this["LOGO_IMAGE_URL"])); } } - + [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("")] @@ -61,16 +61,16 @@ namespace BreCalClient.Properties { this["FilterCriteria"] = value; } } - + [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("https://brecaldevel.bsmd-emswe.eu")] + [global::System.Configuration.DefaultSettingValueAttribute("https://brecaltest.bsmd-emswe.eu")] public string API_URL { get { return ((string)(this["API_URL"])); } } - + [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("800")] @@ -82,7 +82,7 @@ namespace BreCalClient.Properties { this["Width"] = value; } } - + [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("450")] @@ -94,7 +94,7 @@ namespace BreCalClient.Properties { this["Height"] = value; } } - + [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("0")] @@ -106,7 +106,7 @@ namespace BreCalClient.Properties { this["Left"] = value; } } - + [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("0")] @@ -118,7 +118,7 @@ namespace BreCalClient.Properties { this["Top"] = value; } } - + [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("0")] @@ -130,7 +130,7 @@ namespace BreCalClient.Properties { this["W1Left"] = value; } } - + [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("0")] @@ -142,7 +142,7 @@ namespace BreCalClient.Properties { this["W1Top"] = value; } } - + [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("0")] @@ -154,7 +154,7 @@ namespace BreCalClient.Properties { this["W2Left"] = value; } } - + [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("0")] @@ -166,7 +166,7 @@ namespace BreCalClient.Properties { this["W2Top"] = value; } } - + [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("0")] @@ -178,7 +178,7 @@ namespace BreCalClient.Properties { this["W3Left"] = value; } } - + [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("0")] @@ -190,7 +190,7 @@ namespace BreCalClient.Properties { this["W3Top"] = value; } } - + [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("0")] @@ -202,7 +202,7 @@ namespace BreCalClient.Properties { this["W4Left"] = value; } } - + [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("0")] @@ -214,7 +214,7 @@ namespace BreCalClient.Properties { this["W4Top"] = value; } } - + [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("")] @@ -226,7 +226,7 @@ namespace BreCalClient.Properties { this["FilterCriteriaMap"] = value; } } - + [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public global::System.Collections.Specialized.StringCollection Notifications { @@ -237,7 +237,7 @@ namespace BreCalClient.Properties { this["Notifications"] = value; } } - + [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("0")] @@ -249,7 +249,7 @@ namespace BreCalClient.Properties { this["W5Top"] = value; } } - + [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("0")] diff --git a/src/BreCalClient/Properties/Settings.settings b/src/BreCalClient/Properties/Settings.settings index e7203cb..5c0ce15 100644 --- a/src/BreCalClient/Properties/Settings.settings +++ b/src/BreCalClient/Properties/Settings.settings @@ -3,7 +3,7 @@ - #1D751F + #751D1F !!Bremen calling Testversion!! @@ -15,7 +15,7 @@ - https://brecaldevel.bsmd-emswe.eu + https://brecaltest.bsmd-emswe.eu 800 diff --git a/src/BreCalClient/ShipcallControl.xaml b/src/BreCalClient/ShipcallControl.xaml index 5557643..81c8131 100644 --- a/src/BreCalClient/ShipcallControl.xaml +++ b/src/BreCalClient/ShipcallControl.xaml @@ -5,7 +5,7 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:p = "clr-namespace:BreCalClient.Resources" xmlns:sets="clr-namespace:BreCalClient.Properties" - xmlns:db="clr-namespace:BreCalClient;assembly=BreCalDevelClient" + xmlns:db="clr-namespace:BreCalClient;assembly=BreCalTestClient" mc:Ignorable="d" d:DesignHeight="135" d:DesignWidth="800"> diff --git a/src/BreCalClient/ShipcallControl.xaml.cs b/src/BreCalClient/ShipcallControl.xaml.cs index 1ff0158..7e24700 100644 --- a/src/BreCalClient/ShipcallControl.xaml.cs +++ b/src/BreCalClient/ShipcallControl.xaml.cs @@ -215,13 +215,13 @@ namespace BreCalClient switch (this.ShipcallControlModel?.Shipcall?.Type) { case ShipcallType.Arrival: // incoming - this.imageShipcallType.Source = new BitmapImage(new Uri("pack://application:,,,/BreCalDevelClient;component/Resources/arrow_down_red.png")); + this.imageShipcallType.Source = new BitmapImage(new Uri("pack://application:,,,/BreCalTestClient;component/Resources/arrow_down_red.png")); break; case ShipcallType.Departure: // outgoing - this.imageShipcallType.Source = new BitmapImage(new Uri("pack://application:,,,/BreCalDevelClient;component/Resources/arrow_up_blue.png")); + this.imageShipcallType.Source = new BitmapImage(new Uri("pack://application:,,,/BreCalTestClient;component/Resources/arrow_up_blue.png")); break; case ShipcallType.Shifting: // shifting - this.imageShipcallType.Source = new BitmapImage(new Uri("pack://application:,,,/BreCalDevelClient;component/Resources/arrow_right_green.png")); + this.imageShipcallType.Source = new BitmapImage(new Uri("pack://application:,,,/BreCalTestClient;component/Resources/arrow_right_green.png")); break; default: break; @@ -230,13 +230,13 @@ namespace BreCalClient switch(this.ShipcallControlModel?.LightMode) { case EvaluationType.Green: - this.imageEvaluation.Source = new BitmapImage(new Uri("pack://application:,,,/BreCalDevelClient;component/Resources/check.png")); + this.imageEvaluation.Source = new BitmapImage(new Uri("pack://application:,,,/BreCalTestClient;component/Resources/check.png")); break; case EvaluationType.Yellow: - this.imageEvaluation.Source = new BitmapImage(new Uri("pack://application:,,,/BreCalDevelClient;component/Resources/sign_warning.png")); + this.imageEvaluation.Source = new BitmapImage(new Uri("pack://application:,,,/BreCalTestClient;component/Resources/sign_warning.png")); break; case EvaluationType.Red: - this.imageEvaluation.Source = new BitmapImage(new Uri("pack://application:,,,/BreCalDevelClient;component/Resources/delete2.png")); + this.imageEvaluation.Source = new BitmapImage(new Uri("pack://application:,,,/BreCalTestClient;component/Resources/delete2.png")); break; default: break; diff --git a/src/RoleEditor/App.config b/src/RoleEditor/App.config index 51c1ce1..bd2b4e4 100644 --- a/src/RoleEditor/App.config +++ b/src/RoleEditor/App.config @@ -8,7 +8,7 @@ - Server=localhost;User ID=ds;Password=HalloWach_2323XXL!!;Database=bremen_calling_devel;Port=33306 + Server=localhost;User ID=ds;Password=HalloWach_2323XXL!!;Database=bremen_calling_test;Port=33306 diff --git a/src/RoleEditor/Properties/Settings.Designer.cs b/src/RoleEditor/Properties/Settings.Designer.cs index c0ea20b..e97e569 100644 --- a/src/RoleEditor/Properties/Settings.Designer.cs +++ b/src/RoleEditor/Properties/Settings.Designer.cs @@ -9,24 +9,24 @@ //------------------------------------------------------------------------------ namespace RoleEditor.Properties { - - + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.10.0.0")] internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { - + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - + public static Settings Default { get { return defaultInstance; } } - + [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("Server=localhost;User ID=ds;Password=HalloWach_2323XXL!!;Database=bremen_calling_" + - "devel;Port=33306")] + "test;Port=33306")] public string ConnectionString { get { return ((string)(this["ConnectionString"])); diff --git a/src/RoleEditor/Properties/Settings.settings b/src/RoleEditor/Properties/Settings.settings index 33aa443..e7843c5 100644 --- a/src/RoleEditor/Properties/Settings.settings +++ b/src/RoleEditor/Properties/Settings.settings @@ -3,7 +3,7 @@ - Server=localhost;User ID=ds;Password=HalloWach_2323XXL!!;Database=bremen_calling_devel;Port=33306 + Server=localhost;User ID=ds;Password=HalloWach_2323XXL!!;Database=bremen_calling_test;Port=33306 \ No newline at end of file diff --git a/src/server/BreCal/__init__.py b/src/server/BreCal/__init__.py index c2012e2..8924b11 100644 --- a/src/server/BreCal/__init__.py +++ b/src/server/BreCal/__init__.py @@ -69,7 +69,7 @@ def create_app(test_config=None, instance_path=None): app.register_blueprint(history.bp) app.register_blueprint(ports.bp) - logging.basicConfig(filename='brecaldevel.log', level=logging.DEBUG, format='%(asctime)s | %(name)s | %(levelname)s | %(message)s') + logging.basicConfig(filename='brecaltest.log', level=logging.DEBUG, format='%(asctime)s | %(name)s | %(levelname)s | %(message)s') local_db.initPool(os.path.dirname(app.instance_path)) logging.info('App started') diff --git a/src/server/BreCal/local_db.py b/src/server/BreCal/local_db.py index 03801b2..3c7b936 100644 --- a/src/server/BreCal/local_db.py +++ b/src/server/BreCal/local_db.py @@ -7,11 +7,11 @@ import sys from BreCal.schemas import defs config_path = None -def initPool(instancePath, connection_filename="connection_data_devel.json"): +def initPool(instancePath, connection_filename="connection_data_test.json"): try: global config_path if(config_path == None): - config_path = os.path.join(instancePath,f'../../../secure/{connection_filename}') #connection_data_devel.json'); + config_path = os.path.join(instancePath,f'../../../secure/{connection_filename}') #connection_data_test.json'); # config_path = "E:/temp/connection_data.json" print (config_path) @@ -32,7 +32,7 @@ def initPool(instancePath, connection_filename="connection_data_devel.json"): print("DB connection successful") conn_from_pool.close() - credentials_file = "email_credentials_devel.json" + credentials_file = "email_credentials_test.json" credentials_path = os.path.join(instancePath,f'../../../secure/{credentials_file}') # credentials_path = "E:/temp/email_credentials_devel.json" From 213f7cf58c8edeaa33e4d35cbb9485525bba0e49 Mon Sep 17 00:00:00 2001 From: Daniel Schick Date: Tue, 21 Jan 2025 14:52:50 +0100 Subject: [PATCH 02/23] fixed path --- src/server/flaskapp.wsgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server/flaskapp.wsgi b/src/server/flaskapp.wsgi index 17846d8..4bf64f7 100644 --- a/src/server/flaskapp.wsgi +++ b/src/server/flaskapp.wsgi @@ -2,7 +2,7 @@ import os import sys import logging -sys.path.insert(0, '/var/www/brecal_devel/src/server') +sys.path.insert(0, '/var/www/brecal_test/src/server') sys.path.insert(0, '/var/www/venv/lib/python3.12/site-packages/') import schedule From 6dedc04957a1faec89a4b643b6aa7426e5d7df6b Mon Sep 17 00:00:00 2001 From: Daniel Schick Date: Tue, 21 Jan 2025 15:19:18 +0100 Subject: [PATCH 03/23] changed bg color for missing data --- src/BreCalClient/AppNotificationPart.xaml.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BreCalClient/AppNotificationPart.xaml.cs b/src/BreCalClient/AppNotificationPart.xaml.cs index b2f26ad..39a2f52 100644 --- a/src/BreCalClient/AppNotificationPart.xaml.cs +++ b/src/BreCalClient/AppNotificationPart.xaml.cs @@ -35,7 +35,7 @@ namespace BreCalClient this.ContentWrapper.Background = Brushes.Gray; break; case "MissingData": - this.ContentWrapper.Background= Brushes.Yellow; + this.ContentWrapper.Background = Brushes.DarkKhaki; break; case "Cancelled": this.ContentWrapper.Background = Brushes.DarkGray; From 64c66070764b32eaeb7e836a65d4dfec48d0ed04 Mon Sep 17 00:00:00 2001 From: Daniel Schick Date: Mon, 3 Feb 2025 10:35:46 +0100 Subject: [PATCH 04/23] Fix E-Mail validation error reporting --- src/server/BreCal/schemas/model.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/server/BreCal/schemas/model.py b/src/server/BreCal/schemas/model.py index 72e64f3..4a75daa 100644 --- a/src/server/BreCal/schemas/model.py +++ b/src/server/BreCal/schemas/model.py @@ -8,6 +8,7 @@ from marshmallow_dataclass import dataclass from typing import List import json +import re import datetime from BreCal.validators.time_logic import validate_time_is_in_not_too_distant_future from BreCal.validators.validation_base_utils import check_if_string_has_special_characters @@ -506,7 +507,7 @@ class UserSchema(Schema): @validates("user_email") def validate_user_email(self, value): - if value is not None and not "@" in value: + if value and not re.match(r"[^@]+@[^@]+\.[^@]+", value) in value: raise ValidationError({"user_email":f"invalid email address"}) From fce897fae41f48f539ba06414ecf32d17fd4d84a Mon Sep 17 00:00:00 2001 From: Daniel Schick Date: Mon, 3 Feb 2025 11:14:51 +0100 Subject: [PATCH 05/23] Fix filtering of notifications depending on participant assignment to shipcall in case the notification has no participant id --- src/BreCalClient/AppNotification.cs | 18 ++++++++++++++++-- src/BreCalClient/NotificationDialog.xaml | 1 + 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/BreCalClient/AppNotification.cs b/src/BreCalClient/AppNotification.cs index 3164052..46faaa5 100644 --- a/src/BreCalClient/AppNotification.cs +++ b/src/BreCalClient/AppNotification.cs @@ -95,11 +95,11 @@ namespace BreCalClient SaveNotifications(); } - internal static bool UpdateNotifications(List notifications, System.Collections.Concurrent.ConcurrentDictionary currentShipcalls, ToastViewModel vm) + internal static bool UpdateNotifications(List notifications, System.Collections.Concurrent.ConcurrentDictionary currentShipcalls, ToastViewModel vm) { bool result = false; - foreach (BreCalClient.misc.Model.Notification notification in notifications) + foreach (Notification notification in notifications) { if (notification.ParticipantId.HasValue && notification.ParticipantId.Value != App.Participant.Id) // not meant for us continue; @@ -107,6 +107,20 @@ namespace BreCalClient if (!currentShipcalls.ContainsKey(notification.ShipcallId)) // not one of our shipcalls (maybe for another port or filtered) continue; + // filter out notifications for shipcalls where we are not nomiated/assigned + if (!notification.ParticipantId.HasValue) + { + bool iAmAssigned = false; + foreach (ParticipantAssignment p in currentShipcalls[notification.ShipcallId].AssignedParticipants.Values) + { + if (p.ParticipantId.Equals(App.Participant.Id)) + { + iAmAssigned = true; break; + } + } + if (!iAmAssigned) continue; + } + if (!_notificationsCollection.Where(x => x.Id == notification.Id).Any()) { List newList = new(_notificationsCollection); diff --git a/src/BreCalClient/NotificationDialog.xaml b/src/BreCalClient/NotificationDialog.xaml index 30a756e..9297083 100644 --- a/src/BreCalClient/NotificationDialog.xaml +++ b/src/BreCalClient/NotificationDialog.xaml @@ -35,6 +35,7 @@ + From 21471d4d41cc6a91ffb82a727d1170696f19fba5 Mon Sep 17 00:00:00 2001 From: Daniel Schick Date: Mon, 3 Feb 2025 11:56:44 +0100 Subject: [PATCH 06/23] Allow shipcall PUT also by PILOT --- .../BreCal/validators/input_validation_shipcall.py | 9 ++++++--- .../tests/validators/test_input_validation_shipcall.py | 10 +++++----- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/server/BreCal/validators/input_validation_shipcall.py b/src/server/BreCal/validators/input_validation_shipcall.py index 060909f..eb5efd0 100644 --- a/src/server/BreCal/validators/input_validation_shipcall.py +++ b/src/server/BreCal/validators/input_validation_shipcall.py @@ -546,11 +546,13 @@ class InputValidationShipcall(): # query = 'SELECT * FROM shipcall_participant_map where (shipcall_id = ?shipcall_id? AND type=?participant_type?)' # assigned_agency = execute_sql_query_standalone(query=query, model=ShipcallParticipantMap, param={"shipcall_id" : shipcall_id, "participant_type":int(ParticipantType.AGENCY)}) assigned_agency = get_assigned_participant_of_type(shipcall_id, participant_type=ParticipantType.AGENCY) + assigned_pilot = get_assigned_participant_of_type(shipcall_id, participant_type=ParticipantType.PILOT) an_agency_is_assigned = True if assigned_agency is not None else False else: # Agency assigned? User must belong to the assigned agency or be a BSMD user, in case the flag is set assigned_agency = [spm for spm in shipcall_participant_map if int(spm.type) == int(ParticipantType.AGENCY)] + assigned_pilot = [spm for spm in shipcall_participant_map if int(spm.type) == int(ParticipantType.PILOT)] an_agency_is_assigned = len(assigned_agency)==1 if len(assigned_agency)>1: @@ -567,18 +569,19 @@ class InputValidationShipcall(): ### USER authority ### # determine, whether the user is a) the assigned agency or b) a BSMD participant user_is_assigned_agency = (user_participant_id == assigned_agency.id) + user_is_assigned_pilot = (user_participant_id == assigned_pilot.id) # when the BSMD flag is set: the user must be either BSMD or the assigned agency # when the BSMD flag is not set: the user must be the assigned agency - user_is_authorized = (user_is_bsmd or user_is_assigned_agency) #if agency_has_bsmd_flag else user_is_assigned_agency + user_is_authorized = (user_is_bsmd or user_is_assigned_agency or user_is_assigned_pilot) #if agency_has_bsmd_flag else user_is_assigned_agency if not user_is_authorized: - raise werkzeug.exceptions.Forbidden(f"PUT Requests for shipcalls can only be issued by an assigned AGENCY or BSMD users (if the special-flag is enabled). Assigned Agency: {assigned_agency} with Flags: {assigned_agency.flags}") # Forbidden: 403 + raise werkzeug.exceptions.Forbidden(f"PUT Requests for shipcalls can only be issued by an assigned AGENCY / BSMD / PILOT (if the special-flag is enabled). Assigned Agency: {assigned_agency} with Flags: {assigned_agency.flags}") # Forbidden: 403 else: # when there is no assigned agency, only BSMD users can update the shipcall if not user_is_bsmd: - raise werkzeug.exceptions.Forbidden(f"PUT Requests for shipcalls can only be issued by an assigned AGENCY or BSMD users (if the special-flag is enabled). There is no assigned agency yet, so only BSMD users can change datasets.") # part of a pytest.raises. Forbidden: 403 + raise werkzeug.exceptions.Forbidden(f"PUT Requests for shipcalls can only be issued by an assigned AGENCY / BSMD / PILOT users (if the special-flag is enabled). There is no assigned agency yet, so only BSMD users can change datasets.") # part of a pytest.raises. Forbidden: 403 return diff --git a/src/server/tests/validators/test_input_validation_shipcall.py b/src/server/tests/validators/test_input_validation_shipcall.py index 0e48f55..bdb9e52 100644 --- a/src/server/tests/validators/test_input_validation_shipcall.py +++ b/src/server/tests/validators/test_input_validation_shipcall.py @@ -637,7 +637,7 @@ def test_shipcall_put_request_fails_when_different_participant_id_is_assigned(ge # agency with different participant id is assigned ivs = InputValidationShipcall() - with pytest.raises(werkzeug.exceptions.Forbidden, match=f"PUT Requests for shipcalls can only be issued by an assigned AGENCY or BSMD users"): + with pytest.raises(werkzeug.exceptions.Forbidden, match=f"PUT Requests for shipcalls can only be issued by an assigned AGENCY BSMD PILOT users"): ivs.check_user_is_authorized_for_put_request(user_data, loadedModel, content, spm_shipcall_data) return @@ -706,7 +706,7 @@ def test_shipcall_put_request_fails_when_no_agency_is_assigned(get_shipcall_id_a # no agency assigned ivs = InputValidationShipcall() - with pytest.raises(werkzeug.exceptions.Forbidden, match=re.escape(f"PUT Requests for shipcalls can only be issued by an assigned AGENCY or BSMD users (if the special-flag is enabled). There is no assigned agency yet, so only BSMD users can change datasets.")): + with pytest.raises(werkzeug.exceptions.Forbidden, match=re.escape(f"PUT Requests for shipcalls can only be issued by an assigned AGENCY BSMD PILOT users (if the special-flag is enabled). There is no assigned agency yet, so only BSMD users can change datasets.")): ivs.check_user_is_authorized_for_put_request(user_data, loadedModel, content, spm_shipcall_data) return @@ -738,7 +738,7 @@ def test_shipcall_put_request_fails_when_user_is_not_authorized(get_shipcall_id_ # current user is not authorized ivs = InputValidationShipcall() - with pytest.raises(werkzeug.exceptions.Forbidden, match=f"PUT Requests for shipcalls can only be issued by an assigned AGENCY or BSMD users"): + with pytest.raises(werkzeug.exceptions.Forbidden, match=f"PUT Requests for shipcalls can only be issued by an assigned AGENCY BSMD PILOT users"): ivs.check_user_is_authorized_for_put_request(user_data, loadedModel, content, spm_shipcall_data) return @@ -769,7 +769,7 @@ def test_shipcall_put_request_fails_when_user_tries_self_assignment(get_shipcall # self-assignment. User is participant 6, and wants to assign participant 6. ivs = InputValidationShipcall() - with pytest.raises(werkzeug.exceptions.Forbidden, match=re.escape("PUT Requests for shipcalls can only be issued by an assigned AGENCY or BSMD users (if the special-flag is enabled). There is no assigned agency yet, so only BSMD users can change datasets.")): + with pytest.raises(werkzeug.exceptions.Forbidden, match=re.escape("PUT Requests for shipcalls can only be issued by an assigned AGENCY BSMD PILOT users (if the special-flag is enabled). There is no assigned agency yet, so only BSMD users can change datasets.")): # previous error message: An agency cannot self-register for a shipcall. The request is issued by an agency-user and tries to assign an AGENCY as the participant of the shipcall."" # however, self-assignment is no longer possible, because the SPM is verified beforehand. ivs.check_user_is_authorized_for_put_request(user_data, loadedModel, content, spm_shipcall_data) @@ -846,7 +846,7 @@ def test_shipcall_put_request_fails_input_validation_shipcall_when_shipcall_is_c assert user.participant_id == 4 #### verification should fail, because participant_id 4 is ParticipantType.PILOT (neither an assigned agency, nor bsmd) - with pytest.raises(werkzeug.exceptions.Forbidden, match="PUT Requests for shipcalls can only be issued by an assigned AGENCY or BSMD user"): + with pytest.raises(werkzeug.exceptions.Forbidden, match="PUT Requests for shipcalls can only be issued by an assigned AGENCY BSMD PILOT user"): InputValidationShipcall.evaluate_put_data(user_data, loadedModel, content) ### PASSES: From ea634a3af274c7421bced84fd25c948de1a12806 Mon Sep 17 00:00:00 2001 From: Daniel Schick Date: Mon, 3 Feb 2025 12:02:24 +0100 Subject: [PATCH 07/23] Allow pilots to enter tidal times --- src/BreCalClient/EditTimesControl.xaml | 21 ++++++---- src/BreCalClient/EditTimesControl.xaml.cs | 50 +++++++++++++++++++++++ src/BreCalClient/MainWindow.xaml.cs | 7 ++++ 3 files changed, 71 insertions(+), 7 deletions(-) diff --git a/src/BreCalClient/EditTimesControl.xaml b/src/BreCalClient/EditTimesControl.xaml index 03cac40..870c9c9 100644 --- a/src/BreCalClient/EditTimesControl.xaml +++ b/src/BreCalClient/EditTimesControl.xaml @@ -7,7 +7,7 @@ xmlns:p = "clr-namespace:BreCalClient.Resources" xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit" mc:Ignorable="d" Left="{local:SettingBinding W1Left}" Top="{local:SettingBinding W1Top}" - Title="{x:Static p:Resources.textEditTimes}" Height="331" Width="500" Loaded="Window_Loaded" ResizeMode="CanResizeWithGrip" Icon="Resources/containership.ico"> + Title="{x:Static p:Resources.textEditTimes}" Height="415" Width="500" Loaded="Window_Loaded" ResizeMode="CanResizeWithGrip" Icon="Resources/containership.ico"> @@ -22,6 +22,9 @@ + + + @@ -35,8 +38,10 @@