# website
The main website for MIT SciOly. The website stack is based off Django, and is meant to be hosted on SIPB's web scripts service on the scioly Athena locker. For access to the locker and for instructions on how to update the live webpage, please talk to members of the planning committee.

## Running the website locally (developer instructions)

To run the website locally, you need Python 2.7+ and Django version 1.6. <br>
This procedure outlines the easiest way to get up and running immediately, but your local development environment may vary.
1. Install Python 2.7+ and pip as appropriate on your system
2. Clone this repository by running `git clone git@github.mit.edu:SciOly/website.git`
3. Install the dependencies by running `pip install -r requirements.txt` from the base directory of this repository
    * This step may require admin or sudo privileges
    * Windows users may have to manually install some dependencies from .whl files
4. Use main/manage.py to issue commands to the server. 
    * To start the development server on a local port, navigate to the main/ folder and run `./manage.py runserver`. This should start the server on port 8000.
    * Navigate to localhost:8000 and you should see the homepage
    * As long as the development server is running, any changes you make to the files will be automatically reflected in the running version.
    * **IMPORTANT**: Do NOT use this command to start the server in the Athena locker. This is for development mode only and WILL NOT WORK to deploy the live version.

## Structure

This website follows the [recommended structure](http://www.revsys.com/blog/2014/nov/21/recommended-django-project-layout/) for a Django project.

Important notes are that there is a separate settings file in `main/main/settings/prod.py` which overrides some settings for the production server. Default settings are saved in `main/main/settings/__init__.py`. The most important settings here are the `TEMPLATES` variable, which defines where Django searches for `.html` files to render, and `STATIC_URL`, which defines where static files such as Javascript, CSS, images, and file uploads are stored. 

Almost all the actual pages are stored in `main/main/templates`: these are the files that should be changed to add, edit, or remove content.

## Adding Posts to the Homepage

The most common action you will need to do is add new posts. To add a new post to the homepage screen, navigate to `main/main/templates/recent_posts`. Add an html file with the content of your new post (do NOT include the title or date here). Open the `views.py` file, and locate the `index` method, which returns the homepage. Here, you should see a variable `post_list`, which defines the list of posts on the homepage and the order in which they appear. 

Insert your new post in the FIRST POSITION in the list by instantiating a new `Post` object: the title, anchor, and content are mandatory, while the date and update are optional but recommended. To obtain the content of your post, call `render_to_string('recent_posts/YOUR_NEW_POST.html')` as shown in the example.

**NOTE:** The names of the anchors in the post list must be unique.

To remove a post from the homepage, either delete or (preferably) comment out the corresponding entry in `post_list`

## Adding Entries to the Archive

After every tournament, please add an entry into the archive page at `main/main/template/archive.html`. Add a new `tournament_history` div and use the previous years as a template. Be sure that the relevant static content is also loaded on the server!

## Test Distribution and AWS credentials

This website is linked to the MIT SciOly AWS account to host the most recent tournament's tests.

In order to do this, two files must exist in the `keys`. The first is a file called `aws_keys`, which has the following three lines:
```
[PROFILE_NAME]
aws_access_key_id:ACCESS_KEY_ID
aws_secret_access_key:ACCESS_KEY_SECRET
```

Additionally, a file called `team_data.csv` must exist. This file is a csv with one line for each team, where the first column is the TEAM NUMBER and the second column is the TEAM PASSWORD to access their exam.

Neither of these files should EVER be added to the repo. Contact the webmaster/tournament director for copies of these files.

## TODOs (please keep me updated with every commit!)

* Styling of sidebar:
    * Submenus
    * On homepage, add list of recent posts/titles and links
* Document deployment and static file considerations


