From df9698930cf9b5768bb931a697c9d526ecf62088 Mon Sep 17 00:00:00 2001 From: Sarthak Date: Mon, 20 Dec 2021 01:22:54 +0530 Subject: [PATCH] Frontend added with login completed crud apis completed and some ui things like tables and form to add new spending completed --- api/admin.py | 3 +- api/migrations/0001_initial.py | 29 ++++ .../0002_alter_transaction_created.py | 19 ++ ...e_transaction_username_transaction_user.py | 24 +++ api/models.py | 22 +++ api/serializers.py | 17 ++ api/urls.py | 7 +- api/views.py | 64 +++++++ db.sqlite3 | Bin 155648 -> 139264 bytes frontend/models.py | 2 - frontend/templates/frontend/accounts.html | 0 frontend/templates/frontend/home.html | 16 -- frontend/templates/home.html | 162 ++++++++++++++++++ frontend/templates/{accounts => }/login.html | 4 +- frontend/views.py | 10 +- 15 files changed, 348 insertions(+), 31 deletions(-) create mode 100644 api/migrations/0001_initial.py create mode 100644 api/migrations/0002_alter_transaction_created.py create mode 100644 api/migrations/0003_remove_transaction_username_transaction_user.py create mode 100644 api/serializers.py delete mode 100644 frontend/templates/frontend/accounts.html delete mode 100644 frontend/templates/frontend/home.html create mode 100644 frontend/templates/home.html rename frontend/templates/{accounts => }/login.html (97%) diff --git a/api/admin.py b/api/admin.py index 8c38f3f..de4554a 100644 --- a/api/admin.py +++ b/api/admin.py @@ -1,3 +1,4 @@ from django.contrib import admin +from .models import Transaction -# Register your models here. +admin.site.register(Transaction) \ No newline at end of file diff --git a/api/migrations/0001_initial.py b/api/migrations/0001_initial.py new file mode 100644 index 0000000..517954b --- /dev/null +++ b/api/migrations/0001_initial.py @@ -0,0 +1,29 @@ +# Generated by Django 4.0 on 2021-12-19 18:34 + +from django.db import migrations, models +import django.db.models.deletion +import django.utils.timezone + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ('auth', '0012_alter_user_first_name_max_length'), + ] + + operations = [ + migrations.CreateModel( + name='Transaction', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('created', models.DateTimeField(default=django.utils.timezone.now, editable=False)), + ('name', models.CharField(max_length=500)), + ('amount', models.IntegerField()), + ('category', models.CharField(choices=[('ren', 'Rent'), ('tra', 'Travel'), ('inv', 'Investment'), ('sho', 'Shopping'), ('lea', 'Learning'), ('fee', 'Fees'), ('oth', 'Other')], default='oth', max_length=3)), + ('note', models.TextField()), + ('username', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='auth.user')), + ], + ), + ] diff --git a/api/migrations/0002_alter_transaction_created.py b/api/migrations/0002_alter_transaction_created.py new file mode 100644 index 0000000..7343de2 --- /dev/null +++ b/api/migrations/0002_alter_transaction_created.py @@ -0,0 +1,19 @@ +# Generated by Django 4.0 on 2021-12-19 18:43 + +from django.db import migrations, models +import django.utils.timezone + + +class Migration(migrations.Migration): + + dependencies = [ + ('api', '0001_initial'), + ] + + operations = [ + migrations.AlterField( + model_name='transaction', + name='created', + field=models.DateTimeField(default=django.utils.timezone.now), + ), + ] diff --git a/api/migrations/0003_remove_transaction_username_transaction_user.py b/api/migrations/0003_remove_transaction_username_transaction_user.py new file mode 100644 index 0000000..bb463f8 --- /dev/null +++ b/api/migrations/0003_remove_transaction_username_transaction_user.py @@ -0,0 +1,24 @@ +# Generated by Django 4.0 on 2021-12-20 06:34 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('auth', '0012_alter_user_first_name_max_length'), + ('api', '0002_alter_transaction_created'), + ] + + operations = [ + migrations.RemoveField( + model_name='transaction', + name='username', + ), + migrations.AddField( + model_name='transaction', + name='user', + field=models.ForeignKey(default=None, on_delete=django.db.models.deletion.CASCADE, to='auth.user'), + ), + ] diff --git a/api/models.py b/api/models.py index 137941f..afb51c9 100644 --- a/api/models.py +++ b/api/models.py @@ -1 +1,23 @@ +from django.utils.timezone import now from django.db import models +from django.contrib.auth.models import User + +class Transaction(models.Model): + user = models.ForeignKey(User, on_delete=models.CASCADE, default=None) + created = models.DateTimeField(default=now, editable=True) + name = models.CharField(max_length=500) + amount = models.IntegerField() + categories = [ + ('ren', 'Rent'), + ('tra', 'Travel'), + ('inv', 'Investment'), + ('sho', 'Shopping'), + ('lea', 'Learning'), + ('fee', 'Fees'), + ('oth', 'Other'), + ] + category = models.CharField(max_length=3, default='oth', choices=categories) + note = models.TextField() + + def __str__(self): + return (str(self.user) + ' ' + str(self.amount)) \ No newline at end of file diff --git a/api/serializers.py b/api/serializers.py new file mode 100644 index 0000000..cf443ff --- /dev/null +++ b/api/serializers.py @@ -0,0 +1,17 @@ +from rest_framework import serializers +from .models import Transaction + +class TransactionSearializer(serializers.ModelSerializer): + class Meta: + model = Transaction + fields = ('id', 'user', 'created', 'name', 'amount', 'category', 'note') + +# class CreateTransactionSerializer(serializers.ModelSerializer): +# class Meta: +# model = Transaction +# fields = ('user', 'name', 'amount', 'category', 'note') + +# class UpdateTransactionSerializer(serializers.ModelSerializer): +# class Meta: +# model = Transaction +# fields = ('id', 'name', 'amount', 'category', 'note') \ No newline at end of file diff --git a/api/urls.py b/api/urls.py index 96afd02..2302837 100644 --- a/api/urls.py +++ b/api/urls.py @@ -1,6 +1,9 @@ from django.urls import path - from .views import * + urlpatterns = [ - # path('', home), + path('', TransactionView.as_view()), + path('create-transaction', CreateTransactionView.as_view()), + path('update-transaction', UpdateTransactionView.as_view()), + path('delete-transaction', DeleteTransactionView.as_view()), ] \ No newline at end of file diff --git a/api/views.py b/api/views.py index e69de29..f7af388 100644 --- a/api/views.py +++ b/api/views.py @@ -0,0 +1,64 @@ +from rest_framework import generics, status +from django.shortcuts import render, redirect +from django.http import JsonResponse +from django.contrib.auth.models import User +from django.contrib.auth.decorators import login_required +from .serializers import * +from .models import Transaction +from rest_framework.views import APIView +from rest_framework.response import Response +import json + +class TransactionView(generics.ListAPIView): + def get(self, request, format=None): + serializer_class = TransactionSearializer + queryset = Transaction.objects.filter(user=request.user) + dat = [] + for i in queryset: + dat.append(TransactionSearializer(i).data) + return Response({'data':dat}, status=status.HTTP_200_OK) + +class CreateTransactionView(APIView): + def post(self, request, format=None): + if request.user.is_authenticated: + + user = request.user + name = request.data.get('name') + amount = request.data.get('amount') + category = request.data.get('category') + note = request.data.get('note') + + transaction = Transaction(user=user, name=name, amount=amount, category=category, note=note) + transaction.save() + + return Response(TransactionSearializer(transaction).data, status=status.HTTP_201_CREATED) + return Response({'message':'Login Required'}, status=status.HTTP_404_NOT_FOUND) + +class UpdateTransactionView(APIView): + def post(self, request, format=None): + if request.user.is_authenticated: + id = request.data.get('id') + + queryset = Transaction.objects.filter(id=id) + transaction = queryset[0] + transaction.name = request.data.get('name') + transaction.amount = request.data.get('amount') + transaction.category = request.data.get('category') + transaction.note = request.data.get('note') + transaction.save(update_fields=['name','amount','category','note']) + + return Response(TransactionSearializer(transaction).data, status=status.HTTP_200_OK) + return Response({'message':'Login Required'}, status=status.HTTP_404_NOT_FOUND) + + +class DeleteTransactionView(APIView): + def post(self, request, format=None): + if request.user.is_authenticated: + id = request.data.get('id') + + queryset = Transaction.objects.filter(id=id) + transaction = queryset[0] + transaction.delete() + + return Response({'message':'Deleted Successfully'}, status=status.HTTP_200_OK) + return Response({'message':'Login Required'}, status=status.HTTP_404_NOT_FOUND) \ No newline at end of file diff --git a/db.sqlite3 b/db.sqlite3 index b25a27b35ecb3bfa1405a0c6885c4bf0a01c7b94..f4fa423849bfdd7a02b19ba8a218be7844a7dc0a 100644 GIT binary patch delta 5332 zcmcIoNo*VE73Odxk&;Y}Y)X+G%QhuDt{t27%s)FFH|8da5*JAnDT+Ws56R)q87{*` z0t(u0b4b!Ot_Q7vrbrMVm!>^56&f9qwr+ZG+e^}*Nf97LiyRW9Yc6RK6h-=zvMo|} z;52Xu%#e8hd+&e$_x`u>;Q0Ly6_yPKWu=+@uA06 z-RLo0XxKRP^P$H#iP4oIj2!RR9D2Z36|2>(ELGL#kBqedZo(NWNm~JHA!&l**x*>d z#wgo_QWnQ?GFB0ba$Srm6+x;B2?YwqYE`i!3B}uq00)Gb0OoF`1jn%?f8Gd{dTuBM zF`=M{m9|dm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i088Lc=O~VFV>PepOuA%nQxvHz;1Eb@`LONT{GrAow$943E zl~#_=aNU~p#StL8&Dq^}@vX5#LYqnfuI2Cp0zd!=00AHX1b_e#00KY&2wa4K6A9f% ze{Z6{KJ@nh{oPXnqtF3hc@#T!@e$|%fDVA>rDi_X4gfof00e*l5C8%|;PXuYum5kiZ`$Z3&l>s%en0>SybJ;#9@)J% z(boAb(d+H>#J%?x7Ivo=i}A$t?A&oQ{bXY9S!j8_nv|;36JtBcgQBEHH#19{<7d6E zg4bZJznQb9?OpDLhK4@f`8fg?Fyb{pJ(AbA@ZIR&SrH!hR0>TN@uqi{h6mgWQM^913$0 z^xd-$4?F5@|GQe-ALX8MVP#XWQ>d>E;$?DI-2kz9@BO8ZB#!%w{J zw={?PRp$Jz`^J^z(oLbcS*zqj^H2wH9cvowv4PLj^zHSIZZH+g5&u_9! zmn`#rYU8f8vD5mxZFAEv1V@DEP)G=edA>GCd2O}FaZitT*n@8SOUYe1&5M<7i4TSQ z1fE5|zJ;TLswmq9VRe2zRhe2=$AiJ@QQy|aljP1;dSH7zI>9gT!Lg;{@(Fdt!+=tg{I`h`m^oj z$?0`vePVp?P$|#m#`0UGjmg|6dehow8qpQLX>H?e{TBIZ_E@xW_iEj^UbQ)5`Yo0I zMQ;6=Yg#bH@{sx2ziHLow7T8APK?FvkM;Gi#tk64T|{4K7e?6F5W4?kIqt*1?Wi~V ziq`Ds*Q2@g-0Dg+HSug!-Pn41@NBnQ%q~?H6U%d})q{njSZ+SMzX#2}ESmZiMqgoH zMVodIn*Hs^0ghz@Oj+5hX3L7qWaY63iZuYQS|va2Ca1ZgTW)gT-i|E3 i_)0q?@!B2m0|Gz*2mk>f00e*l5C8%|00^8*;Qs^PC|8~U diff --git a/frontend/models.py b/frontend/models.py index 71a8362..137941f 100644 --- a/frontend/models.py +++ b/frontend/models.py @@ -1,3 +1 @@ from django.db import models - -# Create your models here. diff --git a/frontend/templates/frontend/accounts.html b/frontend/templates/frontend/accounts.html deleted file mode 100644 index e69de29..0000000 diff --git a/frontend/templates/frontend/home.html b/frontend/templates/frontend/home.html deleted file mode 100644 index 6e2fdc3..0000000 --- a/frontend/templates/frontend/home.html +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - BudMan - BudMan is a web app that helps you track and adjust your spending so that you are in control of money. - -

BudMan - BudMan is a web app that helps you track and adjust your spending so that you are in control of money.

- {% if user.is_authenticated %} -

Logged in as

{{request.user}}

- {% endif %} - Login - Logout - - \ No newline at end of file diff --git a/frontend/templates/home.html b/frontend/templates/home.html new file mode 100644 index 0000000..6fd85c6 --- /dev/null +++ b/frontend/templates/home.html @@ -0,0 +1,162 @@ + + + + + + + + BudMan - BudMan is a web app that helps you track and adjust your spending so that you are in control of + money. + + + + + + + + + + + + + {% if user.is_authenticated %} +

Logged in as

+

{{request.user}}

+ Logout +

Spendings

+ +
+ + +
+ + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
NameCreatedAmountcategoryNote
Purchase 1SitAmetAmetAmet + + + +
+ + + {% else %} +

BudMan - BudMan is a web app that helps you track and adjust your spending so that you are in control of money. +

+ Login + + + + {% endif %} + + + + + + + \ No newline at end of file diff --git a/frontend/templates/accounts/login.html b/frontend/templates/login.html similarity index 97% rename from frontend/templates/accounts/login.html rename to frontend/templates/login.html index 8427d45..7a8c978 100644 --- a/frontend/templates/accounts/login.html +++ b/frontend/templates/login.html @@ -8,7 +8,6 @@ Sign in -{% block body %} Home @@ -48,5 +47,4 @@

Sign Up

- -{% endblock %} \ No newline at end of file + \ No newline at end of file diff --git a/frontend/views.py b/frontend/views.py index 81400a2..3e8b7e1 100644 --- a/frontend/views.py +++ b/frontend/views.py @@ -5,11 +5,10 @@ from django.contrib.auth import authenticate, login, logout from django.contrib import messages from django.contrib.auth.models import User -from django.contrib.auth.decorators import login_required def home(request): context = {} - return render(request, 'frontend/home.html',context) + return render(request, 'home.html',context) @unauthenticated_user def loginPage(request): @@ -35,11 +34,8 @@ def loginPage(request): messages.info(request, 'Username OR password is incorrect') context = {'form':form} - return render (request, 'accounts/login.html', context) + return render (request, 'login.html', context) def logoutUser(request): logout(request) - return redirect('login') - - -# @login_required(login_url='login') \ No newline at end of file + return redirect('login') \ No newline at end of file