Title: [opsview] [11277] Fixed icon, so that it is now set to a default value, LOGO - Opsview, if not
Revision
11277
Author
tvoon
Date
2013-01-29 14:01:44 +0000 (Tue, 29 Jan 2013)

Log Message

Fixed icon, so that it is now set to a default value, LOGO - Opsview, if not
defined

Modified Paths

Modified: trunk/opsview-core/lib/Opsview/ResultSet/Hosts.pm
===================================================================
--- trunk/opsview-core/lib/Opsview/ResultSet/Hosts.pm	2013-01-29 13:42:27 UTC (rev 11276)
+++ trunk/opsview-core/lib/Opsview/ResultSet/Hosts.pm	2013-01-29 14:01:44 UTC (rev 11277)
@@ -47,10 +47,6 @@
             push @$errors, "Host group is not a leaf";
         }
     }
-
-    if ( !$attrs->{icon} ) {
-        $attrs->{icon} = "LOGO - Opsview";
-    }
 }
 
 sub synchronise_intxn_pre_insert {
@@ -66,6 +62,13 @@
           ->search( { lft => \"= (rgt-1)" }, { order_by => "lft" } )->first;
         $object->hostgroup($first_alphabetic_leaf_hostgroup);
     }
+
+    # We need this here to cover new hosts added. Opsview::Schema::Hosts::store_columns() will sort out
+    # updates
+    if ( !$attrs->{icon} ) {
+        my $default_icon = "LOGO - Opsview";
+        $object->icon($default_icon);
+    }
 }
 
 sub synchronise_intxn_many_to_many_pre {

Modified: trunk/opsview-core/lib/Opsview/Schema/Hosts.pm
===================================================================
--- trunk/opsview-core/lib/Opsview/Schema/Hosts.pm	2013-01-29 13:42:27 UTC (rev 11276)
+++ trunk/opsview-core/lib/Opsview/Schema/Hosts.pm	2013-01-29 14:01:44 UTC (rev 11277)
@@ -630,15 +630,20 @@
     };
 }
 
+# We sort out storage so that the icon field is always populated
+sub store_column {
+    my ( $self, $name, $value ) = @_;
+    if ( $name eq "icon" ) {
+        if ( !defined $value || $value eq "" ) {
+            $value = "LOGO - Opsview";
+        }
+    }
+    $self->next::method( $name, $value );
+}
+
 sub new {
     my ( $class, $attrs ) = @_;
 
-    unless ( $attrs->{icon} ) {
-
-        # TODO - check for existence of this logo
-        $attrs->{icon} = "LOGO - Opsview";
-    }
-
     unless ( $attrs->{monitored_by} ) {
         $attrs->{monitored_by} = 1;
     }
@@ -1308,9 +1313,12 @@
 __PACKAGE__->validation_module( "Data::FormValidator" );
 sub validation_profile { shift->get_dfv_profile }
 
+# icon should be a required field, but this is not enforced at the moment. There are
+# various tests failures if this happens
+# store_column() will default to the LOGO - Opsview, so an icon will always get set
 sub get_dfv_profile {
     return {
-        required => [qw/name icon/],
+        required => [qw/name/],
         optional => [
             qw/ip snmpv3_authpassword snmpv3_privpassword other_addresses rancid_password notification_options snmp_version nmis_node_type/
         ],

_______________________________________________
Opsview-checkins mailing list
[email protected]
http://lists.opsview.org/lists/listinfo/opsview-checkins

Reply via email to