start super app
This commit is contained in:
parent
5161e2859d
commit
6c4e3a4ba0
15 changed files with 146 additions and 2 deletions
|
|
@ -44,6 +44,7 @@ INSTALLED_APPS = [
|
|||
'apps.users',
|
||||
'apps.transactions',
|
||||
'apps.gooyal_oauth2',
|
||||
'apps.superapp',
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
|
|
|
|||
|
|
@ -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'),
|
||||
|
|
|
|||
0
apps/superapp/__init__.py
Normal file
0
apps/superapp/__init__.py
Normal file
4
apps/superapp/admin.py
Normal file
4
apps/superapp/admin.py
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
from django.contrib import admin
|
||||
from .models import App
|
||||
# Register your models here.
|
||||
admin.site.register(App)
|
||||
6
apps/superapp/apps.py
Normal file
6
apps/superapp/apps.py
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class SuperappConfig(AppConfig):
|
||||
default_auto_field = 'django.db.models.BigAutoField'
|
||||
name = 'apps.superapp'
|
||||
27
apps/superapp/migrations/0001_initial.py
Normal file
27
apps/superapp/migrations/0001_initial.py
Normal file
|
|
@ -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')),
|
||||
],
|
||||
),
|
||||
]
|
||||
22
apps/superapp/migrations/0002_remove_app_link_app_url.py
Normal file
22
apps/superapp/migrations/0002_remove_app_link_app_url.py
Normal file
|
|
@ -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'),
|
||||
),
|
||||
]
|
||||
0
apps/superapp/migrations/__init__.py
Normal file
0
apps/superapp/migrations/__init__.py
Normal file
25
apps/superapp/models.py
Normal file
25
apps/superapp/models.py
Normal file
|
|
@ -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
|
||||
3
apps/superapp/tests.py
Normal file
3
apps/superapp/tests.py
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
8
apps/superapp/urls.py
Normal file
8
apps/superapp/urls.py
Normal file
|
|
@ -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('<uuid>', AppDetailView.as_view(), name='app_detail'),
|
||||
]
|
||||
20
apps/superapp/views.py
Normal file
20
apps/superapp/views.py
Normal file
|
|
@ -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)
|
||||
|
|
@ -38,7 +38,7 @@
|
|||
<div class="collapse navbar-collapse" id="navbarNav">
|
||||
<ul class="navbar-nav">
|
||||
<li class="nav-item active">
|
||||
<a class="nav-link" href="{% url 'home' %}">home <span class="sr-only"></span></a>
|
||||
<a class="nav-link" href="{% url 'superapp:app_list' %}">home <span class="sr-only"></span></a>
|
||||
</li>
|
||||
{% if request.user.is_authenticated %}
|
||||
<li class="nav-item">
|
||||
|
|
|
|||
15
templates/superapp/app_detail.html
Normal file
15
templates/superapp/app_detail.html
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
{% extends "base_generic.html" %}
|
||||
|
||||
{% block content %}
|
||||
<link rel="import" href="{{ object.url }}">
|
||||
<br>
|
||||
<object data="{{ object.url }}" width="100%" height="100%">
|
||||
<embed src="{{ object.url }}" width="100%" height="100%"> </embed>
|
||||
Error: Embedded data could not be displayed.
|
||||
</object>
|
||||
<br>
|
||||
<iframe src="{{ object.url }}" name="iframe_a"></iframe>
|
||||
<p><a href="http://www.w3schools.com" target="iframe_a">www.google.com</a></p>
|
||||
|
||||
<a href="{{ object.url }}" target="_self">link</a>
|
||||
{% endblock %}
|
||||
12
templates/superapp/app_list.html
Normal file
12
templates/superapp/app_list.html
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
{% extends "base_generic.html" %}
|
||||
|
||||
{% block content %}
|
||||
{% for app in object_list %}
|
||||
{% if app.type == app.AppTypeChoices.EXTERNAL %}
|
||||
<a href="{% url 'superapp:app_detail' app.uuid|lower %}">{{ app }}</a><br>
|
||||
{% else %}
|
||||
<a href="{% url app.url %}">{{ app }}</a><br>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
{% endblock %}
|
||||
Loading…
Add table
Reference in a new issue