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

Add support of version masking #1393

Merged
merged 1 commit into from
Nov 10, 2022
Merged

Add support of version masking #1393

merged 1 commit into from
Nov 10, 2022

Conversation

asaunier
Copy link
Member

@asaunier asaunier commented Oct 1, 2022

No description provided.

@asaunier asaunier changed the title [WIP] Add support of version masking Add support of version masking Oct 2, 2022
@asaunier asaunier marked this pull request as ready for review October 2, 2022 11:52
@asaunier
Copy link
Member Author

asaunier commented Oct 2, 2022

UI PR at c2corg/c2c_ui#2947

schema,
cook_locale=True
)
# TODO if masked, return limited info as in DocumentInfoRest?
Copy link
Member

Choose a reason for hiding this comment

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

this TODO is not yet resolved?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, it's not: as for now when a version is masked, the API returns nothing as the archived documents. See https://github.com/c2corg/v6_api/pull/1393/files#diff-33ce4bfbec662d496fcd00822bfdb6174d23586982306f66c15194dba40f771cR72
Perhaps returning at least the version title as in DocumentInfoRest would be nice? See

class DocumentInfoRest(object):
""" Base class for all views that return a basic/info version for a
document, that only contains the document_id and title/title_prefix
of the requested locale.

I have not tried yet to figure out if this is easily feasible though.

@asaunier asaunier marked this pull request as draft October 8, 2022 12:16
@asaunier
Copy link
Member Author

asaunier commented Oct 8, 2022

There's still an issue as the cache of the versions and of the document history is not refreshed when a version is masked/unmasked.
Edit: Fixed

@asaunier asaunier marked this pull request as ready for review November 2, 2022 22:19
@asaunier asaunier requested a review from lbesson November 2, 2022 22:19
Copy link
Member

@lbesson lbesson left a comment

Choose a reason for hiding this comment

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

(Stupid?) remarks / questions, please keep in mind I'm dumb as f*** with python:

  • you're not testing that only a moderator can read a version that is masked?
  • what about diffs? If we can make the diff between a masked version and another, then it's the same as if we didn't mask it.

@brunobesson
Copy link
Member

what about diffs? If we can make the diff between a masked version and another, then it's the same as if we didn't mask it.

As far as I invstigated it some time ago, a moderator will see the diff between all versions, but a normal user will se the diff between unmasked versions only.

@asaunier
Copy link
Member Author

asaunier commented Nov 3, 2022

@lbesson A version is returned only if not masked or if the user is a moderator. See
https://github.com/c2corg/v6_api/pull/1393/files#diff-33ce4bfbec662d496fcd00822bfdb6174d23586982306f66c15194dba40f771cR72-R85

About the diff: there is no diff view on the API side. It's done on the UI side making requests to the API to get both versions to diff. If one version is masked it won't be exposed on the UI side either when diffing.

@lbesson
Copy link
Member

lbesson commented Nov 4, 2022

@lbesson A version is returned only if not masked or if the user is a moderator

Yes. I was just saying there are no unit tests added to check that this is properly implemented.

@lbesson
Copy link
Member

lbesson commented Nov 4, 2022

So we're back to the 'stupid' remark qualification :)

@lbesson
Copy link
Member

lbesson commented Nov 8, 2022

should we merge?

@asaunier
Copy link
Member Author

asaunier commented Nov 8, 2022

@lbesson I had planned to do so when the UI part would be ready but I think we can merge it anyway as the PR only adds a new attribute and new services/tests, not changing the existing API behaviour.
And that might make it easier to have other people test the UI :)

@lbesson
Copy link
Member

lbesson commented Nov 8, 2022

How is db migration handled?

I understand alembic is used for that, but should the migration scripts be run manually, or is the service handling it?

@brunobesson
Copy link
Member

@asaunier
Copy link
Member Author

asaunier commented Nov 8, 2022

Thanks @brunobesson for the link to the doc.
In short, when upgrading the demo/prod API, one has to activate the maintenance mode and run the alembic ugrade command manually.

@asaunier
Copy link
Member Author

@lbesson @brunobesson I will merge the PR this evening if it's OK for you.

@asaunier asaunier merged commit cbd0dc7 into master Nov 10, 2022
@asaunier asaunier deleted the mask_version branch November 10, 2022 21:48
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.

3 participants