Skip to content
This repository has been archived by the owner on May 14, 2024. It is now read-only.

Tagstore API improvements #15

Merged
merged 5 commits into from
Nov 8, 2018
Merged

Tagstore API improvements #15

merged 5 commits into from
Nov 8, 2018

Conversation

bradenmacdonald
Copy link
Contributor

@bradenmacdonald bradenmacdonald commented Nov 7, 2018

A few last API improvements to make this tagstore API a bit nicer, before we get too locked in.

  • Per @symbolist's suggestion, Tag.tag is now Tag.name which I think is much nicer
  • The API was missing a way to get an existing Tag without constructing it yourself, so I added a get_tag() method
  • Made the Taxonomy class a bit more pythonic by giving it some methods, so now you can do taxonomy.add_tag('foo') instead of tagstore.add_tag_to_taxonomy('foo', taxonomy)

Testing instructions:

  • The unit tests should cover everything quite well, so mostly review the code. You can also run the updated example code from README.rst.

Copy link
Contributor

@pomegranited pomegranited left a comment

Choose a reason for hiding this comment

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

Thanks for these tweaks @bradenmacdonald , the API is looking much nicer!

I did a full read through everything again since we're fine tuning, and made several suggestions below.

But the code example works as described, so will approve when these changes are made.

tagstore/README.rst Show resolved Hide resolved
tagstore/backends/django.py Outdated Show resolved Hide resolved
tagstore/README.rst Show resolved Hide resolved
tagstore/backends/django.py Show resolved Hide resolved
tagstore/models/taxonomy.py Outdated Show resolved Hide resolved
Add the specified tag to this given taxonomy, and retuns it.

Will be a no-op if the tag already exists in the taxonomy (case-insensitive),
however the returned (existing) Tag may differ in case.
Copy link
Contributor

Choose a reason for hiding this comment

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

I wasn't able to find a case where the "returned (existing) Tag may differ in case" occurrs.. suggest something like this instead?

If a Tag already exists in the taxonomy with the given name (case-insensitive) with the given parent, then that Tag is returned and no changes are made.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wasn't able to find a case where the "returned (existing) Tag may differ in case"

There is a test case showing that? https://github.com/open-craft/blockstore/blob/05a88e283d81f67bb7094df6d7a453ef40ab3890/tagstore/backends/tests.py#L73-L75

I do like your wording though, so I'll use it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah gotcha.. thanks for that example!

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like your change to the wording hasn't make it in yet?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It did make it in in tagstore.py but I missed taxonomy.py. Fixed now :)

tagstore/tagstore.py Show resolved Hide resolved
@bradenmacdonald
Copy link
Contributor Author

Thanks @pomegranited, great points. Fixes are all made in aba94c9

Copy link
Contributor

@pomegranited pomegranited left a comment

Choose a reason for hiding this comment

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

@bradenmacdonald Thank you for these changes! I think there's just one missing, but ok to merge once it's in 👍

  • I tested this by running the API example code from the updated README and checking the results came out as expected.
  • I read through the code.
  • I checked for accessibility issues N/A
  • Includes great documentation.

@bradenmacdonald bradenmacdonald merged commit 81e3c98 into master Nov 8, 2018
@bradenmacdonald bradenmacdonald deleted the tags-api-improvements branch November 8, 2018 04:07
@openedx-webhooks
Copy link

Although this pull request is already merged, I've created OSPR-5476 so that we can track it in Jira.

There is nothing you have to do. No action is needed from your side. Thanks again for your contribution.

@openedx-webhooks openedx-webhooks added merged open-source-contribution PR author is not from Axim or 2U and removed open-source-contribution PR author is not from Axim or 2U labels Jan 22, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
merged open-source-contribution PR author is not from Axim or 2U
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants