Skip to content

Commit

Permalink
Basic user/ip search for staff
Browse files Browse the repository at this point in the history
  • Loading branch information
abh committed Mar 28, 2012
1 parent e239242 commit eda48fa
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 6 deletions.
10 changes: 10 additions & 0 deletions apache/sites/manage.tmpl
Expand Up @@ -21,6 +21,11 @@
[% PH %] NTPPool::Control::Manage->super
</Location>

<Location /scores/>
SetHandler perl-script
[% PH %] NTPPool::Control::Scores->super
</Location>

<Location /manage/vendor>
SetHandler perl-script
[% PH %] NTPPool::Control::Vendor->super
Expand All @@ -31,6 +36,11 @@
[% PH %] NTPPool::Control::Manage::Equipment->super
</Location>

<Location /api>
SetHandler perl-script
[% PH %] NTPPool::Control::API->super
</Location>

<Location /static>
SetHandler perl-script
[% PH %] NTPPool::Control::Basic->super
Expand Down
8 changes: 5 additions & 3 deletions docs/ntppool/tpl/server.html → docs/shared/tpl/server.html
Expand Up @@ -31,10 +31,12 @@ <h3>[% server.ip %] [% IF server.hostname; '/ ' _ server.hostname; END %]</h3>
[% END %]

[% IF server.admin.public_profile
OR combust.user.id == server.admin.id
OR combust.user.privileges.see_all_user_profiles %]
OR combust.user.id == server.admin.id
OR combust.user.is_staff %]
Server admin: <a href="/user/[% (server.admin.username || server.admin.id) | html | uri %]"
>[% server.admin.username || server.admin.email %]</a><br/>
>[% server.admin.username || server.admin.email %]</a>
(<a href="mailto:[% server.admin.email |uri%]">[% server.admin.email |html %]</a>)
<br/>
[% END %]
[% "Zones:" | l %]
[% FOR zone = server.zones_display %]
Expand Down
1 change: 1 addition & 0 deletions docs/shared/tpl/style/default.html
Expand Up @@ -7,6 +7,7 @@
<link rel="shortcut icon" href="[% combust.static_url('/images/favicon.ico') %]" type="image/x-icon" />

<link rel="stylesheet" type="text/css" href="[% combust.static_url("/css/reset-fonts-grids.css") %]">

<link rel="stylesheet" href="[% combust.static_url("/css/master.css") %]" type="text/css" media="screen" charset="utf-8" />
<link rel="stylesheet" href="[% combust.static_url("/css/content.css") %]" type="text/css" media="screen" charset="utf-8" />
<link rel="icon" href="[% combust.static_url("/images/favicon.ico") %]" type="image/x-icon" />
Expand Down
6 changes: 6 additions & 0 deletions lib/NP/Model/User.pm
Expand Up @@ -4,6 +4,12 @@ use Net::IP;

sub BAD_SERVER_THRESHOLD { -15 }

sub is_staff {
my $self = shift;
my $privileges = $self->privileges;
return $privileges->see_all_servers or $privileges->see_all_user_profiles or $privileges->support_staff;
}

sub who {
my $self = shift;
$self->username || $self->email;
Expand Down
7 changes: 6 additions & 1 deletion lib/NTPPool/Control.pm
Expand Up @@ -191,7 +191,12 @@ sub _url {
$uri->scheme('https');
}
if ($args) {
$uri->query($args);
if (ref $args) {
$uri->query_form(%$args);
}
else {
$uri->query($args);
}
}
return $uri->as_string;
}
Expand Down
11 changes: 10 additions & 1 deletion lib/NTPPool/Control/Manage.pm
Expand Up @@ -83,7 +83,16 @@ sub manage_dispatch {
return $self->handle_delete
if $self->request->uri =~ m!^/manage/server/delete!;
return $self->show_manage if $self->request->uri =~ m!^/manage/servers!;
return $self->redirect('/manage/servers');

return $self->redirect('/manage/servers')
unless $self->user->is_staff;

return $self->show_staff;
}

sub show_staff {
my $self = shift;
return OK, $self->evaluate_template('tpl/staff.html');
}

sub show_manage {
Expand Down
14 changes: 13 additions & 1 deletion lib/NTPPool/Control/Scores.pm
Expand Up @@ -15,7 +15,16 @@ BEGIN {
sub render {
my $self = shift;

$self->cache_control('s-maxage=1800');
my $public = $self->site->name eq 'ntppool' ? 1 : 0;
$self->cache_control('s-maxage=1800') if $public;

unless ($public or $self->user) {
$self->redirect( $self->www_url( $self->request->uri, $self->request->query_parameters ));
}

if (!$public) {
$self->tpl_param('manage_site', 1);
}

return $self->redirect('/scores/') if ($self->request->uri =~ m!^/s/?$!);

Expand Down Expand Up @@ -206,5 +215,8 @@ sub _calc_y {
(($h->score - 20) * -1) + 1;
}

sub bc_user_class { NP::Model->user }
sub bc_info_required { 'username,email' }


1;

0 comments on commit eda48fa

Please sign in to comment.