Responsible for all the server-side logic on top of Django using GraphQL (through graphene-django) for the communication with queplanta/frontend.
Everything starts with a data revision control (db module), it's the base of everything. All data is controlled by it, all changes are recorded so we have a consistent history of what happened, who did it and from where the action came from. Since all data is public, so is all of it's history, no object is ever deleted from the database.
All model's should extend from db.models.DocumentBase
instead of django.db.models.Model
, see posts/models.py as an example.
The key difference from django's Model is that you should always pass request
as the first argument to save
and delete
methods.
It needs the request instance to store the authenticated user, the useragent and it's ip address so we can better audit changes in the future.
DucumentBase.objects
uses a custom manager that always returns the document's current state, to search on history use objects_revisions
instead, like:
>>> post = Post(body='some value')
>>> post.save(request=request)
>>> print(Post.objects.all().count())
1
>>> print(Post.objects_revisions.all().count())
1
>>> post.body = 'edited'
>>> post.save(request=request)
>>> print(Post.objects.all().count())
1
>>> print(Post.objects_revisions.all().count())
2
>>> post.delete(request=request)
>>> print(Post.objects.all().count())
0
>>> print(Post.objects_revisions.all().count())
3
To contribute to the project please go to CONTRIBUTING.md