Add API route for transactions
This commit is contained in:
parent
0f39901c76
commit
df1490dd2d
|
@ -203,9 +203,23 @@ class CardSerializer(serializers.ModelSerializer):
|
||||||
|
|
||||||
|
|
||||||
class TransactionSerializer(serializers.ModelSerializer):
|
class TransactionSerializer(serializers.ModelSerializer):
|
||||||
|
account_type = serializers.ChoiceField(['Interac', 'TD Chequing', 'Paypal', 'Dream Pmt', 'PayPal', 'Square Pmt', 'Member', 'Clearing', 'Cash'])
|
||||||
|
info_source = serializers.ChoiceField(['Web', 'DB Edit', 'System', 'Receipt or Stmt', 'Quicken Import', 'Paypal IPN', 'Auto', 'Nexus DB Bulk', 'PayPal IPN', 'IPN Trigger', 'Intranet Receipt', 'Automatic', 'Manual'])
|
||||||
class Meta:
|
class Meta:
|
||||||
model = models.Transaction
|
model = models.Transaction
|
||||||
fields = '__all__'
|
fields = '__all__'
|
||||||
|
read_only_fields = [
|
||||||
|
'id',
|
||||||
|
'last_seen_at',
|
||||||
|
'user',
|
||||||
|
'recorder',
|
||||||
|
]
|
||||||
|
|
||||||
|
def create(self, validated_data):
|
||||||
|
member = get_object_or_404(models.Member, id=validated_data['member_id'])
|
||||||
|
if member.user:
|
||||||
|
validated_data['user'] = member.user
|
||||||
|
return super().create(validated_data)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -135,7 +135,7 @@ class MemberViewSet(Base, Retrieve, Update):
|
||||||
|
|
||||||
|
|
||||||
class CardViewSet(Base, Create, Retrieve, Update, Destroy):
|
class CardViewSet(Base, Create, Retrieve, Update, Destroy):
|
||||||
permission_classes = [AllowMetadata | IsAuthenticated, IsObjOwnerOrAdmin, IsAdminOrReadOnly]
|
permission_classes = [AllowMetadata | IsAuthenticated, IsObjOwnerOrAdmin]
|
||||||
queryset = models.Card.objects.all()
|
queryset = models.Card.objects.all()
|
||||||
serializer_class = serializers.CardSerializer
|
serializer_class = serializers.CardSerializer
|
||||||
|
|
||||||
|
@ -192,6 +192,15 @@ class TrainingViewSet(Base, Retrieve, Create, Update):
|
||||||
serializer.save(user=self.request.user)
|
serializer.save(user=self.request.user)
|
||||||
|
|
||||||
|
|
||||||
|
class TransactionViewSet(Base, Create, Retrieve, Update):
|
||||||
|
permission_classes = [AllowMetadata | IsAuthenticated, IsObjOwnerOrAdmin]
|
||||||
|
queryset = models.Transaction.objects.all()
|
||||||
|
serializer_class = serializers.TransactionSerializer
|
||||||
|
|
||||||
|
def perform_create(self, serializer):
|
||||||
|
serializer.save(recorder=self.request.user)
|
||||||
|
|
||||||
|
|
||||||
class UserView(views.APIView):
|
class UserView(views.APIView):
|
||||||
permission_classes = [AllowMetadata | IsAuthenticated]
|
permission_classes = [AllowMetadata | IsAuthenticated]
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ router.register(r'members', views.MemberViewSet, basename='members')
|
||||||
router.register(r'courses', views.CourseViewSet, basename='course')
|
router.register(r'courses', views.CourseViewSet, basename='course')
|
||||||
router.register(r'sessions', views.SessionViewSet, basename='session')
|
router.register(r'sessions', views.SessionViewSet, basename='session')
|
||||||
router.register(r'training', views.TrainingViewSet, basename='training')
|
router.register(r'training', views.TrainingViewSet, basename='training')
|
||||||
|
router.register(r'transactions', views.TransactionViewSet, basename='transaction')
|
||||||
#router.register(r'me', views.FullMemberView, basename='fullmember')
|
#router.register(r'me', views.FullMemberView, basename='fullmember')
|
||||||
#router.register(r'registration', views.RegistrationViewSet, basename='register')
|
#router.register(r'registration', views.RegistrationViewSet, basename='register')
|
||||||
|
|
||||||
|
|
|
@ -75,7 +75,7 @@ export function TransactionDetail(props) {
|
||||||
</Table.Row>
|
</Table.Row>
|
||||||
<Table.Row>
|
<Table.Row>
|
||||||
<Table.Cell>Account:</Table.Cell>
|
<Table.Cell>Account:</Table.Cell>
|
||||||
<Table.Cell>{t.account}</Table.Cell>
|
<Table.Cell>{t.account_type}</Table.Cell>
|
||||||
</Table.Row>
|
</Table.Row>
|
||||||
<Table.Row>
|
<Table.Row>
|
||||||
<Table.Cell>Info Source:</Table.Cell>
|
<Table.Cell>Info Source:</Table.Cell>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user