view backend/arangodb/FeedEntry.py @ 258:4ca1fac32dde

Pull the constant of days to keep feed entries into the abstract class
author Dirk Olmes <dirk@xanthippe.ping.de>
date Tue, 12 Mar 2019 02:39:18 +0100
parents f79be01821c4
children 304917762618
line wrap: on
line source

# -*- coding: utf-8 -*-
from datetime import datetime

class FeedEntry(object):
    def __init__(self, document):
        super(FeedEntry, self).__init__()
        self.document = document

    def __getattr__(self, attribute):
        if attribute == 'updated':
            return self._parse_updated()
        return self.document[attribute]

    def _parse_updated(self):
        value = self.document['updated']
        return datetime(*value)

    def markRead(self):
        self.document['read'] = True
        self.document.patch()