Deme Training Guide

Noam, Chris and Mike can you guys add and edit as you see fit. This is my impression as of right now.

How to make a new item:

First decide where you want to put this. Modules or in the Core (cms). If you do it in the core that means that everyone will be able to use this item when they download the basic django installation.


There are 3 steps to making a new item: Model, View, Template.

Model:
This is found in models.py
The model is the basic architecture of the item. Here we define what information the item will contain.
Figure out what your new item will extend. What functionality do you want.
Two sections:
Setup: This is usually boilerplate so just look at a different item and see what they put for it.
Fields: This is where we look to see what the user fills in about the item. There are many types of fields like Dates, Texts, numbers etc... so look to another item and also at the django docs to see what fields you want.
Also there can be different functions you might want.

Views:
This is found in views.py
The Viewer is what we can do with the item.
Many viewers only need two lines of code:
accepted_item_type = ...
viewer_name = '...'

If we want to be able to add, delete, edit, or most importantly show, using something other than the generic item viewer then we will need to write a different function.

If you are extending an existing viewer chances are you can copy and paste (with minor changes) to make the viewer for your new item.

Template:
This can be found in the templates folder usually named show.html
Here we write out the HTML, CSS, and Javascript for how we want our item to show up. You can write it out like basic HTML, but with the added feature of using template tags. These give you logic and references to the item's fields found in the model.
Logic is used with brackets like so: {%ifequal a b %}. You must also end the if statement like so {% endifequal %}
Model variables are referred to like so: {{event.name}}. You can enter these anywhere and it will show up in your browser as the text that the user entered for that specific field.

Now you should be able to go into your terminal and fire up the server by first syncing by writing "script/reset_db.sh" and then run the server by running "./manage.py runserver" It will give you a link that you paste into your browser so that you can run deme locally on your computer.




Git-tyup!

How to deal with git.
To update your files run "git pull"
Whenever you want to commit a change here's what you do
git pull
python manage.py migrate
git status (shows what's different)
git add <files you want to commit>
git commit
git push

Now if you want them to show up on the Deme site you have to ssh into deme. You may need somebody to add you as a user.

ssh <user>@deme.stanford.edu

Then pull from git, update the homepage of Deme to display the current commit number, and you're golden

cd /var/www/deme/deme_django/
sudo -u www-data git pull
Now git the hell outta there with "exit"

You might also need to restart apache if the server is down by going into deme typing: sudo /etc/init.d/apache2 restart




For Internet Explorer users: Click on the Tools menu, located at the top of your browser window. When the drop-down menu appears, select the option labeled Full Screen.

For Chrome users:Click on the Chrome "wrench" icon, located in the upper right hand corner of your browser window. When the drop-down menu appears, select the choice labeled Full Screen.

For Firefox user:Click on the View menu, located at the top of your browser window. When the drop-down menu appears, select the option labeled Full Screen.

For Safari users: Safari currently does not support the ability to go fullscreen.