From 250e2a3eddabb6e088e99f71b62c706d7f4852b6 Mon Sep 17 00:00:00 2001 From: mahdavi Date: Tue, 2 Jul 2024 12:45:59 +0330 Subject: [PATCH] splite wallet from accounts --- apps/superapp/__init__.py | 0 apps/superapp/admin.py | 4 -- apps/superapp/apps.py | 6 --- apps/superapp/migrations/0001_initial.py | 27 ----------- .../0002_remove_app_link_app_url.py | 22 --------- apps/superapp/migrations/__init__.py | 0 apps/superapp/models.py | 25 ---------- apps/superapp/serializers.py | 19 -------- apps/superapp/tests.py | 3 -- apps/superapp/urls.py | 11 ----- apps/superapp/views.py | 48 ------------------- manage.py | 2 +- utils/rpc_client.py | 3 +- {accounts => wallet}/__init__.py | 0 {accounts => wallet}/broker_rpc.py | 2 +- {accounts => wallet}/celery.py | 2 +- {accounts => wallet}/settings.py | 8 ++-- {accounts => wallet}/urls.py | 2 +- {accounts => wallet}/wsgi.py | 4 +- 19 files changed, 12 insertions(+), 176 deletions(-) delete mode 100644 apps/superapp/__init__.py delete mode 100644 apps/superapp/admin.py delete mode 100644 apps/superapp/apps.py delete mode 100644 apps/superapp/migrations/0001_initial.py delete mode 100644 apps/superapp/migrations/0002_remove_app_link_app_url.py delete mode 100644 apps/superapp/migrations/__init__.py delete mode 100644 apps/superapp/models.py delete mode 100755 apps/superapp/serializers.py delete mode 100644 apps/superapp/tests.py delete mode 100644 apps/superapp/urls.py delete mode 100644 apps/superapp/views.py rename {accounts => wallet}/__init__.py (100%) rename {accounts => wallet}/broker_rpc.py (63%) rename {accounts => wallet}/celery.py (90%) rename {accounts => wallet}/settings.py (97%) rename {accounts => wallet}/urls.py (98%) rename {accounts => wallet}/wsgi.py (73%) diff --git a/apps/superapp/__init__.py b/apps/superapp/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/apps/superapp/admin.py b/apps/superapp/admin.py deleted file mode 100644 index 3110802..0000000 --- a/apps/superapp/admin.py +++ /dev/null @@ -1,4 +0,0 @@ -from django.contrib import admin -from .models import App -# Register your models here. -admin.site.register(App) \ No newline at end of file diff --git a/apps/superapp/apps.py b/apps/superapp/apps.py deleted file mode 100644 index 6c4bff2..0000000 --- a/apps/superapp/apps.py +++ /dev/null @@ -1,6 +0,0 @@ -from django.apps import AppConfig - - -class SuperappConfig(AppConfig): - default_auto_field = 'django.db.models.BigAutoField' - name = 'apps.superapp' diff --git a/apps/superapp/migrations/0001_initial.py b/apps/superapp/migrations/0001_initial.py deleted file mode 100644 index ea041da..0000000 --- a/apps/superapp/migrations/0001_initial.py +++ /dev/null @@ -1,27 +0,0 @@ -# Generated by Django 4.1 on 2022-09-03 20:02 - -from django.db import migrations, models -import uuid - - -class Migration(migrations.Migration): - - initial = True - - dependencies = [ - ] - - operations = [ - migrations.CreateModel( - name='App', - fields=[ - ('uuid', models.UUIDField(db_index=True, default=uuid.uuid4, editable=False, primary_key=True, serialize=False, unique=True)), - ('title', models.CharField(blank=True, max_length=30, verbose_name='title')), - ('description', models.TextField(blank=True, null=True, verbose_name='description')), - ('order', models.IntegerField(blank=True, null=True, verbose_name='order')), - ('logo', models.ImageField(blank=True, null=True, upload_to='apps_logo')), - ('type', models.IntegerField(blank=True, choices=[(0, 'internal'), (1, 'external')], null=True, verbose_name='app type')), - ('link', models.URLField(blank=True, null=True, verbose_name='link')), - ], - ), - ] diff --git a/apps/superapp/migrations/0002_remove_app_link_app_url.py b/apps/superapp/migrations/0002_remove_app_link_app_url.py deleted file mode 100644 index 83c7b31..0000000 --- a/apps/superapp/migrations/0002_remove_app_link_app_url.py +++ /dev/null @@ -1,22 +0,0 @@ -# Generated by Django 4.1 on 2022-09-03 20:16 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('superapp', '0001_initial'), - ] - - operations = [ - migrations.RemoveField( - model_name='app', - name='link', - ), - migrations.AddField( - model_name='app', - name='url', - field=models.CharField(blank=True, max_length=30, verbose_name='url'), - ), - ] diff --git a/apps/superapp/migrations/__init__.py b/apps/superapp/migrations/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/apps/superapp/models.py b/apps/superapp/models.py deleted file mode 100644 index 1626a0d..0000000 --- a/apps/superapp/models.py +++ /dev/null @@ -1,25 +0,0 @@ -import uuid -from django.db import models -from django.utils import timezone -from django.utils.translation import gettext_lazy as _ - - -# Create your models here. -class App(models.Model): - class AppTypeChoices(models.IntegerChoices): - INTERNAL = 0, _('internal') - EXTERNAL = 1, _('external') - - uuid = models.UUIDField(primary_key=True, editable=False, default=uuid.uuid4, unique=True, db_index=True) - title = models.CharField(_('title'), max_length=30, blank=True) - description = models.TextField(_('description'), null=True, blank=True) - order = models.IntegerField(_("order"), blank=True, null=True) - logo = models.ImageField(upload_to='apps_logo', null=True, blank=True) - type = models.IntegerField(_("app type"), choices=AppTypeChoices.choices, blank=True, null=True) - url = models.CharField(_('url'), max_length=30, blank=True) - - def get_uuid(self): - return str(self.uuid) - - def __str__(self): - return self.title \ No newline at end of file diff --git a/apps/superapp/serializers.py b/apps/superapp/serializers.py deleted file mode 100755 index 277499f..0000000 --- a/apps/superapp/serializers.py +++ /dev/null @@ -1,19 +0,0 @@ -from rest_framework import serializers -from rest_framework.exceptions import APIException - -from apps.users.serializers import PublicUserSerializer -from .models import App - - -class AppSerializer(serializers.ModelSerializer): - class Meta: - model = App - fields = ( - 'uuid', - 'title', - 'description', - 'order', - "logo", - "type", - 'url', - ) diff --git a/apps/superapp/tests.py b/apps/superapp/tests.py deleted file mode 100644 index 7ce503c..0000000 --- a/apps/superapp/tests.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.test import TestCase - -# Create your tests here. diff --git a/apps/superapp/urls.py b/apps/superapp/urls.py deleted file mode 100644 index a08640f..0000000 --- a/apps/superapp/urls.py +++ /dev/null @@ -1,11 +0,0 @@ -from django.urls import path -from .views import AppListView, AppDetailView, AppListAPIView, AppDetailAPIView - -app_name = "superapp" - -urlpatterns = [ - path('api/applications/', AppListAPIView.as_view(), name='app_list_api'), - path('api/applications/', AppDetailAPIView.as_view(), name='app_detail_api'), - path('', AppListView.as_view(), name='app_list'), - path('', AppDetailView.as_view(), name='app_detail'), -] \ No newline at end of file diff --git a/apps/superapp/views.py b/apps/superapp/views.py deleted file mode 100644 index 20bb40c..0000000 --- a/apps/superapp/views.py +++ /dev/null @@ -1,48 +0,0 @@ -from django.contrib.auth.decorators import login_required -from django.shortcuts import render -from django.utils.decorators import method_decorator -from django.views.generic import ListView, DetailView -from rest_framework import generics - -from .models import App -from .serializers import AppSerializer -from ..accounts_oauth2.rest_framework import IsAuthenticatedOrTokenMatchesOASRequirements - - -@method_decorator(login_required, name='dispatch') -class AppListView(ListView): - model = App - template_name = 'superapp/app_list.html'\ - - -@method_decorator(login_required, name='dispatch') -class AppDetailView(DetailView): - model = App - template_name = 'superapp/app_detail.html' - pk_url_kwarg = 'uuid' - - # def get_queryset(self): - # return App.objects.filter(type=App.AppTypeChoices.EXTERNAL) - - -class AppListAPIView(generics.ListAPIView): - permission_classes = [IsAuthenticatedOrTokenMatchesOASRequirements] - serializer_class = AppSerializer - required_alternate_scopes = { - "GET": [['superapp.applications:list']], - } - - def get_queryset(self): - return App.objects.all() - - -class AppDetailAPIView(generics.RetrieveAPIView): - permission_classes = [IsAuthenticatedOrTokenMatchesOASRequirements] - serializer_class = AppSerializer - lookup_field = 'uuid' - required_alternate_scopes = { - "GET": [['superapp.applications:retrieve']], - } - - def get_queryset(self): - return App.objects.all() diff --git a/manage.py b/manage.py index 7a22e43..ffd5d2d 100644 --- a/manage.py +++ b/manage.py @@ -5,7 +5,7 @@ import sys def main(): - os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'accounts.settings') + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'wallet.settings') try: from django.core.management import execute_from_command_line except ImportError as exc: diff --git a/utils/rpc_client.py b/utils/rpc_client.py index b1bb4b2..da1707b 100644 --- a/utils/rpc_client.py +++ b/utils/rpc_client.py @@ -66,4 +66,5 @@ for i in range(1000): response = rpc.call(request) # print(response.decode()) # print(type(response.decode())) - print(i) \ No newline at end of file + +print(i) \ No newline at end of file diff --git a/accounts/__init__.py b/wallet/__init__.py similarity index 100% rename from accounts/__init__.py rename to wallet/__init__.py diff --git a/accounts/broker_rpc.py b/wallet/broker_rpc.py similarity index 63% rename from accounts/broker_rpc.py rename to wallet/broker_rpc.py index 6b322c4..df141d9 100644 --- a/accounts/broker_rpc.py +++ b/wallet/broker_rpc.py @@ -1,6 +1,6 @@ #!/usr/bin/env python import os -os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'accounts.settings') +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'wallet.settings') from utils.broker import get_rpc_broker_consumer diff --git a/accounts/celery.py b/wallet/celery.py similarity index 90% rename from accounts/celery.py rename to wallet/celery.py index 6b7fc88..a0c2e6e 100644 --- a/accounts/celery.py +++ b/wallet/celery.py @@ -6,7 +6,7 @@ # from django.conf import settings # # # set the default Django settings module for the 'celery' program. -# # os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'accounts.settings') +# # os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'wallet.settings') # # app = Celery('notification_service') # diff --git a/accounts/settings.py b/wallet/settings.py similarity index 97% rename from accounts/settings.py rename to wallet/settings.py index ad94a78..c96fb54 100644 --- a/accounts/settings.py +++ b/wallet/settings.py @@ -1,5 +1,5 @@ """ -Django settings for accounts project. +Django settings for wallet project. Generated by 'django-admin startproject' using Django 5.0.4. @@ -104,8 +104,8 @@ REST_FRAMEWORK = { } SPECTACULAR_SETTINGS = { - 'TITLE': 'accounts', - 'DESCRIPTION': 'accounts api reference', + 'TITLE': 'wallet', + 'DESCRIPTION': 'wallet api reference', 'VERSION': '1.0.0', 'SERVE_INCLUDE_SCHEMA': False, # OTHER SETTINGS @@ -136,7 +136,7 @@ AUTHENTICATION_BACKENDS = ( 'django.contrib.auth.backends.ModelBackend', ) -WSGI_APPLICATION = 'accounts.wsgi.application' +WSGI_APPLICATION = 'wallet.wsgi.application' # Database # https://docs.djangoproject.com/en/5.0/ref/settings/#databases diff --git a/accounts/urls.py b/wallet/urls.py similarity index 98% rename from accounts/urls.py rename to wallet/urls.py index 513a567..41fd070 100644 --- a/accounts/urls.py +++ b/wallet/urls.py @@ -1,4 +1,4 @@ -"""accounts URL Configuration +"""wallet URL Configuration The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/2.2/topics/http/urls/ diff --git a/accounts/wsgi.py b/wallet/wsgi.py similarity index 73% rename from accounts/wsgi.py rename to wallet/wsgi.py index d4e6b0e..68001d5 100644 --- a/accounts/wsgi.py +++ b/wallet/wsgi.py @@ -1,5 +1,5 @@ """ -WSGI config for accounts project. +WSGI config for wallet project. It exposes the WSGI callable as a module-level variable named ``application``. @@ -11,6 +11,6 @@ import os from django.core.wsgi import get_wsgi_application -os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'accounts.settings') +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'wallet.settings') application = get_wsgi_application()