[Rt-commit] rt branch, experimental/4.2/dashboard-tables, created. rt-4.0.0rc6-188-gfa74943

Alex Vandiver alexmv at bestpractical.com
Wed Nov 27 17:21:35 EST 2013


The branch, experimental/4.2/dashboard-tables has been created
        at  fa749439f7aedee3040261e6715d3fbbfc16b5b1 (commit)

- Log -----------------------------------------------------------------
commit d8e530e541b4827082825ca6ca56068f3a7bf0b3
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Mon Mar 21 09:47:49 2011 -0400

    Give RT::Dashboard the _CoreAccessible treatment

diff --git a/lib/RT/Dashboard.pm b/lib/RT/Dashboard.pm
index 431eb9b..286cf9a 100644
--- a/lib/RT/Dashboard.pm
+++ b/lib/RT/Dashboard.pm
@@ -427,6 +427,92 @@ sub CurrentUserCanCreateAny {
     return 0;
 }
 
+=head2 id
+
+Returns the current value of id.
+(In the database, id is stored as int(11).)
+
+=head2 Name
+
+Returns the current value of Name.
+(In the database, Name is stored as varchar(255).)
+
+=head2 SetName VALUE
+
+Set Name to VALUE.
+Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
+(In the database, Name will be stored as a varchar(255).)
+
+=head2 Content
+
+Returns the current value of Content.
+(In the database, Content is stored as blob.)
+
+=head2 SetContent VALUE
+
+Set Content to VALUE.
+Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
+(In the database, Content will be stored as a blob.)
+
+=head2 ObjectType
+
+Returns the current value of ObjectType.
+(In the database, ObjectType is stored as varchar(64).)
+
+=head2 SetObjectType VALUE
+
+Set ObjectType to VALUE.
+Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
+(In the database, ObjectType will be stored as a varchar(64).)
+
+=head2 ObjectId
+
+Returns the current value of ObjectId.
+(In the database, ObjectId is stored as int(11).)
+
+=head2 SetObjectId VALUE
+
+Set ObjectId to VALUE.
+Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
+(In the database, ObjectId will be stored as a int(11).)
+
+=head2 Creator
+
+Returns the current value of Creator.
+(In the database, Creator is stored as int(11).)
+
+=head2 Created
+
+Returns the current value of Created.
+(In the database, Created is stored as datetime.)
+
+=head2 LastUpdatedBy
+
+Returns the current value of LastUpdatedBy.
+(In the database, LastUpdatedBy is stored as int(11).)
+
+=head2 LastUpdated
+
+Returns the current value of LastUpdated.
+(In the database, LastUpdated is stored as datetime.)
+
+=cut
+
+sub _CoreAccessible {
+    {
+        id => {read => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(11)', default => ''},
+        Name => {read => 1, write => 1, sql_type => 12, length => 255,  is_blob => 0,  is_numeric => 0,  type => 'varchar(255)', default => ''},
+        Content => {read => 1, write => 1, sql_type => -4, length => 0,  is_blob => 1,  is_numeric => 0,  type => 'blob', default => ''},
+        ObjectType => {read => 1, write => 1, sql_type => 12, length => 64,  is_blob => 0,  is_numeric => 0,  type => 'varchar(64)', default => ''},
+        ObjectId => {read => 1, write => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(11)', default => ''},
+        Creator => {read => 1, auto => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(11)', default => '0'},
+        Created => {read => 1, auto => 1, sql_type => 11, length => 0,  is_blob => 0,  is_numeric => 0,  type => 'datetime', default => ''},
+        LastUpdatedBy => {read => 1, auto => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(11)', default => '0'},
+        LastUpdated => {read => 1, auto => 1, sql_type => 11, length => 0,  is_blob => 0,  is_numeric => 0,  type => 'datetime', default => ''},
+ }
+};
+
 RT::Base->_ImportOverlays();
 
 1;
+

commit 3f3d8bf23cae959ef0525cd61847dd4f4754b205
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Mon Mar 21 10:07:05 2011 -0400

    Dashboard schema

diff --git a/etc/schema.Oracle b/etc/schema.Oracle
index 4bcae6c..4fb1397 100755
--- a/etc/schema.Oracle
+++ b/etc/schema.Oracle
@@ -479,3 +479,17 @@ Created DATE,
 LastUpdatedBy NUMBER(11,0) DEFAULT 0 NOT NULL,
 LastUpdated DATE
 );
+
+CREATE SEQUENCE Dashboards_seq;
+CREATE TABLE Dashboards (
+	id 			NUMBER(11,0) PRIMARY KEY,
+	Name 			VARCHAR2(255) NOT NULL,
+  	Content 	CLOB,
+	ObjectType	VARCHAR2(25) NOT NULL,
+	ObjectId	NUMBER(11,0) DEFAULT 0 NOT NULL,
+	Creator 		NUMBER(11,0) DEFAULT 0 NOT NULL,
+	Created 		DATE,
+	LastUpdatedBy 		NUMBER(11,0) DEFAULT 0 NOT NULL,
+	LastUpdated		DATE
+);
+
diff --git a/etc/schema.Pg b/etc/schema.Pg
index 565f76b..8e0b940 100755
--- a/etc/schema.Pg
+++ b/etc/schema.Pg
@@ -713,3 +713,17 @@ LastUpdated TIMESTAMP NULL,
 PRIMARY KEY (id)
 );
 
+CREATE SEQUENCE dashboards_id_seq;
+CREATE TABLE Dashboards (
+  id INTEGER DEFAULT nextval('dashboards_id_seq'),
+  Name varchar(255) NOT NULL,
+  Content text,
+  ObjectType varchar(64),
+  ObjectId integer,
+  Creator integer NOT NULL DEFAULT 0,
+  Created TIMESTAMP NULL,
+  LastUpdatedBy integer NOT NULL DEFAULT 0,
+  LastUpdated TIMESTAMP NULL,
+  PRIMARY KEY (id)
+);
+
diff --git a/etc/schema.SQLite b/etc/schema.SQLite
index 138971c..139387e 100755
--- a/etc/schema.SQLite
+++ b/etc/schema.SQLite
@@ -504,3 +504,16 @@ Created TIMESTAMP NULL,
 LastUpdatedBy integer NOT NULL DEFAULT 0,
 LastUpdated TIMESTAMP NULL
 );
+
+CREATE TABLE Dashboards (
+  id INTEGER PRIMARY KEY,
+  Name varchar(255) NOT NULL,
+  Content LONGTEXT NULL,
+  ObjectType varchar(25) NOT NULL,
+  ObjectId INTEGER default 0,
+  Creator integer NULL,
+  Created DATETIME NULL,
+  LastUpdatedBy integer NULL,
+  LastUpdated DATETIME NULL
+);
+
diff --git a/etc/schema.mysql b/etc/schema.mysql
index c313aaf..4d7bb5c 100755
--- a/etc/schema.mysql
+++ b/etc/schema.mysql
@@ -497,3 +497,16 @@ CREATE TABLE ObjectClasses (
   LastUpdated datetime default NULL,
   PRIMARY KEY  (id)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+CREATE TABLE Dashboards (
+  id INTEGER NOT NULL AUTO_INCREMENT,
+  Name varchar(255) NULL,
+  Content BLOB,
+  ObjectType varchar(64) CHARACTER SET ascii,
+  ObjectId integer,
+  Creator integer NOT NULL DEFAULT 0,
+  Created DATETIME NULL,
+  LastUpdatedBy integer NOT NULL DEFAULT 0,
+  LastUpdated DATETIME NULL,
+  PRIMARY KEY (id)
+) ENGINE=InnoDB CHARACTER SET utf8;

commit 01896a802cd43dc3106b47477cf68f7dbc110c4b
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Mon Mar 21 10:09:13 2011 -0400

    Upgrade schemata for dashboards

diff --git a/etc/upgrade/4.1.1/schema.Oracle b/etc/upgrade/4.1.1/schema.Oracle
new file mode 100644
index 0000000..5c94c5c
--- /dev/null
+++ b/etc/upgrade/4.1.1/schema.Oracle
@@ -0,0 +1,13 @@
+CREATE SEQUENCE Dashboards_seq;
+CREATE TABLE Dashboards (
+	id 			NUMBER(11,0) PRIMARY KEY,
+	Name 			VARCHAR2(255) NOT NULL,
+  	Content 	CLOB,
+	ObjectType	VARCHAR2(25) NOT NULL,
+	ObjectId	NUMBER(11,0) DEFAULT 0 NOT NULL,
+	Creator 		NUMBER(11,0) DEFAULT 0 NOT NULL,
+	Created 		DATE,
+	LastUpdatedBy 		NUMBER(11,0) DEFAULT 0 NOT NULL,
+	LastUpdated		DATE
+);
+
diff --git a/etc/upgrade/4.1.1/schema.Pg b/etc/upgrade/4.1.1/schema.Pg
new file mode 100644
index 0000000..5ad0c15
--- /dev/null
+++ b/etc/upgrade/4.1.1/schema.Pg
@@ -0,0 +1,14 @@
+CREATE SEQUENCE dashboards_id_seq;
+CREATE TABLE Dashboards (
+  id INTEGER DEFAULT nextval('dashboards_id_seq'),
+  Name varchar(255) NOT NULL,
+  Content text,
+  ObjectType varchar(64),
+  ObjectId integer,
+  Creator integer NOT NULL DEFAULT 0,
+  Created TIMESTAMP NULL,
+  LastUpdatedBy integer NOT NULL DEFAULT 0,
+  LastUpdated TIMESTAMP NULL,
+  PRIMARY KEY (id)
+);
+
diff --git a/etc/upgrade/4.1.1/schema.SQLite b/etc/upgrade/4.1.1/schema.SQLite
new file mode 100644
index 0000000..12a41ec
--- /dev/null
+++ b/etc/upgrade/4.1.1/schema.SQLite
@@ -0,0 +1,12 @@
+CREATE TABLE Dashboards (
+  id INTEGER PRIMARY KEY,
+  Name varchar(255) NOT NULL,
+  Content LONGTEXT NULL,
+  ObjectType varchar(25) NOT NULL,
+  ObjectId INTEGER default 0,
+  Creator integer NULL,
+  Created DATETIME NULL,
+  LastUpdatedBy integer NULL,
+  LastUpdated DATETIME NULL
+);
+
diff --git a/etc/upgrade/4.1.1/schema.mysql b/etc/upgrade/4.1.1/schema.mysql
new file mode 100644
index 0000000..4dfdcbd
--- /dev/null
+++ b/etc/upgrade/4.1.1/schema.mysql
@@ -0,0 +1,13 @@
+CREATE TABLE Dashboards (
+  id INTEGER NOT NULL AUTO_INCREMENT,
+  Name varchar(255) NULL,
+  Content BLOB,
+  ObjectType varchar(64) CHARACTER SET ascii,
+  ObjectId integer,
+  Creator integer NOT NULL DEFAULT 0,
+  Created DATETIME NULL,
+  LastUpdatedBy integer NOT NULL DEFAULT 0,
+  LastUpdated DATETIME NULL,
+  PRIMARY KEY (id)
+) ENGINE=InnoDB CHARACTER SET utf8;
+

commit 8f7baddf7c4e6ad028a73f9fd034f15338bdbaaa
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Mon Mar 21 10:26:20 2011 -0400

    Upgrade script for attributes into dashboards
    
        Still need to handle subscriptions

diff --git a/etc/upgrade/4.1.1/content b/etc/upgrade/4.1.1/content
new file mode 100644
index 0000000..15586e5
--- /dev/null
+++ b/etc/upgrade/4.1.1/content
@@ -0,0 +1,52 @@
+my $convert_attributes = sub {
+    my $obj = shift;
+
+    for my $attribute ($obj->Attributes->Named('Dashboard')) {
+        my $dashboard = RT::Dashboard->new($RT::SystemUser);
+
+        my ($ok, $msg) = $dashboard->Create(
+            Name       => $attr->Description,
+            Content    => $attr->Content,
+            ObjectType => ref($obj),
+            ObjectId   => $obj->id,
+        );
+
+        if (!$ok) {
+            $RT::Logger->error("Unable to reify attribute " . $attr->id . " into a dashboard: $msg");
+            next;
+        }
+
+        ($ok, $msg) = $attr->Delete;
+
+        if (!$ok) {
+            $RT::Logger->error("Reified attribute into dashboard " . $dashboard->id . " but couldn't delete attribute: $msg");
+            next;
+        }
+
+        $RT::Logger->debug("Reified attribute into a dashboard: $msg");
+    }
+};
+
+ at Final = (
+    sub {
+        my $users = RT::Users->new($RT::SystemUser);
+        $users->UnLimit;
+
+        while (my $user = $users->Next) {
+            $convert_attributes->($user);
+        }
+    },
+    sub {
+        my $groups = RT::Groups->new($RT::SystemUser);
+        $groups->UnLimit;
+
+        while (my $group = $groups->Next) {
+            $convert_attributes->($group);
+        }
+    },
+    sub {
+        my $system = RT::System->new($RT::SystemUser);
+        $convert_attributes->($system);
+    },
+);
+

commit 3b9971b2f51676d153fc32b76b5bbf3f86b74dc8
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Mon Mar 21 11:15:28 2011 -0400

    Upgrade subscriptions when we recreate dashboards

diff --git a/etc/upgrade/4.1.1/content b/etc/upgrade/4.1.1/content
index 15586e5..902230b 100644
--- a/etc/upgrade/4.1.1/content
+++ b/etc/upgrade/4.1.1/content
@@ -1,7 +1,11 @@
+my %new_id_for;
+
 my $convert_attributes = sub {
     my $obj = shift;
 
     for my $attribute ($obj->Attributes->Named('Dashboard')) {
+        my $attr_id = $attribute->id;
+
         my $dashboard = RT::Dashboard->new($RT::SystemUser);
 
         my ($ok, $msg) = $dashboard->Create(
@@ -12,18 +16,20 @@ my $convert_attributes = sub {
         );
 
         if (!$ok) {
-            $RT::Logger->error("Unable to reify attribute " . $attr->id . " into a dashboard: $msg");
+            $RT::Logger->error("Unable to reify attribute $attr_id into a dashboard: $msg");
             next;
         }
 
+        $new_id_for{$attr_id} = $dashboard->id;
+
         ($ok, $msg) = $attr->Delete;
 
         if (!$ok) {
-            $RT::Logger->error("Reified attribute into dashboard " . $dashboard->id . " but couldn't delete attribute: $msg");
+            $RT::Logger->error("Reified attribute $attr_id into dashboard " . $dashboard->id . " but couldn't delete attribute: $msg");
             next;
         }
 
-        $RT::Logger->debug("Reified attribute into a dashboard: $msg");
+        $RT::Logger->debug("Reified attribute $attr_id into a dashboard: $msg");
     }
 };
 
@@ -48,5 +54,24 @@ my $convert_attributes = sub {
         my $system = RT::System->new($RT::SystemUser);
         $convert_attributes->($system);
     },
+
+    sub {
+        my $users = RT::Users->new($RT::SystemUser);
+        $users->UnLimit;
+
+        while (my $user = $users->Next) {
+            for my $subscription ($users->Attributes->Named('Subscription')) {
+                my $old_id = $subscription->SubValue('DashboardId');
+                my $new_id = $new_id_for{$old_id};
+
+                if (!$new_id) {
+                    $RT::Logger->error("Can't update subscription " . $subscription->id . " for old-style dashboard $old_id since it has no new-style ID");
+                    next;
+                }
+
+                $subscription->SetSubValue(DashboardId => $new_id);
+            }
+        }
+    },
 );
 

commit 6643907e8d81ed6b1dd8775b604600dde150d936
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Mon Mar 21 11:18:36 2011 -0400

    For successful subscription updates, debug log

diff --git a/etc/upgrade/4.1.1/content b/etc/upgrade/4.1.1/content
index 902230b..632d20e 100644
--- a/etc/upgrade/4.1.1/content
+++ b/etc/upgrade/4.1.1/content
@@ -69,7 +69,14 @@ my $convert_attributes = sub {
                     next;
                 }
 
-                $subscription->SetSubValue(DashboardId => $new_id);
+                my ($ok, $msg) = $subscription->SetSubValue(DashboardId => $new_id);
+
+                if (!$ok) {
+                    $RT::Logger->error("Unable to update subscription " . $subscription->id . " from dashboard $old_id to $new_id: $msg");
+                    next;
+                }
+
+                $RT::Logger->debug("Updated subscription " . $subscription->id . " from dashboard $old_id to $new_id");
             }
         }
     },

commit 3e62d98da3d066e3b3593d44586667c5ffda7a4e
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Tue Mar 22 13:08:56 2011 -0400

    Dashboards->LimitToObject

diff --git a/lib/RT/Dashboards.pm b/lib/RT/Dashboards.pm
index 3509a0a..58ccd63 100644
--- a/lib/RT/Dashboards.pm
+++ b/lib/RT/Dashboards.pm
@@ -76,6 +76,21 @@ sub RecordClass {
     return 'RT::Dashboard';
 }
 
+=head2 LimitToObject
+
+The Dashboards object will load the dashboards belonging to the passed-in user
+or group. Repeated calls to the same object should DTRT.
+
+=cut
+
+sub LimitToObject {
+    my $self = shift;
+    my $obj  = shift;
+
+    my $privacy = join('-',ref($obj),$obj->Id);
+    return $self->LimitToPrivacy($privacy);
+}
+
 =head2 LimitToPrivacy
 
 Takes one argument: a privacy string, of the format "<class>-<id>", as produced

commit 71312da32ff0bb7175de23d07d43d3d8fd12f7e7
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Tue Mar 22 13:10:53 2011 -0400

    Use LimitToObject instead of LimitToPrivacy for forward compat

diff --git a/share/html/Admin/Global/DashboardsInMenu.html b/share/html/Admin/Global/DashboardsInMenu.html
index c57a41a..fb12b90 100644
--- a/share/html/Admin/Global/DashboardsInMenu.html
+++ b/share/html/Admin/Global/DashboardsInMenu.html
@@ -71,7 +71,7 @@ my $default_dashboards_in_menu =
 
 use RT::Dashboards;
 my $dashboards = RT::Dashboards->new( $RT::SystemUser );
-$dashboards->LimitToPrivacy('RT::System-' . $sys->id);
+$dashboards->LimitToObject($sys);
 
 my @dashboards;
 while ( my $dashboard = $dashboards->Next ) {
diff --git a/share/html/Dashboards/Elements/ShowDashboards b/share/html/Dashboards/Elements/ShowDashboards
index ec32426..2cc1c24 100644
--- a/share/html/Dashboards/Elements/ShowDashboards
+++ b/share/html/Dashboards/Elements/ShowDashboards
@@ -47,7 +47,7 @@
 %# END BPS TAGGED BLOCK }}}
 % foreach my $Object (@Objects) {
 %   my $Dashboards = RT::Dashboards->new($session{CurrentUser});
-%   $Dashboards->LimitToPrivacy(join('-',ref($Object),$Object->Id));
+%   $Dashboards->LimitToObject($Object);
 %   my $title;
 %   if (ref $Object eq 'RT::User' && $Object->Id == $session{CurrentUser}->Id) {
 %       $title = loc("My dashboards");

commit 580a45b472bb425212e7ef6c58865cdb6d4e30ba
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Tue Mar 22 13:51:30 2011 -0400

    Rebase RT::Dashboards onto RT::SearchBuilder

diff --git a/lib/RT/Dashboards.pm b/lib/RT/Dashboards.pm
index 58ccd63..872afcf 100644
--- a/lib/RT/Dashboards.pm
+++ b/lib/RT/Dashboards.pm
@@ -48,17 +48,11 @@
 
 =head1 NAME
 
-  RT::Dashboards - a pseudo-collection for Dashboard objects.
+  RT::Dashboards - a collection for Dashboard objects
 
 =head1 SYNOPSIS
 
-  use RT::Dashboards
-
-=head1 DESCRIPTION
-
-  Dashboards is an object consisting of a number of Dashboard objects.
-  It works more or less like a DBIx::SearchBuilder collection, although it
-  is not.
+  use RT::Dashboards;
 
 =head1 METHODS
 
@@ -66,15 +60,12 @@
 =cut
 
 package RT::Dashboards;
-
-use RT::Dashboard;
-
 use strict;
-use base 'RT::SharedSettings';
+use warnings;
 
-sub RecordClass {
-    return 'RT::Dashboard';
-}
+use base 'RT::SearchBuilder';
+
+use RT::Dashboard;
 
 =head2 LimitToObject
 
@@ -118,10 +109,6 @@ sub LimitToPrivacy {
     }
 }
 
-sub ColumnMapClassName {
-    return 'RT__Dashboard';
-}
-
 RT::Base->_ImportOverlays();
 
 1;

commit 580922e61a53330e32127caa4d31dbced4dc69aa
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Tue Mar 22 13:52:29 2011 -0400

    Give RT::Dashboards NewItem

diff --git a/lib/RT/Dashboards.pm b/lib/RT/Dashboards.pm
index 872afcf..c2946b6 100644
--- a/lib/RT/Dashboards.pm
+++ b/lib/RT/Dashboards.pm
@@ -109,6 +109,17 @@ sub LimitToPrivacy {
     }
 }
 
+=head2 NewItem
+
+Returns an empty new L<RT::Dashboard> record.
+
+=cut
+
+sub NewItem {
+    my $self = shift;
+    return RT::Dashboard->new($self->CurrentUser);
+}
+
 RT::Base->_ImportOverlays();
 
 1;

commit 8d821d643c63d36f51c26ed7e592d2592a1ff824
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Tue Mar 22 13:55:09 2011 -0400

    Make RT::Dashboard an RT::Record

diff --git a/lib/RT/Dashboard.pm b/lib/RT/Dashboard.pm
index 286cf9a..2135f70 100644
--- a/lib/RT/Dashboard.pm
+++ b/lib/RT/Dashboard.pm
@@ -48,33 +48,30 @@
 
 =head1 NAME
 
-  RT::Dashboard - an API for saving and retrieving dashboards
+  RT::Dashboard - a dashboard object
 
 =head1 SYNOPSIS
 
-  use RT::Dashboard
+  use RT::Dashboard;
 
 =head1 DESCRIPTION
 
-  Dashboard is an object that can belong to either an RT::User or an
-  RT::Group.  It consists of an ID, a name, and a number of
-  saved searches and portlets.
-
 =head1 METHODS
 
 
 =cut
 
 package RT::Dashboard;
-
-use RT::SavedSearch;
-
 use strict;
 use warnings;
 
-use base qw/RT::SharedSetting/;
+use base 'RT::Record';
 
+use RT::SavedSearch;
 use RT::System;
+
+sub Table { 'Dashboards' }
+
 RT::System::AddRights(
     SubscribeDashboard => 'Subscribe to dashboards', #loc_pair
 

commit b96dbec61465cfeeb69751bc0dfcbb558b94e2bd
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Tue Mar 22 13:55:18 2011 -0400

    RT::Dashboards needs a ->Table

diff --git a/lib/RT/Dashboards.pm b/lib/RT/Dashboards.pm
index c2946b6..701a607 100644
--- a/lib/RT/Dashboards.pm
+++ b/lib/RT/Dashboards.pm
@@ -67,6 +67,8 @@ use base 'RT::SearchBuilder';
 
 use RT::Dashboard;
 
+sub Table { 'Dashboards' }
+
 =head2 LimitToObject
 
 The Dashboards object will load the dashboards belonging to the passed-in user

commit 1c4fd3aad9ab35c43cfa68cb6020e372175c46b0
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Tue Mar 22 13:59:42 2011 -0400

    Kill LimitToPrivacy for a real LimitToObject

diff --git a/lib/RT/Dashboards.pm b/lib/RT/Dashboards.pm
index 701a607..5037b6f 100644
--- a/lib/RT/Dashboards.pm
+++ b/lib/RT/Dashboards.pm
@@ -80,35 +80,15 @@ sub LimitToObject {
     my $self = shift;
     my $obj  = shift;
 
-    my $privacy = join('-',ref($obj),$obj->Id);
-    return $self->LimitToPrivacy($privacy);
-}
-
-=head2 LimitToPrivacy
-
-Takes one argument: a privacy string, of the format "<class>-<id>", as produced
-by RT::Dashboard::Privacy(). The Dashboards object will load the dashboards
-belonging to that user or group. Repeated calls to the same object should DTRT.
-
-=cut
-
-sub LimitToPrivacy {
-    my $self = shift;
-    my $privacy = shift;
-
-    my $object = $self->_GetObject($privacy);
-
-    if ($object) {
-        $self->{'objects'} = [];
-        my @dashboard_atts = $object->Attributes->Named('Dashboard');
-        foreach my $att (@dashboard_atts) {
-            my $dashboard = RT::Dashboard->new($self->CurrentUser);
-            $dashboard->Load($privacy, $att->Id);
-            push(@{$self->{'objects'}}, $dashboard);
-        }
-    } else {
-        $RT::Logger->error("Could not load object $privacy");
-    }
+    $self->Limit(
+        FIELD => 'ObjectType',
+        VALUE => ref($obj);
+    );
+
+    $self->Limit(
+        FIELD => 'ObjectId',
+        VALUE => $obj->id,
+    );
 }
 
 =head2 NewItem

commit 1f745db7fb68632af72483e5947fb49eb728f709
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Tue Mar 22 14:02:40 2011 -0400

    Typo fix

diff --git a/lib/RT/Dashboards.pm b/lib/RT/Dashboards.pm
index 5037b6f..c5a9729 100644
--- a/lib/RT/Dashboards.pm
+++ b/lib/RT/Dashboards.pm
@@ -82,7 +82,7 @@ sub LimitToObject {
 
     $self->Limit(
         FIELD => 'ObjectType',
-        VALUE => ref($obj);
+        VALUE => ref($obj),
     );
 
     $self->Limit(

commit 4638945c4cea1ba831bd5efd64f222285c3039c8
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Tue Mar 22 14:10:26 2011 -0400

    Remove some RT::SharedSetting-specific stuff

diff --git a/lib/RT/Dashboard.pm b/lib/RT/Dashboard.pm
index 2135f70..3ea4519 100644
--- a/lib/RT/Dashboard.pm
+++ b/lib/RT/Dashboard.pm
@@ -100,59 +100,6 @@ RT::System::AddRightCategories(
     DeleteOwnDashboard => 'Staff',
 );
 
-=head2 ObjectName
-
-An object of this class is called "dashboard"
-
-=cut
-
-sub ObjectName { "dashboard" }
-
-sub SaveAttribute {
-    my $self   = shift;
-    my $object = shift;
-    my $args   = shift;
-
-    return $object->AddAttribute(
-        'Name'        => 'Dashboard',
-        'Description' => $args->{'Name'},
-        'Content'     => {Panes => $args->{'Panes'}},
-    );
-}
-
-sub UpdateAttribute {
-    my $self = shift;
-    my $args = shift;
-
-    my ($status, $msg) = (1, undef);
-    if (defined $args->{'Panes'}) {
-        ($status, $msg) = $self->{'Attribute'}->SetSubValues(
-            Panes => $args->{'Panes'},
-        );
-    }
-
-    if ($status && $args->{'Name'}) {
-        ($status, $msg) = $self->{'Attribute'}->SetDescription($args->{'Name'})
-            unless $self->Name eq $args->{'Name'};
-    }
-
-    if ($status && $args->{'Privacy'}) {
-        my ($new_obj_type, $new_obj_id) = split /-/, $args->{'Privacy'};
-        my ($obj_type, $obj_id) = split /-/, $self->Privacy;
-
-        my $attr = $self->{'Attribute'};
-        if ($new_obj_type ne $obj_type) {
-            ($status, $msg) = $attr->SetObjectType($new_obj_type);
-        }
-        if ($status && $new_obj_id != $obj_id ) {
-            ($status, $msg) = $attr->SetObjectId($new_obj_id);
-        }
-        $self->{'Privacy'} = $args->{'Privacy'} if $status;
-    }
-
-    return ($status, $msg);
-}
-
 =head2 Panes
 
 Returns a hashref of pane name to portlets

commit 414eb7f19a09874e9b6e80e89b2bd631e069714a
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Tue Mar 22 14:10:34 2011 -0400

    Pull Panes out from Content

diff --git a/lib/RT/Dashboard.pm b/lib/RT/Dashboard.pm
index 3ea4519..8759f2b 100644
--- a/lib/RT/Dashboard.pm
+++ b/lib/RT/Dashboard.pm
@@ -108,8 +108,7 @@ Returns a hashref of pane name to portlets
 
 sub Panes {
     my $self = shift;
-    return unless ref($self->{'Attribute'}) eq 'RT::Attribute';
-    return $self->{'Attribute'}->SubValue('Panes') || {};
+    return $self->Content->{Panes} || {};
 }
 
 =head2 Portlets

commit 0409c5dd12140ca31853d5ffbd5e8004062c4849
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Tue Mar 22 14:38:06 2011 -0400

    RT::Dashboard->Create which accepts Privacy

diff --git a/lib/RT/Dashboard.pm b/lib/RT/Dashboard.pm
index 8759f2b..0fdcbd3 100644
--- a/lib/RT/Dashboard.pm
+++ b/lib/RT/Dashboard.pm
@@ -100,6 +100,24 @@ RT::System::AddRightCategories(
     DeleteOwnDashboard => 'Staff',
 );
 
+=head2 Create
+
+Accepts a C<Privacy> instead of an C<ObjectType> and C<ObjectId>.
+
+=cut
+
+sub Create {
+    my $self = shift;
+    my %args = @_;
+
+    # canonicalize Privacy into ObjectType and ObjectId
+    if ($args{Privacy}) {
+        ($args{ObjectType}, $args{ObjectId}) = split '-', delete $args{Privacy};
+    }
+
+    return $self->SUPER::Create(%args);
+}
+
 =head2 Panes
 
 Returns a hashref of pane name to portlets

commit fa749439f7aedee3040261e6715d3fbbfc16b5b1
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Tue Mar 22 14:39:34 2011 -0400

    Create not Save

diff --git a/share/html/Dashboards/Modify.html b/share/html/Dashboards/Modify.html
index 553248b..3efb66e 100644
--- a/share/html/Dashboards/Modify.html
+++ b/share/html/Dashboards/Modify.html
@@ -101,7 +101,7 @@ else {
     if ($id eq 'new') {
         $tried_create = 1;
 
-        my ($val, $msg) = $Dashboard->Save(
+        my ($val, $msg) = $Dashboard->Create(
             Name    => $ARGS{'Name'},
             Privacy => $ARGS{'Privacy'},
         );

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


More information about the rt-commit mailing list