Hi folks, see attached patch for fix of a minor bug in medusa. Comments?
It is my first patch, be merciful ;-)
Marian
>From a42f7ed778df4691d5bec20006abdda4c9715a60 Mon Sep 17 00:00:00 2001
From: Marian Csontos <mcsontos(a)redhat.com>
Date: Wed, 25 Mar 2009 12:49:03 +0100
Subject: [PATCH] FIX: Changes to boolean values are not tracked properly - history record is created even if value does not change.
DEVEL CHANGES:
* True and False need to be stringified.
* Removed some duplicated code.
---
Medusa/medusa/controllers.py | 26 +++++++++-----------------
1 files changed, 9 insertions(+), 17 deletions(-)
diff --git a/Medusa/medusa/controllers.py b/Medusa/medusa/controllers.py
index c11ebde..28572f5 100644
--- a/Medusa/medusa/controllers.py
+++ b/Medusa/medusa/controllers.py
@@ -697,29 +697,21 @@ class Root(RPCRoot):
# catch nullable fields return None.
if current_val == 'None':
current_val = ""
- if kw.get(field):
- if current_val != str(kw[field]):
-# sys.stderr.write("\nfield: " + field + ", Old: " + current_val + ", New: " + str(kw[field]) + " " + "\n")
- activity = SystemActivity(identity.current.user, 'WEBUI', 'Changed', field, current_val, kw[field] )
- system.activity.append(activity)
- else:
- if current_val != "":
- activity = SystemActivity(identity.current.user, 'WEBUI', 'Changed', field, current_val, "" )
- system.activity.append(activity)
+ new_val = str(kw.get(field) or "")
+ if current_val != new_val:
+# sys.stderr.write("\nfield: " + field + ", Old: " + current_val + ", New: " + str(kw[field]) + " " + "\n")
+ activity = SystemActivity(identity.current.user, 'WEBUI', 'Changed', field, current_val, new_val )
+ system.activity.append(activity)
log_bool_fields = [ 'shared', 'private' ]
for field in log_bool_fields:
try:
current_val = str(system.__dict__[field])
except KeyError:
current_val = ""
- if kw.get(field):
- if current_val != True:
- activity = SystemActivity(identity.current.user, 'WEBUI', 'Changed', field, current_val, "True" )
- system.activity.append(activity)
- else:
- if current_val != False:
- activity = SystemActivity(identity.current.user, 'WEBUI', 'Changed', field, current_val, "False" )
- system.activity.append(activity)
+ new_val = str(kw.get(field) or False)
+ if current_val != new_val:
+ activity = SystemActivity(identity.current.user, 'WEBUI', 'Changed', field, current_val, new_val )
+ system.activity.append(activity)
system.status_id=kw['status_id']
system.location=kw['location']
system.model=kw['model']
--
1.6.0.6