Revision UI removed & activity stream improved#3972
Conversation
Remove the legacy revision controller 'tests' Activities are now just templates. Removes all _html 'helpers'. Remove leftover mentions of activity_streams.py and missed _html helpers from actions. Switch activity action based on group type. Fix 'View this version' links. Redirect legacy history page to activity feed (this page is not referenced by anything in core ckan) Revert a small change that breaks old fanstatic-based CKAN. Remove mentions to user_activity_list_html and _html test checks. Store complete package dict in activity. Store user name at time of change. Show historic package versions. Legacy tests do not include valid users when creating test packages. Ignore authentication when creating the package dict for the activity record.
…arly the last person to use less used a more recent version (than 2.5.2) because the color values in main.css are no longer long-hand (e.g. main.css has #ffffff rather than the #fff short-hand found in the .less file)
…u can look at old versions of those too.
|
@davidread this is great!, are you still working on it? |
|
@amercader Yes :) |
…functions: activity_show (which takes activity IDs) and activity_list_show (which takes object IDs).
|
In this PR only admins see the old versions of datasets (i.e. not everyone). The concern I have is with existing CKAN sites, where I don't think we should suddenly make the old versions so visible. I'd expect the vast majority of admins had previously assumed that old versions were not released. They wouldn't wish to show old versions which may have incorrect metadata, or multiple draft versions, which may be embarrassing. The previous versions of datasets (excluding resources) have been available only in obscure places:
A site owner can allow anyone to see the old versions, by simply overriding the auth function activity_list_show, if they choose. @wardi and anyone else - it would be good to hear if you think this is right. |
… diff on the command-line.
…re the revision stuff is split off into a separate model in revision_legacy_code.py, and only used for the migration and its tests.
41203fa to
6c89fa0
Compare
* Use PackageDictizeMonkeyPatch to patch package_dictize, because a context manager like this cleans up after itself effectively, so any tests that run after test_migrate_package_activity.py and test_revision_legacy_code.py will use the standard package_show now. * Fix test_revision_legacy_code.py now package_extra_revision table is not being populated at the moment. * Copied in create_object_version() from vdm, so we can use PackageExtraRevision without its .continuity being mapped to the PackageExtra.
6c89fa0 to
15507df
Compare
|
@wardi I've now removed the restrictions about having to do the migration before you upgrade beyond this version. I think this is good to merge, so please do take a look! |
|
I was hoping this would reduce CKAN's code size, but the extra is due to the new diff functionality, and ckan/migration/revision_legacy_code.py which is starting to include hacked bits of vdm, so it's not really in the CKAN codebase proper to concern devs in the future. |
|
Anything else to contribute for this MR? My team has been evaluating implementing a similar feature and it'd be great to get this merged so we can use it :) |
|
looking great, just had one minor comment about an API parameter above |
75592d9 to
9bc6e76
Compare
9bc6e76 to
6b5c6d1
Compare
|
@wardi said:
@amercader @smotornyuk can either of you merge this PR now, please? It's been a long-time fork and I'm really keen to move on and get the rest of vdm removed. |
|
Thanks for your work on this @davidread (and @TkTech for starting it)! Really thorough and well-thought. |
Fixes #3484
Revision UI removed (as warned in CKAN 2.7.0 changelog):
/revision/list- List of which datasets changed. Not easy to page through 200 at a time. Not used or useful as far as we can tell./revision/{id}- Detail of a revision - displays timestamp and the dataset - no use. Problematic when there are billions of revisions you have billions of these pages that get indexed./revision/edit/{id}- to undelete a revision. No-one uses this method. Better ways to achieve this./revision/diff/{id}- diffs different versions of a dataset. Replaced by/dataset/changes/History page removed -
/dataset/{id}/historynow redirects to Activity Stream. The History page was not supported or linked to from anywhere (on default templates) but it was useful for admins. The functionality of seeing the past versions is fully replaced by the Activity Stream now. (The Atom feed at the same URL is also removed:/dataset/{id}/history?format=atom, again deprecated. But there is a feed of datasets ordered by metadata_modified at/feed/dataset.atom, and the changes are in the package_activity_list API which could be made an Atom feed if there is interest.)Activity Stream saves the full dictized dataset, rather than just the package table. Migration script:
migrate_package_activity.py(discussed below)Activity Stream for a dataset now has 2 new links against each activity item: "View this version" to view the dataset as it was and "Changes" - the diff since the previous version:



The changes (diff) page looks like this:
...
This isn't the clearest - changes are not highlighted - you have to look in the margin for a letter. But it's a pretty good start and can be improved.
ckan.auth.public_activity_stream_detail. The default is False, so that sites upgrading don't suddenly splurge this detail without taking the conscious act of changing it, although we encourage it in the changelog. New sites will have it set to True by default, because it is added that way indeployment.ini_templ.Viewing old versions of datasets is done with a different parameter name. Uses
?activity_id=<id>rather than@<revision_id>or@<date>. (This breaking change is ok because the only links to these were from the history page which was not linked to itself.)Activity Stream model is simplified - we use just Activity and remove ActivityDetail. Previously when you update a resource, it'd create an Activity('changed package') and also a connected ActivityDetail('resource changed'). This just seems too complex in the model. Now if you change just an extra field or a resource field, it'll simple say 'X updated the dataset Y', rather than 'X added the resource Z to the dataset Y'.


Before:
After:
Since we store the pkg_dict on every commit, we could in future write logic that could analyze the diff to describe the change in more detail, like before. But it's worth it for the simpler model.
migrate_package_activity.py.activity_detail_listlogic function is removedNew action functions for viewing an activity:
activity_showand very similar:activity_data_showmaking command-line diffs possible e.g.:activity_diff.migrate_package_activity.py- migrates activity stream to store the full package dict, using the package revision tables.paster db upgrademigrations, it is a standalone script. Ideally you download it and run it against any version of CKAN (I've tested it 2.3-2.8) before you upgrade to this version of CKAN. But if you don't, that is fine - you can upgrade to this or a future CKAN version, and run this migration if you want - the only downside of not migrating is that the "View this version" and "Changes" links will 404 until you do run the migration (and by default only admins can see Changes page anyway). (An earlier version of this PR prevented you upgrading until the migratino was done, but is no longer the case.)I think we are agreed that it is ok to remove Revision UI and History page without prior deprecation because they are long unlinked and unsupported.
This PR removes a chunk of code to do with 'revisions'. However migrate_package_activity.py requires the revisions still in the model. A future PR (looking like https://github.com/ckan/ckan/pull/4664/files#diff-67c809480fe3487c995fb33d7d134d84) can remove the rest:
This PR follows on from #4627: Activity Stream is displayed with standard templates, rather than via action functions that returned HTML.
This PR took over from the original work on this issue that was #3485
Todo:
Features: