themoonsheep / moonsheep

Moonsheep digitizes huge, messy paper and PDF archives through crowdsourcing and cutting edge technology.
http://moonsheep.org
GNU Affero General Public License v3.0
9 stars 3 forks source link

Structured data export #48

Closed pisipite closed 4 years ago

pisipite commented 7 years ago

to be able to export the data into different formats.

KrzysztofMadejski commented 7 years ago

Acceptance Criteria (may be a bit more loose):

KrzysztofMadejski commented 7 years ago

To implement REST API there are some libraries mentioned here: https://github.com/humiaozuzu/awesome-flask

KrzysztofMadejski commented 6 years ago

Ideally models should be registered with moonsheep and everything else should work out of the box.

from django.db import models
from moonsheep import register

@register.model(api=True, export_exclude_fields=[])
class Declaration(models.Model):
     ...

Effect:

All @register.model parameters should be optional.

KrzysztofMadejski commented 5 years ago

@catileptic I'm working on it now.

KrzysztofMadejski commented 4 years ago

Implementing an API for domain model is as simple as:

from moonsheep.api import AppApi
urlpatterns = [
    # url(r'^admin/', admin.site.urls),
    # url(r'^moonsheep/', include('moonsheep.urls')),
    # ...

    url(r'^api/opora/', include(AppApi('opora').urls)),
]

AppApi scans for all domain models defined in your app (passed in the param) and generates URL for each using Django Rest Framework. Rest Framework gives you a nice html interface to play with requests, discovery (listing of all endpoints). Using moonsheep-opora example: http://localhost:8000/api/opora/

api-generated