Skip to content

Commit

Permalink
Web app "mark as don't care".
Browse files Browse the repository at this point in the history
For #254.
  • Loading branch information
lemon24 committed Oct 7, 2021
1 parent a9661d1 commit 6388a40
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ Unreleased
to mark an entry as unread/unimportant through a boolean flag.
(:issue:`256`)

* In the web application, allow marking an entry as "don't care"
(read + unimportant explicitly set by the user) with a single button.
(:issue:`254`)


Version 2.1
-----------
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ Usage:
>>> [e.title for e in entries]
['H.I. #108: Project Cyclops', 'H.I. #107: One Year of Weird', ...]
>>>
>>> reader.mark_as_read(entries[0])
>>> reader.mark_entry_as_read(entries[0])
>>>
>>> [e.title for e in reader.get_entries(read=False)]
['H.I. #107: One Year of Weird', 'H.I. #106: Water on Mars', ...]
Expand Down
2 changes: 1 addition & 1 deletion src/reader/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
Mark the first entry as read::
reader.mark_as_read(entries[0])
reader.mark_entry_as_read(entries[0])
Print the titles of the unread entries::
Expand Down
8 changes: 8 additions & 0 deletions src/reader/_app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,14 @@ def mark_as_unread(data):
get_reader().mark_entry_as_unread((feed_url, entry_id))


@form_api
@readererror_to_apierror()
def mark_as_dont_care(data):
feed_url = data['feed-url']
entry_id = data['entry-id']
get_reader()._mark_entry_as_dont_care((feed_url, entry_id))


@form_api(really=True)
@readererror_to_apierror()
def mark_all_as_read(data):
Expand Down
5 changes: 5 additions & 0 deletions src/reader/_app/templates/entries.html
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,11 @@ <h2><a href="{{ entry.link }}">
{{ macros.simple_button('.form_api', 'mark-as-important', 'important', leave_disabled=true, next=next, context=context) }}
{% endif %}

{% if not (entry.read and not entry.important and entry.important_modified) %}
{{ macros.simple_button('.form_api', 'mark-as-dont-care', "don't care", leave_disabled=true, next=next, context=context) }}
{% endif %}


{% endif %} {# not read only #}


Expand Down
16 changes: 16 additions & 0 deletions src/reader/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1260,6 +1260,22 @@ def mark_entry_as_unimportant(self, entry: EntryInput) -> None:
"""
return self.mark_entry_as_important(entry, False)

def _mark_entry_as_dont_care(self, entry: EntryInput) -> None:
"""Mark an entry as read and unimportant at the same time,
resulting in the same read_modified and important_modified.
This method becoming public is pending on #254.
Presumably, we could just use mark_entry_as_{read,important} instead
and get the slightly different timestamps,
but it's likely better to collect more accurate data.
"""
modified_naive = self._now()
feed_url, entry_id = _entry_argument(entry)
self._storage.mark_as_read(feed_url, entry_id, True, modified_naive)
self._storage.mark_as_important(feed_url, entry_id, False, modified_naive)

def get_feed_metadata(
self,
feed: FeedInput,
Expand Down
18 changes: 18 additions & 0 deletions tests/test_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -3154,3 +3154,21 @@ def test_entry_read_important_modified_argument(reader, flag, monkeypatch_tz):
getattr(reader, f'mark_entry_as_{flag}')(entry, modified=datetime(2010, 1, 1))
entry = next(reader.get_entries())
assert getattr(entry, f'{flag}_modified') == utc_datetime(2010, 1, 1, 6)


@rename_argument('reader', 'reader_with_one_feed')
def test_mark_as_dont_care(reader):
reader.update_feeds()

entry = next(reader.get_entries())
reader._now = lambda: naive_datetime(2010, 1, 1)
reader.mark_entry_as_important(entry)

reader._now = lambda: naive_datetime(2010, 1, 2)
reader._mark_entry_as_dont_care(entry)
entry = next(reader.get_entries())

assert entry.read
assert entry.read_modified == datetime(2010, 1, 2)
assert not entry.important
assert entry.important_modified == datetime(2010, 1, 2)

0 comments on commit 6388a40

Please sign in to comment.