-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Fix related items activity streams #283
Comments
@seanh Is this the right way to do the related item change: Remove the current "new related item" activity and have "new related item with dataset" and new related item without dataset" |
@nigelbabu Hmm. You could do that. But could you add an |
@nigelbabu cheers |
@tobes I still need to finish a tiny bit of work in my pull request. I'll knock it off first thing tomorrow. |
@nigelbabu can this be closed now? |
This is being fixed in pull request #308. |
* Check that the context has user key. * Check that a user object exists corresponding to value of 'user' in context.
* Check that user_id matches user used to create related_item. * Check that the related item matches the dataset created/modified/deleted. * Check that the dataset key is set to none when creating/updating.
activity_create() was validating the data dict passed to it, but then passing the original, unvalidated data dict on to model save. Make it pass the validated data dict instead. Fixing this reveals another problem, a JSONDecodeError when pulling activities out of the database. Invalid JSON is getting into the data column of the activity table. default_create_activity_schema() runs unicode() on the 'data' field of the activity dict. This has the effect of turning a Python dict (the 'data' field's value) into a Python string. The schema should not do this, because the data field uses SQLAlchemy's JsonDictType at the model level, so the dict is turned into a string at the model level, it doesn't need to be turned into a string at the schema level first. To fix the second problem, just remove the unicode from default_create_activity_schema.
The activity_create docstring claims that 'user_id' can be either name or an id, but in fact only ids work. Change the schema to allow names or ids.
There's no need for related_update logic function to check whether 'user' is in the context and raise NotAuthorised. 'user' is always in the context, and if the user is not logged in or not authorised to edit the related item, then the related_update authorization function will raise an error.
It looks wrong to me:
{actor} created the link to related {related_type} {related_item}
, should be{actor} added the {related_type} {related_item} to the dataset {dataset}
e.g.seanh added the application Bike Share Map to the dataset Bikes
, or if a related item is added that does not belong to any dataset (can be done via API) then just{actor} added the {related_type} {related_item}
.Also add activities for updating and delete related items.
Original bug at okfn/ckanext-pdeu#31
The text was updated successfully, but these errors were encountered: