From 6717fa4fba2b7ec4e007e895f09ed088e04d1d67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?GOLDERWEB=20=E2=80=93=20Jonathan=20Golder?= Date: Sat, 27 Aug 2016 00:07:28 +0200 Subject: [PATCH] Add method to generate notice for article discpage We need a method to generate the template to add to article discpages Related Task: [https://fs.golderweb.de/index.php?do=details&task_id=29 FS#29] --- lib/redfam.py | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/lib/redfam.py b/lib/redfam.py index 4da1ea4..b2277fc 100644 --- a/lib/redfam.py +++ b/lib/redfam.py @@ -487,6 +487,50 @@ class RedFamWorker( RedFam ): return ( self.redpagetitle + "#" + str(anchor_code).strip() ) + def generate_disc_notice_template( self ): + """ + Generates notice template to add on discussion Pages of Articles when + redundancy discussion is finished + + @return Notice template to add on article disc + @rtype wikicode-node + """ + + # Generate template boilerplate + template = mwparser.nodes.template.Template( + jogobot.config['redundances']['disc_notice_template_name']) + + # Index of first article's param + param_cnt = 3 + + # Iterate over articles in redfam + for article in self._articlesList: + # Make sure to only use 8 articles (max. param 10) + if param_cnt > 10: + break + + # Add param for article + template.add( param_cnt, article, True ) + + param_cnt += 1 + + # Add begin + template.add( "Beginn", self._mysql.data[ 'beginning' ].strftime( + "%d. %B %Y").lstrip("0"), True ) + + # Add end + template.add( "Ende", self._mysql.data[ 'ending' ].strftime( + "%d. %B %Y").lstrip("0"), True ) + + # Add link to related reddisc + template.add( "Diskussion", self.get_disc_link(), True ) + + # Add signature and timestamp + # Not used atm + # template.add( 1, "-- ~~~~", True ) + + return template + @classmethod def list_by_status( cls, status ): """