[Rt-commit] r15419 - in rt/branches/3.999-DANGEROUS: lib/RT share/html/Dashboards share/html/Dashboards/Elements t/web
sunnavy at bestpractical.com
sunnavy at bestpractical.com
Mon Aug 25 05:00:35 EDT 2008
Author: sunnavy
Date: Mon Aug 25 05:00:35 2008
New Revision: 15419
Modified:
rt/branches/3.999-DANGEROUS/ (props changed)
rt/branches/3.999-DANGEROUS/lib/RT/Dashboard.pm
rt/branches/3.999-DANGEROUS/share/html/Dashboards/Elements/ShowDashboards
rt/branches/3.999-DANGEROUS/share/html/Dashboards/Elements/ShowSubscription
rt/branches/3.999-DANGEROUS/share/html/Dashboards/Elements/Tabs
rt/branches/3.999-DANGEROUS/share/html/Dashboards/Modify.html
rt/branches/3.999-DANGEROUS/share/html/Dashboards/Queries.html
rt/branches/3.999-DANGEROUS/share/html/Dashboards/Render.html
rt/branches/3.999-DANGEROUS/share/html/Dashboards/Subscription.html
rt/branches/3.999-DANGEROUS/t/web/dashboards-groups.t
rt/branches/3.999-DANGEROUS/t/web/dashboards.t
Log:
r16038 at sunnavys-mb: sunnavy | 2008-08-25 16:56:29 +0800
many name fixes for Dashboard, and still can not pass all the dashboard tests yet
Modified: rt/branches/3.999-DANGEROUS/lib/RT/Dashboard.pm
==============================================================================
--- rt/branches/3.999-DANGEROUS/lib/RT/Dashboard.pm (original)
+++ rt/branches/3.999-DANGEROUS/lib/RT/Dashboard.pm Mon Aug 25 05:00:35 2008
@@ -238,7 +238,7 @@
push @objects, $CurrentUser->user_object
if $self->current_user->has_right(
right => "${prefix}OwnDashboard",
- object => $RT::System,
+ object => RT->system_user,
);
my $groups = RT::Model::GroupCollection->new( current_user => $CurrentUser );
@@ -258,7 +258,7 @@
push @objects, RT::System->new( current_user => $CurrentUser )
if $CurrentUser->has_right(
right => "${prefix}Dashboard",
- object => $RT::System,
+ object => RT->system_user,
);
return @objects;
@@ -299,7 +299,7 @@
|| join( '', $args{right}, $level, 'Dashboard' );
# all rights, except group rights, are global
- $object = $RT::System unless $object->isa('RT::Model::Group');
+ $object = RT->system_user unless $object->isa('RT::Model::Group');
return $self->current_user->has_right(
right => $right,
Modified: rt/branches/3.999-DANGEROUS/share/html/Dashboards/Elements/ShowDashboards
==============================================================================
--- rt/branches/3.999-DANGEROUS/share/html/Dashboards/Elements/ShowDashboards (original)
+++ rt/branches/3.999-DANGEROUS/share/html/Dashboards/Elements/ShowDashboards Mon Aug 25 05:00:35 2008
@@ -62,7 +62,7 @@
my %subscription_for;
for my $attr (Jifty->web->current_user->user_object->attributes->named('Subscription')) {
- $subscription_for{$attr->sub_value('DashboardId')} = $attr;
+ $subscription_for{$attr->sub_value('dashboard_id')} = $attr;
}
</%INIT>
Modified: rt/branches/3.999-DANGEROUS/share/html/Dashboards/Elements/ShowSubscription
==============================================================================
--- rt/branches/3.999-DANGEROUS/share/html/Dashboards/Elements/ShowSubscription (original)
+++ rt/branches/3.999-DANGEROUS/share/html/Dashboards/Elements/ShowSubscription Mon Aug 25 05:00:35 2008
@@ -51,7 +51,7 @@
$subscription => undef
</%ARGS>
<%INIT>
-my $url = sprintf '%s/Dashboards/Subscription.html?DashboardId=%d',
+my $url = sprintf '%s/Dashboards/Subscription.html?dashboard_id=%d',
RT->config->get('WebPath'),
$dashboard->id,;
Modified: rt/branches/3.999-DANGEROUS/share/html/Dashboards/Elements/Tabs
==============================================================================
--- rt/branches/3.999-DANGEROUS/share/html/Dashboards/Elements/Tabs (original)
+++ rt/branches/3.999-DANGEROUS/share/html/Dashboards/Elements/Tabs Mon Aug 25 05:00:35 2008
@@ -76,7 +76,8 @@
},
c_Subscription => { title => loc('Subscription'),
- path => "Dashboards/Subscription.html?DashboardId=" . $dashboard_obj->id
+ path =>
+ "Dashboards/Subscription.html?dashboard_id=" . $dashboard_obj->id
},
@@ -100,11 +101,11 @@
path => "Dashboards/index.html" };
my $dashboard = RT::Dashboard->new( current_user => Jifty->web->current_user );
-my @objects = $dashboard->_privacy_objects(Create => 1);
+my @objects = $dashboard->_privacy_objects(create => 1);
if (@objects) {
$tabs->{"B"} = { title => loc('New dashboard'),
- path => "Dashboards/Modify.html?Create=1",
+ path => "Dashboards/Modify.html?create=1",
separator => 1 };
}
Modified: rt/branches/3.999-DANGEROUS/share/html/Dashboards/Modify.html
==============================================================================
--- rt/branches/3.999-DANGEROUS/share/html/Dashboards/Modify.html (original)
+++ rt/branches/3.999-DANGEROUS/share/html/Dashboards/Modify.html Mon Aug 25 05:00:35 2008
@@ -89,12 +89,12 @@
use RT::Dashboard;
my $Dashboard = RT::Dashboard->new( current_user => Jifty->web->current_user );
-my @privacies = $Dashboard->_privacy_objects(($create ? 'Create' : 'Modify') => 1);
+my @privacies = $Dashboard->_privacy_objects(($create ? 'create' : 'modify') => 1);
abort(loc("Permission denied")) if @privacies == 0;
if ($create) {
- $current_subtab = 'Dashboards/Modify.html?Create=1';
+ $current_subtab = 'Dashboards/Modify.html?create=1';
$title = loc("Create a new dashboard");
}
else {
@@ -125,7 +125,7 @@
# If the create failed
else {
$create = 1;
- $current_subtab = 'Dashboards/Modify.html?Create=1';
+ $current_subtab = 'Dashboards/Modify.html?create=1';
$title = loc("Create a new dashboard");
}
}
Modified: rt/branches/3.999-DANGEROUS/share/html/Dashboards/Queries.html
==============================================================================
--- rt/branches/3.999-DANGEROUS/share/html/Dashboards/Queries.html (original)
+++ rt/branches/3.999-DANGEROUS/share/html/Dashboards/Queries.html Mon Aug 25 05:00:35 2008
@@ -104,7 +104,7 @@
push @objs, RT::SavedSearches->new( current_user => Jifty->web->current_user )->_privacy_objects
if Jifty->web->current_user->has_right( right => 'LoadSavedSearch',
- object => $RT::System );
+ object => RT->system_user );
for my $object (@objs) {
for ($m->comp("/Search/Elements/SearchesForObject", object => $object)) {
Modified: rt/branches/3.999-DANGEROUS/share/html/Dashboards/Render.html
==============================================================================
--- rt/branches/3.999-DANGEROUS/share/html/Dashboards/Render.html (original)
+++ rt/branches/3.999-DANGEROUS/share/html/Dashboards/Render.html Mon Aug 25 05:00:35 2008
@@ -87,7 +87,7 @@
# try to load the subscription to this id
for my $sub (Jifty->web->current_user->user_object->attributes->named('Subscription')) {
- next unless $sub->sub_value('DashboardId') == $id;
+ next unless $sub->sub_value('dashboard_id') == $id;
$SubscriptionObj = $sub;
$Loaded = 1;
last;
Modified: rt/branches/3.999-DANGEROUS/share/html/Dashboards/Subscription.html
==============================================================================
--- rt/branches/3.999-DANGEROUS/share/html/Dashboards/Subscription.html (original)
+++ rt/branches/3.999-DANGEROUS/share/html/Dashboards/Subscription.html Mon Aug 25 05:00:35 2008
@@ -54,7 +54,7 @@
<& /Elements/ListActions, actions => \@results &>
<form action="<%RT->config->get('WebPath')%>/Dashboards/Subscription.html" method="post" enctype="multipart/form-data" name="subscribe_dashboard">
-<input type="hidden" class="hidden" name="dashboard_id" value="<% $fields{'DashboardId'} %>" />
+<input type="hidden" class="hidden" name="dashboard_id" value="<% $fields{'dashboard_id'} %>" />
<table width="100%" border="0">
<tr>
@@ -78,7 +78,7 @@
<ol>
% for my $query (@searches) {
% my $name;
-% if ($query->{Attribute}->name =~ /^Search - (.*)$/) {
+% if ($query->{attribute}->name =~ /^Search - (.*)$/) {
% $name = $1;
% } else {
% $name = $query->name;
@@ -166,7 +166,7 @@
<%INIT>
-my $current_subtab = 'Dashboards/Subscription.html?DashboardId=' . $dashboard_id;
+my $current_subtab = 'Dashboards/Subscription.html?dashboard_id=' . $dashboard_id;
my ($title, @results);
my ($val, $msg);
@@ -178,27 +178,27 @@
my $SubscriptionObj = RT::Model::Attribute->new( current_user => Jifty->web->current_user );
-# first let's see if we already have a subscription to this DashboardId
+# first let's see if we already have a subscription to this dashboard_id
for my $sub (Jifty->web->current_user->user_object->attributes->named('Subscription')) {
- next unless $sub->sub_value('DashboardId') == $dashboard_id;
+ next unless $sub->sub_value('dashboard_id') == $dashboard_id;
$SubscriptionObj = $sub;
last;
}
$dashboard_id = $SubscriptionObj->id
- ? $SubscriptionObj->sub_value('DashboardId')
+ ? $SubscriptionObj->sub_value('dashboard_id')
: $ARGS{'dashboard_id'};
($val, $msg) = $DashboardObj->load_by_id($dashboard_id);
$val || abort(loc("Couldn't load dashboard %1: %2.", $dashboard_id, $msg));
my %fields = (
- DashboardId => $dashboard_id,
- Frequency => 'daily',
- Hour => '06:00',
- Dow => 'Monday',
- Dom => 1,
- Rows => 20,
+ dashboard_id => $dashboard_id,
+ frequency => 'daily',
+ hour => '06:00',
+ dow => 'Monday',
+ dom => 1,
+ rows => 20,
);
# update any fields with the values from the subscription object
@@ -210,7 +210,7 @@
# finally, update any fields with arguments passed in by the user
for my $field (keys %fields) {
- next if $field eq 'DashboardId'; # but this one is immutable
+ next if $field eq 'dashboard_id'; # but this one is immutable
$fields{$field} = $ARGS{$field}
if defined($ARGS{$field});
}
@@ -220,9 +220,9 @@
if (defined $ARGS{save}) {
# update
if ($SubscriptionObj->id) {
- $dashboard_id = delete $fields{'DashboardId'}; # immutable
+ $dashboard_id = delete $fields{'dashboard_id'}; # immutable
($val, $msg) = $SubscriptionObj->set_sub_values(%fields);
- $fields{'DashboardId'} = $dashboard_id;
+ $fields{'dashboard_id'} = $dashboard_id;
# not so good to spew base64-encoded data at the user :)
if ($msg =~ /^Content changed from/) {
@@ -239,9 +239,9 @@
my ($val, $msg) = $SubscriptionObj->create(
name => 'subscription',
description => 'Subscription to dashboard ' . $dashboard_id,
- ContentType => 'storable',
- Object => Jifty->web->current_user->user_object,
- Content => \%fields,
+ content_type => 'storable',
+ object => Jifty->web->current_user->user_object,
+ content => \%fields,
);
if ($val) {
push @results, loc("Subscribed to dashboard %1", $DashboardObj->name);
Modified: rt/branches/3.999-DANGEROUS/t/web/dashboards-groups.t
==============================================================================
--- rt/branches/3.999-DANGEROUS/t/web/dashboards-groups.t (original)
+++ rt/branches/3.999-DANGEROUS/t/web/dashboards-groups.t Mon Aug 25 05:00:35 2008
@@ -3,6 +3,7 @@
use Test::More tests => 36;
use RT::Test;
+use RT::Dashboard;
my ($baseurl, $m) = RT::Test->started_ok;
my $url = $m->rt_base_url;
@@ -25,7 +26,7 @@
# grant the user all these rights so we can make sure that the group rights
# are checked and not these as well
-$user_obj->principal_object->grant_right(right => $_, object => $RT::System)
+$user_obj->principal_object->grant_right(right => $_, object => RT->system_user)
for qw/SubscribeDashboard CreateOwnDashboard SeeOwnDashboard ModifyOwnDashboard DeleteOwnDashboard/;
# }}}
# create and test groups (outer < inner < user) {{{
@@ -60,16 +61,17 @@
$m->follow_link_ok({text => "New dashboard"});
$m->form_name( 'modify_dashboard' );
-is_deeply([$m->current_form->find_input('Privacy')->possible_values], ["RT::Model::User-" . $user_obj->id], "the only selectable privacy is user");
+is_deeply([$m->current_form->find_input('privacy')->possible_values], ["RT::Model::User-" . $user_obj->id], "the only selectable privacy is user");
$m->content_lacks('Delete', "Delete button hidden because we are creating");
$user_obj->principal_object->grant_right(right => 'CreateGroupDashboard', object => $inner_group);
$m->follow_link_ok({text => "New dashboard"});
$m->form_name( 'modify_dashboard' );
-is_deeply([$m->current_form->find_input('Privacy')->possible_values], ["RT::Model::User-" . $user_obj->id, "RT::Group-" . $inner_group->id], "the only selectable privacies are user and inner group (not outer group)");
-$m->field("Name" => 'inner dashboard');
-$m->field("Privacy" => "RT::Group-" . $inner_group->id);
+is_deeply([$m->current_form->find_input('privacy')->possible_values],
+ ["RT::Model::User-" . $user_obj->id, "RT::Model::Group-" . $inner_group->id], "the only selectable privacies are user and inner group (not outer group)");
+$m->field("name" => 'inner dashboard');
+$m->field("privacy" => "RT::Model::Group-" . $inner_group->id);
$m->content_lacks('Delete', "Delete button hidden because we are creating");
$m->click_button(value => 'Save Changes');
@@ -77,13 +79,13 @@
$m->content_contains("Saved dashboard inner dashboard");
$m->content_lacks('Delete', "Delete button hidden because we lack DeleteDashboard");
-my $dashboard = RT::Dashboard->new($currentuser);
+my $dashboard = RT::Dashboard->new(current_user => $currentuser);
my ($id) = $m->content =~ /name="id" value="(\d+)"/;
ok($id, "got an ID, $id");
$dashboard->load_by_id($id);
is($dashboard->name, "inner dashboard");
-is($dashboard->privacy, 'RT::Group-' . $inner_group->id, "correct privacy");
+is($dashboard->privacy, 'RT::Model::Group-' . $inner_group->id, "correct privacy");
is($dashboard->possible_hidden_searches, 0, "all searches are visible");
$m->get_ok("/Dashboards/Modify.html?id=$id");
Modified: rt/branches/3.999-DANGEROUS/t/web/dashboards.t
==============================================================================
--- rt/branches/3.999-DANGEROUS/t/web/dashboards.t (original)
+++ rt/branches/3.999-DANGEROUS/t/web/dashboards.t Mon Aug 25 05:00:35 2008
@@ -3,6 +3,7 @@
use Test::More tests => 78;
use RT::Test;
+use RT::Dashboard;
my ($baseurl, $m) = RT::Test->started_ok;
my $url = $m->rt_base_url;
@@ -31,14 +32,20 @@
$m->content_contains("Permission denied");
$m->content_lacks("Save Changes");
-$user_obj->principal_object->grant_right(right => 'ModifyOwnDashboard', object => $RT::System);
+$user_obj->principal_object->grant_right(
+ right => 'ModifyOwnDashboard',
+ object => RT->system_user
+);
# Modify itself is no longer good enough, you need Create
$m->get_ok($url."Dashboards/Modify.html?Create=1");
$m->content_contains("Permission denied");
$m->content_lacks("Save Changes");
-$user_obj->principal_object->grant_right(right => 'CreateOwnDashboard', object => $RT::System);
+$user_obj->principal_object->grant_right(
+ right => 'CreateOwnDashboard',
+ object => RT->system_user
+);
$m->get_ok($url."Dashboards/Modify.html?Create=1");
$m->content_lacks("Permission denied");
@@ -49,7 +56,7 @@
$m->follow_link_ok({text => "New dashboard"});
$m->form_name( 'modify_dashboard' );
-$m->field("Name" => 'different dashboard');
+$m->field("name" => 'different dashboard');
$m->content_lacks('Delete', "Delete button hidden because we are creating");
$m->click_button(value => 'Save Changes');
$m->content_lacks("No permission to create dashboards");
@@ -59,7 +66,7 @@
$m->get_ok($url."Dashboards/index.html");
$m->content_lacks("different dashboard", "we lack SeeOwnDashboard");
-$user_obj->principal_object->grant_right(right => 'SeeOwnDashboard', object => $RT::System);
+$user_obj->principal_object->grant_right(right => 'SeeOwnDashboard', object => RT->system_user);
$m->get_ok($url."Dashboards/index.html");
$m->content_contains("different dashboard", "we now have SeeOwnDashboard");
@@ -77,11 +84,11 @@
$m->follow_link_ok({text => "Queries"});
$m->content_contains("Modify the queries of dashboard different dashboard");
$m->form_name( 'dashboard_queries' );
-$m->field('Searches-Available' => ["2-RT::System-1"]);
+$m->field('searches-Available' => ["2-RT::System-1"]);
$m->click_button(name => 'add');
$m->content_contains("Dashboard updated");
-my $dashboard = RT::Dashboard->new($currentuser);
+my $dashboard = RT::Dashboard->new( current_user => $currentuser);
my ($id) = $m->content =~ /name="id" value="(\d+)"/;
ok($id, "got an ID, $id");
$dashboard->load_by_id($id);
@@ -95,12 +102,12 @@
like($searches[0]->name, qr/newest unowned tickets/, "correct search name");
$m->form_name( 'dashboard_queries' );
-$m->field('Searches-Available' => ["1-RT::System-1"]);
+$m->field('searches-Available' => ["1-RT::System-1"]);
$m->click_button(name => 'add');
$m->content_contains("Dashboard updated");
RT::Record->flush_cache if RT::Record->can('FlushCache');
-$dashboard = RT::Dashboard->new($currentuser);
+$dashboard = RT::Dashboard->new( current_user => $currentuser);
$dashboard->load_by_id($id);
@searches = $dashboard->searches;
@@ -136,7 +143,7 @@
RT::Record->flush_cache if RT::Record->can('FlushCache');
is($user_obj->attributes->named('Subscription'), 0, "no subscriptions");
-$user_obj->principal_object->grant_right(right => 'SubscribeDashboard', object => $RT::System);
+$user_obj->principal_object->grant_right(right => 'SubscribeDashboard', object => RT->system_user);
$m->get_ok("/Dashboards/Modify.html?id=$id");
$m->follow_link_ok({text => "Subscription"});
@@ -163,7 +170,7 @@
$m->get_ok("/Dashboards/Modify.html?id=$id&Delete=1");
$m->content_contains("Permission denied", "unable to delete dashboard because we lack DeleteOwnDashboard");
-$user_obj->principal_object->grant_right(right => 'DeleteOwnDashboard', object => $RT::System);
+$user_obj->principal_object->grant_right(right => 'DeleteOwnDashboard', object => RT->system_user);
$m->get_ok("/Dashboards/Modify.html?id=$id");
$m->content_contains('Delete', "Delete button shows because we have DeleteOwnDashboard");
More information about the Rt-commit
mailing list