Example #1
0
    def save(self):
        '''
        When document is saved, the last modified field is updated to
        make sure it is always correct.
        '''

        if not self.authorKey:
            user = UserManager.getUser()
            self.authorKey = user.key
            self.author = user.name

        self.lastModified = datetime.datetime.utcnow()
        NewebeDocument.save(self)
Example #2
0
    def toDict(self, localized=True):
        """
        Return a dict representation of the document (copy).

        Removes _rev key and convert date field and request date field
        to local timezone if *localized* is set to True.
        """

        docDict = NewebeDocument.toDict(self, localized)

        if localized and docDict.get("requestDate", ""):

            utc_date = date_util.get_date_from_db_date(docDict.get("requestDate"))
            date = date_util.convert_utc_date_to_timezone(utc_date)
            docDict["requestDate"] = date_util.get_db_date_from_date(date)

        return docDict
Example #3
0
    def toDict(self, localized=True):
        '''
        Return a dict representation of the document (copy).

        Removes _rev key and convert date field and last modified field
        to local timezone if *localized* is set to True.
        '''

        docDict = NewebeDocument.toDict(self, localized)

        if localized and "lastModified" in docDict:

            utc_date = get_date_from_db_date(docDict.get("lastModified"))
            date = convert_utc_date_to_timezone(utc_date)
            docDict["lastModified"] = get_db_date_from_date(date)

        return docDict
Example #4
0
    def toDict(self, localized=True):
        '''
        Return a dict representation of the document (copy).

        Removes _rev key and convert date field and request date field
        to local timezone if *localized* is set to True.
        '''

        docDict = NewebeDocument.toDict(self, localized)

        if localized and docDict.get("requestDate", ""):

            utc_date = date_util.get_date_from_db_date(
                docDict.get("requestDate"))
            date = date_util.convert_utc_date_to_timezone(utc_date)
            docDict["requestDate"] = date_util.get_db_date_from_date(date)

        return docDict