Skip to content
This repository has been archived by the owner on Apr 20, 2024. It is now read-only.

Commit

Permalink
Merge pull request #51 from eastgenomics/minify
Browse files Browse the repository at this point in the history
Update to Running Total Page (Minify and Clean Up View.py) (#51)
  • Loading branch information
jethror1 authored Mar 20, 2023
2 parents be32e93 + e1dcf3f commit b81ab57
Show file tree
Hide file tree
Showing 25 changed files with 819 additions and 914 deletions.
41 changes: 27 additions & 14 deletions Ploutos/Ploutos/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@

from pathlib import Path
import os
from dotenv import load_dotenv

load_dotenv()

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
Expand All @@ -30,7 +27,7 @@
DB_USERNAME = os.environ["DB_USERNAME"]
DB_PASSWORD = os.environ["DB_PASSWORD"]
DB_NAME = os.environ["DB_NAME"]
DB_PORT = os.environ.get("DB_PORT", 3306)
DB_PORT = int(os.environ.get("DB_PORT", 3306))

# Django secret key
SECRET_KEY = os.environ["SECRET_KEY"]
Expand Down Expand Up @@ -81,12 +78,7 @@
LOGIN_URL = "/ploutos/accounts/login"
LOGIN_REDIRECT_URL = "/ploutos"

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/


# Application definition

INSTALLED_APPS = [
"dashboard.apps.DashboardConfig",
"django.contrib.admin",
Expand All @@ -98,6 +90,9 @@
"django_extensions",
"crispy_bootstrap5",
"crispy_forms",
"compressor",
"cachalot",
"debug_toolbar",
]

MIDDLEWARE = [
Expand All @@ -108,6 +103,7 @@
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
"debug_toolbar.middleware.DebugToolbarMiddleware",
]

ROOT_URLCONF = "Ploutos.urls"
Expand Down Expand Up @@ -142,7 +138,7 @@
"NAME": DB_NAME,
"USER": DB_USERNAME,
"PASSWORD": DB_PASSWORD,
"HOST": "db",
"HOST": "db", # Edit this in local Runserver
"PORT": DB_PORT,
}
}
Expand Down Expand Up @@ -185,10 +181,10 @@
CRISPY_TEMPLATE_PACK = "bootstrap5"


# Settings for logging
ERROR_LOG = "/logs/ploutos-error.log"
DEBUG_LOG = "/logs/ploutos-debug.log"
EXECUTION_LOG = "/logs/executions_log.log"
# Logging (Docker)
ERROR_LOG = "/logs/ploutos-error.log" # Edit in local Runserver
DEBUG_LOG = "/logs/ploutos-debug.log" # Edit in local Runserver
EXECUTION_LOG = "/logs/executions_log.log" # Edit in local Runserver

with open(ERROR_LOG, "a+"):
pass
Expand Down Expand Up @@ -266,3 +262,20 @@
SESSION_EXPIRE_AT_BROWSER_CLOSE = True
SESSION_COOKIE_AGE = 1800
SESSION_SAVE_EVERY_REQUEST = True

STATICFILES_FINDERS = (
"django.contrib.staticfiles.finders.FileSystemFinder",
"django.contrib.staticfiles.finders.AppDirectoriesFinder",
"compressor.finders.CompressorFinder",
)

COMPRESS_ENABLED = True

# CACHE SETTING
# COMMENT OUT in local Runserver
CACHES = {
"default": {
"BACKEND": "django.core.cache.backends.memcached.PyMemcacheCache",
"LOCATION": "cache:11211",
}
}
2 changes: 2 additions & 0 deletions Ploutos/Ploutos/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,6 @@
path("", include("dashboard.urls")),
path("ploutos/admin/", admin.site.urls),
path("ploutos/accounts/", include("django.contrib.auth.urls")),
# debug toolbar. only show during DEBUG True
path("ploutos/__debug__/", include("debug_toolbar.urls")),
]
6 changes: 5 additions & 1 deletion Ploutos/dashboard/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ def clean(self):
end = self.cleaned_data["end"]

# Check both dates are entered
if not start and not end:
self.add_error(None, error="Please enter dates")
if start and not end:
self.add_error(
"end", "If entering a start date please include an end date"
Expand Down Expand Up @@ -161,7 +163,9 @@ def clean(self):
start_month = self.cleaned_data["start_month"]
end_month = self.cleaned_data["end_month"]

# Check both start and end entered
if start_month == "---" and end_month == "---":
self.add_error(None, "Please enter date")

if start_month == "---" and end_month != "---":
self.add_error(
"start_month",
Expand Down
49 changes: 30 additions & 19 deletions Ploutos/dashboard/templates/dashboard/base.html
Original file line number Diff line number Diff line change
@@ -1,33 +1,43 @@
{% load static %}
{% load compress %}
<!DOCTYPE html>
<html lang="en">
<head>
{% load static %}
<head>
<title>Ploutos</title>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

<!-- Favicon -->
<link rel="shortcut icon" href="{% static 'favicon.png' %}"/>

{% compress js %}
<!-- jQuery v3.6.3 -->
<script type="text/javascript" src="{% static 'js/jquery-3.6.0.min.js' %}"></script>
{% endcompress %}

<!-- CSS and Favicon -->
<!-- CSS & Bootstrap v5.1.3 CSS -->
{% compress css %}
<link rel="stylesheet" href="{% static 'css/style.css' %}">
<link rel="shortcut icon" href="{% static 'favicon-16x16.png' %}"/>

<!-- Bootstrap v5.1.3 CSS -->
<link rel="stylesheet" href="{% static 'css/bootstrap.min.css' %}">
{% endcompress %}

<!-- Bootstrap v5.1.3 JS -->
{% compress js %}
<script src="{% static 'js/bootstrap.min.js' %}"></script>
{% endcompress %}

{% compress css %}
<!-- DataTables CSS & JS -->
<link rel="stylesheet" href="{% static 'datatables/dataTables.bootstrap5.min.css' %}"/>
<link rel="stylesheet" href="{% static 'datatables/buttons.bootstrap5.min.css' %}"/>
<link rel="stylesheet" href="{% static 'datatables/colReorder.bootstrap5.min.css' %}"/>
<link rel="stylesheet" href="{% static 'datatables/fixedHeader.bootstrap5.min.css' %}"/>
<link rel="stylesheet" href="{% static 'datatables/responsive.bootstrap5.min.css' %}"/>
<link rel="stylesheet" href="{% static 'datatables/scroller.bootstrap5.min.css' %}"/>

{% endcompress %}

{% compress js %}
<script type="text/javascript" src="{% static 'datatables/jszip.min.js' %}"></script>
<script type="text/javascript" src="{% static 'datatables/jquery.dataTables.min.js' %}"></script>
<script type="text/javascript" src="{% static 'datatables/dataTables.bootstrap5.min.js' %}"></script>
Expand All @@ -37,22 +47,23 @@
<script type="text/javascript" src="{% static 'datatables/dataTables.colReorder.min.js' %}"></script>
<script type="text/javascript" src="{% static 'datatables/dataTables.fixedHeader.min.js' %}"></script>
<script type="text/javascript" src="{% static 'datatables/dataTables.responsive.min.js' %}"></script>
<script type="text/javascript" src="{% static 'datatables/responsive.bootstrap5.js' %}"></script>
<script type="text/javascript" src="{% static 'datatables/responsive.bootstrap5.min.js' %}"></script>
<script type="text/javascript" src="{% static 'datatables/dataTables.scroller.min.js' %}"></script>
<script type="text/javascript" src="{% static 'datatables/dataTables.hyperLink.js' %}"></script>

<!-- Highcharts JS -->
<script src="{% static 'js/highcharts.js' %}"></script>

<script src="https://code.highcharts.com/10.2/modules/no-data-to-display.js"></script>
<script src="https://code.highcharts.com/10.2/modules/exporting.js"></script>
<script src="https://code.highcharts.com/10.2/modules/export-data.js"></script>
<script src="https://code.highcharts.com/10.2/modules/accessibility.js"></script>
<script type="text/javascript" src="{% static 'datatables/dataTables.hyperLink.min.js' %}"></script>
{% endcompress %}

{% compress js %}
<!-- Highcharts JS -->
<script src="{% static 'js/highcharts.min.js' %}"></script>
<script src="{% static 'js/no-data-to-display.min.js' %}"></script>
<script src="{% static 'js/exporting.min.js' %}"></script>
<script src="{% static 'js/export-data.min.js' %}"></script>
<script src="{% static 'js/accessibility.min.js' %}"></script>
{% endcompress %}

</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark py-0" style="background-color: #34495e ;">
<nav class="navbar navbar-expand-lg navbar-dark py-0" style="background-color:#34495e ;">
<div class="container-fluid">
<a class="navbar-brand fs-3" id="navbar-logo" href="{% url 'index' %}">Ploutos</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
Expand Down Expand Up @@ -98,5 +109,5 @@
{% block content %}{% endblock %}

{% block script %}{% endblock %}
</body>
</body>
</html>
Loading

0 comments on commit b81ab57

Please sign in to comment.