-
Couldn't load subscription status.
- Fork 485
Add a HasNoteTag filter rule #2037
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.
Pull Request Overview
This PR implements HasNoteTag filter rules that allow matching objects (people, families, events, places, sources, citations, media, and repositories) based on whether they have notes with a specified tag. The implementation follows a consistent pattern across all object types by inheriting from a common base class.
- Adds HasNoteTagBase class with core logic for checking if objects have notes with specified tags
- Creates HasNoteTag filter rule classes for all major object types in Gramps
- Registers the new filter rules in the appropriate module exports
Reviewed Changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| gramps/gen/filters/rules/_hasnotetagbase.py | Base class implementing the core logic for note tag filtering |
| gramps/gen/filters/rules/*/hasnotetag.py | Entity-specific implementations inheriting from HasNoteTagBase |
| gramps/gen/filters/rules/*/init.py | Registration of HasNoteTag classes in module exports |
| # ------------------------------------------------------------------------- | ||
| class HasNoteTagBase(Rule): | ||
| """ | ||
| Objects having a note with a particular tag.. |
Copilot
AI
Aug 4, 2025
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 docstring has an extra period at the end. It should be 'Objects having a note with a particular tag.'
| Objects having a note with a particular tag.. | |
| Objects having a note with a particular tag. |
|
|
||
| labels = [_("Tag:")] | ||
| name = _("Objects with notes with a specified tag.") | ||
| description = _("Matches notes with a specified tag ") |
Copilot
AI
Aug 4, 2025
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 description has a trailing space that should be removed. It should be 'Matches notes with a specified tag'
| description = _("Matches notes with a specified tag ") | |
| description = _("Matches notes with a specified tag") |
|
|
||
| def __init__(self, arg, use_regex=False, use_case=False): | ||
| super().__init__(arg, use_regex, use_case) | ||
| self.tag = None |
Copilot
AI
Aug 4, 2025
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 'self.tag' attribute is initialized but never used in the class. Consider removing it or implementing its intended functionality.
| self.tag = 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.
Is this supposed to be self.tag_handle = None ?
| notelist = obj.note_list | ||
| for notehandle in notelist: | ||
| note = db.get_note_from_handle(notehandle) | ||
| if self.tag_handle in note.tag_list: |
Copilot
AI
Aug 4, 2025
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.
This code assumes 'note.tag_list' exists but doesn't handle the case where 'note' could be None. Add a null check: 'if note and self.tag_handle in note.tag_list:'
| if self.tag_handle in note.tag_list: | |
| if note and self.tag_handle in note.tag_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.
Is this better still:
if note is not None and self.tag_handle is not None and self.tag_handle in note.tag_list:
Add a rule that matches objects with a note with a specified tag.