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 deletion of entries on folder journal through --delete flag #1328

Merged
merged 3 commits into from
Aug 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion jrnl/FolderJournal.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,14 @@ def write(self):
# print("empty file: {}".format(filename))
os.remove(filename)

def delete_entries(self, entries_to_delete):
"""Deletes specific entries from a journal."""
for entry in entries_to_delete:
self.entries.remove(entry)
self._diff_entry_dates.append(entry.date)

def parse_editable_str(self, edited):
"""Parses the output of self.editable_str and updates it's entries."""
"""Parses the output of self.editable_str and updates its entries."""
Copy link
Member

Choose a reason for hiding this comment

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

💥

mod_entries = self._parse(edited)
diff_entries = set(self.entries) - set(mod_entries)
for e in diff_entries:
Expand Down
20 changes: 10 additions & 10 deletions tests/bdd/features/delete.feature
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ Feature: Delete entries from journal
| config_file |
| basic_onefile.yaml |
| basic_encrypted.yaml |
# | basic_folder.yaml | @todo
# | basic_dayone.yaml | @todo
| basic_folder.yaml |
# | basic_dayone.yaml | @todo


Scenario Outline: Backing out of interactive delete does not change journal
Expand Down Expand Up @@ -66,7 +66,7 @@ Feature: Delete entries from journal
Examples: Configs
| config_file |
| basic_onefile.yaml |
# | basic_folder.yaml | @todo
| basic_folder.yaml |
# | basic_dayone.yaml | @todo


Expand All @@ -82,7 +82,7 @@ Feature: Delete entries from journal
Examples: Configs
| config_file |
| basic_onefile.yaml |
# | basic_folder.yaml | @todo
| basic_folder.yaml |
# | basic_dayone.yaml | @todo


Expand All @@ -98,7 +98,7 @@ Feature: Delete entries from journal
Examples: Configs
| config_file |
| basic_onefile.yaml |
# | basic_folder.yaml | @todo
| basic_folder.yaml |
# | basic_dayone.yaml | @todo


Expand All @@ -114,7 +114,7 @@ Feature: Delete entries from journal
Examples: Configs
| config_file |
| basic_onefile.yaml |
# | basic_folder.yaml | @todo
| basic_folder.yaml |
# | basic_dayone.yaml | @todo


Expand All @@ -130,7 +130,7 @@ Feature: Delete entries from journal
Examples: Configs
| config_file |
| basic_onefile.yaml |
# | basic_folder.yaml | @todo
| basic_folder.yaml |
# | basic_dayone.yaml | @todo


Expand All @@ -146,7 +146,7 @@ Feature: Delete entries from journal
Examples: Configs
| config_file |
| basic_onefile.yaml |
# | basic_folder.yaml | @todo
| basic_folder.yaml |
# | basic_dayone.yaml | @todo


Expand All @@ -162,7 +162,7 @@ Feature: Delete entries from journal
Examples: Configs
| config_file |
| basic_onefile.yaml |
# | basic_folder.yaml | @todo
| basic_folder.yaml |
# | basic_dayone.yaml | @todo


Expand All @@ -178,5 +178,5 @@ Feature: Delete entries from journal
Examples: Configs
| config_file |
| basic_onefile.yaml |
# | basic_folder.yaml | @todo
| basic_folder.yaml |
# | basic_dayone.yaml | @todo