diff options
author | Stefanie Nobel <stefanie.nobel@googlemail.com> | 2011-08-28 12:40:54 (GMT) |
---|---|---|
committer | Stefanie Nobel <stefanie.nobel@googlemail.com> | 2011-08-28 12:40:54 (GMT) |
commit | 09589d4ac67fea7fdca56673aa66eb4e94f19ec0 (patch) | |
tree | 3a9521c96ead3d0453719dd9fe9fb79a6579de8a /nutrinoweb | |
parent | fea038ff741a2b8a5da670fc5dc710426be9ba2e (diff) | |
parent | b1db04eb335745ba1261e18bbf0602ab9740ab4f (diff) |
merge databasesolutions
Diffstat (limited to 'nutrinoweb')
-rw-r--r-- | nutrinoweb/activity.py | 56 | ||||
-rw-r--r-- | nutrinoweb/controllers/Avatar.py | 170 | ||||
-rw-r--r-- | nutrinoweb/controllers/database_manager.py | 103 | ||||
-rw-r--r-- | nutrinoweb/controllers/eating.py | 10 | ||||
-rw-r--r-- | nutrinoweb/controllers/main.py | 8 | ||||
-rw-r--r-- | nutrinoweb/controllers/sparetime.py | 4 | ||||
-rw-r--r-- | nutrinoweb/ui/toolbar.py | 17 |
7 files changed, 276 insertions, 92 deletions
diff --git a/nutrinoweb/activity.py b/nutrinoweb/activity.py index 7722908..f02b619 100644 --- a/nutrinoweb/activity.py +++ b/nutrinoweb/activity.py @@ -1,5 +1,5 @@ # python import -import logging +import os, sys, threading, time # gettext import from gettext import gettext as _ @@ -8,15 +8,45 @@ from sugar.activity import activity # hulahop import from hulahop.webview import WebView -# atoideweb import - first to update lib path -import run +# add lib path to current python path +sys.path.append(os.path.join(activity.get_bundle_path(), 'lib')) # server import from server import config -from server.flask import logger +from server.flask import app, run_app as __run, logger +# nutriweb import +from nutrinoweb.controllers import app -URL_BASE = 'http://localhost:5000/' + +# get port from config +_port = config.Config().get('server>port', type_=int) +_port = '5000' if _port is None or _port == '' else _port +# .. +URL_BASE = 'http://localhost:%s' % _port + + +class ThreadServer(threading.Thread): + + def __init__(self, activity_): + # init parent + threading.Thread.__init__(self) + # main flag + self._die = False + # start right now + self.start() + + def kill(self): + self._die = True + + def run(self): + # do run + __run() + # ... + while self._die is False: + continue + # .. + del app def _toolbar_changed(toolbox, page, activity_): @@ -25,22 +55,24 @@ def _toolbar_changed(toolbox, page, activity_): # is the activity tab? if page == 0: # show the activity screen - activity_.change_screen('activity') + activity_.change_screen('main') else: pass # propagate it return True -class NutrinoWebActivity(run.Server, activity.Activity): +class NutrinoWebActivity(activity.Activity): def __init__(self, handle): + # init thread server + self._thread = ThreadServer(self) + # .. + time.sleep(5) # init parents activity.Activity.__init__(self, handle) self.max_participants = 1 # .. - run.Server.__init__(self) - # .. if config.Config().get('activity>use-toolbar', type_=bool): self.__init_toolbar() else: @@ -56,7 +88,7 @@ class NutrinoWebActivity(run.Server, activity.Activity): return self._toolbox def change_screen(self, name): - self.web_view.load_uri(URL_BASE + name) + self.web_view.load_uri('%s/%s' % (URL_BASE, name)) def __init_toolbar(self): """Keep an example of how to manage toolbar in our webapp ... @@ -93,5 +125,7 @@ class NutrinoWebActivity(run.Server, activity.Activity): pass def close(self, skip_save=False): - run.Server.close(self) + # stop the thread + self._thread.kill() + # .. activity.Activity.close(self, skip_save=True) diff --git a/nutrinoweb/controllers/Avatar.py b/nutrinoweb/controllers/Avatar.py index 3eaab37..a804218 100644 --- a/nutrinoweb/controllers/Avatar.py +++ b/nutrinoweb/controllers/Avatar.py @@ -1,51 +1,99 @@ -import os -import json +#import os +#import json -path_to_this_file = os.path.abspath( __file__ ) -temp_json = os.path.join(os.path.dirname(path_to_this_file), "../../sample/status.json") +#path_to_this_file = os.path.abspath( __file__ ) +#temp_json = os.path.join(os.path.dirname(path_to_this_file), "../../sample/status.json") +# python import +import os, json + +# server import +from server.tools import storage +DATA = storage.get_path(path='data', bundle=False) + +# ensure path +storage.check_dir(DATA) + +# status path +DATA_STATUS = os.path.join(DATA, 'status.json') +# .. +storage.check_file(DATA_STATUS) class Character: - + def __init__(self): - - self.water = 0.0 - self.energie = 0.0 - self.calcium = 0.0 - self.iron = 0.0 - self.magnesium = 0.0 - self.phosphorus = 0.0 - self.potassium = 0.0 - self.sodium = 0.0 - self.zinc = 0.0 - self.copper = 0.0 - self.vit_c = 0.0 - self.thiamin = 0.0 - self.riboflavin = 0.0 - self.niacin = 0.0 - self.panto_acid = 0.0 - self.vit_b6 = 0.0 - self.folate_tot = 0.0 - self.vit_b12 = 0.0 - self.vit_a = 0.0 - self.vit_e = 0.0 - self.vit_d = 0.0 - self.vit_total = 0.0 - self.construction = 0.0 + self.water = 0.0 + self.energie = 0.0 + self.calcium = 0.0 + self.iron = 0.0 + self.magnesium = 0.0 + self.phosphorus = 0.0 + self.potassium = 0.0 + self.sodium = 0.0 + self.zinc = 0.0 + self.copper = 0.0 + self.vit_c = 0.0 + self.thiamin = 0.0 + self.riboflavin = 0.0 + self.niacin = 0.0 + self.panto_acid = 0.0 + self.vit_b6 = 0.0 + self.folate_tot = 0.0 + self.vit_b12 = 0.0 + self.vit_a = 0.0 + self.vit_e = 0.0 + self.vit_d = 0.0 + self.vit_total = 0.0 + self.construction = 0.0 def load_status(self): - fh = open(temp_json,'r') + fh = open(DATA_STATUS,'r') status = json.load(fh) fh.close() return status + def load_status1(self): + + fobj = open(DATA_STATUS) + + zuordnung = fobj.read().split("|") + + # little check - TODO nicer check + if len(zuordnung) < 23: + pass + else: + # OK! + self.water = zuordnung[1] + self.energie = zuordnung[2] + self.calcium = zuordnung[3] + self.iron =zuordnung[4] + self.magnesium = zuordnung[5] + self.phosphorus = zuordnung[6] + self.potassium = zuordnung[7] + self.sodium = zuordnung[8] + self.zinc = zuordnung[9] + self.copper = zuordnung[10] + self.vit_c = zuordnung[11] + self.thiamin = zuordnung[12] + self.riboflavin = zuordnung[13] + self.niacin =zuordnung[14] + self.panto_acid = zuordnung[15] + self.vit_b6 = zuordnung[16] + self.folate_tot = zuordnung[17] + self.vit_b12 = zuordnung[18] + self.vit_a = zuordnung[19] + self.vit_e = zuordnung[20] + self.vit_d = zuordnung[21] + self.vit_total = zuordnung[22] + self.construction = zuordnung[23] + def save_status(self, status): - fh = open(temp_json,'w') + fh = open(DATA_STATUS,'w') json.dump(status,fh) fh.close() - def reset_status(self): + def reset_status2(self): status = { "water": 0, "energie": 0, @@ -75,5 +123,63 @@ class Character: json.dump(status,fh) fh.close() + status = { + "water": self.water, + "energie": self.energie, + "calcium": self.calcium, + "iron" : self.iron, + "magnesium": self.magnesium, + "phosphorus": self.phosphorus, + "potassium": self.potassium, + "sodium": self.sodium, + "zinc": self.zinc, + "copper": self.copper, + "vit_c": self.vit_c, + "thiamin": self.thiamin, + "riboflavin": self.riboflavin, + "niacin": self.niacin, + "panto_acid": self.panto_acid, + "vit_b6": self.vit_b6, + "folate_tot": self.folate_tot, + "vit_b12": self.vit_b12, + "vit_a": self.vit_a, + "vit_e": self.vit_e, + "vit_d": self.vit_d, + "vit_total": self.vit_total, + "construction": self.construction + } + return status + def save_status1(self, water, energie, calcium, iron, magnesium, phosphorus, + potassium, sodium, zinc, copper, vit_c, thiamin, riboflavin, + niacin, panto_acid, vit_b6, folate_tot, vit_b12, vit_a, vit_e, + vit_d, vit_total, construction): + fobj = open(DATA_STATUS, 'wb') + fobj.truncate() + fobj.write( + '|' + water + + '|' + energie + + '|' + calcium + + '|' + iron + + '|' + magnesium + + '|' + phosphorus + + '|' + potassium + + '|' + sodium + + '|' + zinc + + '|' + copper + + '|' + vit_c + + '|' + thiamin + + '|' + riboflavin + + '|' + niacin + + '|' + panto_acid + + '|' + vit_b6 + + '|' + folate_tot + + '|' + vit_b12 + + '|' + vit_a + + '|' + vit_e + + '|' + vit_d + + '|' + vit_total + + '|' + construction + ) + fobj.close() diff --git a/nutrinoweb/controllers/database_manager.py b/nutrinoweb/controllers/database_manager.py index ca33419..c2e7618 100644 --- a/nutrinoweb/controllers/database_manager.py +++ b/nutrinoweb/controllers/database_manager.py @@ -3,12 +3,45 @@ from sqlite3 import dbapi2 as sqlite3 from contextlib import closing from flask import Flask, request, session, g, redirect, url_for, abort, \ render_template, flash -import re + +# python import +import os, re + +# server import +from server.tools import storage +DATA = storage.get_path(path='data', bundle=False) +SCHEMA = storage.get_path(path='schema', bundle=True) +FILES = storage.get_path(path='files', bundle=True) + +# ensure paths +storage.check_dir(DATA) +storage.check_dir(SCHEMA) +storage.check_dir(FILES) + +# DB paths +DATABASE1 = os.path.join(DATA, 'nutrition.db') +DATABASE2 = os.path.join(DATA, 'sparetime.db') +DATABASE3 = os.path.join(DATA, 'aliments.db') + +# SCHEMA paths +SCHEMA1 = os.path.join(SCHEMA, 'schema1.sql') +SCHEMA2 = os.path.join(SCHEMA, 'schema2.sql') + +# FILE paths +FILE_DINPUT = os.path.join(FILES, 'dbinput.txt') +FILE_SPARTI = os.path.join(FILES, 'dbinputsparetime.txt') +# .. +DATA_ALIMTS = os.path.join(DATA, 'aliments.txt') +DATA_STATUS = os.path.join(DATA, 'status.txt') + +# ensure FILES +storage.check_file(FILE_DINPUT) +storage.check_file(FILE_SPARTI) +# .. +storage.check_file(DATA_ALIMTS) +storage.check_file(DATA_STATUS) # configuration -DATABASE = '/tmp/nutrition.db' -DATABASE2 = '/tmp/sparetime.db' -DATABASE3 = '/tmp/aliments.db' DEBUG = True SECRET_KEY = '12345' @@ -18,58 +51,68 @@ app.config.from_envvar('NUTRINOWEB_SETTINGS', silent=True) def connect_db(database): """Returns a new connection to the database.""" try: - if database == 'nutrition': - return sqlite3.connect('DATABASE') - elif database == 'activity': - return sqlite3.connect('DATABASE2') + print DATABASE1 + print DATABASE2 + print DATABASE3 + if database == 'nutrition': + return sqlite3.connect(DATABASE1) + elif database == 'activity': + return sqlite3.connect(DATABASE2) except: - return redirect(url_for('addentry')) + return redirect(url_for('addentry')) def connect_db3(): """Returns a new connection to the database.""" - return sqlite3.connect('DATABASE3') + return sqlite3.connect(DATABASE3) def init_db3(): """Creates the database tables.""" with closing(connect_db3()) as db: - with app.open_resource('../../sample/schema2.sql') as f: + with app.open_resource(SCHEMA2) as f: db.cursor().executescript(f.read()) db.commit() -def init_db(): +def init_db(database): """Creates the database tables.""" - with closing(connect_db()) as db: - with app.open_resource('../../sample/schema.sql') as f: - db.cursor().executescript(f.read()) - db.commit() + if database == 'nutrition': + with closing(connect_db('nutrition')) as db: + with app.open_resource(SCHEMA1) as f: + db.cursor().executescript(f.read()) + db.commit() + elif database == 'activity': + with closing(connect_db('activity')) as db: + with app.open_resource(SCHEMA1) as f: + db.cursor().executescript(f.read()) + db.commit() -def load_inputfilenutrition(): + +def load_inputfileactivities(): g.db = connect_db('activity') - fobj = open('/Users/stefanienobel/Documents/workspace/nutrinoweb/nutrinoweb/controllers/dbinput.txt') - + fobj = open(FILE_SPARTI) + for line in fobj: zuordnung = line.split("|") g.db.execute('insert into entries (title, water, energie, calcium, iron, magnesium, phosphorus, potassium, sodium, zinc, copper, vit_c, thiamin, riboflavin, niacin, panto_acid, vit_b6, folate_tot, vit_b12, vit_a, vit_e, vit_d, protein) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)', [zuordnung[0], zuordnung[1], zuordnung[2], zuordnung[3], zuordnung[4], zuordnung[5], zuordnung[6], zuordnung[7], zuordnung[8], zuordnung[9], zuordnung[10], zuordnung[11], zuordnung[12], zuordnung[13], zuordnung[14], zuordnung[15], zuordnung[16], zuordnung[17], zuordnung[18], zuordnung[19], zuordnung[20], zuordnung[21], zuordnung[22]]) g.db.commit() fobj.close() -def load_inputfile(): +def load_inputfilenutrition(): g.db = connect_db('nutrition') - fobj = open('/Users/stefanienobel/Documents/workspace/nutrinoweb/nutrinoweb/controllers/dbinputsparetime.txt') + fobj = open(FILE_DINPUT) for line in fobj: zuordnung = line.split("|") - g.db.execute('insert into entries (title, water, energie, calcium, iron, magnesium, phosphorus, potassium, sodium, zinc, copper, vit_c, thiamin, riboflavin, niacin, panto_acid, vit_b6, folate_tot, vit_b12, vit_a, vit_e, vit_d, protein, path, sceanrio) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)', [zuordnung[0], zuordnung[1], zuordnung[2], zuordnung[3], zuordnung[4], zuordnung[5], zuordnung[6], zuordnung[7], zuordnung[8], zuordnung[9], zuordnung[10], zuordnung[11], zuordnung[12], zuordnung[13], zuordnung[14], zuordnung[15], zuordnung[16], zuordnung[17], zuordnung[18], zuordnung[19], zuordnung[20], zuordnung[21], zuordnung[22], 0, 0]) + g.db.execute('insert into entries (title, water, energie, calcium, iron, magnesium, phosphorus, potassium, sodium, zinc, copper, vit_c, thiamin, riboflavin, niacin, panto_acid, vit_b6, folate_tot, vit_b12, vit_a, vit_e, vit_d, protein, path, scenario) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)', [zuordnung[0], zuordnung[1], zuordnung[2], zuordnung[3], zuordnung[4], zuordnung[5], zuordnung[6], zuordnung[7], zuordnung[8], zuordnung[9], zuordnung[10], zuordnung[11], zuordnung[12], zuordnung[13], zuordnung[14], zuordnung[15], zuordnung[16], zuordnung[17], zuordnung[18], zuordnung[19], zuordnung[20], zuordnung[21], zuordnung[22], zuordnung[23], zuordnung[24]]) g.db.commit() fobj.close() def entries(): """Make sure we are connected to the database.""" g.db = connect_db('nutrition') - + # TODO - check the table exist or create it cur = g.db.execute('select title, water, energie, calcium, iron, magnesium, phosphorus, potassium, sodium, zinc, copper, vit_c, thiamin, riboflavin, niacin, panto_acid, vit_b6, folate_tot, vit_b12, vit_a, vit_e, vit_d, protein, scenario from entries order by id desc') entries = [dict(title=row[0], water=row[1], energie=row[2], calcium=row[3], iron=row[4], magnesium=row[5], phosphorus=row[6], potassium=row[7], sodium=row[8], zinc=row[9], copper=row[10], vit_c=row[11], thiamin=row[12], riboflavin=row[13], niacin=row[14], panto_acid=row[15], vit_b6=row[16], folate_tot=row[17], vit_b12=row[18], vit_a=row[19], vit_e=row[20], vit_d=row[21], protein=row[22], scenario=row[23] ) for row in cur.fetchall()] return entries @@ -77,7 +120,7 @@ def entries(): def entriessparetime(): """Make sure we are connected to the database.""" g.db = connect_db('activity') - + # TODO - check the table exist or create it cur = g.db.execute('select title, water, energie, calcium, iron, magnesium, phosphorus, potassium, sodium, zinc, copper, vit_c, thiamin, riboflavin, niacin, panto_acid, vit_b6, folate_tot, vit_b12, vit_a, vit_e, vit_d, protein from entries order by id desc') entries = [dict(title=row[0], water=row[1], energie=row[2], calcium=row[3], iron=row[4], magnesium=row[5], phosphorus=row[6], potassium=row[7], sodium=row[8], zinc=row[9], copper=row[10], vit_c=row[11], thiamin=row[12], riboflavin=row[13], niacin=row[14], panto_acid=row[15], vit_b6=row[16], folate_tot=row[17], vit_b12=row[18], vit_a=row[19], vit_e=row[20], vit_d=row[21], protein=row[22]) for row in cur.fetchall()] return entries @@ -108,7 +151,7 @@ def delete_entry(database): def show_entry(database): g.db = connect_db(database) - + # TODO - check the table exist or create it if database == 'nutrition': entry = g.db.execute('select title, water, energie, calcium, iron, magnesium, phosphorus, potassium, sodium, zinc, copper, vit_c, thiamin, riboflavin, niacin, panto_acid, vit_b6, folate_tot, vit_b12, vit_a, vit_e, vit_d, protein, scenario from entries where title=?', [request.form['title'].upper()]).fetchone() elif database == 'activity': @@ -130,30 +173,30 @@ def return_entry(): return entry def reset_status(): - fobj = open('/Users/stefanienobel/Documents/workspace/nutrinoweb/nutrinoweb/controllers/status.txt', 'w') + fobj = open(DATA_STATUS, 'wb') fobj.truncate() fobj.write('|' + str('0') + '|' + str('0') + '|' + str('0') + '|' + str('0') + '|' + str('0') + '|' + str('0') + '|' + str('0') + '|' + str('0') + '|' + str('0') + '|' + str('0') + '|' + str('0') + '|' + str('0') + '|' + str('0') + '|' + str('0') + '|' + str('0') + '|' + str('0') + '|' + str('0') + '|' + str('0') + '|' + str('0') + '|' + str('0') + '|' + str('0') + '|' + str('0') + '|' + str('0')) fobj.close() def add_entry_tolist(aliment, path, quantity, unit): g.db = connect_db('nutrition') - + # TODO - check the table exist or create it entry = g.db.execute('select title, water, energie, calcium, iron, magnesium, phosphorus, potassium, sodium, zinc, copper, vit_c, thiamin, riboflavin, niacin, panto_acid, vit_b6, folate_tot, vit_b12, vit_a, vit_e, vit_d, protein from entries where title=?', [aliment]).fetchone() - g.db = connect_db3() + # TODO - check the table exist or create it g.db.execute('insert into aliments (title, path, quantity, unit, water, energie, calcium, iron, magnesium, phosphorus, potassium, sodium, zinc, copper, vit_c, thiamin, riboflavin, niacin, panto_acid, vit_b6, folate_tot, vit_b12, vit_a, vit_e, vit_d, protein) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)', [aliment.lower(), path, quantity, unit, entry[1], entry[2], entry[3], entry[4], entry[5], entry[6], entry[7], entry[8], entry[9], entry[10], entry[11], entry[12], entry[13], entry[14], entry[15], entry[16], entry[17], entry[18], entry[19], entry[20], entry[21], entry[22]]) g.db.commit() def aliments(): """Make sure we are connected to the database.""" g.db = connect_db3() - + # TODO - check the table exist or create it cur = g.db.execute('select title, path, quantity, unit, water, energie, calcium, iron, magnesium, phosphorus, potassium, sodium, zinc, copper, vit_c, thiamin, riboflavin, niacin, panto_acid, vit_b6, folate_tot, vit_b12, vit_a, vit_e, vit_d, protein from aliments') aliments = [dict(title=row[0], path=row[1], quantity=row[2], unit=row[3], water=row[4], energie=row[5], calcium=row[6], iron=row[7], magnesium=row[8], phosphorus=row[9], potassium=row[10], sodium=row[11], zinc=row[12], copper=row[13], vit_c=row[14], thiamin=row[15], riboflavin=row[16], niacin=row[17], panto_acid=row[18], vit_b6=row[19], folate_tot=row[20], vit_b12=row[21], vit_a=row[22], vit_e=row[23], vit_d=row[24], protein=row[25]) for row in cur.fetchall()] return aliments def save_aliments(aliments): - fobj = open('/Users/stefanienobel/Documents/workspace/nutrinoweb/nutrinoweb/controllers/aliments.txt', 'w') + fobj = open(DATA_ALIMTS, 'wb') fobj.truncate() for aliment in aliments: fobj.write('|' + str(aliment['quantity']) + ',' + aliment['title']) diff --git a/nutrinoweb/controllers/eating.py b/nutrinoweb/controllers/eating.py index 0fb2238..b8a9b31 100644 --- a/nutrinoweb/controllers/eating.py +++ b/nutrinoweb/controllers/eating.py @@ -16,8 +16,8 @@ IM_PATH = ['../static/images/journal/jauge-energie.png'] @app.route('/eating', methods=['GET', 'POST']) def eating(): - #database_manager.init_db() - #database_manager.load_inputfilenutrition() + database_manager.init_db('nutrition') + database_manager.load_inputfilenutrition() entries = database_manager.entries() IM_PATH = None path = '../../static/images/journal/backgroundeating.png' @@ -69,7 +69,7 @@ def eating(): _text = 'How much do you want?' _visibilitytextbox2 = 'visible' else: - _text = 'Sorry, I do not have ' + request.form['title'] + '. Maybe you should ask somebody else!' + _text = 'Sorry, I do not have ' + request.form['title'] + '. Maybe you should ask somewhere else!' else: _text = 'Sorry, I do not have ' + request.form['title'] + '. Do you want something else?' _visibilitytextbox = 'visible' @@ -170,7 +170,7 @@ def calculateDimension(result, entries): else: pass else: - #part water + #part water water = 100.0 - float(eng['water']) #part energie @@ -179,7 +179,7 @@ def calculateDimension(result, entries): #part vitamine vitamine = 100.0 - float(eng['vit_total']) - #part construction + #part construction construction = 100.0 - float(eng['construction']) _result = [water, energie, vitamine, construction, calculateHeight(float(eng['water'])), calculateHeight(float(eng['energie'])), calculateHeight(float(eng['vit_total'])), calculateHeight(float(eng['construction']))] diff --git a/nutrinoweb/controllers/main.py b/nutrinoweb/controllers/main.py index 2dcbc76..3d7045a 100644 --- a/nutrinoweb/controllers/main.py +++ b/nutrinoweb/controllers/main.py @@ -8,7 +8,7 @@ from gettext import gettext as _ from server.flask import app, logger, render, request, jsonify #eating import for the status -import eating, Avatar +import eating, Avatar, database_manager IM_PATH = ['../static/images/journal/jauge-energie.png'] @@ -22,9 +22,9 @@ def main(): if request.method == 'POST': if 'reset' in request.form: - instance = Avatar.Character() - - instance.reset_status() + #instance = Avatar.Character() + database_manager.reset_status() + #instance.reset_status() _result[0] = 100.0 _result[1] = 100.0 _result[2] = 100.0 diff --git a/nutrinoweb/controllers/sparetime.py b/nutrinoweb/controllers/sparetime.py index 31e8752..f122767 100644 --- a/nutrinoweb/controllers/sparetime.py +++ b/nutrinoweb/controllers/sparetime.py @@ -14,8 +14,8 @@ IM_PATH = ['../static/images/journal/jauge-energie.png'] @app.route('/sparetime', methods=['GET', 'POST']) def sparetime(): - #database_manager.init_db() - #database_manager.load_inputfile() + database_manager.init_db('activity') + database_manager.load_inputfileactivities() entries = database_manager.entriessparetime() content = [ ] # POST diff --git a/nutrinoweb/ui/toolbar.py b/nutrinoweb/ui/toolbar.py index 9266606..f0811c8 100644 --- a/nutrinoweb/ui/toolbar.py +++ b/nutrinoweb/ui/toolbar.py @@ -24,26 +24,27 @@ def _cb_next(widget, toolbar, next_): BUTTONS = { - 'post' : ['document-generic', _cb_next], - 'ajax' : ['document-generic', _cb_next], - 'gallery' : ['document-generic', _cb_next], - 'separator' : [None, None] + 'main' : ['document-generic', _cb_next], + 'eating' : ['document-generic', _cb_next], + 'sparetime': ['document-generic', _cb_next], + 'separator': [None, None] } TOOLBARS = { 'menu' : [ - ['post', 'ajax'], + ['main', 'eating', 'sparetime'], [] ], } TITLES = { 'menu' : { - 'toolbox': _('Menu'), + 'toolbox': _('Debug'), 'buttons': { - 'post': _('Post'), - 'ajax': _('Ajax') + 'main' : _('Activity'), + 'eating' : _('Eating'), + 'sparetime': _('Sparetime') } } } |