Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ShowCancelledTrip #228

Open
skinkie opened this issue Oct 14, 2024 · 0 comments · May be fixed by #229
Open

ShowCancelledTrip #228

skinkie opened this issue Oct 14, 2024 · 0 comments · May be fixed by #229
Assignees
Labels

Comments

@skinkie
Copy link
Contributor

skinkie commented Oct 14, 2024

diff --git a/openebs/form_kv17.py b/openebs/form_kv17.py
index e43cadb..faa299b 100644
--- a/openebs/form_kv17.py
+++ b/openebs/form_kv17.py
@@ -369,7 +369,7 @@ class Kv17ChangeForm(forms.ModelForm):
             self.instance.endtime = endtime
             self.instance.is_cancel = True
             self.instance.monitoring_error = None
-            self.instance.showcancelledtrip = True if self.data['showcancelledtrip'] == 'on' else False
+            self.instance.showcancelledtrip = True if self.data.get('showcancelledtrip', '') == 'on' else False
 
             # Unfortunately, we can't place this any earlier, because we don't have the dataownercode there
             if self.instance.line.dataownercode == self.instance.dataownercode:
@@ -428,7 +428,7 @@ class Kv17ChangeForm(forms.ModelForm):
                 # Shouldn't be necessary, but just in case:
                 self.instance.begintime = None
                 self.instance.endtime = None
-                self.instance.showcancelledtrip = True if self.data['showcancelledtrip'] == 'on' else False
+                self.instance.showcancelledtrip = True if self.data.get('showcancelledtrip', '') == 'on' else False
 
                 # Unfortunately, we can't place this any earlier, because we don't have the dataownercode there
                 if self.instance.journey.dataownercode == self.instance.dataownercode:
@@ -466,7 +466,7 @@ class Kv17ChangeForm(forms.ModelForm):
         self.instance.endtime = endtime
         self.instance.is_cancel = True
         self.instance.monitoring_error = None
-        self.instance.showcancelledtrip = True if self.data['showcancelledtrip'] == 'on' else False
+        self.instance.showcancelledtrip = True if self.data.get('showcancelledtrip', '') == 'on' else False
 
         # Unfortunately, we can't place this any earlier, because we don't have the dataownercode there
         if self.instance.dataownercode == self.user.userprofile.company:
@@ -928,7 +928,7 @@ class Kv17ShortenForm(forms.ModelForm):
             self.instance.begintime = None
             self.instance.endtime = None
             self.instance.is_cancel = False
-            self.instance.showcancelledtrip = True if self.data['showcancelledtrip'] == 'on' else False
+            self.instance.showcancelledtrip = True if self.data.get('showcancelledtrip', '') == 'on' else False
             self.instance.monitoring_error = None
             if len(self.instance.recovered_changes) > 0:
                 self.instance.monitoring_error = self.instance.recovered_changes[0].monitoring_error
@skinkie skinkie added the bug label Oct 14, 2024
@Baasje85 Baasje85 linked a pull request Oct 14, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants