On archived red_fams do not delete possibly existing ending

This commit is contained in:
2015-09-11 13:37:58 +02:00
parent 907ccad63a
commit 47238f0f96

View File

@@ -163,9 +163,6 @@ class RED_FAM_PARSER( RED_FAM ):
self._ending = self.__datetime( ending )
self._status = 1 #__TODO__ STATUS NUMBER
self._changed = True
def __datetime( self, timestamp ):
"""
Decides wether given timestamp is a parseable string or a datetime object and returns a datetime object in both cases
@@ -194,10 +191,11 @@ class RED_FAM_PARSER( RED_FAM ):
- 0 Discussion is running --> no ending, page is not an archive
- 1 Discussion is over --> ending present, page is not an archive
- 2 Discussion is archived --> ending (normaly) present, page is an archive
- 3 and greater status was set by worker script, do not change it
"""
# Diskussion läuft --> Status ? --> 0 ! _ending
# Diskussion beendet --> Status 0 --> 1 _ending
# Diskussion archiviert --> Status 0/1 --> 2 ???
# Do not change stati set by worker script etc.
if not self.__mysql.data['status'] > 2:
# No ending, discussion is running:
# Sometimes archived discussions also have no detectable ending
@@ -208,12 +206,21 @@ class RED_FAM_PARSER( RED_FAM ):
self._status = 1
else:
self._status = 2
else:
self._status = self.__mysql.data[ 'status' ]
def changed( self ):
"""
Checks wether anything has changed and maybe triggers db update
"""
# On archived red_fams do not delete possibly existing ending
if not self._ending and self._status > 1 and self.__mysql.data[ 'ending' ]:
self._ending = self.__mysql.data[ 'ending' ]
# Since status change means something has changed, update database
if( self._status != self.__mysql.data[ 'status' ] or self._beginning != self.__mysql.data[ 'beginning' ] or self._ending != self.__mysql.data[ 'ending' ] or self._red_page_id != self.__mysql.data[ 'red_page_id' ] ):
self.__mysql.update_fam( self._red_page_id, self._beginning, self._ending, self._status )