From f6c79abeaedfeeeac92039e47e3fc875aca9195b Mon Sep 17 00:00:00 2001 From: Felix Sargent Date: Wed, 22 Jan 2025 10:49:08 +0000 Subject: [PATCH] Fixed README.md instructions for initial setup. --- .python-version | 1 + README.md | 42 +++++++++++++++++++++++++------------- approval_polls/settings.py | 2 +- docker-compose.yml | 6 +++--- 4 files changed, 33 insertions(+), 18 deletions(-) create mode 100644 .python-version diff --git a/.python-version b/.python-version new file mode 100644 index 0000000..d4b278f --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.11.7 diff --git a/README.md b/README.md index c236f06..4a86943 100644 --- a/README.md +++ b/README.md @@ -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 @@ -23,32 +24,45 @@ open http://localhost:8000 2. Clone this repository. `git clone git@github.com: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: -`:` + `:` -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 @@ -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 @@ -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! diff --git a/approval_polls/settings.py b/approval_polls/settings.py index bf4ebaa..df8490e 100644 --- a/approval_polls/settings.py +++ b/approval_polls/settings.py @@ -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/ diff --git a/docker-compose.yml b/docker-compose.yml index ea48494..7db02e8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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