eskp.py
changeset 380 1c6c49675d42
parent 317 08fcdd86155a
child 441 c258f9b3f831
equal deleted inserted replaced
379:4036972cf2e1 380:1c6c49675d42
    50         content = publish_parts(rst_data, writer_name='html', settings_overrides=overrides)['html_body']
    50         content = publish_parts(rst_data, writer_name='html', settings_overrides=overrides)['html_body']
    51     return content
    51     return content
    52 
    52 
    53 def get_topmenue():
    53 def get_topmenue():
    54     menue = [
    54     menue = [
    55              ('/ozoneloss', _(u'Ozoneloss'),(
    55              ('/ozoneloss', _(u'Ozoneloss'),
    56              ('/ozoneloss', _(u'overview')),
    56              (('/ozoneloss', _(u'overview')),
    57              ('/ozoneloss/clams/2015', _(u'calculations')),
    57              ('/ozoneloss/clams/2015', _(u'calculations')),
    58              ('/ozoneloss/vpsc/2015', _(u'estimations')),
    58              ('/ozoneloss/vpsc/2015', _(u'estimations')),
    59              ('/ozoneloss/uvi', _(u'uv increase')))),
    59              ('/ozoneloss/uvi', _(u'uv increase')))),
    60 
    60 
    61              ('/eskp', _(u'ESKP'),(None, None)),
    61              ('/eskp', _(u'ESKP'),(None, None)),
    65 
    65 
    66 app.jinja_env.globals.update(get_topmenue=get_topmenue)
    66 app.jinja_env.globals.update(get_topmenue=get_topmenue)
    67 
    67 
    68 def get_o3lossclams_dates():
    68 def get_o3lossclams_dates():
    69     menue = [
    69     menue = [
    70              ('/ozoneloss/clams/2015', _(u'2015')),
    70         ('/ozoneloss/clams/2015', _(u'2015')),
    71              ('/ozoneloss/clams/2012', _(u'2012')),
    71         ('/ozoneloss/clams/2012', _(u'2012')),
    72              ('/ozoneloss/clams/2011', _(u'2011')),
    72         ('/ozoneloss/clams/2011', _(u'2011')),
    73              ('/ozoneloss/clams/2010', _(u'2010')),
    73         ('/ozoneloss/clams/2010', _(u'2010')),
    74              ]
    74         ]
    75     return menue
    75     return menue
    76 
    76 
    77 def get_vpsc_dates():
    77 def get_vpsc_dates():
    78     menue = [
    78     menue = [
    79              ('/ozoneloss/vpsc/2015', _(u'2015')),
    79         ('/ozoneloss/vpsc/2015', _(u'2015')),
    80              ('/ozoneloss/vpsc/2014', _(u'2014')),
    80         ('/ozoneloss/vpsc/2014', _(u'2014')),
    81              ('/ozoneloss/vpsc/2013', _(u'2013')),
    81         ('/ozoneloss/vpsc/2013', _(u'2013')),
    82              ('/ozoneloss/vpsc/2012', _(u'2012')),
    82         ('/ozoneloss/vpsc/2012', _(u'2012')),
    83              ('/ozoneloss/vpsc/2011', _(u'2011')),
    83         ('/ozoneloss/vpsc/2011', _(u'2011')),
    84              ('/ozoneloss/vpsc/2010', _(u'2010')),
    84         ('/ozoneloss/vpsc/2010', _(u'2010')),
    85              ]
    85         ]
    86     return menue
    86     return menue
    87 
    87 
    88 app.jinja_env.globals.update(get_o3lossclams_dates=get_o3lossclams_dates)
    88 app.jinja_env.globals.update(get_o3lossclams_dates=get_o3lossclams_dates)
    89 app.jinja_env.globals.update(get_vpsc_dates=get_vpsc_dates)
    89 app.jinja_env.globals.update(get_vpsc_dates=get_vpsc_dates)
    90 
    90 
   200 def ozoneloss_vspc():
   200 def ozoneloss_vspc():
   201     filename = os.path.join("templates", get_locale(), "rst", "ozoneloss_vpsc.rst")
   201     filename = os.path.join("templates", get_locale(), "rst", "ozoneloss_vpsc.rst")
   202     content = get_content(filename)
   202     content = get_content(filename)
   203     return render_template("/ozoneloss_vpsc.html", act="ozoneloss/vpsc", content=content)
   203     return render_template("/ozoneloss_vpsc.html", act="ozoneloss/vpsc", content=content)
   204 
   204 
   205 @app.route("/ozoneloss/uvi")
   205 
       
   206 @app.route("/ozoneloss/uvi", methods=['GET'])
   206 def ozoneloss_uvi():
   207 def ozoneloss_uvi():
       
   208     # XXX check 'POST' does not work
   207     filename = os.path.join("templates", get_locale(), "rst", "ozoneloss_uvi.rst")
   209     filename = os.path.join("templates", get_locale(), "rst", "ozoneloss_uvi.rst")
   208     content = get_content(filename)
   210     content = get_content(filename)
   209     return render_template("/ozoneloss_uvi.html", act="ozoneloss/uvi", content=content,
   211 
   210                            alt=_(u"UV increase at 52 degrees N for 50 DU ozone depletion"))
   212     lat = 50.
       
   213     o3offset = 50.
       
   214     figname = "uvincr_lat%0.3i_do3%0.3i.svg" % (lat, o3offset)
       
   215 
       
   216 
       
   217     return render_template('ozoneloss_uvi.html', act="ozoneloss/uvi", content=content, figname=figname,
       
   218                            alt=_(u"UV increase at {{lat}} degrees N for {{o3offset}} DU ozone depletion"))
       
   219 
       
   220 @app.route("/ozoneloss/uvi_graph", methods=['POST'])
       
   221 def ozoneloss_uvi_graph():
       
   222     filename = os.path.join("templates", get_locale(), "rst", "ozoneloss_uvi.rst")
       
   223     content = get_content(filename)
       
   224 
       
   225     latstr = request.form['Gradzahl']
       
   226     o3offsetstr = request.form['Dobson-Unit']
       
   227 
       
   228     latstr2 = latstr.replace(u'\xb0', '')
       
   229 
       
   230     if latstr2.endswith(u'N'):
       
   231         latstr2 = latstr2.replace(u'N', '')
       
   232         lat = float(latstr2)
       
   233     if latstr2.endswith(u'S'):
       
   234         latstr2 = latstr2.replace(u'S', '')
       
   235         lat = -float(latstr2)
       
   236 
       
   237 
       
   238     figname = "uvincr_lat%0.3i_do3%0.3i.svg" % (lat, float(o3offsetstr))
       
   239 
       
   240     return render_template('graph.html', act="ozoneloss_uvi_graph", content=content, figname=figname,
       
   241                            o3offsetstr=o3offsetstr, latstr=latstr)
       
   242 
       
   243 
       
   244 
       
   245 
       
   246 
   211 
   247 
   212 @app.route("/iek-7")
   248 @app.route("/iek-7")
   213 def institute():
   249 def institute():
   214     filename = os.path.join("templates", get_locale(), "rst", "iek-7.rst")
   250     filename = os.path.join("templates", get_locale(), "rst", "iek-7.rst")
   215     content = get_content(filename)
   251     content = get_content(filename)
   223         qr_image = qr_image_data(card)
   259         qr_image = qr_image_data(card)
   224         author = render_template("/author_info.html", act="author", title=_(u"IEK-7"),
   260         author = render_template("/author_info.html", act="author", title=_(u"IEK-7"),
   225                                   card=card, image=qr_image, contact=_(u"Contact"), exit=_(u"Close"))
   261                                   card=card, image=qr_image, contact=_(u"Contact"), exit=_(u"Close"))
   226 
   262 
   227     return render_template("/iek-7.html", act="iek-7", content=content,
   263     return render_template("/iek-7.html", act="iek-7", content=content,
   228                            author=author, card=card, contact = u"IEK-7")
   264                            author=author, card=card, contact=u"IEK-7")
   229 
   265 
   230 
   266 
   231 @app.route("/imprint")
   267 @app.route("/imprint")
   232 def imprint():
   268 def imprint():
   233     filename = os.path.join("templates", get_locale(), "rst", "imprint.rst")
   269     filename = os.path.join("templates", get_locale(), "rst", "imprint.rst")
   243     msg = _(u"Url: %(url)s not found", url=request.url)
   279     msg = _(u"Url: %(url)s not found", url=request.url)
   244     info = _(u"This information is not available!")
   280     info = _(u"This information is not available!")
   245     return render_template("404.html", msg=msg, info=info)
   281     return render_template("404.html", msg=msg, info=info)
   246 
   282 
   247 if __name__ == "__main__":
   283 if __name__ == "__main__":
   248     app.run(host='localhost', port=5014, debug=True)
   284     app.run(host='localhost', port=5014)
Impressum Datenschutzerklärung