Request information about reddisc page for redfams

To generate links to related reddisc it is necessary to get at least the
Title of the related reddisc page. As saving the same data in db is
worse, we retreive it via join from red_pages table

Related Task: [https://fs.golderweb.de/index.php?do=details&task_id=26 FS#26]
This commit is contained in:
2016-08-26 18:17:53 +02:00
parent 4055dc52d8
commit b36dc250d2
2 changed files with 19 additions and 6 deletions

View File

@@ -353,10 +353,14 @@ article7 ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? );'
cursor = type( self ).connection.cursor( mysqldb.DictCursor )
cursor.execute(
'SELECT * FROM `{prefix}_red_families` WHERE `status` = ? AND'.
format(prefix=type( self ).db_table_prefix) +
'`ending` >= ?;', ( status, ending ) )
cursor.execute( (
'SELECT * ' +
'FROM `{prefix}_red_families` `F` ' +
'INNER JOIN `{prefix}_red_pages` `P` ' +
'ON `F`.`status` = ? ' +
'AND `F`.`ending` >= ? '
'AND `F`.`red_page_id` = `P`.`page_id`;').format(
prefix=type( self ).db_table_prefix), ( status, ending ) )
while True:
res = cursor.fetchmany( 1000 )

View File

@@ -117,8 +117,8 @@ class RedFam:
"""
# On archived red_fams do not delete possibly existing ending
if( not self._ending and self._status > 1
and self._mysql.data[ 'ending' ] ):
if( not self._ending and self._status > 1 and
self._mysql.data[ 'ending' ] ):
self._ending = self._mysql.data[ 'ending' ]
@@ -447,6 +447,14 @@ class RedFamWorker( RedFam ):
self._mysql.data = mysql_data
# Get related RedPage-Information
self.redpageid = mysql_data[ 'page_id' ]
self.redpagetitle = mysql_data[ 'page_title' ]
# Make sure locale is set to 'de_DE.UTF-8' to prevent problems
# with wrong month abreviations in strptime
locale.setlocale(locale.LC_ALL, 'de_DE.UTF-8')
def update_status( self ):
"""
Sets status to 3 when worked on
@@ -481,6 +489,7 @@ class RedFamWorker( RedFam ):
print(fam)
raise
class RedFamError( Exception ):
"""
Base class for all Errors of RedFam-Module