Hard Red Spring Wheat Dissemination, 2011
JavaScript Python HTML CSS ApacheConf

README

Prerequisites:
 Python:
  Download and Install Python, version 2.7.3 or greater. (http://www.python.org/download)
 Scipy:
  Download and install scipy, version 0.7 or greater. (http://www.scipy.org/download)
 Django:
  Ensure a previous version of Django is not installed; run 
   $ python -c  "import django; print django.get_version()"
  If so, remove it before continuing.
  Download Django (http://www.djangoproject.com/download/)
  Install Django (http://docs.djangoproject.com/en/dev/intro/install/)
  Verify Django is installed correctly:
   $ python -c  "import django; print django.get_version()"
   # should print the version number and exit w/o errors
   # Sep 2012: Verified the project is compatible with Django 1.4
   # Jun 2013: Verified the project is compatible with Django 1.5.1
 
Install to a fresh machine w/apache (Ubuntu/Debian syntax):
NOTE: Ensure a previous version of Django is not installed; run 
 $ python -c  "import django; print django.get_version()"
If so, remove it before continuing.

 $ sudo apt-get install git sqlite3 python-{sqlite,scipy} libapache2-mod-wsgi 
 $ git clone http://github.com/matti-kariluoma-ndsu/wheat-dissem.git
 $ cd wheat-dissem
 $ cat README # this file you are currently reading
 $ wget -O django-1.4.tar.gz http://djangoproject.com/download/1.4/tarball/
 $ tar xzf django-1.4.tar.gz
 $ cd Django-1.4
 $ sudo python setup.py install # should install to /usr/local/lib/python-*
 $ cd ..
 $ cat apache/httpd.conf >> /etc/apache2/httpd.conf # then fix any conflicts
 $ sudo /etc/init.d/apache2 reload # or restart

Database/Models development:
 Should you change one of the models, you must delete the old table
 for that model before your change will take effect.
  $ python manage.py dbshell
  > .schema
  # shows the database schema, look for your old table
  # i.e. if the model you changed was called "Location" in the directory
  # "variety_trials_data", then the table is probably called 
  # "variety_trials_data_location".
  > drop table variety_trials_data_location
  # Hit Ctrl+D to exit.
  
Command to put zipcode.csv into a compatible format for importing to the db:
  $ rm tmp.csv; i=1; while [ $i -lt 43205 ]; do sed -n -e 's/^/\"'"$i"'\",/' -e ''"$i"' p' zipcode.csv >> tmp.csv ;let i=i+1; done; sed 's/\"//g' tmp.csv > tmp2.csv; sed -n '/.*,.../ p' tmp2.csv > import.csv; rm tmp.csv tmp2.csv

To dump a table from the testing (sqlite) db:
  $ sqlite> .separator ";"
  $ sqlite> .mode list
  $ sqlite> .output your_filename.list
  $ sqlite> select * from your_table;
  $ sqlite> .exit
 
To populate a table in the testing (sqlite) db:
  $ sqlite> .separator ";"
  $ sqlite> .import import.list your_table
  $ sqlite> .exit

To add the lines from these files into psql:
	$ psql> \copy variety_trials_data_location from 'your_filename' with delimiter ';' null as ''

NOTE: Did a chmod a+w {variety_trials_website/, variety_trials_website/sqlite.db} , will need to be undone when we move on from sqlite.