annotate FeedEntry.py @ 61:db35ab7753f0

add a preference to hide read feed entries
author Dirk Olmes <dirk@xanthippe.ping.de>
date Sat, 24 Jul 2010 03:11:06 +0200
parents daa2731967fe
children abc0516a1c0c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6
87317ba41816 add a creation date for the feed entry
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 5
diff changeset
1
87317ba41816 add a creation date for the feed entry
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 5
diff changeset
2 from datetime import datetime
4
e0199f383442 retrieve a feed for the given URL, store entries as feed_entry rows into the database
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
3
31
5bb57caa8f66 display a feed's entries sorted by their update date
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 29
diff changeset
4 def compareByUpdateDate(first, second):
5bb57caa8f66 display a feed's entries sorted by their update date
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 29
diff changeset
5 return cmp(first.updated, second.updated)
5bb57caa8f66 display a feed's entries sorted by their update date
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 29
diff changeset
6
4
e0199f383442 retrieve a feed for the given URL, store entries as feed_entry rows into the database
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
7 class FeedEntry(object):
e0199f383442 retrieve a feed for the given URL, store entries as feed_entry rows into the database
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
8 @staticmethod
e0199f383442 retrieve a feed for the given URL, store entries as feed_entry rows into the database
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
9 def findById(id, session):
e0199f383442 retrieve a feed for the given URL, store entries as feed_entry rows into the database
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
10 result = session.query(FeedEntry).filter(FeedEntry.id == id)
e0199f383442 retrieve a feed for the given URL, store entries as feed_entry rows into the database
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
11 return result.first()
e0199f383442 retrieve a feed for the given URL, store entries as feed_entry rows into the database
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
12
5
bfd47f55d85b add the updated date of the feed
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 4
diff changeset
13 def __init__(self):
6
87317ba41816 add a creation date for the feed entry
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 5
diff changeset
14 self.create_timestamp = datetime.now()
29
74481aa49974 add a read flag for feed entries so they can be marked read
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 20
diff changeset
15 self.read = 0
4
e0199f383442 retrieve a feed for the given URL, store entries as feed_entry rows into the database
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
16
e0199f383442 retrieve a feed for the given URL, store entries as feed_entry rows into the database
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
17 def __repr__(self):
20
0b8398ca6cd0 oops forgot these ones
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 18
diff changeset
18 return "<FeedEntry (%d) %s>" % (self.pk, self.title)
18
35225588b895 add a list view for displaying feed entries from the selected feed
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 6
diff changeset
19
35225588b895 add a list view for displaying feed entries from the selected feed
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 6
diff changeset
20 def userPresentableString(self):
33
f371d02fa09d mark unread feed entries bold. Add a menu item to toggle between read/unread
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 31
diff changeset
21 return self.title
f371d02fa09d mark unread feed entries bold. Add a menu item to toggle between read/unread
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 31
diff changeset
22
f371d02fa09d mark unread feed entries bold. Add a menu item to toggle between read/unread
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 31
diff changeset
23 def toggleRead(self):
f371d02fa09d mark unread feed entries bold. Add a menu item to toggle between read/unread
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 31
diff changeset
24 if self.read:
59
daa2731967fe Marking all articles in a feed as read doesn't toggle any more ... it marks all articles as read.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 33
diff changeset
25 self.markUnread()
33
f371d02fa09d mark unread feed entries bold. Add a menu item to toggle between read/unread
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 31
diff changeset
26 else:
59
daa2731967fe Marking all articles in a feed as read doesn't toggle any more ... it marks all articles as read.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 33
diff changeset
27 self.markRead()
daa2731967fe Marking all articles in a feed as read doesn't toggle any more ... it marks all articles as read.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 33
diff changeset
28
daa2731967fe Marking all articles in a feed as read doesn't toggle any more ... it marks all articles as read.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 33
diff changeset
29 def markRead(self):
daa2731967fe Marking all articles in a feed as read doesn't toggle any more ... it marks all articles as read.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 33
diff changeset
30 self.read = 1
daa2731967fe Marking all articles in a feed as read doesn't toggle any more ... it marks all articles as read.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 33
diff changeset
31
daa2731967fe Marking all articles in a feed as read doesn't toggle any more ... it marks all articles as read.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 33
diff changeset
32 def markUnread(self):
daa2731967fe Marking all articles in a feed as read doesn't toggle any more ... it marks all articles as read.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 33
diff changeset
33 self.read = 0