diff --git a/README.rst b/README.rst index 42655afc..187a15cf 100644 --- a/README.rst +++ b/README.rst @@ -1,5 +1,7 @@ symposion_app -=============== +============= + +.. contents:: At this time, considerations have not been made to have the django project run without additional infrastructure. @@ -40,8 +42,36 @@ You may consider testing with testshib. Configure signing and encryption keys, and configure them in the settings.py -VirtualEnv -~~~~~~~~~~ +Running a dev instance in Docker +-------------------------------- + +Assuming you have docker installed and working on your machine:: + ./make_dev_container.sh + +will build you a container and run through the initial setup steps. +The last stage interactively creates a superuser account: you'll need +to interact with this for it to finish. + +Once this has completed, you can hit http://localhost:28000/admin to +log into the admin interface. Once you're logged in, +http://localhost:28000 will take you to the dashboard. + +Note that when you do this you're logged in as a superuser, so what +you see will be different from what a normal user will see. + +Making migrations +~~~~~~~~~~~~~~~~~ + +If you make changes to the data model, you'll need to run "manage.py +makemigrations" to create a matching migration file. If you're on a +mac, or a system without python3, this can be difficult. In such a +case, the ``makemigrations.sh`` script takes advantaged of a docker +container that's slightly modified, and runs the makemigration action +on the files in your working directory. + + +Running a dev instance in a VirtualEnv +-------------------------------------- Not all things are lovely, so we use constraints to force the versions we we wish for without having to do anything ugly. This may require a newer @@ -54,6 +84,9 @@ with a python3 interpreter. - ``source ./venv/bin/activate`` - ``pip install -c constraints.txt -r requirements.txt`` +Once your dev instance is up and running +---------------------------------------- + Pre-post-start configuration ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -72,6 +105,9 @@ Shut down and now run: Now you can run the system and see how it goes. +Admin tasks +----------- + Admin Credentials ~~~~~~~~~~~~~~~~~ diff --git a/docker/Dockerfile.makemigrations b/docker/Dockerfile.makemigrations new file mode 100644 index 00000000..a529085e --- /dev/null +++ b/docker/Dockerfile.makemigrations @@ -0,0 +1,22 @@ +FROM python:3.6 +VOLUME /source +COPY constraints.txt requirements.txt /setup/ +RUN set -ex \ + && buildDeps=' \ + libmysqlclient-dev \ + libffi-dev \ + libfreetype6-dev \ + libjpeg-dev \ + libwebp-dev \ + libpng-dev \ + liblcms2-dev \ + zlib1g-dev \ + libmemcached-dev \ + libsasl2-dev \ + ' \ + && apt-get update \ + && apt-get install -y git xmlsec1 libmysqlclient18 \ + && apt-get install -y $buildDeps --no-install-recommends +RUN pip install -c /setup/constraints.txt -r /setup/requirements.txt +CMD ["python","/source/manage.py", "makemigrations"] + diff --git a/docker/laptop-mode-env b/docker/laptop-mode-env new file mode 100644 index 00000000..6b174fa8 --- /dev/null +++ b/docker/laptop-mode-env @@ -0,0 +1,7 @@ +DJANGO_SECRET_KEY=5CEA51A5-A613-4AEF-A9FB-D0A57D77C13B +STRIPE_PUBLIC_KEY=5CEA51A5-A613-4AEF-A9FB-D0A57D77C13B +STRIPE_SECRET_KEY=5CEA51A5-A613-4AEF-A9FB-D0A57D77C13B +GCS_BUCKET=5CEA51A5-A613-4AEF-A9FB-D0A57D77C13B +GOOGLE_APPLICATION_CREDENTIALS=/dev/null +DATABASE_URL=sqlite:////tmp/symposion.sqlite +SYMPOSION_DEV_MODE=LAPTOP \ No newline at end of file diff --git a/make_dev_container.sh b/make_dev_container.sh new file mode 100755 index 00000000..9a2c33e0 --- /dev/null +++ b/make_dev_container.sh @@ -0,0 +1,25 @@ +#!/bin/bash -x + +CONTAINER_NAME=${1:-symposion_app} + +docker image build -f docker/Dockerfile -t ${CONTAINER_NAME} . +docker container stop symposion +docker container rm symposion +docker container create --env-file docker/laptop-mode-env -p 28000:8000 --name symposion ${CONTAINER_NAME} +docker container start symposion +docker exec symposion ./manage.py migrate +docker exec symposion ./manage.py loaddata ./fixtures/*.json +docker exec symposion ./manage.py create_review_permissions +docker exec -it symposion ./manage.py createsuperuser --username root --email root@example.com + +## The following sets up everything required for rego - tickets and +## t-shirts and stuff. At this stage, it's not something we want. + +#docker exec symposion ./manage.py populate_inventory + +set +x +echo "Now you can log into http://localhost:28000/admin" +echo "Username: root Password: the one you just typed twice" +echo "If you need to test as a non-admin user, create one at" +echo "http://localhost:28000/admin/auth/user/add/ - then log out" +echo "and log back in at http://localhost:28000" diff --git a/makemigrations.sh b/makemigrations.sh new file mode 100755 index 00000000..c59c5a49 --- /dev/null +++ b/makemigrations.sh @@ -0,0 +1,4 @@ +#!/bin/bash -x +docker image build -f docker/Dockerfile.makemigrations -t makemigrations . +docker run -it --env-file=docker/laptop-mode-env -v $(pwd):/source makemigrations + diff --git a/pinaxcon/devmode_settings.py b/pinaxcon/devmode_settings.py new file mode 100644 index 00000000..12bb7148 --- /dev/null +++ b/pinaxcon/devmode_settings.py @@ -0,0 +1,7 @@ +EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' +AUTHENTICATION_BACKENDS = [ + 'symposion.teams.backends.TeamPermissionsBackend', + 'django.contrib.auth.backends.ModelBackend', +] +LOGIN_URL='/accounts/login' + diff --git a/pinaxcon/settings.py b/pinaxcon/settings.py index 1bb945b5..4734f5fa 100644 --- a/pinaxcon/settings.py +++ b/pinaxcon/settings.py @@ -382,3 +382,8 @@ DEFAULT_FILE_STORAGE = 'gapc_storage.storage.GoogleCloudStorage' GAPC_STORAGE = { 'num_retries': 2, } + +DEV_MODE = os.environ.get("SYMPOSION_DEV_MODE", None) +if DEV_MODE and DEV_MODE == "LAPTOP": + print("ENABLING LAPTOP MODE") + from .devmode_settings import * diff --git a/pinaxcon/urls.py b/pinaxcon/urls.py index b21ec45f..35d5ce25 100644 --- a/pinaxcon/urls.py +++ b/pinaxcon/urls.py @@ -33,6 +33,9 @@ urlpatterns = [ if settings.DEBUG: import debug_toolbar urlpatterns.insert(0, url(r'^__debug__/', include(debug_toolbar.urls))) - +if settings.DEV_MODE: + from django.contrib.auth.views import login, logout + urlpatterns.insert(0, url(r'^accounts/logout', logout, {'template_name': 'admin/logout.html'})) + urlpatterns.insert(0, url(r'^accounts/login', login, {'template_name': 'admin/login.html'})) urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)