From 6bf2ddd3372a68c24fd6576421a4df28877c2de2 Mon Sep 17 00:00:00 2001 From: Byron Jones Date: Tue, 3 Mar 2015 13:50:39 +0800 Subject: Bug 1134765: Report for recruiting data --- extensions/BMO/Extension.pm | 4 + extensions/BMO/lib/Reports/Recruiting.pm | 107 +++++++++++++++++++++ .../default/bug/create/comment-recruiting.txt.tmpl | 27 +++--- .../user-error-auth_failure_object.html.tmpl | 2 + .../en/default/hook/reports/menu-end.html.tmpl | 7 ++ .../default/pages/recruiting_dashboard.html.tmpl | 46 +++++++++ 6 files changed, 178 insertions(+), 15 deletions(-) create mode 100644 extensions/BMO/lib/Reports/Recruiting.pm create mode 100644 extensions/BMO/template/en/default/pages/recruiting_dashboard.html.tmpl (limited to 'extensions/BMO') diff --git a/extensions/BMO/Extension.pm b/extensions/BMO/Extension.pm index 62f88287a..637ff3139 100644 --- a/extensions/BMO/Extension.pm +++ b/extensions/BMO/Extension.pm @@ -174,6 +174,10 @@ sub page_before_template { require Bugzilla::Extension::BMO::Reports::Groups; Bugzilla::Extension::BMO::Reports::Groups::members_report($vars); } + elsif ($page eq 'recruiting_dashboard.html') { + require Bugzilla::Extension::BMO::Reports::Recruiting; + Bugzilla::Extension::BMO::Reports::Recruiting::report($vars); + } elsif ($page eq 'email_queue.html') { print Bugzilla->cgi->redirect('view_job_queue.cgi'); } diff --git a/extensions/BMO/lib/Reports/Recruiting.pm b/extensions/BMO/lib/Reports/Recruiting.pm new file mode 100644 index 000000000..34d61b681 --- /dev/null +++ b/extensions/BMO/lib/Reports/Recruiting.pm @@ -0,0 +1,107 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# This Source Code Form is "Incompatible With Secondary Licenses", as +# defined by the Mozilla Public License, v. 2.0. + +package Bugzilla::Extension::BMO::Reports::Recruiting; +use strict; +use warnings; + +use Bugzilla::Error; +use Bugzilla::Bug; +use Bugzilla::Product; + +sub report { + my ($vars) = @_; + my $user = Bugzilla->user; + + $user->in_group('hr') + || ThrowUserError('auth_failure', { group => 'hr', + action => 'run', + object => 'recruiting_dashboard' }); + + my $product = Bugzilla::Product->check({ name => 'Recruiting', cache => 1 }); + + # find all open recruiting bugs + my $bugs = Bugzilla::Bug->match({ + product_id => $product->id, + resolution => '', + }); + + # filter bugs based on visibility and re-bless + $user->visible_bugs($bugs); + $bugs = [ + map { bless($_, 'RecuritingBug') } + grep { $user->can_see_bug($_->id) } + @$bugs + ]; + + $vars->{bugs} = $bugs; +} + +1; + +package RecuritingBug; +use strict; +use warnings; + +use base qw(Bugzilla::Bug); + +use Bugzilla::Comment; +use Bugzilla::Util qw(trim); + +sub _extract { + my ($self) = @_; + return if exists $self->{recruitment_data}; + $self->{recruitment_data} = {}; + + # we only need the first comment + my $comment = Bugzilla::Comment->match({ + bug_id => $self->id, + LIMIT => 1, + })->[0]->body; + + # extract just what we need + # changing the comment will break this + + if ($comment =~ /\nHiring Manager:\s+(.+)VP Authority:\n/s) { + $self->{recruitment_data}->{hiring_manager} = trim($1); + } + if ($comment =~ /\nVP Authority:\s+(.+)HRBP:\n/s) { + $self->{recruitment_data}->{scvp} = trim($1); + } + if ($comment =~ /\nWhat part of your strategic plan does this role impact\?\s+(.+)Why is this critical for success\?\n/s) { + $self->{recruitment_data}->{strategic_plan} = trim($1); + } + if ($comment =~ /\nWhy is this critical for success\?\s+(.+)$/s) { + $self->{recruitment_data}->{why_critical} = trim($1); + } +} + +sub hiring_manager { + my ($self) = @_; + $self->_extract(); + return $self->{recruitment_data}->{hiring_manager}; +} + +sub scvp { + my ($self) = @_; + $self->_extract(); + return $self->{recruitment_data}->{scvp}; +} + +sub strategic_plan { + my ($self) = @_; + $self->_extract(); + return $self->{recruitment_data}->{strategic_plan}; +} + +sub why_critical { + my ($self) = @_; + $self->_extract(); + return $self->{recruitment_data}->{why_critical}; +} + +1; diff --git a/extensions/BMO/template/en/default/bug/create/comment-recruiting.txt.tmpl b/extensions/BMO/template/en/default/bug/create/comment-recruiting.txt.tmpl index 579d385f9..077697b32 100644 --- a/extensions/BMO/template/en/default/bug/create/comment-recruiting.txt.tmpl +++ b/extensions/BMO/template/en/default/bug/create/comment-recruiting.txt.tmpl @@ -1,22 +1,19 @@ -[%# The contents of this file are subject to the Mozilla Public - # License Version 1.1 (the "License"); you may not use this file - # except in compliance with the License. You may obtain a copy of - # the License at http://www.mozilla.org/MPL/ +[%# This Source Code Form is subject to the terms of the Mozilla Public + # License, v. 2.0. If a copy of the MPL was not distributed with this + # file, You can obtain one at http://mozilla.org/MPL/2.0/. # - # Software distributed under the License is distributed on an "AS - # IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - # implied. See the License for the specific language governing - # rights and limitations under the License. - # - # The Original Code is the BMO Bugzilla Extension. + # This Source Code Form is "Incompatible With Secondary Licenses", as + # defined by the Mozilla Public License, v. 2.0. + #%] + +[%# + # IMPORTANT # - # The Initial Developer of the Original Code is the Mozilla Foundation - # Portions created by the Initial Developers are Copyright (C) 2011 the - # Initial Developer. All Rights Reserved. + # If you update this template, you must also update the parsing code in + # extensions/BMO/lib/Reports/Recruiting.pm # - # Contributor(s): - # David Lawrence #%] + [% USE Bugzilla %] [% cgi = Bugzilla.cgi %] diff --git a/extensions/BMO/template/en/default/hook/global/user-error-auth_failure_object.html.tmpl b/extensions/BMO/template/en/default/hook/global/user-error-auth_failure_object.html.tmpl index 7fae9d1b0..9a1f220dd 100644 --- a/extensions/BMO/template/en/default/hook/global/user-error-auth_failure_object.html.tmpl +++ b/extensions/BMO/template/en/default/hook/global/user-error-auth_failure_object.html.tmpl @@ -16,4 +16,6 @@ comments [% ELSIF object == 'bounty_attachments' %] bounty attachments +[% ELSIF object == 'recruiting_dashboard' %] + the Recruiting Dashboard [% END %] diff --git a/extensions/BMO/template/en/default/hook/reports/menu-end.html.tmpl b/extensions/BMO/template/en/default/hook/reports/menu-end.html.tmpl index 34c51db81..991a685be 100644 --- a/extensions/BMO/template/en/default/hook/reports/menu-end.html.tmpl +++ b/extensions/BMO/template/en/default/hook/reports/menu-end.html.tmpl @@ -59,5 +59,12 @@ - TheSchwartz queue [% END %] + [% IF user.in_group('hr') %] +
  • + + Recruiting Dashboard + - Dashboard for open requested requisitions. +
  • + [% END %] diff --git a/extensions/BMO/template/en/default/pages/recruiting_dashboard.html.tmpl b/extensions/BMO/template/en/default/pages/recruiting_dashboard.html.tmpl new file mode 100644 index 000000000..8eeae3b87 --- /dev/null +++ b/extensions/BMO/template/en/default/pages/recruiting_dashboard.html.tmpl @@ -0,0 +1,46 @@ +[%# This Source Code Form is subject to the terms of the Mozilla Public + # License, v. 2.0. If a copy of the MPL was not distributed with this + # file, You can obtain one at http://mozilla.org/MPL/2.0/. + # + # This Source Code Form is "Incompatible With Secondary Licenses", as + # defined by the Mozilla Public License, v. 2.0. + #%] + +[% PROCESS global/variables.none.tmpl %] +[% INCLUDE global/header.html.tmpl + title = "Recruiting Dashboard" + style_urls = [ "extensions/BMO/web/styles/reports.css" ] + style = "#report td { vertical-align: top; }" +%] + +

    Recuriting Dashboard

    + +[% IF bugs.size %] + + + + + + + + + + + [% FOREACH bug = bugs %] + + + + + + + + + [% END %] +
    [% terms.Bug %]SummaryHiring ManagerSCVPPart of Strategic PlanWhy is this critical for success
    [% bug.id FILTER bug_link(bug) FILTER none %][% bug.short_desc FILTER html %][% bug.hiring_manager FILTER html %][% bug.scvp FILTER html %][% bug.strategic_plan FILTER html FILTER html_line_break %][% bug.why_critical FILTER html FILTER html_line_break %]
    +[% ELSE %] +

    + No open recruiting requisitions. +

    +[% END %] + +[% INCLUDE global/footer.html.tmpl %] -- cgit v1.2.3-24-g4f1b