[freeside-commits] branch master updated. 426d4e697c5a96fc4884c444835b7e17b181b93b

Ivan ivan at 420.am
Mon Aug 5 13:28:04 PDT 2013


The branch, master has been updated
       via  426d4e697c5a96fc4884c444835b7e17b181b93b (commit)
      from  a57b44fce003ff336e5e9b3990f4a4b6e288f758 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 426d4e697c5a96fc4884c444835b7e17b181b93b
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Mon Aug 5 13:28:03 2013 -0700

    prevent deletion of a tower sector with customers, RT#24197

diff --git a/FS/FS/tower.pm b/FS/FS/tower.pm
index 227e3eb..052836e 100644
--- a/FS/FS/tower.pm
+++ b/FS/FS/tower.pm
@@ -59,8 +59,6 @@ points to.  You can ask the object for a copy with the I<hash> method.
 
 =cut
 
-# the new method can be inherited from FS::Record, if a table method is defined
-
 sub table { 'tower'; }
 
 =item insert
@@ -68,23 +66,15 @@ sub table { 'tower'; }
 Adds this record to the database.  If there is an error, returns the error,
 otherwise returns false.
 
-=cut
-
 =item delete
 
 Delete this record from the database.
 
-=cut
-
 =item replace OLD_RECORD
 
 Replaces the OLD_RECORD with this one in the database.  If there is an error,
 returns the error, otherwise returns false.
 
-=cut
-
-# the replace method can be inherited from FS::Record
-
 =item check
 
 Checks all fields to make sure this is a valid tower.  If there is
@@ -93,9 +83,6 @@ and replace methods.
 
 =cut
 
-# the check method should currently be supplied - FS::Record contains some
-# data checking routines
-
 sub check {
   my $self = shift;
 
diff --git a/FS/FS/tower_sector.pm b/FS/FS/tower_sector.pm
index 80e7f51..3605190 100644
--- a/FS/FS/tower_sector.pm
+++ b/FS/FS/tower_sector.pm
@@ -2,8 +2,9 @@ package FS::tower_sector;
 
 use strict;
 use base qw( FS::Record );
-use FS::Record qw( qsearchs ); # qsearch );
+use FS::Record qw( qsearch qsearchs );
 use FS::tower;
+use FS::svc_broadband;
 
 =head1 NAME
 
@@ -26,8 +27,8 @@ FS::tower_sector - Object methods for tower_sector records
 
 =head1 DESCRIPTION
 
-An FS::tower_sector object represents an example.  FS::tower_sector inherits from
-FS::Record.  The following fields are currently supported:
+An FS::tower_sector object represents an tower sector.  FS::tower_sector
+inherits from FS::Record.  The following fields are currently supported:
 
 =over 4
 
@@ -56,15 +57,13 @@ ip_addr
 
 =item new HASHREF
 
-Creates a new example.  To add the example to the database, see L<"insert">.
+Creates a new sector.  To add the sector to the database, see L<"insert">.
 
 Note that this stores the hash reference, not a distinct copy of the hash it
 points to.  You can ask the object for a copy with the I<hash> method.
 
 =cut
 
-# the new method can be inherited from FS::Record, if a table method is defined
-
 sub table { 'tower_sector'; }
 
 =item insert
@@ -72,38 +71,35 @@ sub table { 'tower_sector'; }
 Adds this record to the database.  If there is an error, returns the error,
 otherwise returns false.
 
-=cut
-
-# the insert method can be inherited from FS::Record
-
 =item delete
 
 Delete this record from the database.
 
 =cut
 
-# the delete method can be inherited from FS::Record
+sub delete {
+  my $self = shift;
+
+  #not the most efficient, not not awful, and its not like deleting a sector
+  # with customers is a common operation
+  return "Can't delete a sector with customers" if $self->svc_broadband;
+
+  $self->SUPER::delete;
+}
 
 =item replace OLD_RECORD
 
 Replaces the OLD_RECORD with this one in the database.  If there is an error,
 returns the error, otherwise returns false.
 
-=cut
-
-# the replace method can be inherited from FS::Record
-
 =item check
 
-Checks all fields to make sure this is a valid example.  If there is
+Checks all fields to make sure this is a valid sector.  If there is
 an error, returns the error, otherwise returns false.  Called by the insert
 and replace methods.
 
 =cut
 
-# the check method should currently be supplied - FS::Record contains some
-# data checking routines
-
 sub check {
   my $self = shift;
 
@@ -145,6 +141,17 @@ sub description {
   }
 }
 
+=item svc_broadband
+
+Returns the services on this tower sector.
+
+=cut
+
+sub svc_broadband {
+  my $self = shift;
+  qsearch('svc_broadband', { 'sectornum' => $self->sectornum });
+}
+
 =back
 
 =head1 BUGS

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/tower.pm        |   13 -------------
 FS/FS/tower_sector.pm |   45 ++++++++++++++++++++++++++-------------------
 2 files changed, 26 insertions(+), 32 deletions(-)




More information about the freeside-commits mailing list