transaction app to wallet app
This commit is contained in:
parent
6c4e3a4ba0
commit
cadf32e360
18 changed files with 55 additions and 73 deletions
|
|
@ -42,7 +42,7 @@ INSTALLED_APPS = [
|
|||
'rest_framework',
|
||||
'corsheaders',
|
||||
'apps.users',
|
||||
'apps.transactions',
|
||||
'apps.wallet',
|
||||
'apps.gooyal_oauth2',
|
||||
'apps.superapp',
|
||||
]
|
||||
|
|
@ -178,7 +178,7 @@ USE_TZ = True
|
|||
# LOGIN_URL = '/accounts/login/'
|
||||
# LOGIN_REDIRECT_URL = '/accounts/profile/'
|
||||
|
||||
LOGIN_URL = '/login/'
|
||||
# LOGIN_URL =
|
||||
LOGIN_REDIRECT_URL = '/'
|
||||
|
||||
AUTH_USER_MODEL = 'users.User'
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ Including another URLconf
|
|||
from django.conf import settings
|
||||
# from django.conf.urls import url
|
||||
from django.conf.urls.static import static
|
||||
from django.contrib.auth.views import LogoutView
|
||||
from django.urls import path, include
|
||||
from django.contrib import admin
|
||||
from rest_framework import permissions
|
||||
|
|
@ -24,45 +23,23 @@ from drf_spectacular.views import SpectacularAPIView, SpectacularRedocView, Spec
|
|||
|
||||
|
||||
# from apps.gooyal_oauth2.views.introspect import introspect_token
|
||||
from apps.transactions.views import TransactionList, TransactionDetail, TransactionPay, TransactionReceipt, \
|
||||
from apps.wallet.views import TransactionList, TransactionDetail, TransactionPay, TransactionReceipt, \
|
||||
WithdrawVerify, WithdrawSubmit, DepositSubmit, DepositVerify
|
||||
from apps.users.views import UserListView, UserDetailView, AccountView, RequestOTPView, ChangePasswordView, \
|
||||
OTPLoginView, home, UserInquiryView
|
||||
from django.contrib.auth import urls as auth_urls
|
||||
|
||||
|
||||
urlpatterns = [
|
||||
# YOUR PATTERNS
|
||||
path('swagger/', SpectacularAPIView.as_view(), name='schema'),
|
||||
# Optional UI:
|
||||
path('swagger/swagger-ui/', SpectacularSwaggerView.as_view(url_name='schema'), name='swagger-ui'),
|
||||
path('swagger/redoc/', SpectacularRedocView.as_view(url_name='schema'), name='redoc'),
|
||||
|
||||
path('admin/', admin.site.urls),
|
||||
# path('accounts/', include(auth_urls)),
|
||||
path('login/', OTPLoginView.as_view(), name='login'),
|
||||
path('logout/', LogoutView.as_view(), name='logout'),
|
||||
path('wallet/', include('apps.wallet.urls')),
|
||||
path('users/', include('apps.users.urls')),
|
||||
path('', include('apps.superapp.urls')),
|
||||
# path('', home, name='home'),
|
||||
path('oauth2/', include('oauth2_provider.urls', namespace='oauth2_provider')),
|
||||
|
||||
path('account/', AccountView.as_view(), name='account'),
|
||||
path('users/', UserListView.as_view()),
|
||||
path('users/<uuid>/', UserDetailView.as_view(), name='user_detail'),
|
||||
path('request_otp/', RequestOTPView.as_view(), name='register'),
|
||||
path('change_password/', ChangePasswordView.as_view(), name='change_password'),
|
||||
# path('province', ProvinceApiView.as_view(), name='province'),
|
||||
# path('inquiry/', UserInquiryView.as_view(), name='inquiry'),
|
||||
|
||||
path('transactions/', TransactionList.as_view(), name='transactions'),
|
||||
path('transactions/<uuid>', TransactionDetail.as_view(), name='transaction_detail'),
|
||||
path('transactions/<uuid>/pay', TransactionPay.as_view(), name='transaction_pay'),
|
||||
path('transactions/<uuid>/receipt', TransactionReceipt.as_view(), name='transaction_receipt'),
|
||||
#
|
||||
path('deposit/', DepositSubmit.as_view(), name='deposit_submit'),
|
||||
path('deposit/<uuid>/verify', DepositVerify.as_view(), name='deposit_verify'),
|
||||
#
|
||||
path('withdraw/', WithdrawSubmit.as_view(), name='withdraw_submit'),
|
||||
path('withdraw/<uuid>/verify', WithdrawVerify.as_view(), name='withdraw_verify'),
|
||||
]
|
||||
|
||||
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||
|
|
|
|||
|
|
@ -1,5 +0,0 @@
|
|||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class TransactionsConfig(AppConfig):
|
||||
name = 'apps.transactions'
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
# Generated by Django 4.1 on 2022-08-17 19:05
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
('transactions', '0001_initial'),
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='transaction',
|
||||
name='payee',
|
||||
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='receipts', to=settings.AUTH_USER_MODEL),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='transaction',
|
||||
name='payer',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='payments', to=settings.AUTH_USER_MODEL),
|
||||
),
|
||||
]
|
||||
16
apps/users/urls.py
Normal file
16
apps/users/urls.py
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
from django.urls import path
|
||||
from django.contrib.auth.views import LogoutView
|
||||
from .views import UserListView, UserDetailView, AccountView, RequestOTPView, ChangePasswordView, \
|
||||
OTPLoginView
|
||||
|
||||
app_name = "users"
|
||||
|
||||
urlpatterns = [
|
||||
path('login/', OTPLoginView.as_view(), name='login'),
|
||||
path('logout/', LogoutView.as_view(), name='logout'),
|
||||
path('api/account/', AccountView.as_view(), name='account'),
|
||||
path('api/users/', UserListView.as_view()),
|
||||
path('api/users/<uuid>/', UserDetailView.as_view(), name='user_detail'),
|
||||
path('api/request_otp/', RequestOTPView.as_view(), name='request_otp'),
|
||||
path('api/change_password/', ChangePasswordView.as_view(), name='change_password'),
|
||||
]
|
||||
|
|
@ -95,11 +95,6 @@ class ChangePasswordView(generics.UpdateAPIView):
|
|||
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
|
||||
|
||||
|
||||
@login_required
|
||||
def home(request):
|
||||
return render(request, 'registration/profile.html')
|
||||
|
||||
|
||||
class OTPLoginView(LoginView):
|
||||
"""
|
||||
Display the login form and handle the login action.
|
||||
|
|
|
|||
5
apps/wallet/apps.py
Executable file
5
apps/wallet/apps.py
Executable file
|
|
@ -0,0 +1,5 @@
|
|||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class WalletConfig(AppConfig):
|
||||
name = 'apps.wallet'
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
# Generated by Django 4.1 on 2022-08-17 19:05
|
||||
# Generated by Django 4.1 on 2022-09-04 12:55
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
import uuid
|
||||
|
||||
|
||||
|
|
@ -9,6 +11,7 @@ class Migration(migrations.Migration):
|
|||
initial = True
|
||||
|
||||
dependencies = [
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
]
|
||||
|
||||
operations = [
|
||||
|
|
@ -23,6 +26,8 @@ class Migration(migrations.Migration):
|
|||
('last_update', models.DateTimeField(auto_now=True, null=True, verbose_name='last update')),
|
||||
('application_client_id', models.CharField(db_index=True, max_length=100, null=True)),
|
||||
('detail_id', models.IntegerField(blank=True, null=True)),
|
||||
('payee', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='receipts', to=settings.AUTH_USER_MODEL)),
|
||||
('payer', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='payments', to=settings.AUTH_USER_MODEL)),
|
||||
],
|
||||
),
|
||||
]
|
||||
17
apps/wallet/urls.py
Normal file
17
apps/wallet/urls.py
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
from django.urls import path
|
||||
from .views import TransactionList, TransactionDetail, TransactionPay, TransactionReceipt, \
|
||||
WithdrawVerify, WithdrawSubmit, DepositSubmit, DepositVerify
|
||||
app_name = "wallet"
|
||||
|
||||
urlpatterns = [
|
||||
path('transactions/', TransactionList.as_view(), name='transactions'),
|
||||
path('transactions/<uuid>', TransactionDetail.as_view(), name='transaction_detail'),
|
||||
path('transactions/<uuid>/pay', TransactionPay.as_view(), name='transaction_pay'),
|
||||
path('transactions/<uuid>/receipt', TransactionReceipt.as_view(), name='transaction_receipt'),
|
||||
#
|
||||
path('deposit/', DepositSubmit.as_view(), name='deposit_submit'),
|
||||
path('deposit/<uuid>/verify', DepositVerify.as_view(), name='deposit_verify'),
|
||||
#
|
||||
path('withdraw/', WithdrawSubmit.as_view(), name='withdraw_submit'),
|
||||
path('withdraw/<uuid>/verify', WithdrawVerify.as_view(), name='withdraw_verify'),
|
||||
]
|
||||
|
|
@ -5,8 +5,8 @@ from rest_framework import generics, permissions
|
|||
from rest_framework.response import Response
|
||||
|
||||
from apps.gooyal_oauth2.rest_framework import IsAuthenticatedOrTokenMatchesOASRequirements
|
||||
from apps.transactions.models import Transaction
|
||||
from apps.transactions.serializers import TransactionSerializer, DepositSerializer, WithdrawSerializer
|
||||
from apps.wallet.models import Transaction
|
||||
from apps.wallet.serializers import TransactionSerializer, DepositSerializer, WithdrawSerializer
|
||||
from apps.users.constans import STATE_CHOICES
|
||||
|
||||
|
||||
|
|
@ -42,7 +42,7 @@
|
|||
</li>
|
||||
{% if request.user.is_authenticated %}
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{% url 'logout' %}">({{ request.user.phone_number }}) Logout</a>
|
||||
<a class="nav-link" href="{% url 'users:logout' %}">({{ request.user.phone_number }}) Logout</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
{# </div>#}
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<form class="login100-form validate-form flex-sb flex-w" method="post" action="{% url 'login' %}">
|
||||
<form class="login100-form validate-form flex-sb flex-w" method="post" action="{% url 'users:login' %}">
|
||||
{% csrf_token %}
|
||||
|
||||
|
||||
|
|
@ -96,7 +96,7 @@
|
|||
// var data = {'username': mobileNumberOrUsername}
|
||||
//}
|
||||
|
||||
$.post("/request_otp/", data).done(
|
||||
$.post("{% url 'users:request_otp' %}", data).done(
|
||||
function (result) {
|
||||
console.log(result);
|
||||
if (result.hasOwnProperty('ttl')) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue