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

Fix related items activity streams #283

Closed
nigelbabu opened this issue Jan 17, 2013 · 6 comments
Closed

Fix related items activity streams #283

nigelbabu opened this issue Jan 17, 2013 · 6 comments
Assignees

Comments

@nigelbabu
Copy link
Contributor

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

@nigelbabu
Copy link
Contributor Author

@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"

@seanh
Copy link
Contributor

seanh commented Jan 17, 2013

@nigelbabu Hmm. You could do that. But could you add an if statement to activity_stream_string_new_related_item() and make it return a different string depending on whether the related item belongs to a dataset? That might be simpler.

@tobes
Copy link
Contributor

tobes commented Feb 19, 2013

@nigelbabu
is this now resolved if so please close. If not what was the outcome of this issue and what is still to do?

cheers

@nigelbabu
Copy link
Contributor Author

@tobes I still need to finish a tiny bit of work in my pull request. I'll knock it off first thing tomorrow.

@tobes
Copy link
Contributor

tobes commented Mar 14, 2013

@nigelbabu can this be closed now?

@nigelbabu
Copy link
Contributor Author

This is being fixed in pull request #308.

nigelbabu added a commit that referenced this issue Mar 26, 2013
* Check that the context has user key.
* Check that a user object exists corresponding to
  value of 'user' in context.
nigelbabu added a commit that referenced this issue Mar 26, 2013
* 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.
seanh pushed a commit that referenced this issue May 15, 2013
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.
seanh pushed a commit that referenced this issue May 15, 2013
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.
seanh pushed a commit that referenced this issue May 15, 2013
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.
@tobes tobes closed this as completed May 15, 2013
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

No branches or pull requests

3 participants