[freeside-commits] branch FREESIDE_3_BRANCH updated. 7e0eb79c2efc03e27a4e8207b92526a2ac436602
Ivan
ivan at 420.am
Tue Aug 12 16:41:17 PDT 2014
The branch, FREESIDE_3_BRANCH has been updated
via 7e0eb79c2efc03e27a4e8207b92526a2ac436602 (commit)
from 6959e1e35908df64676d9626711e70b66715575d (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 7e0eb79c2efc03e27a4e8207b92526a2ac436602
Author: Ivan Kohler <ivan at freeside.biz>
Date: Tue Aug 12 16:41:15 2014 -0700
svc_cable unique serialnum and mac_addr, RT#
diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm
index 9e71af1..1828cba 100644
--- a/FS/FS/Schema.pm
+++ b/FS/FS/Schema.pm
@@ -4488,7 +4488,7 @@ sub tables_hashref {
'mac_addr', 'varchar', 'NULL', 12, '', '',
],
'primary_key' => 'svcnum',
- 'unique' => [],
+ 'unique' => [ ['serialnum'] , ['mac_addr'] ],
'index' => [],
},
diff --git a/FS/FS/svc_cable.pm b/FS/FS/svc_cable.pm
index 0c0d684..944f781 100644
--- a/FS/FS/svc_cable.pm
+++ b/FS/FS/svc_cable.pm
@@ -56,7 +56,7 @@ points to. You can ask the object for a copy with the I<hash> method.
sub table { 'svc_cable'; }
-sub table_dupcheck_fields { ( 'mac_addr' ); }
+sub table_dupcheck_fields { ( 'serialnum', 'mac_addr' ); }
sub search_sql {
my( $class, $string ) = @_;
@@ -171,6 +171,27 @@ sub check {
$self->SUPER::check;
}
+sub _check_duplicate {
+ my $self = shift;
+
+ # Not reliable checks because the table isn't locked, but that's why we have
+ # unique indices. These are just to give friendlier error messages.
+
+ my @dup_mac;
+ @dup_mac = $self->find_duplicates('global', 'mac_addr');
+ if ( @dup_mac ) {
+ return "MAC address in use (svcnum ".$dup_mac[0]->svcnum.")";
+ }
+
+ my @dup_serial;
+ @dup_serial = $self->find_duplicates('global', 'serialnum');
+ if ( @dup_serial ) {
+ return "Serial number in use (svcnum ".$dup_serial[0]->svcnum.")";
+ }
+
+ '';
+}
+
=item cable_provider
Returns the cable_provider object for this record.
-----------------------------------------------------------------------
Summary of changes:
FS/FS/Schema.pm | 2 +-
FS/FS/svc_cable.pm | 23 ++++++++++++++++++++++-
2 files changed, 23 insertions(+), 2 deletions(-)
More information about the freeside-commits
mailing list