Skip to content

georga-app/georga-server-django

Repository files navigation

GeoRGA Server Django

What is this?

Install for development

Generate the certs for JWT ./scripts/generate_jwt_certs.sh

Execute the migration in your DB python manage.py migrate

Load the demo data python manage.py loaddata georga/fixtures/*

Start the server python manage.py runserver

You can login under /admin/ with the superadmin user [email protected] and georga

Further current testusers are (use password georga for all accounts):

Upgrade

  1. Unpin versions in requirements.txt

  2. Upgrade pip packages

    docker compose run --rm --service-ports server bash

    pip install --upgrade -r requirements.txt

  3. Test/Fix startup

    ./scripts/startup.sh

  4. Run/Fix tests

    ./manage.py test

  5. Pin new versions in requirements.txt

Contribute

Deploy

Test

Run django tests:

./manage.py test
./manage.py test --verbosity 2 --failfast --timing --keepdb --parallel auto
./manage.py test --verbosity 2 --keepdb --pdb

UML Diagram

docker compose run --rm --service-ports server bash
> apt-get update && apt-get install -y graphviz graphviz-dev
> pip install django-extensions pygraphviz
> vi settings.py
    INSTALLED_APPS = [
        [...]
        'django_extensions',
    ]
> ./manage.py graph_models -a \
    -X Mixin*,Abstract*,Group,Permission,ContentType,Session,LogEntry,Site \
    -o georga-uml.png

Use

GraphQL

When you open http://localhost:8000/graphql you will be presented with GraphiQL an in-browser GraphQL client. In GraphiQL you find the api docs in the top right corner.

Obtain an JWT

mutation {
  tokenAuth(email:"[email protected]", password:"georga") {
    payload
    refreshExpiresIn
    token
  }
}

Get all Users

To query data from the server you need to send an Header including your JWT with each request you make. In GraphiQL you can archive this by setting in the bottom left under Request Headers this:

{
  "Authorization": "JWT <YOUR_TOKEN>"
}

And then execute the query:

query {
  listPersons {
    edges {
      node {
        email
      }
    }
  }
}

Initial and demo data

For initial contents and/or demodata in the database, the yaml-files in folder fixtures can be used.

Load the demo data python manage.py loaddata georga/fixtures/*

For getting the password hash for a users' password, e.g. to insert it into demodata in fixtures/005_person.yaml the following custom management command can be used:

python manage.py get_pw_hash passwordstring

Test Subscriptions

Note: GraphiQL does not support subscriptions. Use another desktop client like Altair or Playground instead.

subscription {
  testSubscription() {
    event
  }
}

To test push messages, use the testSubscription mutation:

mutation {
  testSubscription(message="message") {
    response
  }
}

Relay

Relay is a specification to provide a consistent interface for global identification and pagination. See also graphene python docs.

In all graphql requests, the id field is masked by the relay global ID, which is a base64 coded string <model>:<uuid>.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages