From b09f09ff7be8a64bb2f0a2ac3692941aaae5ea89 Mon Sep 17 00:00:00 2001 From: Stefanie Nobel Date: Sun, 28 Aug 2011 10:25:50 +0000 Subject: .json instead of .txt for status --- diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 6068657..0000000 --- a/.DS_Store +++ /dev/null Binary files differ diff --git a/.gitignore b/.gitignore index c7d20ce..eb6e0b4 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,5 @@ syntax: glob *.new dist docs/build +.DS_Store +data/ diff --git a/DATABASE3 b/DATABASE3 index 0ce335c..8d8c913 100644 --- a/DATABASE3 +++ b/DATABASE3 Binary files differ diff --git a/activity/activity-nutriweb.svg b/activity/activity-nutriweb.svg deleted file mode 100644 index 0726484..0000000 --- a/activity/activity-nutriweb.svg +++ /dev/null @@ -1,232 +0,0 @@ - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/docs/.DS_Store b/docs/.DS_Store deleted file mode 100644 index 226dc11..0000000 --- a/docs/.DS_Store +++ /dev/null Binary files differ diff --git a/docs/source/.DS_Store b/docs/source/.DS_Store deleted file mode 100644 index e1a71de..0000000 --- a/docs/source/.DS_Store +++ /dev/null Binary files differ diff --git a/lib/server/__init__.py b/lib/server/__init__.py index a779594..06b0b1d 100644 --- a/lib/server/__init__.py +++ b/lib/server/__init__.py @@ -1,2 +1,4 @@ # server import from server._server import Server +# .. +from server.flask import BUNDLE, ROOT diff --git a/lib/server/config.py b/lib/server/config.py index 659ec18..9180e54 100644 --- a/lib/server/config.py +++ b/lib/server/config.py @@ -4,7 +4,7 @@ import logging from ConfigParser import SafeConfigParser # get application logger -logger = logging.getLogger('nutriweb') +logger = logging.getLogger('atoideweb') class Config(object): diff --git a/lib/server/flask/__init__.py b/lib/server/flask/__init__.py index 7d75791..f079068 100644 --- a/lib/server/flask/__init__.py +++ b/lib/server/flask/__init__.py @@ -2,4 +2,4 @@ from flask import request, jsonify # server import -from server.flask._app import logger, app, render, run_app +from server.flask._app import logger, app, render, run_app, BUNDLE, ROOT diff --git a/lib/server/flask/_app.py b/lib/server/flask/_app.py index cb2d4c3..bc6f3b3 100644 --- a/lib/server/flask/_app.py +++ b/lib/server/flask/_app.py @@ -15,23 +15,29 @@ APP_NAME = 'my_activity' if APP_NAME is None else APP_NAME _debug = config.Config().get('server>debug') _key = config.Config().get('server>secret_key') -# our activity root directory relative to the current one -PROJET_ROOT = os.path.join(os.path.dirname(__file__), '..', '..', '..') - # flask import import flask +# sugar or debug root path factory +try: + from sugar.activity import activity + BUNDLE = activity.get_bundle_path() + ROOT = activity.get_bundle_path() +except Exception, e: + BUNDLE = '.' + ROOT = '.' + # init app app = flask.Flask(__name__) app.debug = True if _debug is None else _debug app.secret_key = 'NO_KEY_OOPS' if _key is None else _key # override jinja template path -app.jinja_loader.searchpath = [os.path.join(PROJET_ROOT, 'templates')] +app.jinja_loader.searchpath = [os.path.join(BUNDLE, 'templates')] # init static folder path from werkzeug import SharedDataMiddleware app.wsgi_app = SharedDataMiddleware(app.wsgi_app, - {'/static': os.path.join(PROJET_ROOT, 'static')}) + {'/static': os.path.join(BUNDLE, 'static')}) # set basic logging out of sugar try: diff --git a/lib/server/tools/__init__.py b/lib/server/tools/__init__.py new file mode 100644 index 0000000..ec464ac --- /dev/null +++ b/lib/server/tools/__init__.py @@ -0,0 +1 @@ +from server.tools._obj import obj diff --git a/lib/server/tools/_obj.py b/lib/server/tools/_obj.py new file mode 100644 index 0000000..c2c3383 --- /dev/null +++ b/lib/server/tools/_obj.py @@ -0,0 +1,8 @@ + +class obj(object): + def __init__(self, d): + for a, b in d.items(): + if isinstance(b, (list, tuple)): + setattr(self, a, [obj(x) if isinstance(x, dict) else x for x in b]) + else: + setattr(self, a, obj(b) if isinstance(b, dict) else b) diff --git a/lib/server/tools/image.py b/lib/server/tools/image.py new file mode 100644 index 0000000..cffc156 --- /dev/null +++ b/lib/server/tools/image.py @@ -0,0 +1,110 @@ + +# python import +import logging, os, struct, StringIO + +# atoideweb import +from atoideweb.tools import registry + + +def compute_width_height(width, height, max_width, max_height, use_max=False): + # compute ratio + _ratio_scr = max_width / float(max_height) + _ratio_img = width / float(height) + # .. + if width > max_width\ + or height > max_height: + if _ratio_img > _ratio_scr: + width = max_width + height = int(max_width / _ratio_img) + elif _ratio_img < _ratio_scr: + width = int(max_height * _ratio_img) + height = max_height + else: + width = max_width + height = max_height + # .. + return width, height + # .. + elif use_max is True: + return max_width, max_height + # .. + else: + return width, height + + +def get_image_info(path): + """Tricky method found on Internet that returns the image info from a given + raw image data. + """ + # little check + _info = registry.InfoRegistry().get_info(path) + # already exist + if _info is not None: + return _info + elif os.path.exists(path): + pass + else: + return None, 0, 0 + # read file + _f = open(path) + _data = _f.read() + _f.close() + # + size = len(_data) + height = 0 + width = 0 + content_type = None + + # handle GIFs + if (size >= 10) and _data[:6] in ('GIF87a', 'GIF89a'): + # Check to see if content_type is correct + content_type = 'image/gif' + w, h = struct.unpack("= 24) and _data.startswith('\211PNG\r\n\032\n') + and (_data[12:16] == 'IHDR')): + content_type = 'image/png' + w, h = struct.unpack(">LL", _data[16:24]) + width = int(w) + height = int(h) + + # Maybe this is for an older PNG version. + elif (size >= 16) and _data.startswith('\211PNG\r\n\032\n'): + # Check to see if we have the right content type + content_type = 'image/png' + w, h = struct.unpack(">LL", _data[8:16]) + width = int(w) + height = int(h) + + # handle JPEGs + elif (size >= 2) and _data.startswith('\377\330'): + content_type = 'image/jpeg' + jpeg = StringIO.StringIO(_data) + jpeg.read(2) + b = jpeg.read(1) + try: + while (b and ord(b) != 0xDA): + while (ord(b) != 0xFF): b = jpeg.read(1) + while (ord(b) == 0xFF): b = jpeg.read(1) + if (ord(b) >= 0xC0 and ord(b) <= 0xC3): + jpeg.read(3) + h, w = struct.unpack(">HH", jpeg.read(4)) + break + else: + jpeg.read(int(struct.unpack(">H", jpeg.read(2))[0])-2) + b = jpeg.read(1) + width = int(w) + height = int(h) + except struct.error: + pass + except ValueError: + pass + # udpate registry + registry.InfoRegistry().set_info(path, (content_type, width, height)) + # .. + return content_type, width, height diff --git a/lib/server/tools/registry.py b/lib/server/tools/registry.py new file mode 100644 index 0000000..7e575c3 --- /dev/null +++ b/lib/server/tools/registry.py @@ -0,0 +1,48 @@ + +# python import +import logging + + +class Registry(object): + + class __Singleton: + """Our singleton object. + """ + + def __init__(self): + """Create the new singleton for a simple use. + """ + # ensure config + self.__dict = dict() + + def get_info(self, path): + # .. + if path in self.__dict: + return self.__dict[path] + else: + return None + + def set_info(self, path, info): + # clear previous + if path in self.__dict: + del self.__dict[path] + else: + pass + # ... + self.__dict[path] = info + + # singleton instance + instance = None + + def __new__(c, force=False): + """Singleton new init. + """ + # if doesn't already initialized + if not Registry.instance \ + or force is True: + # create a new instance + Registry.instance = Registry.__Singleton() + else: + pass + # return the manager object + return Registry.instance diff --git a/lib/server/tools/sound.py b/lib/server/tools/sound.py new file mode 100644 index 0000000..7ac6a57 --- /dev/null +++ b/lib/server/tools/sound.py @@ -0,0 +1,111 @@ + +# python import +import gst +# .. +from datetime import timedelta + + +class Player(object): + + def __init__(self, loop=False): + # playing flag + self.playing = False + self.loop = loop + # player object + self.player = None + self._init_player() + # file to play + self._soundfile = None + + def _reload_cb(self, bus, message): + if self.loop is True: + self.player.set_state(gst.STATE_READY) + self.player.set_state(gst.STATE_PLAYING) + else: + pass + + def _error_cb(self, bus, message): + self.player.set_state(gst.STATE_NULL) + + def _init_player(self): + # make player + self.player = gst.element_factory_make("playbin", "player") + # video fake + _fakesink = gst.element_factory_make('fakesink', "my-fakesink") + self.player.set_property("video-sink", _fakesink) + # bus .. + bus = self.player.get_bus() + bus.add_signal_watch() + bus.connect('message::eos', self._reload_cb) + bus.connect('message::error', self._error_cb) + + def serialize(self): + # little check + if self._soundfile is None: + return None + else: + return file(self._soundfile, 'r').read() + + def load(self, soundfile): + # file to play + self._soundfile = soundfile + # little check + if self._soundfile is None: + pass + else: + # load sound file + self.player.set_state(gst.STATE_NULL) + self.player.set_property('uri', 'file://' + self._soundfile) + + def get_position(self): + # little check + if self._soundfile is None: + return None + else: + # ... + _position = self.player.query_duration(gst.FORMAT_TIME)[0] + # ... + return timedelta(seconds=(_position / gst.SECOND)) + + def get_duration(self): + # little check + if self._soundfile is None: + return None + else: + # _duration = self.player.query_duration(gst.FORMAT_TIME)[0] + # .. + _parser = gst.parse_launch("filesrc name=source ! decodebin2 ! fakesink") + # .. + _source = _parser.get_by_name("source") + _source.set_property("location", self._soundfile) + # .. + _parser.set_state(gst.STATE_PLAYING) + _parser.get_state() + # .. + _format = gst.Format(gst.FORMAT_TIME) + _duration = _parser.query_duration(_format)[0] + _parser.set_state(gst.STATE_NULL) + # .. + return timedelta(seconds=(_duration / gst.SECOND)) + + def seek(self, time): + # little check + if self._soundfile is None: + return + else: + # format time + _seek = time * 1000000000 + # do seek + self.player.seek_simple(gst.FORMAT_TIME, gst.SEEK_FLAG_FLUSH, _seek) + + def play(self): + self.playing = True + self.player.set_state(gst.STATE_PLAYING) + + def pause(self): + self.playing = False + self.player.set_state(gst.STATE_PAUSED) + + def stop(self): + self.playing = False + self.player.set_state(gst.STATE_NULL) diff --git a/lib/server/tools/storage.py b/lib/server/tools/storage.py new file mode 100644 index 0000000..535eb66 --- /dev/null +++ b/lib/server/tools/storage.py @@ -0,0 +1,135 @@ + +# python import +import os + +# server import +from server import BUNDLE, ROOT + + +ACTIVITY_NAMES = { + 'paint': 'org.laptop.Oficina', + 'record': 'org.laptop.RecordActivity', + } + + +def get_path(path=None, bundle=True): + # .. + path = 'static' if path is None else os.path.join('static', path) + # .. + if bundle is True: + return os.path.join(BUNDLE, path) + else: + return os.path.join(ROOT, 'data', path) + + +def list_dir(path=None, bundle=True): + # .. + path = get_path(path=path, bundle=bundle) + # .. + return [os.path.join(path, _f) for _f in os.listdir(path)] + + +def get_sound_path(filename, path=None, bundle=True, ext=None): + # .. + path = get_path(path=path, bundle=bundle) + filename = filename if ext is None else '%s.%s' % (filename, ext) + # .. + return os.path.join(path, filename) + + +def get_sound_path(filename, path=None, bundle=True, ext='ogg'): + # .. + return get_sound_path(filename, path=path, bundle=bundle, ext=ext) + + +def get_image_path(filename, path=None, bundle=True, ext='png'): + # .. + return get_sound_path(filename, path=path, bundle=bundle, ext=ext) + + +def __do_query(query): + from sugar.datastore import datastore + # find in ds + _results, _count = datastore.find(query, sorting='timestamp') + for _r in _results: + # get meta + _m = _r.get_metadata() + if 'activity' in query: + yield _r + elif _m['activity'] == '': + yield _r + else: + continue + + +def get_journal_objects(activity_name=None, mime_type=None): + # init + _query = dict() + # prepare query name + if activity_name is None\ + and mime_type is None: + return [] + elif mime_type is None: + return __do_query({'activity': ACTIVITY_NAMES[activity_name]}) + else: + return __do_query({'mime_type': mime_type}) + + +def list_info_from_journal(activity_name=None, mime_type=None): + # get objects first + _objs = get_journal_objects(activity_name=activity_name, mime_type=mime_type) + # make unique titles + _titles = {} + # return infos + for _o in _objs: + # get meta + _m = _o.get_metadata() + # get title + _t = _m['title'] + # ensure description + _d = _m['description'] if 'description' in _m else '' + _p = _m['preview'] if 'preview' in _m else None + # little check + if _t in _titles: + # udpate reg + _titles[_t] += 1 + # update value to show + _t = '%s (%s)' % (_t, _titles[_t]) + # init title reg + else: + _titles[_t] = 1 + # ensure info + yield { + 'activity_id' : _m['activity_id'], + 'description' : _d, + 'timestamp' : _m['timestamp'], + 'preview' : _p, + 'title' : _t, + } + + +def list_files_from_journal(activity_name=None, mime_type=None): + # get objects first + _objs = get_journal_objects(activity_name=activity_name, + mime_type=mime_type) + # return paths + for _o in _objs: + # TODO open the files + yield _o.get_file_path() + + +def get_path_from_journal(timestamp, mime_type): + from sugar.datastore import datastore + # .. + _query = { + 'timestamp': int(timestamp), + 'mime_type': mime_type + } + # find in ds + _results, _count = datastore.find(_query) + # .. + if _count == 1: + # get path + return _results[0].get_file_path() + else: + return None diff --git a/nutrinoweb/.DS_Store b/nutrinoweb/.DS_Store deleted file mode 100644 index 8a60703..0000000 --- a/nutrinoweb/.DS_Store +++ /dev/null Binary files differ diff --git a/nutrinoweb/controllers/.DS_Store b/nutrinoweb/controllers/.DS_Store deleted file mode 100644 index f7dace6..0000000 --- a/nutrinoweb/controllers/.DS_Store +++ /dev/null Binary files differ diff --git a/nutrinoweb/controllers/Avatar.py b/nutrinoweb/controllers/Avatar.py index 6dbfebe..3eaab37 100644 --- a/nutrinoweb/controllers/Avatar.py +++ b/nutrinoweb/controllers/Avatar.py @@ -1,3 +1,10 @@ +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") + + class Character: def __init__(self): @@ -26,75 +33,47 @@ class Character: self.vit_total = 0.0 self.construction = 0.0 - - def reset(self, gender=None): - """ - Restore some character properties to its default values. - """ - pass + def load_status(self): + fh = open(temp_json,'r') + status = json.load(fh) + fh.close() - def load_status(self): - fobj = open('/Users/stefanienobel/Documents/workspace/nutrinoweb/nutrinoweb/controllers/status.txt') - - for line in fobj: - zuordnung = line.split("|") - 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] + return status - fobj.close() + def save_status(self, status): + fh = open(temp_json,'w') + 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 reset_status(self): + status = { + "water": 0, + "energie": 0, + "calcium": 0, + "iron" : 0, + "magnesium": 0, + "phosphorus": 0, + "potassium": 0, + "sodium": 0, + "zinc": 0, + "copper": 0, + "vit_c": 0, + "thiamin": 0, + "riboflavin": 0, + "niacin": 0, + "panto_acid": 0, + "vit_b6": 0, + "folate_tot": 0, + "vit_b12": 0, + "vit_a": 0, + "vit_e": 0, + "vit_d": 0, + "vit_total": 0, + "construction": 0 + } + fh = open(temp_json,'w') + json.dump(status,fh) + fh.close() - def save_status(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('/Users/stefanienobel/Documents/workspace/nutrinoweb/nutrinoweb/controllers/status.txt', 'w') - 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 f67ea23..ca33419 100644 --- a/nutrinoweb/controllers/database_manager.py +++ b/nutrinoweb/controllers/database_manager.py @@ -32,14 +32,14 @@ def connect_db3(): def init_db3(): """Creates the database tables.""" with closing(connect_db3()) as db: - with app.open_resource('schema2.sql') as f: + with app.open_resource('../../sample/schema2.sql') as f: db.cursor().executescript(f.read()) db.commit() def init_db(): """Creates the database tables.""" with closing(connect_db()) as db: - with app.open_resource('schema.sql') as f: + with app.open_resource('../../sample/schema.sql') as f: db.cursor().executescript(f.read()) db.commit() @@ -153,10 +153,10 @@ def aliments(): return aliments def save_aliments(aliments): - fobj = open('/Users/stefanienobel/Documents/workspace/nutrinoweb/nutrinoweb/controllers/aliments.txt', 'w') - fobj.truncate() - for aliment in aliments: - fobj.write('|' + str(aliment['quantity']) + ',' + aliment['title']) - fobj.close() + fobj = open('/Users/stefanienobel/Documents/workspace/nutrinoweb/nutrinoweb/controllers/aliments.txt', 'w') + fobj.truncate() + for aliment in aliments: + fobj.write('|' + str(aliment['quantity']) + ',' + aliment['title']) + fobj.close() diff --git a/nutrinoweb/controllers/eating.py b/nutrinoweb/controllers/eating.py index 0fdeb94..0fb2238 100644 --- a/nutrinoweb/controllers/eating.py +++ b/nutrinoweb/controllers/eating.py @@ -139,9 +139,34 @@ def calculateDimension(result, entries): #part construction _construction = controllValue((factor*calculateConstruction(float(entry['protein']))) + float(eng['construction'])) construction = calculateHeight(_construction) - - status = instance.save_status(str(_water), str(_energie), str(_vitamine[1]), str(_vitamine[2]),str(_vitamine[3]),str(_vitamine[4]),str(_vitamine[5]),str(_vitamine[6]),str(_vitamine[7]),str(_vitamine[8]),str(_vitamine[9]),str(_vitamine[10]),str(_vitamine[11]),str(_vitamine[12]),str(_vitamine[13]),str(_vitamine[14]),str(_vitamine[15]),str(_vitamine[16]),str(_vitamine[17]),str(_vitamine[18]), str(_vitamine[19]), str(_vitamine[0]), str(_construction)) - + + status = { + "water": _water, + "energie": _energie, + "calcium": _vitamine[1], + "iron" : _vitamine[2], + "magnesium": _vitamine[3], + "phosphorus": _vitamine[4], + "potassium": _vitamine[5], + "sodium": _vitamine[6], + "zinc": _vitamine[7], + "copper": _vitamine[8], + "vit_c": _vitamine[9], + "thiamin": _vitamine[10], + "riboflavin": _vitamine[11], + "niacin": _vitamine[12], + "panto_acid": _vitamine[13], + "vit_b6": _vitamine[14], + "folate_tot": _vitamine[15], + "vit_b12": _vitamine[16], + "vit_a": _vitamine[17], + "vit_e": _vitamine[18], + "vit_d": _vitamine[19], + "vit_total": _vitamine[0], + "construction": _construction + } + + instance.save_status(status) else: pass else: diff --git a/nutrinoweb/controllers/main.py b/nutrinoweb/controllers/main.py index b4bcd97..2dcbc76 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, database_manager +import eating, Avatar IM_PATH = ['../static/images/journal/jauge-energie.png'] @@ -22,7 +22,9 @@ def main(): if request.method == 'POST': if 'reset' in request.form: - database_manager.reset_status() + instance = Avatar.Character() + + instance.reset_status() _result[0] = 100.0 _result[1] = 100.0 _result[2] = 100.0 diff --git a/nutrinoweb/controllers/schema.sql b/nutrinoweb/controllers/schema.sql deleted file mode 100644 index fab8d9a..0000000 --- a/nutrinoweb/controllers/schema.sql +++ /dev/null @@ -1,29 +0,0 @@ -drop table if exists entries; -create table entries( - id integer primary key autoincrement, - title string not null, - water string not null, - energie string not null, - calcium string not null, - iron string not null, - magnesium string not null, - phosphorus string not null, - potassium string not null, - sodium string not null, - zinc string not null, - copper string not null, - vit_c string not null, - thiamin string not null, - riboflavin string not null, - niacin string not null, - panto_acid string not null, - vit_b6 string not null, - folate_tot string not null, - vit_b12 string not null, - vit_a string not null, - vit_e string not null, - vit_d string not null, - protein string not null, - path string, - scenario string -); diff --git a/nutrinoweb/controllers/schema2.sql b/nutrinoweb/controllers/schema2.sql deleted file mode 100644 index 17bb3c7..0000000 --- a/nutrinoweb/controllers/schema2.sql +++ /dev/null @@ -1,30 +0,0 @@ -drop table if exists aliments; -create table aliments( - id integer primary key autoincrement, - title string not null, - path string not null, - quantity string not null, - unit string not null, - water string not null, - energie string not null, - calcium string not null, - iron string not null, - magnesium string not null, - phosphorus string not null, - potassium string not null, - sodium string not null, - zinc string not null, - copper string not null, - vit_c string not null, - thiamin string not null, - riboflavin string not null, - niacin string not null, - panto_acid string not null, - vit_b6 string not null, - folate_tot string not null, - vit_b12 string not null, - vit_a string not null, - vit_e string not null, - vit_d string not null, - protein string not null -); diff --git a/nutrinoweb/controllers/sparetime.py b/nutrinoweb/controllers/sparetime.py index 18c3270..31e8752 100644 --- a/nutrinoweb/controllers/sparetime.py +++ b/nutrinoweb/controllers/sparetime.py @@ -99,8 +99,33 @@ def calculateDimension(factor, result, entries): _construction = controllValue(float(eng['construction']) - (factor*calculateConstruction(float(entry['protein'])))) construction = calculateHeight(_construction) - status = instance.save_status(str(_water), str(_energie), str(_vitamine[1]), str(_vitamine[2]),str(_vitamine[3]),str(_vitamine[4]),str(_vitamine[5]),str(_vitamine[6]),str(_vitamine[7]),str(_vitamine[8]),str(_vitamine[9]),str(_vitamine[10]),str(_vitamine[11]),str(_vitamine[12]),str(_vitamine[13]),str(_vitamine[14]),str(_vitamine[15]),str(_vitamine[16]),str(_vitamine[17]),str(_vitamine[18]), str(_vitamine[19]), str(_vitamine[0]), str(_construction)) - + status = { + "water": _water, + "energie": _energie, + "calcium": _vitamine[1], + "iron" : _vitamine[2], + "magnesium": _vitamine[3], + "phosphorus": _vitamine[4], + "potassium": _vitamine[5], + "sodium": _vitamine[6], + "zinc": _vitamine[7], + "copper": _vitamine[8], + "vit_c": _vitamine[9], + "thiamin": _vitamine[10], + "riboflavin": _vitamine[11], + "niacin": _vitamine[12], + "panto_acid": _vitamine[13], + "vit_b6": _vitamine[14], + "folate_tot": _vitamine[15], + "vit_b12": _vitamine[16], + "vit_a": _vitamine[17], + "vit_e": _vitamine[18], + "vit_d": _vitamine[19], + "vit_total": _vitamine[0], + "construction": _construction + } + + instance.save_status(status) else: pass diff --git a/po/.DS_Store b/po/.DS_Store deleted file mode 100644 index 5008ddf..0000000 --- a/po/.DS_Store +++ /dev/null Binary files differ diff --git a/nutrinoweb/controllers/aliments.txt b/sample/aliments.txt index b43ba12..b43ba12 100644 --- a/nutrinoweb/controllers/aliments.txt +++ b/sample/aliments.txt diff --git a/nutrinoweb/controllers/dbinput.txt b/sample/dbinput.txt index b9d4a11..b9d4a11 100755 --- a/nutrinoweb/controllers/dbinput.txt +++ b/sample/dbinput.txt diff --git a/nutrinoweb/controllers/dbinputsparetime.txt b/sample/dbinputsparetime.txt index 7b3e42e..7b3e42e 100755 --- a/nutrinoweb/controllers/dbinputsparetime.txt +++ b/sample/dbinputsparetime.txt diff --git a/nutrinoweb/controllers/status.txt b/sample/status.txt index 074328b..074328b 100644 --- a/nutrinoweb/controllers/status.txt +++ b/sample/status.txt diff --git a/nutrinoweb/controllers/statusanfang.txt b/sample/statusanfang.txt index 84ae936..84ae936 100644 --- a/nutrinoweb/controllers/statusanfang.txt +++ b/sample/statusanfang.txt diff --git a/static/.DS_Store b/static/.DS_Store deleted file mode 100644 index 2d8c43b..0000000 --- a/static/.DS_Store +++ /dev/null Binary files differ diff --git a/static/css/.DS_Store b/static/css/.DS_Store deleted file mode 100644 index 5008ddf..0000000 --- a/static/css/.DS_Store +++ /dev/null Binary files differ diff --git a/static/images/.DS_Store b/static/images/.DS_Store deleted file mode 100644 index 4f78abc..0000000 --- a/static/images/.DS_Store +++ /dev/null Binary files differ diff --git a/static/images/journal/.DS_Store b/static/images/journal/.DS_Store deleted file mode 100644 index 8e6e528..0000000 --- a/static/images/journal/.DS_Store +++ /dev/null Binary files differ diff --git a/static/images/journal/activities/SLEEPING.png b/static/images/journal/activities/SLEEPING.png new file mode 100644 index 0000000..cc30c45 --- /dev/null +++ b/static/images/journal/activities/SLEEPING.png Binary files differ diff --git a/static/images/journal/aliments/.DS_Store b/static/images/journal/aliments/.DS_Store deleted file mode 100644 index 87c447d..0000000 --- a/static/images/journal/aliments/.DS_Store +++ /dev/null Binary files differ diff --git a/templates/.DS_Store b/templates/.DS_Store deleted file mode 100644 index 0e54788..0000000 --- a/templates/.DS_Store +++ /dev/null Binary files differ diff --git a/templates/nutrinoweb/.DS_Store b/templates/nutrinoweb/.DS_Store deleted file mode 100644 index 5008ddf..0000000 --- a/templates/nutrinoweb/.DS_Store +++ /dev/null Binary files differ diff --git a/templates/nutrinoweb/main.html b/templates/nutrinoweb/main.html index 8694901..20a8c9a 100644 --- a/templates/nutrinoweb/main.html +++ b/templates/nutrinoweb/main.html @@ -12,7 +12,7 @@ {% for cont in content %} -
+