- Installation
- Usage : public endpoints
- Usage: frontend pages
PostgreSQL server needs to be installed and started.
On Ubuntu, this means installing the following packages:
apt install postgresql-9.6 postgis
On Mac OS, this can be installed with brew with the following commands :
brew install postgresql postgis
For development, you need to create a database and a role with owner
rights, and add the postgis
extension to the database.
sudo -u postgres psql
# the following commmands should be typed inside psql
CREATE ROLE api WITH PASSWORD 'password';
CREATE DATABASE api WITH owner api;
\connect api
CREATE EXTENSION postgis;
For testing, the api
role need to be a superuser to be able to create
a new test database with the postgis
extension.
sudo -u postgres psql
# the following commmands should be typed inside psql
ALTER ROLE api WITH superuser;
Python 3.6 is recommended.
To install Python dependencies, run :
pip install -r requirements.txt
To run the tests :
coverage run --source='.' manage.py test
in the src
directory.
Run:
./manage.py createsuperperson
Open a django console with:
./manage.py shell
Then execute the following commands:
from clients.models import Client
c = Client.objects.create(label='client_login', name='Nom du client')
c.role.set_password('client_password')
c.role.is_superuser = True
c.role.save()
You can load data in the database. All role passwords are 'incredible password'.s
./manage.py loaddata fixtures.json
To update and commit it in a git diff readable way, use the following command :
./manage.py dumpdata authentication clients events groups front people polls
The list of all published, upcoming events (paginated).
To get the complete list in one request, use /events/summary
.
The list of all calendars. Events are part of one calendar.
The list of all published groups.
To get the complete list in one request, use /groups/summary
.
Profile of the authenticated user.
Each resource expose a series of filter that you can use to fetch a subset of the resource collection.
Filters can be passed as query parameters, eg https://api.lafranceinsoumise.fr/legacy/groups/?contact_email=example@example.com
contact_email
nb_path
: path on legacy NationBuilder websiteclose_to
: find events close to a given location. Value must be a JSON Object withmax_distance
: distance in meterscoordinates
: array of coordinates [Longitude, Latitude]
order_by_distance_to
: list all events, but by ordering them by distance to JSON array of [Longitude, Latitude]. By getting the first page, you get the 25 closest events.
after
: ISO 8601 Datetime, get only events finishing after this datebefore
: ISO 8601 Datetime, get only events starting before this datecalendar
: String, get only events belonging to a specific calendar
An optional HTML frontend is available for the API.
The following additional environment variables are used to configure the HTML frontend.
ENABLE_FRONT
when set toyes
enable the front pages routes. Leave unset, empty or set tono
to disable it.OAUTH_CLIENT_ID
andOAUTH_CLIENT_SECRET
are the id and secret of the client that should be used to authenticate to the OAUTH provider.OAUTH_AUTHORIZATION_URL
andOAUTH_TOKEN_URL
are the URIs for the oauth authorization endpoint to which the end user should first be redirected, and of the token exchange endpoint, at which the authorization code can be exchanged for the access token.OAUTH_REDIRECT_DOMAIN
is the base domain that is to be used in the uri redirection from the OAUTH provider back to the front pages serverOAUTH_LOGOFF_URL
is the URI to which the end user should be sent to disconnect her.
- An event management section, that a user can visit to see the events she organised, and those she RSVPed to. Events she organised may be modified through this section
- A support group management section that allows the user to see the list of groups she is part of, and to modify those of which she is a group manager.