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

Scope Tags to Content Types #1505

Merged
merged 64 commits into from
Apr 14, 2022

Conversation

timizuoebideri1
Copy link
Contributor

@timizuoebideri1 timizuoebideri1 commented Mar 16, 2022

Fixes: #872

  • Scope tags to content types
  • Create PrimaryModelRelatedContentType as an helper class to get ContentType models that are subclasses of PrimaryModel

Features

Create a Tag with a content type
NB: If content_type is left blank, Tag would be available to all content_types
Screenshot 2022-03-21 at 12 08 32 PM

Tag constrained to a particular content type cannot be applied to other content types
Tags
Screenshot 2022-03-21 at 12 28 19 PM

(example 1) Site
Screenshot 2022-03-21 at 12 21 57 PM

(example 2) Device
Screenshot 2022-03-21 at 12 24 15 PM

 - Add content_types to TagFilterSet, TagForm and TagTable
 - Create PrimaryModelRelatedContentType class
Copy link
Contributor

@glennmatthews glennmatthews left a comment

Choose a reason for hiding this comment

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

With this as a draft, it's not clear to me how complete this is currently considered to be - I presume you're yet to implement the corresponding model logic to only allow assigning a given tag to a given object if the content_type is a permitted one for that tag?

nautobot/extras/utils.py Outdated Show resolved Hide resolved
@timizuoebideri1
Copy link
Contributor Author

timizuoebideri1 commented Mar 17, 2022

With this as a draft, it's not clear to me how complete this is currently considered to be - I presume you're yet to implement the corresponding model logic to only allow assigning a given tag to a given object if the content_type is a permitted one for that tag?

Acceptance Criteria

  • Similar to the status pattern already implemented, a tag constrained to a particular content type cannot be applied to other content types
  • Similar to the status pattern, a tag could be constrained to multiple content types
  • For migration, tags would by default be available to all content types
  • Enforcement should be done both in the UI & API
  • Should be able to filter tags by content types

@timizuoebideri1 timizuoebideri1 force-pushed the timizuo-feat-GH872-scope-tags-to-content_types branch from 24ffa5c to 84214e7 Compare March 17, 2022 16:11
@timizuoebideri1 timizuoebideri1 force-pushed the timizuo-feat-GH872-scope-tags-to-content_types branch from 2a4ef16 to d8fc2ec Compare March 18, 2022 11:36
nautobot/extras/migrations/0030_tag_content_types.py Outdated Show resolved Hide resolved
nautobot/extras/models/tags.py Outdated Show resolved Hide resolved
nautobot/extras/templates/extras/tag.html Outdated Show resolved Hide resolved
…zuo-feat-GH872-scope-tags-to-content_types
Make ModelSubclassesQuery reuseable
Add content_types to TagSerializer
@timizuoebideri1 timizuoebideri1 force-pushed the timizuo-feat-GH872-scope-tags-to-content_types branch from d48d358 to b87e5f1 Compare March 21, 2022 10:06
@timizuoebideri1 timizuoebideri1 marked this pull request as ready for review March 21, 2022 11:31
nautobot/extras/models/tags.py Outdated Show resolved Hide resolved
nautobot/extras/api/serializers.py Show resolved Hide resolved
nautobot/extras/models/tags.py Outdated Show resolved Hide resolved
nautobot/extras/forms.py Outdated Show resolved Hide resolved
nautobot/circuits/migrations/0008_auto_tags.py Outdated Show resolved Hide resolved
@glennmatthews
Copy link
Contributor

Can you also update https://github.com/nautobot/nautobot/blob/next/nautobot/docs/release-notes/version-1.3.md?plain=1#L82 so that it's accurate now (We now have three versioned API endpoints as of this PR).

 - TagSerializerVersion13 now inherits from TagSerializer
 - Remove create method from TagViewSet cause is redundant
 - Delete irrelevant migrations
 - Add content_types to tags in tests
 - Update Docs
…zuo-feat-GH872-scope-tags-to-content_types
Copy link
Contributor

@glennmatthews glennmatthews left a comment

Choose a reason for hiding this comment

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

Just a couple more release-note changes, otherwise looks good!

nautobot/docs/release-notes/version-1.3.md Outdated Show resolved Hide resolved
nautobot/docs/release-notes/version-1.3.md Show resolved Hide resolved
@bryanculver bryanculver changed the title Add contentypes to Tag Scope Tags to Content Types Apr 12, 2022
nautobot/extras/forms.py Show resolved Hide resolved
nautobot/extras/api/serializers.py Outdated Show resolved Hide resolved
Add is not None check

Co-authored-by: Glenn Matthews <glenn.matthews@networktocode.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Scope tags to content types
4 participants