All transactions endpoint
This commit is contained in:
parent
60c875c2a5
commit
887d2074dc
9 changed files with 36 additions and 0 deletions
0
nummi/api/__init__.py
Normal file
0
nummi/api/__init__.py
Normal file
3
nummi/api/admin.py
Normal file
3
nummi/api/admin.py
Normal file
|
@ -0,0 +1,3 @@
|
|||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
6
nummi/api/apps.py
Normal file
6
nummi/api/apps.py
Normal file
|
@ -0,0 +1,6 @@
|
|||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class ApiConfig(AppConfig):
|
||||
default_auto_field = "django.db.models.BigAutoField"
|
||||
name = "api"
|
0
nummi/api/migrations/__init__.py
Normal file
0
nummi/api/migrations/__init__.py
Normal file
3
nummi/api/models.py
Normal file
3
nummi/api/models.py
Normal file
|
@ -0,0 +1,3 @@
|
|||
from django.db import models
|
||||
|
||||
# Create your models here.
|
3
nummi/api/tests.py
Normal file
3
nummi/api/tests.py
Normal file
|
@ -0,0 +1,3 @@
|
|||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
7
nummi/api/urls.py
Normal file
7
nummi/api/urls.py
Normal file
|
@ -0,0 +1,7 @@
|
|||
from django.urls import path
|
||||
|
||||
from . import views
|
||||
|
||||
urlpatterns = [
|
||||
path("transactions", views.TransactionListView.as_view(), name="index"),
|
||||
]
|
13
nummi/api/views.py
Normal file
13
nummi/api/views.py
Normal file
|
@ -0,0 +1,13 @@
|
|||
from django.http import JsonResponse
|
||||
from django.views import View
|
||||
from django.views.generic.list import MultipleObjectMixin
|
||||
|
||||
from main.models import Transaction
|
||||
from main.views import UserMixin
|
||||
|
||||
|
||||
class TransactionListView(UserMixin, MultipleObjectMixin, View):
|
||||
model = Transaction
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
return JsonResponse({"transactions": list(self.get_queryset().values())})
|
|
@ -20,6 +20,7 @@ from django.urls import include, path
|
|||
urlpatterns = i18n_patterns(
|
||||
path("", include("main.urls")),
|
||||
path("plot/", include("plot.urls")),
|
||||
path("api/", include("api.urls")),
|
||||
path("admin/", admin.site.urls),
|
||||
prefix_default_language=False,
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue