-
Notifications
You must be signed in to change notification settings - Fork 0
Add api for history objects. #217
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, could you add some short tests for the history endpoints?
@whirish I wrote some basic stuff. It failed normally because the mockup did not add user info about changes. I wonder how should we handle that in production. I just made it so it returned none now. Also on stv tests there seems to be not many changes, is it because the order of the tests? How can I make sure it happens after certain changes? Or should I make the changes and test that they are there in the same method? That seems more reliable. |
@ataalik Sorry for the late response, totally missed your commit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks cool! Thank you.
Btw, can we squash migrations?
def get_queryset(self): | ||
queryset = self.queryset | ||
if self.action == "list": | ||
stv = self.request.query_params.get("stv", None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this return all events, even the creation event? Should we filter it out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is a subclass of ReadOnlyViewSet, so no creation method is implemented
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean, what should we do with initial geometry upload event? Should it be accessible and shown to user?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so, in case we want to rollback to the instance's initial state
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes are logged in three categories. Creation, change, deletion. As Liam said creation is used for rolling back to initial version so it is needed I think.
@@ -168,3 +168,26 @@ def test_api_can_not_create_stv(self): | |||
self.assertEqual(response.status_code, status.HTTP_201_CREATED) | |||
response = self.client.post(url, data_overlapping) | |||
self.assertEqual(response.status_code, status.HTTP_409_CONFLICT) | |||
|
|||
@authorized |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need an authorization to perform a get request for stv-history-list?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After closer inspection yes we do, do you think an unauthorized user would have need to see historical records? If so we can change it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For me it would be easier without extra headers on GET, because I already have all the coding done for this.
On the other side, I can't object against doing it as a protected with authorization method.
What will happened if you'll try to rollback not the latest change? Will it rewrite all the newer changes? Example:
What will happened if user will decide to revert history batch №3, what will remain in the database?
|
For #215
Adds api endpoints for inspecting changes on STVs and TEs.
You can filter STVs using these parameters:
You can filter TEs using:
Reverting changes can be done by sending a PUT request to a specific reversion instance. Ex:
PUT /api/te-history/1/
There is also default DRF pagination using "limit" and "offset" parameters.
What is missing:
Reverting history with api.Done!