Skip to content

A cloud profile server for Geopaparazzi based on the awesome Cookiecutter-Django

License

Notifications You must be signed in to change notification settings

brentfraser/cookiecutter-geopaparazzi-server

 
 

Repository files navigation

Cookiecutter Geopaparazzi Reference Server

Based on Cookiecutter-Django, Cookiecutter Geopaparazzi Reference Server is a framework for jumpstarting production-ready Geopaparazzi cloud projects quickly.

Features

  • For Django 2.0
  • Works with Python 3.6
  • Twitter Bootstrap v4.0.0 (maintained Foundation fork also available)
  • 12-Factor based settings via django-environ
  • Secure by default. We believe in SSL.
  • Optimized development and production settings
  • Registration via django-allauth
  • Comes with custom user model ready to go
  • Grunt build for compass and livereload
  • Send emails via Anymail (using Mailgun by default, but switchable)
  • Media storage using Amazon S3 or DigitalOcean Spaces
  • Docker support using docker-compose for development and production (using Caddy with LetsEncrypt support)
  • Procfile for deploying to Heroku
  • Instructions for deploying to PythonAnywhere
  • Run tests with unittest or py.test
  • Uses PostGIS/PostgreSQL for spatial database functionality

Optional Integrations

These features can be enabled during initial project setup.

  • Serve static files from Amazon S3 or Whitenoise
  • Configuration for Celery
  • Integration with MailHog for local email testing
  • Integration with Sentry for error logging

Prerequisites

Usage

Here are the basic instructions for setting up a local development system, discussed in more detail in this blog post. Before you begin, open a console window and create a directory to hold the project source code and demo data you will download

$ mkdir /grs
$ cd /grs
  1. Install cookiecutter
$ pip install "cookiecutter>=1.4.0"
  1. Run it against the latest repo for the reference server
$ cookiecutter https://github.com/geoanalytic/cookiecutter-geopaparazzi-server

You will be asked a number of questions, some of which are only applicable to production systems. For development purposes, you should enter ‘y’ to the following choices (these should be the defaults):

  • docker
  • celery
  • whitenoise
  1. CD into the directory created by the cookiecutter process and then build and run the containers:
$ cd geopaparazzi_reference_server
$ docker-compose -f local.yml build
$ docker-compose -f local.yml up -d
$ docker-compose -f local.yml ps

If everything is working, the last command should result in a report like this:

                    Name                                  Command               State           Ports
--------------------------------------------------------------------------------------------------------------
geopaparazzi_reference_server_celerybeat_1     /entrypoint /start-celerybeat    Up
geopaparazzi_reference_server_celeryworker_1   /entrypoint /start-celeryw ...   Up
geopaparazzi_reference_server_django_1         /entrypoint /start               Up      0.0.0.0:8000->8000/tcp
geopaparazzi_reference_server_flower_1         /entrypoint /start-flower        Up      0.0.0.0:5555->5555/tcp
geopaparazzi_reference_server_postgres_1       /bin/sh -c /docker-entrypo ...   Up      5432/tcp
geopaparazzi_reference_server_redis_1          docker-entrypoint.sh redis ...   Up      6379/tcp

What you see is six containers running within an isolated network that allows the containers to communicate among themselves. Only the django and flower containers are open to outside connections. Each container does one thing:

  • django … provides the python based web framework
  • postgres … provides a PostgreSQL/PostGIS database
  • redis … provides a message broker and in memory cache for performance and to support celery tasks
  • celeryworker … provides an on demand asysnchronous processing capability
  • celerybeat … provides scheduled background processing capability
  • flower … provides a real-time monitoring tool for the celery tasks
  1. Get the database and static assets set up, create a superuser
$ docker-compose -f local.yml run --rm django python manage.py collectstatic
$ docker-compose -f local.yml run --rm django python manage.py createsuperuser

The second command will prompt you to enter a username, email and password for the superuser. You will need those credentials to access the system so write them down!

  1. Run the tests
$ docker-compose -f local.yml run --rm django py.test

Starting geotabloid_postgres_1 ... done
PostgreSQL is available
Test session starts (platform: linux, Python 3.6.5, pytest 3.8.0, pytest-sugar 0.9.1)
Django settings: config.settings.test (from ini file)
rootdir: /app, inifile: pytest.ini
plugins: sugar-0.9.1, django-3.4.3, celery-4.2.1

    geotabloid/users/tests/test_forms.py ✓                  2% ▎
    geotabloid/users/tests/test_models.py ✓                 4% ▍
    geotabloid/users/tests/test_urls.py ✓✓✓✓               11% █▏
    geotabloid/users/tests/test_views.py ✓✓✓               16% █▋
    gp_projects/tests/test_models.py ✓✓✓                   21% ██▏
    profiles/tests/test_api.py ✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓     61% ██████▎
    profiles/tests/test_models.py ✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓  100% ██████████

Results (6.31s):
      57 passed
  1. Now load the demo data

Download the demo data from here. Note that you need to install Httpie and edit the load_local.sh file, replacing user:password with the values you provided for the superuser and your server IP address for the uploadurl entries.

$ cd location/of/demo/data
$ ./load_local.sh

Next, point your browser at http://localhost:8000/admin, login with your superuser credentials and edit the Profiles and create Profilesets for your superuser as described in the original post.

  1. Connect Geopaparazzi to your server

You will need to figure out the IP address of the computer the server is running on. On Linux, use the command hostname -I. On Windows, the command ipconfig should work. On your mobile, start the app and select the settings (gear) icon, then select Cloud Server Settings and fill in the user, password and Cloud Profiles URL as shown:

  1. Download the cloud profiles, collect some tracks and notes, then upload your user project data.

Cookiecutter-Django Stuff

As noted, this project is derived from the Cookiecutter-Django You can find lots of helpful documentation there, here are some of the essential links:

"Your Stuff"

Scattered throughout the Python and HTML of this project are places marked with "your stuff". This is where third-party libraries are to be integrated with your project.

About

A cloud profile server for Geopaparazzi based on the awesome Cookiecutter-Django

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 59.3%
  • HTML 17.3%
  • Shell 8.9%
  • JavaScript 8.1%
  • Makefile 2.1%
  • Dockerfile 2.0%
  • Other 2.3%