Merge pull request #4 in QRTR/qrtr-services from QRTR-110 to master
* commit 'd00fb4b5a15803c23bd0dd6586a9f88404dfe2a7': [QRTR-110] Added Filtering options, and adjusted for Django 3.2 updates. Updates to new slice backend, and updated access permissions. migration fixing typo on slice fk Fixed transactionserializer invalid field references.
This commit is contained in:
commit
d43d9b4c31
@ -113,7 +113,9 @@ class InstitutionSerializer(serializers.HyperlinkedModelSerializer):
|
||||
class TransactionSerializer(serializers.HyperlinkedModelSerializer):
|
||||
class Meta:
|
||||
model = Transaction
|
||||
fields = ['url', 'datetime', 'Bank', 'details']
|
||||
fields = ['url', 'authorized_date',
|
||||
'bank', 'name','details','slice','trans_id',
|
||||
'updated_at','created_at']
|
||||
|
||||
|
||||
class SliceSerializer(serializers.HyperlinkedModelSerializer):
|
||||
|
||||
@ -47,6 +47,7 @@ INSTALLED_APPS = [
|
||||
'qrtr_account',
|
||||
'corsheaders',
|
||||
'rest_framework_simplejwt.token_blacklist',
|
||||
'django_filters',
|
||||
]
|
||||
|
||||
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
|
||||
@ -92,6 +93,7 @@ TEMPLATES = [
|
||||
|
||||
WSGI_APPLICATION = 'core.wsgi.application'
|
||||
|
||||
DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
|
||||
|
||||
# Database
|
||||
# https://docs.djangoproject.com/en/2.2/ref/settings/#databases
|
||||
@ -102,7 +104,10 @@ REST_FRAMEWORK = {
|
||||
'rest_framework.authentication.SessionAuthentication',
|
||||
'rest_framework.authentication.TokenAuthentication',
|
||||
'dj_rest_auth.jwt_auth.JWTCookieAuthentication'
|
||||
]
|
||||
],
|
||||
'DEFAULT_FILTER_BACKENDS': (
|
||||
'django_filters.rest_framework.DjangoFilterBackend',
|
||||
)
|
||||
}
|
||||
|
||||
REST_USE_JWT = True
|
||||
|
||||
@ -2,4 +2,4 @@ from django.apps import AppConfig
|
||||
|
||||
|
||||
class QrtrAccountConfig(AppConfig):
|
||||
name = 'QRTR Account'
|
||||
name = 'qrtr_account'
|
||||
|
||||
18
qrtr_account/migrations/0008_auto_20210211_0136.py
Normal file
18
qrtr_account/migrations/0008_auto_20210211_0136.py
Normal file
@ -0,0 +1,18 @@
|
||||
# Generated by Django 3.1.3 on 2021-02-11 01:36
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('qrtr_account', '0007_auto_20210128_0325'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RenameField(
|
||||
model_name='transaction',
|
||||
old_name='Slice',
|
||||
new_name='slice',
|
||||
),
|
||||
]
|
||||
20
qrtr_account/migrations/0009_auto_20210211_0202.py
Normal file
20
qrtr_account/migrations/0009_auto_20210211_0202.py
Normal file
@ -0,0 +1,20 @@
|
||||
# Generated by Django 3.1.3 on 2021-02-11 02:02
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('contenttypes', '0002_remove_content_type_name'),
|
||||
('qrtr_account', '0008_auto_20210211_0136'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='slice',
|
||||
name='parent_type',
|
||||
field=models.ForeignKey(limit_choices_to=models.Q(models.Q(('app_label', 'qrtr_account'), ('model', 'bank')), models.Q(('app_label', 'qrtr_account'), ('model', 'slice')), _connector='OR'), null=True, on_delete=django.db.models.deletion.CASCADE, to='contenttypes.contenttype'),
|
||||
),
|
||||
]
|
||||
20
qrtr_account/migrations/0010_auto_20210211_0202.py
Normal file
20
qrtr_account/migrations/0010_auto_20210211_0202.py
Normal file
@ -0,0 +1,20 @@
|
||||
# Generated by Django 3.1.3 on 2021-02-11 02:02
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('contenttypes', '0002_remove_content_type_name'),
|
||||
('qrtr_account', '0009_auto_20210211_0202'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='slice',
|
||||
name='parent_type',
|
||||
field=models.ForeignKey(blank=True, limit_choices_to=models.Q(models.Q(('app_label', 'qrtr_account'), ('model', 'bank')), models.Q(('app_label', 'qrtr_account'), ('model', 'slice')), _connector='OR'), null=True, on_delete=django.db.models.deletion.CASCADE, to='contenttypes.contenttype'),
|
||||
),
|
||||
]
|
||||
18
qrtr_account/migrations/0011_auto_20210211_0203.py
Normal file
18
qrtr_account/migrations/0011_auto_20210211_0203.py
Normal file
@ -0,0 +1,18 @@
|
||||
# Generated by Django 3.1.3 on 2021-02-11 02:03
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('qrtr_account', '0010_auto_20210211_0202'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='slice',
|
||||
name='parent_id',
|
||||
field=models.PositiveIntegerField(null=True),
|
||||
),
|
||||
]
|
||||
18
qrtr_account/migrations/0012_slice_description.py
Normal file
18
qrtr_account/migrations/0012_slice_description.py
Normal file
@ -0,0 +1,18 @@
|
||||
# Generated by Django 3.1.3 on 2021-02-11 02:35
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('qrtr_account', '0011_auto_20210211_0203'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='slice',
|
||||
name='description',
|
||||
field=models.TextField(blank=True, max_length=255, null=True),
|
||||
),
|
||||
]
|
||||
@ -60,6 +60,7 @@ class Slice(models.Model):
|
||||
name = models.CharField(max_length=250)
|
||||
icon = models.CharField(max_length=250)
|
||||
budget = models.DecimalField(decimal_places=3, max_digits=100)
|
||||
description = models.TextField(max_length=255, null=True, blank=True)
|
||||
avail_parents = models.Q(
|
||||
app_label='qrtr_account',
|
||||
model='bank') | models.Q(
|
||||
@ -68,8 +69,8 @@ class Slice(models.Model):
|
||||
parent_type = models.ForeignKey(
|
||||
ContentType,
|
||||
limit_choices_to=avail_parents,
|
||||
on_delete=models.CASCADE)
|
||||
parent_id = models.PositiveIntegerField()
|
||||
on_delete=models.CASCADE, null=True, blank=True)
|
||||
parent_id = models.PositiveIntegerField(null=True)
|
||||
is_unsliced = models.BooleanField(default=False)
|
||||
slice_of = GenericForeignKey('parent_type', 'parent_id')
|
||||
|
||||
@ -117,7 +118,7 @@ class Transaction(models.Model):
|
||||
related_name='transactions')
|
||||
name = models.CharField(max_length=255)
|
||||
details = models.JSONField()
|
||||
Slice = models.ForeignKey(Slice, on_delete=models.SET_NULL, null=True)
|
||||
slice = models.ForeignKey(Slice, on_delete=models.SET_NULL, null=True)
|
||||
trans_id = models.CharField(max_length=255)
|
||||
updated_at = models.DateTimeField(auto_now=True)
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
from django.shortcuts import render
|
||||
from rest_framework import viewsets, mixins
|
||||
from .models import Account, Bank, Institution, Transaction, Slice, Rule
|
||||
from rest_framework.permissions import IsAuthenticated
|
||||
from connection.models import Connection, ConnectionType
|
||||
from api.serializers import (AccountReadSerializer, AccountWriteSerializer,
|
||||
BankSerializer, BankSerializerPOST,
|
||||
@ -46,6 +47,13 @@ class BankViewSet(viewsets.ModelViewSet):
|
||||
return BankSerializer
|
||||
|
||||
|
||||
class SliceViewSet(viewsets.ModelViewSet):
|
||||
"""API endpoint that allows Banks to be viewed.
|
||||
"""
|
||||
queryset = Slice.objects.all()
|
||||
serializer_class = SliceSerializer
|
||||
|
||||
|
||||
class InstitutionViewSet(viewsets.ReadOnlyModelViewSet):
|
||||
"""API endpoint that allows Banks to be viewed.
|
||||
"""
|
||||
@ -53,18 +61,18 @@ class InstitutionViewSet(viewsets.ReadOnlyModelViewSet):
|
||||
serializer_class = InstitutionSerializer
|
||||
|
||||
|
||||
class TransactionViewSet(viewsets.ReadOnlyModelViewSet):
|
||||
class TransactionViewSet(viewsets.ModelViewSet):
|
||||
"""API endpoint that allows Banks to be viewed.
|
||||
"""
|
||||
queryset = Transaction.objects.all()
|
||||
serializer_class = TransactionSerializer
|
||||
|
||||
|
||||
class SliceViewSet(viewsets.ReadOnlyModelViewSet):
|
||||
"""API endpoint that allows Banks to be viewed.
|
||||
"""
|
||||
queryset = Slice.objects.all()
|
||||
serializer_class = SliceSerializer
|
||||
filterset_fields = {
|
||||
'authorized_date': ['exact', 'lte', 'gte', 'isnull'],
|
||||
'updated_at': ['exact', 'lte', 'gte', 'isnull'],
|
||||
'created_at': ['exact', 'lte', 'gte', 'isnull'],
|
||||
'trans_id': ['exact', 'lte', 'gte', 'isnull'],
|
||||
}
|
||||
|
||||
|
||||
class RuleViewSet(viewsets.ReadOnlyModelViewSet):
|
||||
|
||||
Loading…
Reference in New Issue
Block a user