From d3240bb31f87d81d24eae94db665dee51652f7c6 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Thu, 20 Dec 2012 14:31:03 +0000 Subject: Start of Zurich SDM summary page. --- perllib/FixMyStreet/Cobrand/Zurich.pm | 31 +++++++++++++++++++++++----- templates/web/zurich/admin/header.html | 18 ++++++++-------- templates/web/zurich/admin/index-sdm.html | 34 +++++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+), 13 deletions(-) create mode 100644 templates/web/zurich/admin/index-sdm.html diff --git a/perllib/FixMyStreet/Cobrand/Zurich.pm b/perllib/FixMyStreet/Cobrand/Zurich.pm index db8a9a571..0c362f612 100644 --- a/perllib/FixMyStreet/Cobrand/Zurich.pm +++ b/perllib/FixMyStreet/Cobrand/Zurich.pm @@ -47,15 +47,19 @@ sub admin_type { $c->stash->{body} = $body; my $parent = $body->parent; - my $children = $body->bodies; + my $children = $body->bodies->count; + my $type; if (!$parent) { - return 'super'; + $type = 'super'; } elsif ($parent && $children) { - return 'dm'; + $type = 'dm'; } elsif ($parent) { - return 'sdm'; + $type = 'sdm'; } + + $c->stash->{admin_type} = $type; + return $type; } sub admin { @@ -67,7 +71,7 @@ sub admin { $c->stash->{template} = 'admin/index-dm.html'; my $body = $c->stash->{body}; - my @children = map { $_->id } $body->bodies; + my @children = map { $_->id } $body->bodies->all; my @all = (@children, $body->id); # XXX No multiples or missing bodies @@ -86,6 +90,23 @@ sub admin { }); } elsif ($type eq 'sdm') { $c->stash->{template} = 'admin/index-sdm.html'; + + my $body = $c->stash->{body}; + + # XXX No multiples or missing bodies + my $p = $c->cobrand->problems->search({ + 'me.state' => 'in progress', + bodies_str => $body->id, + } ); + $c->stash->{reports_new} = $p->search({ + 'comments.state' => undef + }, { join => 'comments', distinct => 1 } ); + $c->stash->{reports_unpublished} = $p->search({ + 'comments.state' => 'unconfirmed' + }, { join => 'comments', distinct => 1 } ); + $c->stash->{reports_published} = $p->search({ + 'comments.state' => 'confirmed' + }, { join => 'comments', distinct => 1 } ); } } diff --git a/templates/web/zurich/admin/header.html b/templates/web/zurich/admin/header.html index 1d72deb0f..252f4c2d1 100644 --- a/templates/web/zurich/admin/header.html +++ b/templates/web/zurich/admin/header.html @@ -8,13 +8,15 @@ select { width: auto; }

[% loc('FixMyStreet admin:') %] - [% loc('Summary') %] | - [% loc('Bodies') %] | - [% loc('Reports') %] | - - - [% loc('Users') %] - - + [% loc('Summary') %] +[% IF admin_type == 'dm' OR admin_type == 'super' %] + | [% loc('Bodies') %] + | [% loc('Reports') %] + + + | [% loc('Users') %] + + +[% END %]

[% title %]

diff --git a/templates/web/zurich/admin/index-sdm.html b/templates/web/zurich/admin/index-sdm.html new file mode 100644 index 000000000..c4659d56c --- /dev/null +++ b/templates/web/zurich/admin/index-sdm.html @@ -0,0 +1,34 @@ +[% INCLUDE 'admin/header.html' title=loc('Summary') -%] +[% PROCESS 'admin/report_blocks.html' %] + +

New reports

+[% INCLUDE list, problems = reports_new.all %] + +

Reports awaiting approval

+[% INCLUDE list, problems = reports_unpublished.all %] + +

Reports published

+[% INCLUDE list, problems = reports_published.all %] + +[% INCLUDE 'admin/footer.html' %] + +[% BLOCK list %] + + + + + + + + +[%- FOR problem IN problems %] + + + + + + + +[%- END -%] +
[% loc('ID') %][% loc('Title') %][% loc('Category') %][% loc('Created') %]
[% problem.id %][% PROCESS value_or_nbsp value=problem.title %][% problem.category %][% PROCESS format_time time=problem.created %]
+[% END %] -- cgit v1.2.3