Giter Site home page Giter Site logo

backend's Introduction

queplanta's backend Build Status

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.