Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions lib/MetaCPAN/Web/Controller/Permission.pm
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package MetaCPAN::Web::Controller::Permission;

use Moose;
use List::Util qw(uniq);
use namespace::autoclean;

BEGIN { extends 'MetaCPAN::Web::Controller' }
Expand All @@ -15,6 +16,18 @@ sub distribution : Local Args(1) {
my ( $self, $c, $distribution ) = @_;

$c->forward( 'get', $c, [ 'distribution', $distribution ] );

my $modules = $c->stash->{permission};
my $total_modules = scalar @$modules;
my %num_modules_of;
for my $module (@$modules) {
++$num_modules_of{ $module->{owner} };
++$num_modules_of{$_} for @{ $module->{co_maintainers} };
}
my @releaser = sort grep { $num_modules_of{$_} == $total_modules }
keys %num_modules_of;

$c->stash( releaser => \@releaser );
}

sub module : Local Args(1) {
Expand All @@ -38,6 +51,12 @@ sub get : Private {
}

$c->stash( { search_term => $name, permission => $perms } );

return if $type eq 'module';
$c->stash( {
num_owners => scalar( uniq map $_->{owner}, @$perms ),
num_comaints => scalar( uniq map @{ $_->{co_maintainers} }, @$perms ),
} );
}

__PACKAGE__->meta->make_immutable;
Expand Down
6 changes: 3 additions & 3 deletions root/inc/permission.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<table class="table table-striped">
<tr>
<th>Name</th>
<th>Owner</th>
<th>Co-Maintainers</th>
<th>Module (<% permission.size %>)</th>
<th>Owner (<% num_owners %>)</th>
<th>Co-Maintainers (<% num_comaints %>)</th>
</tr>
<% FOREACH module IN permission %>
<tr>
Expand Down
20 changes: 20 additions & 0 deletions root/permission/distribution.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,24 @@

<h1>Module Permissions for <% search_term %></h1>

<table class="table table-striped" style="width: auto; min-width: 33%">
<tr>
<th>Authorized Releasers (<% releaser.size %>)</th>
</tr>
<% FOREACH author IN releaser %>
<tr>
<td>
<a href="/author/<% author %>"><% author %></a>
</td>
</tr>
<% END %>
<% IF releaser.size == 0 %>
<tr>
<td>
<i>No owner<% IF num_comaints %> or co-maintainer<% END %> has permissions for all modules in this distribution.</i>
</td>
</tr>
<% END %>
</table>

<% INCLUDE 'inc/permission.html' %>