Skip to content

Commit

Permalink
Fixed README.md instructions for initial setup.
Browse files Browse the repository at this point in the history
  • Loading branch information
fsargent committed Jan 22, 2025
1 parent 2cfae99 commit f6c79ab
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 18 deletions.
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.11.7
42 changes: 28 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ The project, taken as a whole, will serve these approval-based webpolls, or the
## Development Setup

```sh
cp .env.dist .env
docker-compose up
docker-compose exec web python manage.py migrate
docker-compose exec web python manage.py test
Expand All @@ -23,32 +24,45 @@ open http://localhost:8000

2. Clone this repository. `git clone [email protected]:electionscience/vote.electionscience.org.git`.

Configure your environment with .env file. You can copy the .env.dist file and fill in the required values.
Configure your environment with .env file. You can copy the .env.dist file and fill in the required values.

1. Before you run the Django server for the first time, you'll need to create the database tables:
`cp .env.dist .env`

`python manage.py syncdb`
3. Install dependencies

```shell
brew install pyenv poetry
pyenv install 3.11.7
pyenv local 3.11.7
pyenv init
poetry install
eval $(poetry env activate)
```

4. Before you run the Django server for the first time, you'll need to create the database tables:

`python manage.py migrate`

This will ask you to create a superuser account, which is necessary if you want to use the Django admin interface.
But also, you'll need a user account in order to create polls in the system, and it's easiest to do that here.
(If you don't create an account here, you'll have to mess around copying urls from the server output to fake confirming an email address in order to create a user account later... so just do it now.)

2. Start the Django server:
5. Start the Django server:

`python manage.py runserver`
`python manage.py runserver`

8. Change the domain name of the site `example.com` to `yourdomainname` in the admin panel (`https://localhost:8000/admin`) so that the activation emails have the correct url.
6. Change the domain name of the site `example.com` to `yourdomainname` in the admin panel (`https://localhost:8000/admin`) so that the activation emails have the correct url.

9. Finally, see how it looks. In your favorite browser, go to the link:
7. Finally, see how it looks. In your favorite browser, go to the link:

`<your domain name>:<port>`
`<your domain name>:<port>`

If you're running the server locally then this would be
If you're running the server locally then this would be

`http://localhost:8000/`
`http://localhost:8000/`

There won't be any polls yet, but you can login with the superuser account you created, or register a new one.
Then you should be able to create polls, vote in them, and see the results.
There won't be any polls yet, but you can login with the superuser account you created, or register a new one.
Then you should be able to create polls, vote in them, and see the results.

## Contributing

Expand All @@ -64,7 +78,7 @@ All contributions are welcome.

## Coding Style

We use Trunk.io to enforce a consistent coding style. You can install it by running `npm install -g @trunk/cli` and then running `trunk check` in the root of the project.
We use [Trunk](trunk.io) to enforce a consistent coding style. You can install it by running `npm install -g @trunk/cli` and then running `trunk check` in the root of the project.

## Testing the code

Expand All @@ -80,4 +94,4 @@ This repo is deployed in production on `fly.io` from [Felix Sargent](felix@elect

Deployment is as easy as running `fly deploy` from the root of the project, if you have it configured.

Ideally, this automatically deploys on push to the Github `main` branch!
This automatically deploys to production on push to the Github `main` branch!
2 changes: 1 addition & 1 deletion approval_polls/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
environ.Env.read_env(os.path.join(os.path.dirname(BASE_DIR), ".env"))
DEBUG = env("DEBUG")
print(DEBUG)
print("Debug?: ", DEBUG)

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/
Expand Down
6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ services:
build: .
entrypoint: gunicorn
command:
- "approval_polls.wsgi:application"
- "-b 0.0.0.0:8000"
- approval_polls.wsgi:application
- -b 0.0.0.0:8000
ports:
- "8000:8000"
- 8000:8000
volumes:
- ./:/code
- ./db.sqlite3:/data/db.sqlite3

0 comments on commit f6c79ab

Please sign in to comment.