Preparation for DataTables
More sidebar items Restructuring
This commit is contained in:
parent
54a8266d34
commit
c04d9410e9
21 changed files with 178 additions and 62 deletions
|
@ -17,7 +17,9 @@ MONSTERCONFIG = MonsterConfig(CONFIG_PATH)
|
|||
SECRET_KEY = ASK.secret_key
|
||||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = True
|
||||
DEBUG = ASK.config.getboolean("ACADEMON", "Debug", fallback=False)
|
||||
|
||||
ADMINS = [(ASK.config.get("ACADEMON", "AdminName"), ASK.config.get("ACADEMON", "AdminEmail"))]
|
||||
|
||||
ALLOWED_HOSTS = [ASK.config["ACADEMON"]["Host"]]
|
||||
CSRF_TRUSTED_ORIGINS = [f"https://{host}" for host in ALLOWED_HOSTS]
|
||||
|
@ -31,6 +33,7 @@ INSTALLED_APPS = [
|
|||
'django.contrib.sessions',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
'ajax_datatable',
|
||||
'dbsettings',
|
||||
'core',
|
||||
]
|
||||
|
@ -127,7 +130,7 @@ USE_TZ = True
|
|||
STATIC_URL = '/static/'
|
||||
|
||||
STATIC_ROOT = None if DEBUG else ASK.config.get(
|
||||
"ACADEMON", "StaticRoot", fallback=BASE_DIR / "static")
|
||||
"ACADEMON", "StaticRoot", fallback=None)
|
||||
|
||||
STATICFILES_DIRS = [
|
||||
BASE_DIR / "static",
|
||||
|
|
|
@ -2,7 +2,7 @@ from django.contrib import admin
|
|||
from django.urls import path, include
|
||||
|
||||
urlpatterns = [
|
||||
path('admin/', admin.site.urls),
|
||||
# path('django-admin/', admin.site.urls),
|
||||
path('api/', include(("api.urls", "api"))),
|
||||
path('', include(("core.urls", "core"))),
|
||||
]
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
from django.urls import path, include
|
||||
|
||||
from .views.urls import VesselsDataTableURLView
|
||||
|
||||
|
||||
urlpatterns = [
|
||||
path("urls/datatable/vessels/", VesselsDataTableURLView.as_view(), name=""),
|
||||
]
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
from django.shortcuts import render
|
||||
|
||||
# Create your views here.
|
0
api/views/__init__.py
Normal file
0
api/views/__init__.py
Normal file
9
api/views/urls.py
Normal file
9
api/views/urls.py
Normal file
|
@ -0,0 +1,9 @@
|
|||
from django.views import View
|
||||
from django.http import JsonResponse
|
||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||
from django.urls import reverse_lazy
|
||||
|
||||
|
||||
class VesselsDataTableURLView(LoginRequiredMixin, View):
|
||||
def get(self, request, *args, **kwargs):
|
||||
return JsonResponse(reverse_lazy("core:admin_vessels_datatable"), safe=False)
|
0
core/templatetags/__init__.py
Normal file
0
core/templatetags/__init__.py
Normal file
13
core/templatetags/admin.py
Normal file
13
core/templatetags/admin.py
Normal file
|
@ -0,0 +1,13 @@
|
|||
from django import template
|
||||
from django.conf import settings
|
||||
|
||||
|
||||
register = template.Library()
|
||||
|
||||
@register.simple_tag
|
||||
def admin_email():
|
||||
return settings.ADMINS[0][1]
|
||||
|
||||
@register.simple_tag
|
||||
def admin_name():
|
||||
return settings.ADMINS[0][0]
|
|
@ -3,6 +3,7 @@ from django.conf import settings
|
|||
|
||||
|
||||
urlpatterns = [
|
||||
path('admin/', include('core.urls.admin')),
|
||||
path('auth/', include("core.urls.auth")),
|
||||
path('', include("core.urls.frontend")),
|
||||
]
|
||||
|
|
11
core/urls/admin.py
Normal file
11
core/urls/admin.py
Normal file
|
@ -0,0 +1,11 @@
|
|||
from django.urls import path
|
||||
|
||||
from ..views.frontend import NotImplementedView
|
||||
from ..views.admin.vessels import AdminVesselsListView, AdminVesselsListDataTableView
|
||||
|
||||
|
||||
urlpatterns = [
|
||||
path("admin/", NotImplementedView.as_view(), name="admin"),
|
||||
path("vessels/", AdminVesselsListView.as_view(), name="admin_vessels"),
|
||||
path("vessels/datatable/", AdminVesselsListDataTableView.as_view(), name="admin_vessels_datatable"),
|
||||
]
|
|
@ -5,8 +5,6 @@ from ..views.frontend import DashboardView, NotImplementedView
|
|||
|
||||
|
||||
urlpatterns = [
|
||||
path("admin/", NotImplementedView.as_view(), name="admin"),
|
||||
path("admin/vessels/", NotImplementedView.as_view(), name="admin_vessels"),
|
||||
path("dashboard/", DashboardView.as_view(), name="dashboard"),
|
||||
path("", RedirectView.as_view(url=reverse_lazy("core:dashboard"))),
|
||||
]
|
|
@ -1,7 +0,0 @@
|
|||
from django.views.generic import ListView
|
||||
|
||||
from ..mixins.auth import SuperuserRequiredMixin
|
||||
|
||||
|
||||
class AdminVesselsListView(TemplateView, SuperuserRequiredMixin):
|
||||
template_name = "core/base.html"
|
1
core/views/admin/__init__.py
Normal file
1
core/views/admin/__init__.py
Normal file
|
@ -0,0 +1 @@
|
|||
from .vessels import AdminVesselsListView, AdminVesselsListDataTableView
|
26
core/views/admin/vessels.py
Normal file
26
core/views/admin/vessels.py
Normal file
|
@ -0,0 +1,26 @@
|
|||
from django.views.generic import ListView, TemplateView
|
||||
|
||||
from ajax_datatable.views import AjaxDatatableView
|
||||
|
||||
from ...models.vessel import Vessel
|
||||
from ...mixins.auth import SuperuserRequiredMixin
|
||||
|
||||
|
||||
class AdminVesselsListView(SuperuserRequiredMixin, TemplateView):
|
||||
template_name = "core/admin/vessels_list.html"
|
||||
|
||||
|
||||
class AdminVesselsListDataTableView(AjaxDatatableView):
|
||||
model = Vessel
|
||||
title = 'Vessels'
|
||||
initial_order = [["name", "asc"], ]
|
||||
length_menu = [[10, 20, 50, 100, -1], [10, 20, 50, 100, 'all']]
|
||||
search_values_separator = '+'
|
||||
|
||||
column_defs = [
|
||||
AjaxDatatableView.render_row_tools_column_def(),
|
||||
{'name': 'id', 'visible': False, },
|
||||
{'name': 'name', 'visible': True, },
|
||||
{'name': 'imo', 'visible': True, },
|
||||
{'name': 'mmsi', 'visible': True, },
|
||||
]
|
|
@ -5,6 +5,7 @@ certifi
|
|||
django-storages
|
||||
boto3
|
||||
django-ajax-datatable
|
||||
pytz
|
||||
|
||||
dbsettings
|
||||
django-autosecretkey
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
[ACADEMON]
|
||||
Host = academon.example.com
|
||||
AdminName = Admin Person
|
||||
AdminEmail = admin@example.com
|
||||
|
||||
[ADONIS]
|
||||
CrewPortalBaseURL=http://adonis/AdonisWebServices/CrewPortalWebService.svc/
|
||||
|
|
9
static/core/js/admin/vessels_datatable.js
Normal file
9
static/core/js/admin/vessels_datatable.js
Normal file
|
@ -0,0 +1,9 @@
|
|||
$(document).ready(function () {
|
||||
$.getJSON("/api/urls/datatable/vessels/")
|
||||
.done(function (data) {
|
||||
AjaxDatatableViewUtils.initialize_table(
|
||||
$('#datatable_vessels'),
|
||||
data,
|
||||
);
|
||||
});
|
||||
});
|
22
templates/core/admin/vessels_list.html
Normal file
22
templates/core/admin/vessels_list.html
Normal file
|
@ -0,0 +1,22 @@
|
|||
{% extends "core/base.html"%}
|
||||
{% load static %}
|
||||
|
||||
{% block styles %}
|
||||
<link href="{% static 'ajax_datatable/css/style.css' %}" rel="stylesheet" />
|
||||
<link rel='stylesheet' href="{% static 'core/dist/css/dataTables.bootstrap4.min.css' %}">
|
||||
<link rel='stylesheet' href="{% static 'core/dist/css/buttons.bootstrap.min.css' %}">
|
||||
{% endblock %}
|
||||
|
||||
{% block scripts %}
|
||||
<script type="text/javascript" src="{% static 'ajax_datatable/js/utils.js' %}"></script>
|
||||
|
||||
<script src="{% static 'core/dist/js/jquery.dataTables.min.js' %}"></script>
|
||||
<script src="{% static 'core/dist/js/dataTables.bootstrap4.min.js' %}"></script>
|
||||
<script src="{% static 'core/dist/js/dataTables.buttons.min.js' %}"></script>
|
||||
<script src="{% static 'core/dist/js/buttons.print.min.js' %}"></script>
|
||||
<script src="{% static 'core/dist/js/buttons.html5.min.js' %}"></script>
|
||||
<script src="{% static 'core/dist/js/buttons.bootstrap.min.js' %}"></script>
|
||||
<script src="{% static 'core/dist/js/jszip.min.js' %}"></script>
|
||||
<script src="{% static 'core/dist/js/pdfmake.min.js' %}"></script>
|
||||
<script src="{% static 'core/dist/js/vfs_fonts.js' %}"></script>
|
||||
{% endblock %}
|
|
@ -16,53 +16,8 @@
|
|||
<body class="hold-transition sidebar-mini">
|
||||
<div class="wrapper">
|
||||
|
||||
<nav class="main-header navbar navbar-expand navbar-white navbar-light">
|
||||
|
||||
<ul class="navbar-nav">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" data-widget="pushmenu" href="#" role="button"><i class="fas fa-bars"></i></a>
|
||||
</li>
|
||||
<li class="nav-item d-none d-sm-inline-block">
|
||||
<a href="/" class="nav-link">Home</a>
|
||||
</li>
|
||||
<li class="nav-item d-none d-sm-inline-block">
|
||||
<a href="mailto:kumitterer@kumi.cruises" class="nav-link">Contact Administrator</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<ul class="navbar-nav ml-auto">
|
||||
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" data-widget="navbar-search" href="#" role="button">
|
||||
<i class="fas fa-search"></i>
|
||||
</a>
|
||||
<div class="navbar-search-block">
|
||||
<form class="form-inline">
|
||||
<div class="input-group input-group-sm">
|
||||
<input class="form-control form-control-navbar" type="search" placeholder="Search" aria-label="Search">
|
||||
<div class="input-group-append">
|
||||
<button class="btn btn-navbar" type="submit">
|
||||
<i class="fas fa-search"></i>
|
||||
</button>
|
||||
<button class="btn btn-navbar" type="button" data-widget="navbar-search">
|
||||
<i class="fas fa-times"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" data-widget="fullscreen" href="#" role="button">
|
||||
<i class="fas fa-expand-arrows-alt"></i>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</nav>
|
||||
|
||||
{% include "core/frontend/sidebar.html" %}
|
||||
{% include "core/navbar.html" %}
|
||||
{% include "core/sidebar.html" %}
|
||||
|
||||
<div class="content-wrapper">
|
||||
|
||||
|
|
47
templates/core/navbar.html
Normal file
47
templates/core/navbar.html
Normal file
|
@ -0,0 +1,47 @@
|
|||
{% load admin %}
|
||||
<nav class="main-header navbar navbar-expand navbar-white navbar-light">
|
||||
|
||||
<ul class="navbar-nav">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" data-widget="pushmenu" href="#" role="button"><i class="fas fa-bars"></i></a>
|
||||
</li>
|
||||
<li class="nav-item d-none d-sm-inline-block">
|
||||
<a href="/" class="nav-link">Home</a>
|
||||
</li>
|
||||
<li class="nav-item d-none d-sm-inline-block">
|
||||
<a href="mailto:{% admin_email %}" class="nav-link">Contact Administrator</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<ul class="navbar-nav ml-auto">
|
||||
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" data-widget="navbar-search" href="#" role="button">
|
||||
<i class="fas fa-search"></i>
|
||||
</a>
|
||||
<div class="navbar-search-block">
|
||||
<form class="form-inline">
|
||||
<div class="input-group input-group-sm">
|
||||
<input class="form-control form-control-navbar" type="search" placeholder="Search"
|
||||
aria-label="Search">
|
||||
<div class="input-group-append">
|
||||
<button class="btn btn-navbar" type="submit">
|
||||
<i class="fas fa-search"></i>
|
||||
</button>
|
||||
<button class="btn btn-navbar" type="button" data-widget="navbar-search">
|
||||
<i class="fas fa-times"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" data-widget="fullscreen" href="#" role="button">
|
||||
<i class="fas fa-expand-arrows-alt"></i>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</nav>
|
|
@ -131,6 +131,30 @@
|
|||
</p>
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a href="{% url "core:admin_vessels" %}" class="nav-link">
|
||||
<i class="nav-icon fas fa-cloud-arrow-up"></i>
|
||||
<p>
|
||||
File Replication Sources
|
||||
</p>
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a href="{% url "core:admin_vessels" %}" class="nav-link">
|
||||
<i class="nav-icon fas fa-cloud-arrow-down"></i>
|
||||
<p>
|
||||
File Replication Targets
|
||||
</p>
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a href="{% url "core:admin_vessels" %}" class="nav-link">
|
||||
<i class="nav-icon fas fa-building-columns"></i>
|
||||
<p>
|
||||
Moodle Instances
|
||||
</p>
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
|
||||
</ul>
|
Loading…
Reference in a new issue