Moving DS creation to use tenant-utils to get current user tenant

Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/6336f9b4
Tree: 
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/6336f9b4
Diff: 
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/6336f9b4

Branch: refs/heads/master
Commit: 6336f9b4a7b7872751c8015094790d9d149518c0
Parents: 13b60e6
Author: nir-sopher <[email protected]>
Authored: Tue Jul 11 02:39:35 2017 +0300
Committer: Jeremy Mitchell <[email protected]>
Committed: Tue Jul 18 12:12:32 2017 -0600

----------------------------------------------------------------------
 traffic_ops/app/lib/API/Deliveryservice.pm | 4 +++-
 traffic_ops/app/lib/UI/DeliveryService.pm  | 4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/6336f9b4/traffic_ops/app/lib/API/Deliveryservice.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/API/Deliveryservice.pm 
b/traffic_ops/app/lib/API/Deliveryservice.pm
index 1587bed..5e748af 100644
--- a/traffic_ops/app/lib/API/Deliveryservice.pm
+++ b/traffic_ops/app/lib/API/Deliveryservice.pm
@@ -21,6 +21,7 @@ package API::Deliveryservice;
 
 # JvD Note: you always want to put Utils as the first use. Sh*t don't work if 
it's after the Mojo lines.
 use UI::Utils;
+use Utils::Tenant;
 
 use Mojo::Base 'Mojolicious::Controller';
 use Data::Dumper;
@@ -463,7 +464,8 @@ sub create {
        }
        
        #setting tenant_id to the user id if tenant is not set. 
-       my $tenant_id = exists($params->{tenantId}) ? $params->{tenantId} :  
$self->current_user_tenant();
+       my $tenantUtils = Utils::Tenant->new($self);
+       my $tenant_id = exists($params->{tenantId}) ? $params->{tenantId} :  
$tenantUtils->current_user_tenant();
 
        my $values = {
                active                 => $params->{active},

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/6336f9b4/traffic_ops/app/lib/UI/DeliveryService.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/UI/DeliveryService.pm 
b/traffic_ops/app/lib/UI/DeliveryService.pm
index b9e33e5..63af8e3 100644
--- a/traffic_ops/app/lib/UI/DeliveryService.pm
+++ b/traffic_ops/app/lib/UI/DeliveryService.pm
@@ -19,6 +19,7 @@ package UI::DeliveryService;
 
 # JvD Note: you always want to put Utils as the first use. Sh*t don't work if 
it's after the Mojo lines.
 use UI::Utils;
+use Utils::Tenant;
 use Mojo::Base 'Mojolicious::Controller';
 use Data::Dumper;
 use JSON;
@@ -1009,6 +1010,7 @@ sub create {
        $self->stash_cdn_selector();
        &stash_role($self);
        if ( $self->check_deliveryservice_input($cdn_id) ) {
+               my $tenantUtils = Utils::Tenant->new($self);
                my $insert = $self->db->resultset('Deliveryservice')->create(
                        {
                                xml_id                      => 
$self->paramAsScalar('ds.xml_id'),
@@ -1054,7 +1056,7 @@ sub create {
                                remap_text         => $self->paramAsScalar( 
'ds.remap_text',         undef ),
                                initial_dispersion => $self->paramAsScalar( 
'ds.initial_dispersion', 1 ),
                                logs_enabled       => 
$self->paramAsScalar('ds.logs_enabled'),
-                               tenant_id => 
current_user_tenant($self),#Tenancy is not dealt by the UI for now. getting the 
tenancy from the user
+                               tenant_id => 
$tenantUtils->current_user_tenant(),#Tenancy is not dealt by the UI for now. 
getting the tenancy from the user
                        }
                );
                $insert->insert();

Reply via email to