add htmx
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
from django.contrib import admin
|
||||
from .models import PasswordEntry
|
||||
|
||||
# Register your models here.
|
||||
admin.site.register(PasswordEntry)
|
||||
|
||||
@@ -13,6 +13,9 @@ class PasswordEntry(models.Model):
|
||||
class Meta:
|
||||
unique_together = ('site', 'username', 'client_id')
|
||||
|
||||
def __str__(self):
|
||||
return self.username
|
||||
|
||||
class MasterHash(models.Model):
|
||||
hash = models.BinaryField()
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
39
wallet_api/templates/base.html
Normal file
39
wallet_api/templates/base.html
Normal file
@@ -0,0 +1,39 @@
|
||||
{% load static %}
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
|
||||
<!-- Bootstrap CSS -->
|
||||
<link
|
||||
href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css"
|
||||
rel="stylesheet"
|
||||
integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC"
|
||||
crossorigin="anonymous"
|
||||
/>
|
||||
|
||||
<script src="{% static 'js/htmx.min.js' %}" defer></script>
|
||||
|
||||
<title>{% if title %}: {{title}} {% endif %}</title>
|
||||
|
||||
{% block extra_head %} {% endblock extra_head %} {% block extra_script %}
|
||||
{%endblock extra_script %}
|
||||
</head>
|
||||
<body>
|
||||
{% block container %}
|
||||
<main role="main" class="container">
|
||||
{% block content %} {% endblock content %}
|
||||
</main>
|
||||
{% endblock container %} {% block footer %} {% endblock footer %}
|
||||
|
||||
<!-- Bootstrap Javascript -->
|
||||
<script
|
||||
src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js"
|
||||
integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM"
|
||||
crossorigin="anonymous"
|
||||
></script>
|
||||
|
||||
{% block body_script %} {% endblock body_script %}
|
||||
</body>
|
||||
</html>
|
||||
27
wallet_api/templates/wallet_api/list_users.html
Normal file
27
wallet_api/templates/wallet_api/list_users.html
Normal file
@@ -0,0 +1,27 @@
|
||||
{% extends "base.html" %} {% load static %} {% block content %}
|
||||
<h1>List Mosquitto Users</h1>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">#</th>
|
||||
<th scope="col">Site</th>
|
||||
<th scope="col">Username</th>
|
||||
<th scope="col">Client ID</th>
|
||||
<th scope="col">Topic</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for user in users %}
|
||||
<tr>
|
||||
<th scope="row">{{ user.id }}</th>
|
||||
<td>{{ user.site }}</td>
|
||||
<td>{{ user.username }}</td>
|
||||
<td>{{ user.client_id }}</td>
|
||||
<td>{{ user.topic }}</td>
|
||||
</tr>
|
||||
{% empty %}
|
||||
<i> No users </i>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% endblock content %}
|
||||
@@ -6,4 +6,5 @@ urlpatterns = [
|
||||
path('get/', views.get_password_api, name='get_password'),
|
||||
path('delete/', views.delete_password_api, name='delete_password'),
|
||||
path('list/', views.list_sites_api, name='list_sites'),
|
||||
path('user/list/', views.list_users, name='list_users'),
|
||||
]
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
from django.http import JsonResponse
|
||||
from django.shortcuts import render
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
from .models import PasswordEntry
|
||||
from .models import PasswordEntry, MasterHash
|
||||
from .utils import authenticate, derive_key, encrypt_password, decrypt_password
|
||||
import json
|
||||
|
||||
def list_users(request):
|
||||
users = PasswordEntry.objects.all()
|
||||
return render(request, 'wallet_api/list_users.html', {'users': users})
|
||||
|
||||
@csrf_exempt
|
||||
def add_password_api(request):
|
||||
if request.method == 'POST':
|
||||
|
||||
Reference in New Issue
Block a user