A cloud profile server for Geopaparazzi based on the awesome Cookiecutter-Django
Clone or download
Pull request Compare This branch is 33 commits ahead, 290 commits behind pydanny:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.github
docs
hooks
tests
{{cookiecutter.project_slug}}
.editorconfig
.gitattributes
.gitignore
.travis.yml
CHANGELOG.md
CONTRIBUTING.rst
CONTRIBUTORS.rst
LICENSE
README.rst
cookiecutter.json
pytest.ini
requirements.txt
setup.py
tox.ini

README.rst

Cookiecutter Geopaparazzi Reference Server

Based on Cookiecutter-Django, Cookiecutter Geopaparazzi Reference Server is a framework for quickly jumpstarting production-ready web servers to manage Geopaparazzi data.

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
  • User 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 (we use "grs" as an example below, but you can use choose your own directory name)

$ mkdir /grs
$ cd /grs
  1. Install cookiecutter
$ pip install "cookiecutter>=1.4.0"
  1. Use cookiecutter to get the latest source code from the geopaparazzi reference server repository
$ 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. Change directory 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. Setup the database and static assets, 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. No other values (e.g. path=. etc) need to be changed.

$ pip install httpie
$ 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.