A Durham Expunction and Restoration (DEAR) project for creating petition forms.
Begin by cloning the repository:
git clone git@github.com:deardurham/dear-petition.git
To run this on a Mac, use Docker for Mac.
Add desired environment variables to the .env
file before creating your virtual environment. You can copy .env.example
to get started. Create a .env
file with the following:
COMPOSE_FILE=local.yml
Build the project containers:
docker-compose build
Run the containers:
docker-compose up -d
Visit http://localhost:8000 in your browser.
Create a superuser:
docker-compose run --rm django python manage.py createsuperuser
Migrate DB:
docker-compose run --rm django python manage.py migrate
See detailed cookiecutter-django Docker documentation.
Run the setup_project.py script from the base directory, providing as a command line argument the directory to the related ciprs-reader project. This will set up the project in your environment.
Developing inside a virtual environment is recommended.
On Mac run the following command to set up a virtual environment:
brew install pipenv
pipenv shell
pip install -r requirements/base.txt
On Linux run the following command to set up a virtual environment:
sudo yum install python-tools
pip3 install pipenv
pipenv shell
pip install -r requirements/base.txt
While inside of the pipenv run the setup_project.py script from the base directory, providing as a command line argument the directory to the related ciprs-reader project. This will set up the project in your environment.
python3 setup-project.py <path-to-ciprs-reader>
Additional Pipenv Notes: To exit the pip environment:
(dear-petition) bash-3.2$ exit
exit
bash-3.2$
To delete the pipenv environment:
bash-3.2$ pipenv --rm
Removing virtualenv (/Users/user/.local/share/virtualenvs/dear-petition-fJpn7FEC)…
Moved to settings.
-
To create a normal user account, just go to Sign Up and fill out the form. Once you submit it, you'll see a "Verify Your E-mail Address" page. Go to your console to see a simulated email verification message. Copy the link into your browser. Now the user's email should be verified and ready to go.
-
To create an superuser account, use this command:
$ python manage.py createsuperuser
For convenience, you can keep your normal user logged in on Chrome and your superuser logged in on Firefox (or similar), so that you can see how the site behaves for both kinds of users.
Running type checks with mypy:
$ mypy dear_petition
To run the tests, check your test coverage, and generate an HTML coverage report:
$ coverage run -m pytest
$ coverage html
$ open htmlcov/index.html
$ pytest
Moved to Live reloading and SASS compilation.
This app comes with Celery.
To run a celery worker:
cd dear_petition
celery -A dear_petition.taskapp worker -l info
Please note: For Celery's import magic to work, it is important where the celery commands are run. If you are in the same folder with manage.py, you should be right.
In development, it is often nice to be able to see emails that are being sent from your application. For that reason local SMTP server MailHog with a web interface is available as docker container.
Container mailhog will start automatically when you will run all docker containers. Please check cookiecutter-django Docker documentation for more details how to start all containers.
With MailHog running, to view messages that are sent by your
application, open your browser and go to http://127.0.0.1:8025
Sentry is an error logging aggregator service. You can sign up for a free account at https://sentry.io/signup/?code=cookiecutter or download and host it yourself. The system is setup with reasonable defaults, including 404 logging and integration with the WSGI application.
You must set the DSN url in production.
The following details how to deploy this application.
See detailed cookiecutter-django Heroku documentation.