From 97132ce88aac5c45e70217b7bff38331ae76bd5f Mon Sep 17 00:00:00 2001 From: Alexis Metaireau Date: Thu, 13 Oct 2011 21:27:56 +0200 Subject: [PATCH] Fix some problems related to postgresql and models --- .gitignore | 1 + README.rst | 12 +++++++++++- budget/default_settings.py | 7 ++++++- budget/models.py | 4 ++-- budget/run.py | 2 ++ requirements.txt | 4 ---- 6 files changed, 22 insertions(+), 8 deletions(-) delete mode 100644 requirements.txt diff --git a/.gitignore b/.gitignore index b034990..6eafef1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ budget/budget.db budget/memory +budget/settings.py *.pyc diff --git a/README.rst b/README.rst index 9b72a0c..6674096 100644 --- a/README.rst +++ b/README.rst @@ -12,10 +12,17 @@ To make it run, you just have to do something like:: $ virtualenv venv $ source venv/bin/activate - $ pip install -r requirements.txt + $ pip install -r budget/requirements.txt $ cd budget $ python run.py +It is also better to actually turn the debugging mode on when you're +developing. You can create a `settings.py` file in the `budget` directory, with +the following content:: + + DEBUG = True + SQLACHEMY_ECHO = DEBUG + Deploy it ========= @@ -33,6 +40,9 @@ To deploy it, I'm using gunicorn and supervisord:: Don't forget to set the right permission for your files ! +Also, create a `settings.py` file with the appropriate values if you need to +use a different database for instance. + How to contribute ================= diff --git a/budget/default_settings.py b/budget/default_settings.py index ff61010..111abf2 100644 --- a/budget/default_settings.py +++ b/budget/default_settings.py @@ -1,6 +1,11 @@ -DEBUG = True +DEBUG = False SQLALCHEMY_DATABASE_URI = 'sqlite:///budget.db' SQLACHEMY_ECHO = DEBUG SECRET_KEY = "tralala" DEFAULT_MAIL_SENDER = ("Budget manager", "budget@notmyidea.org") + +try: + from settings import * +except ImportError: + pass diff --git a/budget/models.py b/budget/models.py index 9d93d2f..f84194e 100644 --- a/budget/models.py +++ b/budget/models.py @@ -92,7 +92,7 @@ class Person(db.Model): _to_serialize = ("id", "name", "activated") id = db.Column(db.Integer, primary_key=True) - project_id = db.Column(db.Integer, db.ForeignKey("project.id")) + project_id = db.Column(db.String, db.ForeignKey("project.id")) bills = db.relationship("Bill", backref="payer") name = db.Column(db.UnicodeText) @@ -163,7 +163,7 @@ class Bill(db.Model): class Archive(db.Model): id = db.Column(db.Integer, primary_key=True) - project_id = db.Column(db.Integer, db.ForeignKey("project.id")) + project_id = db.Column(db.String, db.ForeignKey("project.id")) name = db.Column(db.UnicodeText) @property diff --git a/budget/run.py b/budget/run.py index e1711a7..39b297e 100644 --- a/budget/run.py +++ b/budget/run.py @@ -1,10 +1,12 @@ from web import main, db, mail from api import api +import os from flask import * app = Flask(__name__) app.config.from_object("default_settings") + app.register_blueprint(main) app.register_blueprint(api) diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index e254ef4..0000000 --- a/requirements.txt +++ /dev/null @@ -1,4 +0,0 @@ -flask -flask-wtf -flask-sqlalchemy -flask-mail