Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/nutrinoweb/controllers/main.py
diff options
context:
space:
mode:
Diffstat (limited to 'nutrinoweb/controllers/main.py')
-rw-r--r--nutrinoweb/controllers/main.py87
1 files changed, 57 insertions, 30 deletions
diff --git a/nutrinoweb/controllers/main.py b/nutrinoweb/controllers/main.py
index 3d7045a..fe24ffe 100644
--- a/nutrinoweb/controllers/main.py
+++ b/nutrinoweb/controllers/main.py
@@ -8,48 +8,75 @@ from gettext import gettext as _
from server.flask import app, logger, render, request, jsonify
#eating import for the status
-import eating, Avatar, database_manager
+import Avatar, database_manager
-IM_PATH = ['../static/images/journal/jauge-energie.png']
@app.route('/main', methods=['GET', 'POST'])
def main():
logger.debug("controllermain: enter")
# list images
- _images = IM_PATH
- _result = eating.calculateDimension(None, None)
- position = [70, 0]
+ i = Avatar.Character(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, [70, 0])
if request.method == 'POST':
if 'reset' in request.form:
- #instance = Avatar.Character()
- database_manager.reset_status()
- #instance.reset_status()
- _result[0] = 100.0
- _result[1] = 100.0
- _result[2] = 100.0
- _result[3] = 100.0
- _result[4] = 100.0
- _result[5] = 100.0
- _result[6] = 100.0
- _result[7] = 100.0
- position = [70, 0]
+ i.reset_status()
+ #log reset
+ database_manager.write_log('reset', 's')
+
+ i.load_status()
+
+ #prepare position for the sun
+ position = i.Position
+ positionX = position[0]
+ positionY = position[1]
+
+ #calculate time
+ daytime = "am"
+ hours = int(round(i.Time//60)) + 8
+ minutes = int((i.Time % 60))
+ if (minutes == 0):
+ minutes = "00"
+ else:
+ minutes = str(minutes)
+ if (hours > 11):
+ daytime = "pm"
+ if (hours > 12):
+ hours = hours - 12
+ time = str(hours) + ":" + minutes + " " + daytime
- contents = [dict(
- title= _('Hello'),
- image= _images,
- water= _result[0],
- energie= _result[1],
- vitamine= _result[2],
- construction= _result[3],
- waterstart= _result[4],
- energiestart= _result[5],
- vitaminestart= _result[6],
- constructionstart= _result[7],
- )]
+ #status- and progressinformation of the progressbars (water, energie, vitamine and construction), bars should not move
+ progressbar = [dict(
+ water= calculateHeight(i.Water),
+ energie= calculateHeight(i.Energie),
+ vitamine= calculateHeight(i.Vit_total),
+ construction= calculateHeight(i.Construction),
+ waterstart= calculateHeight(i.Water),
+ energiestart= calculateHeight(i.Energie),
+ vitaminestart= calculateHeight(i.Vit_total),
+ constructionstart= calculateHeight(i.Construction),
+ pathimg = '../../static/images/journal/default.png'
+ )]
+
+ #Sun should not move, so start- and endposition have the same coordinates
+ positionSun = {
+ 'positionX': positionX,
+ 'positionstartX': positionX,
+ 'positionY': positionY,
+ 'positionstartY': positionY,
+ 'timeString': time
+ }
#prepare result
- _content = { 'content': contents, 'position': position}
+ _content = { 'progressbar': progressbar, 'positionSun': positionSun }
# render result
return render('nutrinoweb/main.html', **_content)
+def calculateHeight(height):
+ height = 100.0 - height
+ if height < 0.0:
+ return 5.0
+ elif height == 0.0:
+ return 5.0
+ elif height > 100.0:
+ return 99.00
+ return int(height)