Skip to content
This repository has been archived by the owner on Feb 10, 2023. It is now read-only.

mehalsgmues/MAG-Web

Repository files navigation

ortoloco.ch

Build Status

die regionale gartenkooperative

We implement a "specific" web solution to organize all the work on a farm as a group of about ~400 persons.

Setting up locally

Following instructions work for MacOS.

Set your environment variables

This should do it for your local setup:

export ORTOLOCO_DATABASE_ENGINE=django.db.backends.sqlite3
export ORTOLOCO_DATABASE_NAME=db.sqlite
export ORTOLOCO_EMAIL_HOST=smtp.gmail.com
export ORTOLOCO_EMAIL_PASSWORD=YOUR_GMAIL_APP_PASSWORD
export ORTOLOCO_EMAIL_USER=YOUR_EMAIL@gmail.com

Installing requirements

Clone repository on you machine and enter the directory

cd ortoloco

Now start installing

sudo easy_install pip
sudo pip install virtualenv
virtualenv --distribute venv
source ./venv/bin/activate
pip install --upgrade -r requirements.txt

NOTE: All requirements are not easily installable on Mac OS X. If you encounter some issues (i.e. EnvironmentError: mysql_config not found or pg_config executable not found) you might run instead:

pip install --upgrade -r requirements-mac.txt

wich removes following packages from the requirements:

MySQL-python==1.2.5
django-toolbelt==0.0.1
psycopg2==2.5.1

NOTE: You might be able to install "brew install mysql" and "brew install postgresql" and "brew install pg" instead (before)

Create DB from scratch

In ortoloco/settings.py, comment out all non-django apps (loco_app ,my_ortoloco,static_ortoloco, south, photologue). Then run following command:

./manage.py syncdb

Reactivate the outcommented apps above and run following commands:

./manage.py syncdb
./manage.py migrate

You might be guided through these steps with make createdb.

Backup and restore local dev database

With make savedb you can easily make a snapshot of the current local database file (if using SQLite), and restore it (i.e. the last db snapshot file) with make restoredb.

You might want to look at the Makefile for more details.

Create new migration

When the database structure changes, you must perform a new migration:

./manage.py schemamigration loco_app --auto
./manage.py migrate loco_app

You might be guided through these steps with make migratedb.

Test server

Run following command to launch a server on http://localhost:8000:

./manage.py runserver

You might run this with make, which will additionally open the URL on your browser.

Create admin user

Use following command to create a super user, if not yet available:

manage.py createsuperuser

Create loco for admin user

The first time you try to login with the initial admin user you will encouter an error like User has no Loco. To create a Loco for this user, you have to activate a secret 😄 URL in url.py and call it from the browser:

Afterwards, you might have to logout with following URL:

Change password for super user ('admin' is the username)

./manage.py changepassword admin

How to migrate from mysql to postgres-sql

First read this: https://github.com/lanyrd/mysql-postgresql-converter

Then import the data into the heroku-db (find the values here: https://postgres.heroku.com/databases/ortoloco-database) psql -U -d -h -f path/to/postgres.sql

How to move the live-data to dev

Between Heroku apps

SOURCE_APP=ortoloco
TARGET_APP=ortoloco-dev
heroku pg:backups restore $(heroku pg:backups public-url --app $SOURCE_APP) DATABASE_URL --app $TARGET_APP

See: Importing and Exporting Heroku Postgres Databases with PG Backups

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published