Skip to content
Snippets Groups Projects
Commit 13f0df75 authored by Nico Vermaas's avatar Nico Vermaas
Browse files

add templates, config, static, settings

parent 692980de
No related branches found
No related tags found
No related merge requests found
from atdb.settings.base import *
import os
# Import production setting must remain False.
DEV = False
try:
DEBUG = os.environ['DEBUG']
except:
DEBUG = False
ALLOWED_HOSTS = ["*"]
# True: Enables a header that tells the UA to switch on the XSS filter.
# http://django-secure.readthedocs.io/en/latest/middleware.html#x-xss-protection-1-mode-block
SECURE_BROWSER_XSS_FILTER = True
# Prevents the site from being deployed within a iframe.
# This prevent click-jacking attacks.
# See; https://docs.djangoproject.com/en/1.11/ref/clickjacking/
X_FRAME_OPTIONS = 'DENY'
#####################################################
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': os.environ['DATABASE_NAME'],
'HOST': os.environ['DATABASE_HOST'],
'PORT': os.environ['DATABASE_PORT'],
'USER' : os.environ['DATABASE_USER'],
'PASSWORD' : os.environ['DATABASE_PASSWORD'],
},
}
# Password validation
# https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = []
"""
WSGI config for atdb project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/2.0/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "ldvspec.settings.docker_sdc")
application = get_wsgi_application()
from django.contrib import admin from django.contrib import admin
# Register your models here. # Register your models here.
from .models import LofarData
admin.site.register(LofarData)
\ No newline at end of file
<!DOCTYPE html>
{% load static %}
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>{% block myBlockTitle %}LDV Specification{% endblock %}</title>
<!-- loads the path to static files -->
<script src="https://code.jquery.com/jquery-3.3.1.min.js" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<link href='https://fonts.googleapis.com/css?family=Raleway' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.4.2/css/all.css" integrity="sha384-/rXc/GQVaYpyDdyxK+ecHPVYJSN9bmVFBvjA/9eOB+pb3F2w2N6fc5qB9Ew5yIns" crossorigin="anonymous">
<link href="{% static 'fontawesome_free/css/all.min.css' %}" rel="stylesheet" type="text/css">
<link rel="stylesheet" type="text/css" href="{% static 'ldvspec/style.css' %}"/>
<link rel="icon" href="{% static 'favicon.ico' %}">
{% block extra_js %}{% endblock %}
</head>
<body onload="readFromLocalStorage('search_box')">
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container-fluid">
<ul class="nav navbar-nav">
<!-- Header -->
<li><a class="navbar-brand" href="{% url 'index' %}">
<img src="{% static 'lofardata/ldvspec_logo.png' %}" height="30" alt="">
&nbsp;LDV Specification</a>
</li>
<li><a class="nav-link" href="{% url 'index' %}">Home</a></li>
<li><a class="nav-link" href="{% url 'lofardata' %}">LOFAR Data</a></li>
{% if user.is_authenticated %}
<a class="nav-link" href="{% url 'logout' %}" target="_blank">Logout {{ user.get_username }}</a>
{% endif %}
{% if not user.is_authenticated %}
<a class="nav-link" href="{% url 'login' %}" target="_blank">Login</a>
{% endif %}
</div>
</nav>
<!-- to add blocks of code -->
{% block myBlock %}
{% endblock %}
</body>
</html>
{% extends 'lofardata/base.html' %}
{% load static %}
{% block myBlock %}
<div class="container-fluid details-container">
<div class="row">
</div>
<p class="footer"> Version 1.0.0 (12 jul 2022 - 10:00)
</div>
{% endblock %}
...@@ -14,4 +14,7 @@ urlpatterns = [ ...@@ -14,4 +14,7 @@ urlpatterns = [
# REST API # REST API
path('lofardata/', views.LofarDataView.as_view(), name='lofardata'), path('lofardata/', views.LofarDataView.as_view(), name='lofardata'),
# GUI
path('', views.IndexView.as_view(), name='index'),
] ]
\ No newline at end of file
from django.http import HttpResponse from django.views.generic import ListView
from rest_framework import generics, pagination from rest_framework import generics, pagination
from rest_framework.views import APIView from rest_framework.views import APIView
...@@ -19,13 +19,18 @@ class LofarDataFilter(filters.FilterSet): ...@@ -19,13 +19,18 @@ class LofarDataFilter(filters.FilterSet):
'sas_id': ['exact', 'icontains'], 'sas_id': ['exact', 'icontains'],
} }
# --- GUI --- # ---------- GUI Views -----------
def index(request): class IndexView(ListView):
return HttpResponse("Welcome to LDV-specification.") """
This is the main view of LDV Specification GUI.
"""
template_name = 'lofardata/index.html'
model = LofarData
queryset = LofarData.objects.all().order_by('sas_id')
# --- REST API views --- # ---------- REST API views ----------
class LofarDataView(generics.ListCreateAPIView): class LofarDataView(generics.ListCreateAPIView):
model = LofarData model = LofarData
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment