Update
This commit is contained in:
57
abac/templates/base.html
Normal file
57
abac/templates/base.html
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
<!-- abac/templates/base.html -->
|
||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>{% block title %}Privacy Preserving ABAC{% endblock %}</title>
|
||||||
|
<!-- Bootstrap CSS -->
|
||||||
|
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body class="d-flex flex-column min-vh-100">
|
||||||
|
<header>
|
||||||
|
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
|
||||||
|
<a class="navbar-brand" href="{% url 'home' %}">Privacy Preserving ABAC</a>
|
||||||
|
<span class="navbar-text ml-auto">
|
||||||
|
{% if user.is_authenticated %}
|
||||||
|
{{ user.username }}
|
||||||
|
<a class="btn btn-outline-light ml-3" href="{% url 'logout' %}">Logout</a>
|
||||||
|
{% else %}
|
||||||
|
<a class="btn btn-outline-light" href="{% url 'login' %}">Login</a>
|
||||||
|
{% endif %}
|
||||||
|
</span>
|
||||||
|
</nav>
|
||||||
|
{% if user.is_authenticated %}
|
||||||
|
<nav class="navbar navbar-expand-lg navbar-light bg-light">
|
||||||
|
<button class="btn btn-primary">Upload File</button>
|
||||||
|
{% if perms.abac.can_create_users %}
|
||||||
|
<button class="btn btn-primary ml-2">Create User</button>
|
||||||
|
{% endif %}
|
||||||
|
<span class="ml-auto">
|
||||||
|
<button class="btn btn-primary">Upload Certificate</button>
|
||||||
|
</span>
|
||||||
|
</nav>
|
||||||
|
{% endif %}
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<main class="flex-shrink-0">
|
||||||
|
<div class="container mt-4">
|
||||||
|
{% block content %}{% endblock %}
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
<footer class="footer mt-auto py-3 bg-dark text-white">
|
||||||
|
<div class="container text-center">
|
||||||
|
<span>© 2023 Privacy Preserving ABAC</span>
|
||||||
|
</div>
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
<!-- Bootstrap JS, Popper.js, and jQuery -->
|
||||||
|
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
|
||||||
|
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
14
abac/templates/landing_page.html
Normal file
14
abac/templates/landing_page.html
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
{% extends 'base.html' %}
|
||||||
|
|
||||||
|
{% block title %}Landing Page{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<h2>All Files</h2>
|
||||||
|
<ul>
|
||||||
|
{% for file in files %}
|
||||||
|
<li>{{ file.name }}</li>
|
||||||
|
{% empty %}
|
||||||
|
<li>No files have been uploaded yet.</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
{% endblock %}
|
||||||
12
abac/templates/login.html
Normal file
12
abac/templates/login.html
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{% extends 'base.html' %}
|
||||||
|
|
||||||
|
{% block title %}Login{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<h2>Login</h2>
|
||||||
|
<form method="post">
|
||||||
|
{% csrf_token %}
|
||||||
|
{{ form.as_p }}
|
||||||
|
<button type="submit">Login</button>
|
||||||
|
</form>
|
||||||
|
{% endblock %}
|
||||||
11
abac/urls.py
Normal file
11
abac/urls.py
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
# abac/urls.py
|
||||||
|
|
||||||
|
from django.contrib.auth import views as auth_views
|
||||||
|
from django.urls import path
|
||||||
|
|
||||||
|
from .views import landing_page
|
||||||
|
|
||||||
|
urlpatterns = [
|
||||||
|
path('login/', auth_views.LoginView.as_view(template_name='login.html'), name='login'),
|
||||||
|
path('', landing_page, name='home'),
|
||||||
|
]
|
||||||
@@ -3,7 +3,8 @@ from django.http.response import HttpResponseNotAllowed
|
|||||||
from django.contrib.auth.decorators import permission_required
|
from django.contrib.auth.decorators import permission_required
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
|
|
||||||
# Create your views here.
|
from .models import File
|
||||||
|
|
||||||
def create_user(request):
|
def create_user(request):
|
||||||
special_user = request.user
|
special_user = request.user
|
||||||
if special_user.has_perm('abac.can_create_users'):
|
if special_user.has_perm('abac.can_create_users'):
|
||||||
@@ -16,3 +17,8 @@ def create_user(request):
|
|||||||
def create_user_view(request):
|
def create_user_view(request):
|
||||||
# Your view logic here
|
# Your view logic here
|
||||||
return HttpResponse('New user created')
|
return HttpResponse('New user created')
|
||||||
|
|
||||||
|
|
||||||
|
def landing_page(request):
|
||||||
|
files = File.objects.all()
|
||||||
|
return render(request, 'landing_page.html', {'files': files})
|
||||||
@@ -123,3 +123,6 @@ STATIC_URL = 'static/'
|
|||||||
# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field
|
# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field
|
||||||
|
|
||||||
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
||||||
|
|
||||||
|
LOGIN_REDIRECT_URL = '/'
|
||||||
|
LOGOUT_REDIRECT_URL = '/'
|
||||||
|
|||||||
@@ -15,8 +15,9 @@ Including another URLconf
|
|||||||
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
||||||
"""
|
"""
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.urls import path
|
from django.urls import path, include
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('admin/', admin.site.urls),
|
path('admin/', admin.site.urls),
|
||||||
|
path('abac/', include('abac.urls')),
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user