diff --git a/src/lib/Hydra/Controller/User.pm b/src/lib/Hydra/Controller/User.pm index 95d38599..4f28be28 100644 --- a/src/lib/Hydra/Controller/User.pm +++ b/src/lib/Hydra/Controller/User.pm @@ -229,6 +229,7 @@ sub updatePreferences { $user->update( { fullname => $fullName , emailonerror => $c->stash->{params}->{"emailonerror"} ? 1 : 0 + , publicdashboard => $c->stash->{params}->{"publicdashboard"} ? 1 : 0 }); if (isAdmin($c)) { @@ -336,7 +337,25 @@ sub reset_password :Chained('user') :PathPart('reset-password') :Args(0) { } -sub dashboard :Chained('user') :Args(0) { +sub dashboard_old :Chained('user') :PathPart('dashboard') :Args(0) { + my ($self, $c) = @_; + $c->res->redirect($c->uri_for($self->action_for("dashboard"), $c->req->captures)); +} + + +sub dashboard_base :Chained('/') PathPart('dashboard') CaptureArgs(1) { + my ($self, $c, $userName) = @_; + + $c->stash->{user} = $c->model('DB::Users')->find($userName) + or notFound($c, "User $userName doesn't exist."); + + accessDenied($c, "You do not have permission to view this dashboard.") + unless $c->stash->{user}->publicdashboard || + (defined $c->user && ($userName eq $c->user->username || !isAdmin($c))); +} + + +sub dashboard :Chained('dashboard_base') :PathPart('') :Args(0) { my ($self, $c) = @_; $c->stash->{template} = 'dashboard.tt'; @@ -351,7 +370,7 @@ sub dashboard :Chained('user') :Args(0) { } -sub my_jobs_tab :Chained('user') :PathPart('my-jobs-tab') :Args(0) { +sub my_jobs_tab :Chained('dashboard_base') :PathPart('my-jobs-tab') :Args(0) { my ($self, $c) = @_; $c->stash->{template} = 'dashboard-my-jobs-tab.tt'; @@ -370,7 +389,7 @@ sub my_jobs_tab :Chained('user') :PathPart('my-jobs-tab') :Args(0) { } -sub my_jobsets_tab :Chained('user') :PathPart('my-jobsets-tab') :Args(0) { +sub my_jobsets_tab :Chained('dashboard_base') :PathPart('my-jobsets-tab') :Args(0) { my ($self, $c) = @_; $c->stash->{template} = 'dashboard-my-jobsets-tab.tt'; diff --git a/src/lib/Hydra/Schema/Users.pm b/src/lib/Hydra/Schema/Users.pm index a16370d3..43842fb9 100644 --- a/src/lib/Hydra/Schema/Users.pm +++ b/src/lib/Hydra/Schema/Users.pm @@ -67,6 +67,12 @@ __PACKAGE__->table("Users"); default_value: 'hydra' is_nullable: 0 +=head2 publicdashboard + + data_type: 'boolean' + default_value: false + is_nullable: 0 + =cut __PACKAGE__->add_columns( @@ -82,6 +88,8 @@ __PACKAGE__->add_columns( { data_type => "integer", default_value => 0, is_nullable => 0 }, "type", { data_type => "text", default_value => "hydra", is_nullable => 0 }, + "publicdashboard", + { data_type => "boolean", default_value => \"false", is_nullable => 0 }, ); =head1 PRIMARY KEY @@ -184,8 +192,8 @@ Composing rels: L -> project __PACKAGE__->many_to_many("projects", "projectmembers", "project"); -# Created by DBIx::Class::Schema::Loader v0.07033 @ 2013-11-05 10:22:03 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Gd8KwFcnVShZ/WihvwfgQw +# Created by DBIx::Class::Schema::Loader v0.07043 @ 2016-05-27 11:32:14 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Az1+V+ztJoWUt50NLQR3xg my %hint = ( columns => [ diff --git a/src/root/user.tt b/src/root/user.tt index 3b7e8a73..ba765983 100644 --- a/src/root/user.tt +++ b/src/root/user.tt @@ -65,6 +65,14 @@ +