Skip to content

Commit a566be6

Browse files
authored
Merge pull request metacpan#2473 from metacpan/haarg/other-user-dashboard
allow dashboard to be shown for other users
2 parents e63681a + 145a381 commit a566be6

File tree

2 files changed

+22
-23
lines changed

2 files changed

+22
-23
lines changed

lib/MetaCPAN/Web/Controller/Lab.pm

+21-22
Original file line numberDiff line numberDiff line change
@@ -35,40 +35,39 @@ sub dependencies : Local : Args(0) : Does('Sortable') {
3535
$c->stash( {
3636
template => 'lab/dependencies.html',
3737
module => $module,
38-
data => $data
38+
data => $data,
3939
} );
4040
}
4141

42-
sub dashboard : Local : Args(0) {
42+
sub personal_dashboard : Path('dashboard') : Args(0) {
4343
my ( $self, $c ) = @_;
4444

45-
$c->stash( { template => 'lab/dashboard.html' } );
45+
if ( my $pauseid = $c->req->params->{'pauseid'} ) {
46+
$c->res->redirect( $c->uri_for( '/lab/dashboard', uc $pauseid ),
47+
301 );
48+
$c->detach;
49+
}
4650

47-
my $user = $c->model('API::User')->get_profile( $c->token )->get;
48-
return unless $user;
51+
my $user = $c->model('API::User')->get_profile( $c->token )->get || {};
4952

50-
my $report;
51-
my $pauseid = $c->req->params->{'pauseid'};
52-
if ($pauseid) {
53-
$user = { pauseid => $pauseid };
54-
}
53+
$c->res->header( 'Vary', 'Cookie' );
54+
$c->stash( { personal => 1 } );
55+
$c->go( 'dashboard', [ $user->{pauseid} ] );
56+
}
5557

56-
# I'm not sure if the 300 limit actually corresponds to max distros.
57-
# Setting it at 100 for OALDERS, I got less than 30 results back.
58+
sub dashboard : Local : Args(1) {
59+
my ( $self, $c, $pauseid ) = @_;
5860

59-
if ($user) {
60-
$pauseid = $user->{pauseid};
61-
if ($pauseid) {
62-
$report = $c->model('API::Lab')
63-
->fetch_latest_distros( 300, $pauseid )->get;
64-
}
61+
my $report;
62+
if ($pauseid) {
63+
$report = $c->model('API::Lab')->fetch_latest_distros( 300, $pauseid )
64+
->get;
6565
}
6666

67-
$report->{user} = $user;
68-
6967
$c->stash( {
70-
pauseid => $pauseid,
71-
report => $report,
68+
pauseid => $pauseid,
69+
report => $report,
70+
template => 'lab/dashboard.html',
7271
} );
7372
}
7473

root/lab/dashboard.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<div class="content">
44

5-
<h2>Personal Dashboard</h2>
5+
<h2><% personal ? 'Personal' : pauseid %> Dashboard</h2>
66

77
<% IF report %>
88

0 commit comments

Comments
 (0)