Notes type (data model for notes)

I’m trying to write an SuperTool filter from events to get information about notes type

Looking at Gramps Data Model it said I can find that in event.note.type but SuperTool tells me the type attribute doesn’t exist:


Could you tell me what is the good description of notes data? (text is ok but not type nor NoteType, notetype, note_type…)

NB: This subject could be an answer to that old post from @Link : Filter by Note Type

The ToDo Gramplet or Report source might give a good hint. Without a doubt, those have to filter Notes based on type.

If you read code, let us know how the Gramplet decides to sort which Note object to show first. :grinning_face_with_smiling_eyes:

1 Like

Thank you.

Finally I used NoteCleanup (I did not understand anything about todo gramplet or todo report :joy:) where I’ve find this: db.get_note_from_gramps_id

It works fine, so now I can filter events with to do (or anything else) notes:

(“A faire” is “To Do” in french)

[title]
90. Note['A faire'] - 363p

[category]
Events

[initial_statements]
# Valeurs modifiables - début
note_type = 'À faire'
# Valeurs modifiables - fin

@include note_type_search_init.py

[statements]
@include note_type_search_statement.py

[filter]
gramps_id in events_with_note

[expressions]

[scope]
all

[unwind_lists]
False

[commit_changes]
False

[summary_only]
False

init include:

# note_type_search_init

events_with_note = []

statements include:

# note_type_search_statement

for note in notes:
	read_note = db.get_note_from_gramps_id(note.gramps_id)
	if read_note.type == note_type:
		events_with_note.append(gramps_id)
		break

As a filter:

    <filter name="90. Note['A faire'] - 363p" function="and" comment="363p (E90.363p) - - SuperTool">
      <rule class="GenericFilterRule_Event" use_regex="False">
        <arg value="gramps_id in events_with_note"/>
        <arg value="# Valeurs modifiables - début&lt;br&gt;note_type = 'À faire'&lt;br&gt;# Valeurs modifiables - fin&lt;br&gt;&lt;br&gt;@include note_type_search_init.py"/>
        <arg value="@include note_type_search_statement.py"/>
      </rule>
    </filter>
1 Like

Hi. It seems that I accidentally forgot to include the “type” attribute for notes in SuperTool.
There is now a new version at isotammi-addons/source/SuperTool at master · Taapeli/isotammi-addons · GitHub which fixes this and has some other changes too.

Thanks for noticing this.

Kari

2 Likes