Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow any cobrand to display public asset ID on a report #3920

Closed

Conversation

nephila-nacrea
Copy link
Contributor

@nephila-nacrea nephila-nacrea commented May 11, 2022

Fixes https://github.com/mysociety/societyworks/issues/1959.

Oxfordshire already has functionality for displaying a publicly viewable 'asset ID' (among other data) on each report; this PR extends this functionality so it can be applied to other cobrands, should they so wish. A list of extra fields that can be used as the asset ID can be defined under COBRAND_FEATURES in general.yml.

@codecov
Copy link

codecov bot commented May 11, 2022

Codecov Report

Merging #3920 (6c7a9af) into master (b002b20) will decrease coverage by 8.36%.
The diff coverage is 100.00%.

❗ Current head 6c7a9af differs from pull request most recent head 0fcd606. Consider uploading reports for the commit 0fcd606 to get more accurate results

@@            Coverage Diff             @@
##           master    #3920      +/-   ##
==========================================
- Coverage   82.64%   74.27%   -8.37%     
==========================================
  Files         354      291      -63     
  Lines       24362    19603    -4759     
  Branches     3685     3682       -3     
==========================================
- Hits        20133    14560    -5573     
- Misses       3081     3866     +785     
- Partials     1148     1177      +29     
Impacted Files Coverage Δ
perllib/FixMyStreet/DB/Result/Problem.pm 90.18% <100.00%> (-0.46%) ⬇️
perllib/FixMyStreet/App/Controller/Auth/Profile.pm 15.96% <0.00%> (-82.36%) ⬇️
.../FixMyStreet/App/Controller/Admin/ManifestTheme.pm 18.18% <0.00%> (-81.82%) ⬇️
...ib/FixMyStreet/App/Controller/Admin/DefectTypes.pm 15.09% <0.00%> (-75.48%) ⬇️
perllib/FixMyStreet/App/Form/Claims.pm 6.18% <0.00%> (-75.26%) ⬇️
...llib/FixMyStreet/App/Controller/Open311/Updates.pm 23.68% <0.00%> (-71.06%) ⬇️
perllib/FixMyStreet/App/Controller/JSON.pm 17.64% <0.00%> (-68.63%) ⬇️
...yStreet/App/Controller/Admin/ResponsePriorities.pm 21.73% <0.00%> (-67.40%) ⬇️
perllib/FixMyStreet/App/Controller/Auth/Social.pm 10.88% <0.00%> (-67.36%) ⬇️
perllib/FixMyStreet/App/Controller/Form.pm 20.00% <0.00%> (-66.00%) ⬇️
... and 138 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b002b20...0fcd606. Read the comment docs.

@nephila-nacrea nephila-nacrea force-pushed the issues/public/1959-show-asset-num-report-page branch 4 times, most recently from 9e391f2 to 28d610d Compare May 23, 2022 11:35
@nephila-nacrea nephila-nacrea marked this pull request as ready for review May 23, 2022 11:41
@nephila-nacrea nephila-nacrea changed the title WIP Asset ID fun Allow any cobrand to display public asset ID + other data on a report May 23, 2022
@nephila-nacrea nephila-nacrea changed the title Allow any cobrand to display public asset ID + other data on a report Allow any cobrand to display public asset ID & other data on a report May 23, 2022
@nephila-nacrea
Copy link
Contributor Author

Looking at this again I am not sure if it would be easier to have the config in the cobrand module rather than general.yml (which will have to be deployed beforehand on mysociety-servers). But I am leaving it up for review for now.

Copy link
Member

@dracos dracos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

General outlook and changes made looking good :) Needs bit more work to do less in the base cobrand and keep the cobrand-specific things in their rightful places.

perllib/FixMyStreet/DB/Result/Problem.pm Outdated Show resolved Hide resolved
templates/web/base/report/_cobrand_ref.html Outdated Show resolved Hide resolved
perllib/FixMyStreet/DB/Result/Problem.pm Outdated Show resolved Hide resolved
t/cobrand/public_asset_ids.t Outdated Show resolved Hide resolved
@@ -1,5 +1,5 @@
[% IF problem.bodies_str %]
[% INCLUDE 'report/_council_sent_info.html' %]
[% IF problem.whensent %]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't need to check whensent - we have the asset ID as soon as the report is made, so can show it.

Also we don't want to print out "Not reported to council" at this point if it's not been sent, this is nothing to do with asset IDs and would change lots of existing reports. This is presumably trying to keep the Oxfordshire behaviour, so you need to do that but also not change base behaviour more than is required - so eg the base template including _cobrand_ref.html and nothing else, then Oxfordshire having its own version of that template printing out the "Not reported to council".

The logic before wasn't entirely inconsistent - the bodies_str check Oxfordshire's main_after was doing matched the _main_sent_info check base was doing. But hopefully the above makes it clearer - base _main_after can be simple, always try and show asset IDs, nothing more, fixmystreet.com's version can show the extra stuff for Oxfordshire reports, and Oxfordshire can similarly change that to keep its current behaviour.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have tried to get this back to a similar setup as before, though I don't like having the same large chunk of HTML in two files >.<

templates/web/base/report/_main.html Outdated Show resolved Hide resolved
@nephila-nacrea nephila-nacrea force-pushed the issues/public/1959-show-asset-num-report-page branch from 28d610d to 3b89956 Compare May 31, 2022 10:42
Copy link
Member

@dracos dracos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost, just needs couple more tweaks to template layout and one hook fix.
I think you want:

  • templates/web/base/report/_cobrand_ref.html - your current _cobrand_ref_default.html
  • templates/web/base/report/_main_after.html - includes report/_cobrand_ref.html
  • templates/web/fixmystreet.com/report/_main_after.html - your current base _main_after.html
  • templates/web/fixmystreet.com/report/_cobrand_ref_oxfordshire.html - not in base

Others fine as is. Do ask if that doesn't make sense :)

perllib/FixMyStreet/DB/Result/Problem.pm Outdated Show resolved Hide resolved
templates/web/base/report/_cobrand_ref_default.html Outdated Show resolved Hide resolved
templates/web/base/report/_cobrand_ref_oxfordshire.html Outdated Show resolved Hide resolved
templates/web/base/report/_main_after.html Outdated Show resolved Hide resolved
templates/web/fixmystreet.com/report/_main_after.html Outdated Show resolved Hide resolved
@nephila-nacrea nephila-nacrea force-pushed the issues/public/1959-show-asset-num-report-page branch 3 times, most recently from 829cc22 to 4b77b1a Compare June 1, 2022 20:20
Copy link
Member

@dracos dracos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, one comment to note :)

[% asset_id = problem.public_asset_id; IF asset_id %]
<p><strong>Asset ID:</strong> [% asset_id %]</p>
[% END %]
[% IF column_no %]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to change it back, but note this was deliberate indentation on our part, not a mistake; it can be quite nice in templates to have HTML indented in 4, and the logic to also be indented in 4 but offset by 2, which makes it easy to follow when as here there are conditional and non-conditional parts of the HTML output.

@nephila-nacrea nephila-nacrea force-pushed the issues/public/1959-show-asset-num-report-page branch from 4b77b1a to 0fcd606 Compare June 6, 2022 14:48
@nephila-nacrea nephila-nacrea changed the title Allow any cobrand to display public asset ID & other data on a report Allow any cobrand to display public asset ID on a report Jun 6, 2022
@nephila-nacrea
Copy link
Contributor Author

Merged to master but the way I merged seems to mean Github did not pick up on it.

@nephila-nacrea nephila-nacrea reopened this Jun 6, 2022
@nephila-nacrea nephila-nacrea force-pushed the issues/public/1959-show-asset-num-report-page branch from 0fcd606 to f557eaa Compare June 6, 2022 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants