You need native libraries for development dependencies of Python and Open LDAP because python-ldap
is a source distribution.
E.g. on Ubuntu:
sudo apt install build-essential python3-dev libldap2-dev libsasl2-dev
For other platforms see python-ldap docs
Alternatively, you may choose to use docker for development, in which case you don't need any other
dependencies than docker
(including docker-compose
) and make
.
We assume you've cloned the repository and want to get things going for the first time.
First, get all systems up and running:
make run
...this will build a docker image for the web app, and start all services (database, LDAP, web).
Then you need to get the initial database set up (mostly apply migrations).
make init-data
A couple of web apps you will be using:
- http://localhost:8000 - the shipanaro web application
- https://localhost:9876 - the PHP LDAP admin
Make yourself a user in LDAP:
- Log in to LDAP using these credentials:
- DN: cn=admin,dc=pirata,dc=cat
- Password: admin
- On the sidebar menu, click on
dc=pirata,dc=cat (1)
andCreate new entry here
. - Create a new
Generic Posix Group
namedmilitants
. Make sure you clickCreate
and thenCommit
. - Create a new
Generic User Account
. Make sure you chose the groupmilitants
, fill in all the data, click onCreate
and thenCommit
.
To check the contents of LDAP, you can run
make ldap-list
at any time.
You can now log in to shipanaro with the user you just created in LDAP. After a successful login, the user will be created in Django.
In order to get access to the Django admin site, you need to make this new user a superuser. Open the django shell using:
make shell
Within the shell:
from django.contrib.auth import get_user_model
User = get_user_model()
me = User.objects.get(username="txels")
me.is_staff = True
me.is_superuser = True
me.save()
You can now browse to http://localhost:8000/__capitania__/
which is the URL of
the django admin.
make test
apt install python3{,-pip}
pip3 install pipenv
cd $SHIPANARO_HOME
pipenv shell
pipenv install
...plus find a way to run postgres and LDAP. You can use docker for that ;)
Running things for the first time: since we include a custom user model in the humans
app, running
migrations is a bit tricky - doing it in two steps solves the issue:
(Otherwise you may get an error ValueError: Related model 'humans.user' cannot be resolved
)
In order to run Django's
manage.py
you will have to set a bunch of environment variables. Checkdocker-compose.yml
and theweb
service for reference.
pipenv shell
./manage.py migrate humans
./manage.py migrate
./manage.py createsuperuser
./manage.py runserver
On subsequent updates, you will only need to optionally run migrations (if models have changed), and run the server:
./manage.py migrate
./manage.py runserver
Browse to the admin page and log in with the superuser account you just created.
You can create a membership for your user account via the admin and browse to the profile page to edit your membership (this is the end user-facing page).
./manage.py collectstatic --no-input
yarn install
yarn build # for development
yarn dist # for production