clean apps unused like documents
This commit is contained in:
parent
3bc1eb5f83
commit
75e8a683dd
|
@ -9,12 +9,6 @@
|
||||||
<h3>{{ subtitle }}</h3>
|
<h3>{{ subtitle }}</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="col text-center">
|
<div class="col text-center">
|
||||||
{% if lot %}
|
|
||||||
<a href="{% url 'lot:documents' object.id %}" type="button" class="btn btn-green-admin">
|
|
||||||
<i class="bi bi-folder2"></i>
|
|
||||||
{% trans 'Documents' %}
|
|
||||||
</a>
|
|
||||||
{% endif %}
|
|
||||||
<a href="{# url 'dashboard:exports' object.id #}" type="button" class="btn btn-green-admin">
|
<a href="{# url 'dashboard:exports' object.id #}" type="button" class="btn btn-green-admin">
|
||||||
<i class="bi bi-reply"></i>
|
<i class="bi bi-reply"></i>
|
||||||
{% trans 'Exports' %}
|
{% trans 'Exports' %}
|
||||||
|
|
|
@ -71,17 +71,6 @@ class Device:
|
||||||
)
|
)
|
||||||
return user_properties
|
return user_properties
|
||||||
|
|
||||||
def get_user_documents(self):
|
|
||||||
if not self.uuids:
|
|
||||||
self.get_uuids()
|
|
||||||
|
|
||||||
user_properties = UserProperty.objects.filter(
|
|
||||||
uuid__in=self.uuids,
|
|
||||||
owner=self.owner,
|
|
||||||
type=UserProperty.Type.DOCUMENT
|
|
||||||
)
|
|
||||||
return user_properties
|
|
||||||
|
|
||||||
def get_uuids(self):
|
def get_uuids(self):
|
||||||
for a in self.get_properties():
|
for a in self.get_properties():
|
||||||
if a.uuid not in self.uuids:
|
if a.uuid not in self.uuids:
|
||||||
|
@ -164,7 +153,7 @@ class Device:
|
||||||
ELSE 3
|
ELSE 3
|
||||||
END,
|
END,
|
||||||
t1.created DESC
|
t1.created DESC
|
||||||
) AS row_num
|
) AS row_num
|
||||||
FROM evidence_systemproperty AS t1
|
FROM evidence_systemproperty AS t1
|
||||||
LEFT JOIN lot_devicelot AS t2 ON t1.value = t2.device_id
|
LEFT JOIN lot_devicelot AS t2 ON t1.value = t2.device_id
|
||||||
WHERE t2.device_id IS NULL
|
WHERE t2.device_id IS NULL
|
||||||
|
|
|
@ -1,251 +0,0 @@
|
||||||
{% extends "base.html" %}
|
|
||||||
{% load i18n %}
|
|
||||||
|
|
||||||
{% block content %}
|
|
||||||
<div class="row">
|
|
||||||
<div class="col">
|
|
||||||
<h3>{{ object.pk }}</h3>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="row">
|
|
||||||
<div class="col">
|
|
||||||
<div class="nav nav-tabs nav-tabs-bordered">
|
|
||||||
<li class="nav-items">
|
|
||||||
<a class="nav-link" href="{% url 'device:details' device.pk %}">General details</a>
|
|
||||||
</li>
|
|
||||||
<li class="nav-items">
|
|
||||||
<button class="nav-link active" data-bs-toggle="tab" data-bs-target="#physicalproperties">Physical properties</button>
|
|
||||||
</li>
|
|
||||||
<li class="nav-items">
|
|
||||||
<button class="nav-link" data-bs-toggle="tab" data-bs-target="#documents">Documents</button>
|
|
||||||
</li>
|
|
||||||
<li class="nav-items">
|
|
||||||
<button class="nav-link" data-bs-toggle="tab" data-bs-target="#lots">Lots</button>
|
|
||||||
</li>
|
|
||||||
<li class="nav-items">
|
|
||||||
<button class="nav-link" data-bs-toggle="tab" data-bs-target="#status">Status</button>
|
|
||||||
</li>
|
|
||||||
<li class="nav-items">
|
|
||||||
<button class="nav-link" data-bs-toggle="tab" data-bs-target="#components">Components</button>
|
|
||||||
</li>
|
|
||||||
<li class="nav-items">
|
|
||||||
<button class="nav-link" data-bs-toggle="tab" data-bs-target="#traceabiliy">Traceability log</button>
|
|
||||||
</li>
|
|
||||||
<li class="nav-items">
|
|
||||||
<a class="nav-link" href="">Web</a>
|
|
||||||
</li>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="tab-content pt-2">
|
|
||||||
|
|
||||||
<div class="tab-pane fade profile-overview" id="details">
|
|
||||||
<h5 class="card-title">Details</h5>
|
|
||||||
<div class="row mb-3">
|
|
||||||
<div class="col-lg-3 col-md-4 label ">
|
|
||||||
(<a href="/inventory/device/edit/4W8D3/">Edit Device</a>)
|
|
||||||
</div>
|
|
||||||
<div class="col-lg-9 col-md-8">
|
|
||||||
{%if object.hid %}Snapshot{% else %}Placeholder{% endif %}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-lg-3 col-md-4 label ">Phid</div>
|
|
||||||
<div class="col-lg-9 col-md-8">{{ object.id }}</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-lg-3 col-md-4 label ">Id device internal</div>
|
|
||||||
<div class="col-lg-9 col-md-8"></div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-lg-3 col-md-4 label ">Type</div>
|
|
||||||
<div class="col-lg-9 col-md-8">{{ object.type }}</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-lg-3 col-md-4 label">Manufacturer</div>
|
|
||||||
<div class="col-lg-9 col-md-8">{{ object.manufacturer|default:"" }}</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-lg-3 col-md-4 label">Model</div>
|
|
||||||
<div class="col-lg-9 col-md-8">{{ object.model|default:"" }}</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-lg-3 col-md-4 label">Part Number</div>
|
|
||||||
<div class="col-lg-9 col-md-8">{{ object.part_number|default:"" }}</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-lg-3 col-md-4 label">Serial Number</div>
|
|
||||||
<div class="col-lg-9 col-md-8">{{ object.serial_number|default:"" }}</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="tab-pane fade show active" id="physicalproperties">
|
|
||||||
<h5 class="card-title">Physical Properties</h5>
|
|
||||||
<div class="row mb-3">
|
|
||||||
<div class="col-lg-3 col-md-4 label ">
|
|
||||||
(<a href="{% url 'device:physical_edit' object.pk %}">Edit Physical Properties</a>)
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="row mb-3">
|
|
||||||
<div class="col-lg-3 col-md-4 label ">
|
|
||||||
{% load django_bootstrap5 %}
|
|
||||||
<form role="form" method="post">
|
|
||||||
{% csrf_token %}
|
|
||||||
{% if form.errors %}
|
|
||||||
<div class="alert alert-danger alert-icon alert-icon-border alert-dismissible" role="alert">
|
|
||||||
<div class="icon"><span class="mdi mdi-close-circle-o"></span></div>
|
|
||||||
<div class="message">
|
|
||||||
{% for field, error in form.errors.items %}
|
|
||||||
{{ error }}<br />
|
|
||||||
{% endfor %}
|
|
||||||
<button class="btn-close" type="button" data-dismiss="alert" aria-label="Close"></button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
{% bootstrap_form form %}
|
|
||||||
<div class="form-actions-no-box">
|
|
||||||
<a class="btn btn-grey" href="{% url 'device:details' device.pk %}">{% translate "Cancel" %}</a>
|
|
||||||
<input class="btn btn-green-admin" type="submit" name="submit" value="{% translate 'Save' %}" />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<div class="tab-pane fade profile-overview" id="lots">
|
|
||||||
<h5 class="card-title">Incoming Lots</h5>
|
|
||||||
|
|
||||||
<div class="row">
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<h5 class="card-title">Outgoing Lots</h5>
|
|
||||||
|
|
||||||
<div class="row">
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<h5 class="card-title">Temporary Lots</h5>
|
|
||||||
|
|
||||||
<div class="row">
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="tab-pane fade profile-overview" id="documents">
|
|
||||||
<div class="btn-group dropdown ml-1 mt-1" uib-dropdown="">
|
|
||||||
<a href="/inventory/device/4W8D3/document/add/" class="btn btn-primary">
|
|
||||||
<i class="bi bi-plus"></i>
|
|
||||||
Add new document
|
|
||||||
<span class="caret"></span>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<h5 class="card-title">Documents</h5>
|
|
||||||
<table class="table">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th scope="col">File</th>
|
|
||||||
<th scope="col">Type</th>
|
|
||||||
<th scope="col">Description</th>
|
|
||||||
<th scope="col" data-type="date" data-format="YYYY-MM-DD hh:mm">Uploaded on</th>
|
|
||||||
<th></th>
|
|
||||||
<th></th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="tab-pane fade profile-overview" id="status">
|
|
||||||
<h5 class="card-title">Status Details</h5>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-lg-3 col-md-4 label">Physical State</div>
|
|
||||||
<div class="col-lg-9 col-md-8">
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-lg-3 col-md-4 label">Lifecycle State</div>
|
|
||||||
<div class="col-lg-9 col-md-8">
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-lg-3 col-md-4 label">Allocated State</div>
|
|
||||||
<div class="col-lg-9 col-md-8">
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="tab-pane fade profile-overview" id="traceability">
|
|
||||||
<h5 class="card-title">Traceability log Details</h5>
|
|
||||||
<div class="list-group col-6">
|
|
||||||
|
|
||||||
<div class="list-group-item d-flex justify-content-between align-items-center">
|
|
||||||
Snapshot ✓
|
|
||||||
<small class="text-muted">14:07 23-06-2024</small>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="list-group-item d-flex justify-content-between align-items-center">
|
|
||||||
EraseCrypto ✓
|
|
||||||
<small class="text-muted">14:07 23-06-2024</small>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="list-group-item d-flex justify-content-between align-items-center">
|
|
||||||
EraseCrypto ✓
|
|
||||||
<small class="text-muted">14:07 23-06-2024</small>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="tab-pane fade profile-overview" id="components">
|
|
||||||
<h5 class="card-title">Components Snapshot</h5>
|
|
||||||
<div class="list-group col-6">
|
|
||||||
|
|
||||||
<div class="list-group-item">
|
|
||||||
<div class="d-flex w-100 justify-content-between">
|
|
||||||
<h5 class="mb-1">Motherboard</h5>
|
|
||||||
<small class="text-muted">14:07 23-06-2024</small>
|
|
||||||
</div>
|
|
||||||
<p class="mb-1">
|
|
||||||
hp<br />
|
|
||||||
890e<br />
|
|
||||||
</p>
|
|
||||||
<small class="text-muted">
|
|
||||||
</small>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="list-group-item">
|
|
||||||
<div class="d-flex w-100 justify-content-between">
|
|
||||||
<h5 class="mb-1">NetworkAdapter</h5>
|
|
||||||
<small class="text-muted">14:07 23-06-2024</small>
|
|
||||||
</div>
|
|
||||||
<p class="mb-1">
|
|
||||||
realtek semiconductor co., ltd.<br />
|
|
||||||
rtl8852ae 802.11ax pcie wireless network adapter<br />
|
|
||||||
</p>
|
|
||||||
<small class="text-muted">
|
|
||||||
</small>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% endblock %}
|
|
|
@ -10,7 +10,5 @@ urlpatterns = [
|
||||||
path("<str:pk>/user_property/add", views.AddUserPropertyView.as_view(), name="add_user_property"),
|
path("<str:pk>/user_property/add", views.AddUserPropertyView.as_view(), name="add_user_property"),
|
||||||
path("user_property/<int:pk>/delete", views.DeleteUserPropertyView.as_view(), name="delete_user_property"),
|
path("user_property/<int:pk>/delete", views.DeleteUserPropertyView.as_view(), name="delete_user_property"),
|
||||||
path("user_property/<int:pk>/update", views.UpdateUserPropertyView.as_view(), name="update_user_property"),
|
path("user_property/<int:pk>/update", views.UpdateUserPropertyView.as_view(), name="update_user_property"),
|
||||||
path("<str:pk>/document/add", views.AddDocumentView.as_view(), name="add_document"),
|
|
||||||
path("<str:pk>/public/", views.PublicDeviceWebView.as_view(), name="device_web"),
|
path("<str:pk>/public/", views.PublicDeviceWebView.as_view(), name="device_web"),
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
|
@ -293,34 +293,3 @@ class DeleteUserPropertyView(DashboardView, DeleteView):
|
||||||
|
|
||||||
def get_success_url(self):
|
def get_success_url(self):
|
||||||
return self.request.META.get('HTTP_REFERER', reverse_lazy('device:details', args=[self.object.pk]))
|
return self.request.META.get('HTTP_REFERER', reverse_lazy('device:details', args=[self.object.pk]))
|
||||||
|
|
||||||
class AddDocumentView(DashboardView, CreateView):
|
|
||||||
template_name = "new_user_property.html"
|
|
||||||
title = _("New Document")
|
|
||||||
breadcrumb = "Device / New document"
|
|
||||||
success_url = reverse_lazy('dashboard:unassigned_devices')
|
|
||||||
model = UserProperty
|
|
||||||
fields = ("key", "value")
|
|
||||||
|
|
||||||
def form_valid(self, form):
|
|
||||||
form.instance.owner = self.request.user.institution
|
|
||||||
form.instance.user = self.request.user
|
|
||||||
form.instance.uuid = self.property.uuid
|
|
||||||
form.instance.type = UserProperty.Type.DOCUMENT
|
|
||||||
response = super().form_valid(form)
|
|
||||||
return response
|
|
||||||
|
|
||||||
def get_form_kwargs(self):
|
|
||||||
pk = self.kwargs.get('pk')
|
|
||||||
institution = self.request.user.institution
|
|
||||||
self.property = SystemProperty.objects.filter(
|
|
||||||
owner=institution,
|
|
||||||
value=pk,
|
|
||||||
).first()
|
|
||||||
|
|
||||||
if not self.property:
|
|
||||||
raise Http404
|
|
||||||
|
|
||||||
self.success_url = reverse_lazy('device:details', args=[pk])
|
|
||||||
kwargs = super().get_form_kwargs()
|
|
||||||
return kwargs
|
|
||||||
|
|
|
@ -78,16 +78,13 @@ INSTALLED_APPS = [
|
||||||
'django_extensions',
|
'django_extensions',
|
||||||
'django_bootstrap5',
|
'django_bootstrap5',
|
||||||
'django_tables2',
|
'django_tables2',
|
||||||
"rest_framework",
|
|
||||||
"login",
|
"login",
|
||||||
"user",
|
"user",
|
||||||
"device",
|
"device",
|
||||||
"evidence",
|
"evidence",
|
||||||
"action",
|
|
||||||
"tag",
|
|
||||||
"lot",
|
"lot",
|
||||||
"documents",
|
|
||||||
"dashboard",
|
"dashboard",
|
||||||
|
"action",
|
||||||
"admin",
|
"admin",
|
||||||
"api",
|
"api",
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
from django.contrib import admin
|
|
||||||
|
|
||||||
# Register your models here.
|
|
|
@ -1,6 +0,0 @@
|
||||||
from django.apps import AppConfig
|
|
||||||
|
|
||||||
|
|
||||||
class DocumentsConfig(AppConfig):
|
|
||||||
default_auto_field = "django.db.models.BigAutoField"
|
|
||||||
name = "documents"
|
|
|
@ -1,3 +0,0 @@
|
||||||
from django.db import models
|
|
||||||
|
|
||||||
# Create your models here.
|
|
|
@ -1,3 +0,0 @@
|
||||||
from django.test import TestCase
|
|
||||||
|
|
||||||
# Create your tests here.
|
|
|
@ -1,3 +0,0 @@
|
||||||
from django.shortcuts import render
|
|
||||||
|
|
||||||
# Create your views here.
|
|
19
evidence/migrations/0005_alter_userproperty_type.py
Normal file
19
evidence/migrations/0005_alter_userproperty_type.py
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
# Generated by Django 5.0.6 on 2025-01-29 11:56
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
dependencies = [
|
||||||
|
("evidence", "0004_remove_userproperty_user_unique_type_key_uuid"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="userproperty",
|
||||||
|
name="type",
|
||||||
|
field=models.SmallIntegerField(
|
||||||
|
choices=[(1, "User"), (2, "EraseServer")], default=1
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]
|
|
@ -41,8 +41,7 @@ class UserProperty(Property):
|
||||||
|
|
||||||
class Type(models.IntegerChoices):
|
class Type(models.IntegerChoices):
|
||||||
USER = 1, "User"
|
USER = 1, "User"
|
||||||
DOCUMENT = 2, "Document"
|
ERASE_SERVER = 2, "EraseServer"
|
||||||
ERASE_SERVER = 3, "EraseServer"
|
|
||||||
|
|
||||||
type = models.SmallIntegerField(choices=Type, default=Type.USER)
|
type = models.SmallIntegerField(choices=Type, default=Type.USER)
|
||||||
|
|
||||||
|
|
|
@ -1,43 +0,0 @@
|
||||||
from rest_framework import serializers
|
|
||||||
from evidence.models import EvidenceJson
|
|
||||||
|
|
||||||
import json
|
|
||||||
|
|
||||||
from django.views.decorators.csrf import csrf_exempt
|
|
||||||
from django.http import JsonResponse
|
|
||||||
from evidence.parse import Parse
|
|
||||||
|
|
||||||
class EvidenceSerializer(serializers.ModelSerializer):
|
|
||||||
class Meta:
|
|
||||||
model = EvidenceJson
|
|
||||||
fields = ['id', 'title', 'content']
|
|
||||||
|
|
||||||
@csrf_exempt
|
|
||||||
def webhook_verify(request):
|
|
||||||
if request.method == 'POST':
|
|
||||||
auth_header = request.headers.get('Authorization')
|
|
||||||
if not auth_header or not auth_header.startswith('Bearer '):
|
|
||||||
return JsonResponse({'error': 'Invalid authorization'}, status=401)
|
|
||||||
|
|
||||||
token = auth_header.split(' ')[1]
|
|
||||||
tk = Token.objects.filter(token=token).first()
|
|
||||||
if not tk:
|
|
||||||
return JsonResponse({'error': 'Invalid authorization'}, status=401)
|
|
||||||
|
|
||||||
try:
|
|
||||||
data = json.loads(request.body)
|
|
||||||
except json.JSONDecodeError:
|
|
||||||
return JsonResponse({'error': 'Invalid JSON'}, status=400)
|
|
||||||
|
|
||||||
try:
|
|
||||||
device = Parse(data)
|
|
||||||
except Exception:
|
|
||||||
return JsonResponse({'error': 'Invalid JSON'}, status=400)
|
|
||||||
|
|
||||||
if not device:
|
|
||||||
return JsonResponse({'error': 'Invalid JSON'}, status=400)
|
|
||||||
|
|
||||||
return JsonResponse({"result": "Ok"}, status=200)
|
|
||||||
|
|
||||||
|
|
||||||
return JsonResponse({'error': 'Invalid request method'}, status=400)
|
|
19
lot/migrations/0005_alter_lotproperty_type.py
Normal file
19
lot/migrations/0005_alter_lotproperty_type.py
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
# Generated by Django 5.0.6 on 2025-01-29 11:56
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
dependencies = [
|
||||||
|
("lot", "0004_remove_lotproperty_lot_unique_type_key_lot_and_more"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="lotproperty",
|
||||||
|
name="type",
|
||||||
|
field=models.SmallIntegerField(
|
||||||
|
choices=[(0, "System"), (1, "User")], default=1
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]
|
|
@ -6,8 +6,8 @@ from utils.constants import (
|
||||||
STR_EXTEND_SIZE,
|
STR_EXTEND_SIZE,
|
||||||
)
|
)
|
||||||
|
|
||||||
from user.models import User, Institution
|
from user.models import User, Institution
|
||||||
from evidence.models import Property
|
from evidence.models import Property
|
||||||
# from device.models import Device
|
# from device.models import Device
|
||||||
|
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ class Lot(models.Model):
|
||||||
if DeviceLot.objects.filter(lot=self, device_id=v).exists():
|
if DeviceLot.objects.filter(lot=self, device_id=v).exists():
|
||||||
return
|
return
|
||||||
DeviceLot.objects.create(lot=self, device_id=v)
|
DeviceLot.objects.create(lot=self, device_id=v)
|
||||||
|
|
||||||
def remove(self, v):
|
def remove(self, v):
|
||||||
for d in DeviceLot.objects.filter(lot=self, device_id=v):
|
for d in DeviceLot.objects.filter(lot=self, device_id=v):
|
||||||
d.delete()
|
d.delete()
|
||||||
|
@ -51,6 +51,5 @@ class LotProperty (Property):
|
||||||
class Type(models.IntegerChoices):
|
class Type(models.IntegerChoices):
|
||||||
SYSTEM = 0, "System"
|
SYSTEM = 0, "System"
|
||||||
USER = 1, "User"
|
USER = 1, "User"
|
||||||
DOCUMENT = 2, "Document"
|
|
||||||
|
|
||||||
type = models.SmallIntegerField(choices=Type.choices, default=Type.USER)
|
type = models.SmallIntegerField(choices=Type.choices, default=Type.USER)
|
||||||
|
|
|
@ -1,48 +0,0 @@
|
||||||
{% extends "base.html" %}
|
|
||||||
{% load i18n %}
|
|
||||||
|
|
||||||
{% block content %}
|
|
||||||
<div class="row">
|
|
||||||
<div class="col">
|
|
||||||
<h3>Lot {{ lot.name }}</h3>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="row">
|
|
||||||
<div class="tab-pane fade show active" id="details">
|
|
||||||
<div class="btn-group dropdown ml-1 mt-1" uib-dropdown="">
|
|
||||||
<a href="{% url 'lot:add_document' lot.pk %}" class="btn btn-primary">
|
|
||||||
|
|
||||||
<i class="bi bi-plus"></i>
|
|
||||||
Add new document
|
|
||||||
<span class="caret"></span>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<h5 class="card-title mt-2">Documents</h5>
|
|
||||||
<table class="table table-striped">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th scope="col">Key</th>
|
|
||||||
<th scope="col">Value</th>
|
|
||||||
<th scope="col" data-type="date" data-format="YYYY-MM-DD hh:mm">Created on</th>
|
|
||||||
<th></th>
|
|
||||||
<th></th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{% for a in documents %}
|
|
||||||
<tr>
|
|
||||||
<td>{{ a.key }}</td>
|
|
||||||
<td>{{ a.value }}</td>
|
|
||||||
<td>{{ a.created }}</td>
|
|
||||||
<td></td>
|
|
||||||
<td></td>
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
|
||||||
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% endblock %}
|
|
|
@ -10,8 +10,6 @@ urlpatterns = [
|
||||||
path("add/devices/", views.AddToLotView.as_view(), name="add_devices"),
|
path("add/devices/", views.AddToLotView.as_view(), name="add_devices"),
|
||||||
path("del/devices/", views.DelToLotView.as_view(), name="del_devices"),
|
path("del/devices/", views.DelToLotView.as_view(), name="del_devices"),
|
||||||
path("tag/<int:pk>/", views.LotsTagsView.as_view(), name="tag"),
|
path("tag/<int:pk>/", views.LotsTagsView.as_view(), name="tag"),
|
||||||
path("<int:pk>/document/", views.LotDocumentsView.as_view(), name="documents"),
|
|
||||||
path("<int:pk>/document/add", views.LotAddDocumentView.as_view(), name="add_document"),
|
|
||||||
path("<int:pk>/property", views.LotPropertiesView.as_view(), name="properties"),
|
path("<int:pk>/property", views.LotPropertiesView.as_view(), name="properties"),
|
||||||
path("<int:pk>/property/add", views.AddLotPropertyView.as_view(), name="add_property"),
|
path("<int:pk>/property/add", views.AddLotPropertyView.as_view(), name="add_property"),
|
||||||
path("<int:pk>/property/update", views.UpdateLotPropertyView.as_view(), name="update_property"),
|
path("<int:pk>/property/update", views.UpdateLotPropertyView.as_view(), name="update_property"),
|
||||||
|
|
47
lot/views.py
47
lot/views.py
|
@ -142,53 +142,6 @@ class LotsTagsView(DashboardView, TemplateView):
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
||||||
class LotAddDocumentView(DashboardView, CreateView):
|
|
||||||
template_name = "new_property.html"
|
|
||||||
title = _("New Document")
|
|
||||||
breadcrumb = "Device / New document"
|
|
||||||
success_url = reverse_lazy('dashboard:unassigned_devices')
|
|
||||||
model = LotProperty
|
|
||||||
fields = ("key", "value")
|
|
||||||
|
|
||||||
def form_valid(self, form):
|
|
||||||
form.instance.owner = self.request.user.institution
|
|
||||||
form.instance.user = self.request.user
|
|
||||||
form.instance.lot = self.lot
|
|
||||||
form.instance.type = LotProperty.Type.DOCUMENT
|
|
||||||
response = super().form_valid(form)
|
|
||||||
return response
|
|
||||||
|
|
||||||
def get_form_kwargs(self):
|
|
||||||
pk = self.kwargs.get('pk')
|
|
||||||
self.lot = get_object_or_404(Lot, pk=pk, owner=self.request.user.institution)
|
|
||||||
self.success_url = reverse_lazy('lot:documents', args=[pk])
|
|
||||||
kwargs = super().get_form_kwargs()
|
|
||||||
return kwargs
|
|
||||||
|
|
||||||
|
|
||||||
class LotDocumentsView(DashboardView, TemplateView):
|
|
||||||
template_name = "documents.html"
|
|
||||||
title = _("New Document")
|
|
||||||
breadcrumb = "Devicce / New document"
|
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
|
||||||
self.pk = kwargs.get('pk')
|
|
||||||
context = super().get_context_data(**kwargs)
|
|
||||||
lot = get_object_or_404(Lot, owner=self.request.user.institution, id=self.pk)
|
|
||||||
documents = LotProperty.objects.filter(
|
|
||||||
lot=lot,
|
|
||||||
owner=self.request.user.institution,
|
|
||||||
type=LotProperty.Type.DOCUMENT,
|
|
||||||
)
|
|
||||||
context.update({
|
|
||||||
'lot': lot,
|
|
||||||
'documents': documents,
|
|
||||||
'title': self.title,
|
|
||||||
'breadcrumb': self.breadcrumb
|
|
||||||
})
|
|
||||||
return context
|
|
||||||
|
|
||||||
|
|
||||||
class LotPropertiesView(DashboardView, TemplateView):
|
class LotPropertiesView(DashboardView, TemplateView):
|
||||||
template_name = "properties.html"
|
template_name = "properties.html"
|
||||||
title = _("New Lot Property")
|
title = _("New Lot Property")
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
from django.contrib import admin
|
|
||||||
|
|
||||||
# Register your models here.
|
|
|
@ -1,6 +0,0 @@
|
||||||
from django.apps import AppConfig
|
|
||||||
|
|
||||||
|
|
||||||
class TagConfig(AppConfig):
|
|
||||||
default_auto_field = "django.db.models.BigAutoField"
|
|
||||||
name = "tag"
|
|
|
@ -1,3 +0,0 @@
|
||||||
from django.db import models
|
|
||||||
|
|
||||||
# Create your models here.
|
|
|
@ -1,3 +0,0 @@
|
||||||
from django.test import TestCase
|
|
||||||
|
|
||||||
# Create your tests here.
|
|
|
@ -1,3 +0,0 @@
|
||||||
from django.shortcuts import render
|
|
||||||
|
|
||||||
# Create your views here.
|
|
Loading…
Reference in a new issue