diff options
author | Matthew Somerville <matthew@mysociety.org> | 2012-12-20 14:31:03 +0000 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2012-12-20 14:31:03 +0000 |
commit | d3240bb31f87d81d24eae94db665dee51652f7c6 (patch) | |
tree | eccc77c6b7076bae201544e646744b7ea147bf4d | |
parent | af8c0ffd8aaaa19d84beaf2b1f8a5258574656e0 (diff) |
Start of Zurich SDM summary page.
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Zurich.pm | 31 | ||||
-rw-r--r-- | templates/web/zurich/admin/header.html | 18 | ||||
-rw-r--r-- | templates/web/zurich/admin/index-sdm.html | 34 |
3 files changed, 70 insertions, 13 deletions
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; } </style> <p><strong>[% loc('FixMyStreet admin:') %]</strong> - <a href="/admin/summary">[% loc('Summary') %]</a> | - <a href="/admin/bodies">[% loc('Bodies') %]</a> | - <a href="/admin/reports">[% loc('Reports') %]</a> | - <!-- <a href="timeline">Timeline</a> | --> - <!-- <a href="questionnaire">Survey</a> | --> - <a href="/admin/users">[% loc('Users') %]</a> - <!-- <a href="flagged">Flagged</a> | --> - <!-- <a href="stats">Stats</a> --> + <a href="/admin/summary">[% loc('Summary') %]</a> +[% IF admin_type == 'dm' OR admin_type == 'super' %] + | <a href="/admin/bodies">[% loc('Bodies') %]</a> + | <a href="/admin/reports">[% loc('Reports') %]</a> + <!-- | <a href="timeline">Timeline</a> --> + <!-- | <a href="questionnaire">Survey</a> --> + | <a href="/admin/users">[% loc('Users') %]</a> + <!-- | <a href="flagged">Flagged</a> --> + <!-- | <a href="stats">Stats</a> --> +[% END %] <h1>[% title %]</h1> 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' %] + +<h2>New reports</h2> +[% INCLUDE list, problems = reports_new.all %] + +<h2>Reports awaiting approval</h2> +[% INCLUDE list, problems = reports_unpublished.all %] + +<h2>Reports published</h2> +[% INCLUDE list, problems = reports_published.all %] + +[% INCLUDE 'admin/footer.html' %] + +[% BLOCK list %] +<table cellspacing="0" cellpadding="2" border="1"> + <tr> + <th>[% loc('ID') %]</th> + <th>[% loc('Title') %]</th> + <th>[% loc('Category') %]</th> + <th>[% loc('Created') %]</th> + <!-- <th>*</th> --> + </tr> +[%- FOR problem IN problems %] + <tr[% ' class="adminhidden"' IF problem.state == 'hidden' %]> + <td>[% problem.id %]</td> + <td>[% PROCESS value_or_nbsp value=problem.title %]</td> + <td>[% problem.category %]</td> + <td>[% PROCESS format_time time=problem.created %]</td> + <!-- <td><a href="[% c.uri_for( 'report_edit', problem.id ) %]">[% loc('Edit') %]</a></td> --> + </tr> +[%- END -%] +</table> +[% END %] |