splite wallet from accounts
This commit is contained in:
parent
3c5ea1fefa
commit
250e2a3edd
19 changed files with 12 additions and 176 deletions
|
|
@ -1,4 +0,0 @@
|
||||||
from django.contrib import admin
|
|
||||||
from .models import App
|
|
||||||
# Register your models here.
|
|
||||||
admin.site.register(App)
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
from django.apps import AppConfig
|
|
||||||
|
|
||||||
|
|
||||||
class SuperappConfig(AppConfig):
|
|
||||||
default_auto_field = 'django.db.models.BigAutoField'
|
|
||||||
name = 'apps.superapp'
|
|
||||||
|
|
@ -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')),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
]
|
|
||||||
|
|
@ -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'),
|
|
||||||
),
|
|
||||||
]
|
|
||||||
|
|
@ -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
|
|
||||||
|
|
@ -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',
|
|
||||||
)
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
from django.test import TestCase
|
|
||||||
|
|
||||||
# Create your tests here.
|
|
||||||
|
|
@ -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/<uuid>', AppDetailAPIView.as_view(), name='app_detail_api'),
|
|
||||||
path('', AppListView.as_view(), name='app_list'),
|
|
||||||
path('<uuid>', AppDetailView.as_view(), name='app_detail'),
|
|
||||||
]
|
|
||||||
|
|
@ -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()
|
|
||||||
|
|
@ -5,7 +5,7 @@ import sys
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'accounts.settings')
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'wallet.settings')
|
||||||
try:
|
try:
|
||||||
from django.core.management import execute_from_command_line
|
from django.core.management import execute_from_command_line
|
||||||
except ImportError as exc:
|
except ImportError as exc:
|
||||||
|
|
|
||||||
|
|
@ -66,4 +66,5 @@ for i in range(1000):
|
||||||
response = rpc.call(request)
|
response = rpc.call(request)
|
||||||
# print(response.decode())
|
# print(response.decode())
|
||||||
# print(type(response.decode()))
|
# print(type(response.decode()))
|
||||||
print(i)
|
|
||||||
|
print(i)
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
import os
|
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
|
from utils.broker import get_rpc_broker_consumer
|
||||||
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
# from django.conf import settings
|
# from django.conf import settings
|
||||||
#
|
#
|
||||||
# # set the default Django settings module for the 'celery' program.
|
# # 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')
|
# app = Celery('notification_service')
|
||||||
#
|
#
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
"""
|
"""
|
||||||
Django settings for accounts project.
|
Django settings for wallet project.
|
||||||
|
|
||||||
Generated by 'django-admin startproject' using Django 5.0.4.
|
Generated by 'django-admin startproject' using Django 5.0.4.
|
||||||
|
|
||||||
|
|
@ -104,8 +104,8 @@ REST_FRAMEWORK = {
|
||||||
}
|
}
|
||||||
|
|
||||||
SPECTACULAR_SETTINGS = {
|
SPECTACULAR_SETTINGS = {
|
||||||
'TITLE': 'accounts',
|
'TITLE': 'wallet',
|
||||||
'DESCRIPTION': 'accounts api reference',
|
'DESCRIPTION': 'wallet api reference',
|
||||||
'VERSION': '1.0.0',
|
'VERSION': '1.0.0',
|
||||||
'SERVE_INCLUDE_SCHEMA': False,
|
'SERVE_INCLUDE_SCHEMA': False,
|
||||||
# OTHER SETTINGS
|
# OTHER SETTINGS
|
||||||
|
|
@ -136,7 +136,7 @@ AUTHENTICATION_BACKENDS = (
|
||||||
'django.contrib.auth.backends.ModelBackend',
|
'django.contrib.auth.backends.ModelBackend',
|
||||||
)
|
)
|
||||||
|
|
||||||
WSGI_APPLICATION = 'accounts.wsgi.application'
|
WSGI_APPLICATION = 'wallet.wsgi.application'
|
||||||
|
|
||||||
# Database
|
# Database
|
||||||
# https://docs.djangoproject.com/en/5.0/ref/settings/#databases
|
# https://docs.djangoproject.com/en/5.0/ref/settings/#databases
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
"""accounts URL Configuration
|
"""wallet URL Configuration
|
||||||
|
|
||||||
The `urlpatterns` list routes URLs to views. For more information please see:
|
The `urlpatterns` list routes URLs to views. For more information please see:
|
||||||
https://docs.djangoproject.com/en/2.2/topics/http/urls/
|
https://docs.djangoproject.com/en/2.2/topics/http/urls/
|
||||||
|
|
@ -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``.
|
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
|
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()
|
application = get_wsgi_application()
|
||||||
Loading…
Add table
Reference in a new issue