diff --git a/accounts/settings.py b/accounts/settings.py index eda9c0a..54e7324 100644 --- a/accounts/settings.py +++ b/accounts/settings.py @@ -44,6 +44,7 @@ INSTALLED_APPS = [ 'apps.users', 'apps.transactions', 'apps.gooyal_oauth2', + 'apps.superapp', ] MIDDLEWARE = [ diff --git a/accounts/urls.py b/accounts/urls.py index 320a055..3b80993 100644 --- a/accounts/urls.py +++ b/accounts/urls.py @@ -41,7 +41,8 @@ urlpatterns = [ # path('accounts/', include(auth_urls)), path('login/', OTPLoginView.as_view(), name='login'), path('logout/', LogoutView.as_view(), name='logout'), - path('', home, name='home'), + 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'), diff --git a/apps/superapp/__init__.py b/apps/superapp/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/apps/superapp/admin.py b/apps/superapp/admin.py new file mode 100644 index 0000000..3110802 --- /dev/null +++ b/apps/superapp/admin.py @@ -0,0 +1,4 @@ +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 new file mode 100644 index 0000000..6c4bff2 --- /dev/null +++ b/apps/superapp/apps.py @@ -0,0 +1,6 @@ +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 new file mode 100644 index 0000000..ea041da --- /dev/null +++ b/apps/superapp/migrations/0001_initial.py @@ -0,0 +1,27 @@ +# 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 new file mode 100644 index 0000000..83c7b31 --- /dev/null +++ b/apps/superapp/migrations/0002_remove_app_link_app_url.py @@ -0,0 +1,22 @@ +# 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 new file mode 100644 index 0000000..e69de29 diff --git a/apps/superapp/models.py b/apps/superapp/models.py new file mode 100644 index 0000000..1626a0d --- /dev/null +++ b/apps/superapp/models.py @@ -0,0 +1,25 @@ +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/tests.py b/apps/superapp/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/apps/superapp/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/apps/superapp/urls.py b/apps/superapp/urls.py new file mode 100644 index 0000000..17bf366 --- /dev/null +++ b/apps/superapp/urls.py @@ -0,0 +1,8 @@ +from django.urls import path +from .views import AppListView, AppDetailView +app_name = "superapp" + +urlpatterns = [ + 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 new file mode 100644 index 0000000..6d2c851 --- /dev/null +++ b/apps/superapp/views.py @@ -0,0 +1,20 @@ +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 .models import App + +@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) diff --git a/templates/base.html b/templates/base.html index 201ede4..7fcecd7 100644 --- a/templates/base.html +++ b/templates/base.html @@ -38,7 +38,7 @@