Compare commits

..

139 commits

Author SHA1 Message Date
pedro 976ce43e6e Merge pull request 'redefine_algorithm_names' (#48) from redefine_algorithm_names into main
Reviewed-on: #48
2025-02-10 12:18:49 +00:00
Cayo Puigdefabregas c540bb7f7f redefine algo names as hidalgo1 for ereuse24 2025-02-10 13:16:32 +01:00
pedro 7145e721f1 Merge pull request 'Properties rework, States, StatesDefinitions, DeviceLog, and Notes' (#37) from feature/states into main
Reviewed-on: #37
2025-02-10 12:05:57 +00:00
Cayo Puigdefabregas 3db94ee82b fix more than one snapshot 2025-01-31 17:35:41 +01:00
Cayo Puigdefabregas 5cf51df952 fix rebase with main 2025-01-31 17:11:51 +01:00
Cayo Puigdefabregas e7d958c550 fix lot properties and clean absurd code from chatgpt 2025-01-31 16:53:29 +01:00
Cayo Puigdefabregas 2e932b9725 fix redirect correctly from buttons 2025-01-31 16:53:29 +01:00
Cayo Puigdefabregas a4fb574d07 fix error editing states 2025-01-31 16:53:29 +01:00
Cayo Puigdefabregas a52ce5c889 clean apps unused like documents 2025-01-31 16:53:29 +01:00
Cayo Puigdefabregas f9b93d4790 rebuild details template 2025-01-31 16:53:29 +01:00
Cayo Puigdefabregas 00df679156 fix rebase in parse 2025-01-31 16:53:29 +01:00
pedro 0259c2be2c tests: clarification on error/test 2025-01-31 16:53:29 +01:00
pedro a496045f4d add .editorconfig 2025-01-31 16:53:29 +01:00
pedro 73bb3b4751 e2e: progress 2025-01-31 16:53:29 +01:00
pedro 0db033e2dd init end-to-end tests with playwright 2025-01-31 16:53:29 +01:00
Cayo Puigdefabregas b58cfc9ab1 fix base template 2025-01-31 16:52:12 +01:00
Cayo Puigdefabregas 1cb09fb19f split long line 2025-01-31 16:52:12 +01:00
Cayo Puigdefabregas 9565288eee add version 2025-01-31 16:52:12 +01:00
Cayo Puigdefabregas 8b9ea1cf10 replace waring for yellow in details 2025-01-31 16:52:12 +01:00
Thomas Nahuel Rusiecki ad497e6299 deleting obsolete if statement 2025-01-31 16:52:12 +01:00
Thomas Nahuel Rusiecki c383e692c3 renamed property variable to prop 2025-01-31 16:52:12 +01:00
Thomas Nahuel Rusiecki 4da9961eea added missing components tab 2025-01-31 16:52:12 +01:00
Thomas Nahuel Rusiecki c0c4e29fdc added logging for evidence tag changes 2025-01-31 16:52:12 +01:00
Thomas Nahuel Rusiecki 0a50f75ca4 text size adjustment and displaying none states 2025-01-31 16:52:12 +01:00
Thomas Nahuel Rusiecki 8136684b91 more contrast on save note button 2025-01-31 16:52:12 +01:00
Thomas Nahuel Rusiecki 67d7621509 states and notes view refactoring 2025-01-31 16:52:12 +01:00
Thomas Nahuel Rusiecki 86a7d9f733 userproperties views refactoring 2025-01-31 16:52:12 +01:00
Thomas Nahuel Rusiecki a06cf9f4da better bootstrap tables 2025-01-31 16:52:12 +01:00
Thomas Nahuel Rusiecki a0596f618b view changes 2025-01-31 16:52:12 +01:00
Thomas Nahuel Rusiecki afb7cf8d6e better representiation of delete/edit notes 2025-01-31 16:52:12 +01:00
Thomas Nahuel Rusiecki df386136ce edit update cannot be blank 2025-01-31 16:52:12 +01:00
Thomas Nahuel Rusiecki b1b9f7e100 adding remove button for notes 2025-01-31 16:52:12 +01:00
Thomas Nahuel Rusiecki 8f0b8771a7 notes now can be updated 2025-01-31 16:52:12 +01:00
Thomas Nahuel Rusiecki 11813db7f6 deleted undo state view 2025-01-31 16:52:12 +01:00
Thomas Nahuel Rusiecki 86c2a26130 added a sidebar notes display 2025-01-31 16:52:12 +01:00
Thomas Nahuel Rusiecki 6b7fd09777 changes to state defiinitions list 2025-01-31 16:52:12 +01:00
Thomas Nahuel Rusiecki 643e6c1f45 better success message and removed devicelog var 2025-01-31 16:52:12 +01:00
Thomas Nahuel Rusiecki 2837d3e560 normalized deviceLog messages 2025-01-31 16:52:12 +01:00
Thomas Nahuel Rusiecki 3bed441d10 command for adding default states 2025-01-31 16:52:12 +01:00
Thomas Nahuel Rusiecki 0fb3df0155 erased old logger 2025-01-31 16:52:12 +01:00
Thomas Nahuel Rusiecki 3e2a5f03bf minor cosmetic changes 2025-01-31 16:52:12 +01:00
Thomas Nahuel Rusiecki 1f4515781a state definition list changes and disabled logging 2025-01-31 16:52:12 +01:00
Thomas Nahuel Rusiecki a1381f68fa default value for no state 2025-01-31 16:52:12 +01:00
Thomas Nahuel Rusiecki fcc93955c4 adding orm migrations 2025-01-31 16:52:12 +01:00
Thomas Nahuel Rusiecki 455448aea2 log list now shows log table 2025-01-31 16:52:12 +01:00
Thomas Nahuel Rusiecki afcb6feb22 added logging for states, user properties and notes 2025-01-31 16:52:12 +01:00
Thomas Nahuel Rusiecki 0ca4a83f97 simpler state change and action input 2025-01-31 16:52:12 +01:00
Thomas Nahuel Rusiecki c93915f285 current state table erased and spacing fix 2025-01-31 16:52:12 +01:00
Thomas Nahuel Rusiecki 2b0f0b8d08 deleted unique constraint on userproperty 2025-01-31 16:52:12 +01:00
Thomas Nahuel Rusiecki 18ec5d74c9 notes and log models added 2025-01-31 16:52:12 +01:00
Thomas Nahuel Rusiecki 63c427e3eb device tag bugfix 2025-01-31 16:52:12 +01:00
Thomas Nahuel Rusiecki 5a5dfc3319 lotproperties delete and update added 2025-01-31 16:52:12 +01:00
Thomas Nahuel Rusiecki 519648226b added action migration 2025-01-31 16:52:12 +01:00
Thomas Nahuel Rusiecki 24f5508462 now check for state on delete modal 2025-01-31 16:52:12 +01:00
Thomas Nahuel Rusiecki 0d8ec72d7c cosmetic changes to statesdefinitions list 2025-01-31 16:52:12 +01:00
Thomas Nahuel Rusiecki d75cd75c86 change state delete to undo last state 2025-01-31 16:52:12 +01:00
Thomas Nahuel Rusiecki 85013a340e help icon added and new icon on add button 2025-01-31 16:52:12 +01:00
Thomas Nahuel Rusiecki 24753b1004 minor changes to states view 2025-01-31 16:52:12 +01:00
Thomas Nahuel Rusiecki 2dfe313076 statedefinitions update and delete popup changes 2025-01-31 16:52:12 +01:00
Thomas Nahuel Rusiecki 3db4374cd0 changes to state definitions list 2025-01-31 16:52:12 +01:00
Thomas Nahuel Rusiecki cf48000ef4 statedefinitions edit popup added and url changes 2025-01-31 16:52:12 +01:00
Thomas Nahuel Rusiecki 30826afd45 state button rework and warning if same state 2025-01-31 16:52:12 +01:00
Thomas Nahuel Rusiecki c530454054 current state helper function added 2025-01-31 16:52:12 +01:00
Thomas Nahuel Rusiecki 6e88f77c1b Device-details html modularized into several files 2025-01-31 16:52:11 +01:00
Thomas Nahuel Rusiecki 70175be472 statedefinitions list updated 2025-01-31 16:47:42 +01:00
Thomas Nahuel Rusiecki dbd837b079 updated logging for states 2025-01-31 16:47:42 +01:00
Thomas Nahuel Rusiecki 7a55501c34 statedefinitions delete now uses correct id 2025-01-31 16:47:42 +01:00
Thomas Nahuel Rusiecki d92dec28bb logging for statedefinitions 2025-01-31 16:47:42 +01:00
Thomas Nahuel Rusiecki 3467a483e7 better delete modal 2025-01-31 16:47:42 +01:00
Thomas Nahuel Rusiecki 5a448755c2 erase_server type now userproperty 2025-01-31 16:47:42 +01:00
Thomas Nahuel Rusiecki f3f18e0962 deleted obsolete field type for sysproperties 2025-01-31 16:47:42 +01:00
Thomas Nahuel Rusiecki 080ff4f668 updated views for new model structure 2025-01-31 16:47:42 +01:00
Thomas Nahuel Rusiecki ec9ae644b9 more property model refactoring 2025-01-31 16:47:42 +01:00
Thomas Nahuel Rusiecki b5c57aa4d2 property models refactor 2025-01-31 16:47:42 +01:00
Thomas Nahuel Rusiecki 68d8ff33a7 added logging for user property creation 2025-01-31 16:47:42 +01:00
Thomas Nahuel Rusiecki 3cf6af0c25 made log var a env variable 2025-01-31 16:47:42 +01:00
Thomas Nahuel Rusiecki 4d38e75bba added loggin for state actions 2025-01-31 16:47:42 +01:00
Thomas Nahuel Rusiecki 5c7db7d60d added state delete 2025-01-31 16:47:42 +01:00
Thomas Nahuel Rusiecki 4045baac9f changed tab to log and added logging 2025-01-31 16:47:42 +01:00
Thomas Nahuel Rusiecki 0e3bba0569 changed state visual and ordering 2025-01-31 16:47:42 +01:00
Thomas Nahuel Rusiecki 012e25d086 minor fix for correct tab handling 2025-01-31 16:47:42 +01:00
Thomas Nahuel Rusiecki cfa4b9a291 added current state to device details 2025-01-31 16:47:42 +01:00
Thomas Nahuel Rusiecki 9a9970336b added view and url for new action 2025-01-31 16:47:42 +01:00
Thomas Nahuel Rusiecki 2f23ed7e88 state institution now nullable 2025-01-31 16:47:42 +01:00
Thomas Nahuel Rusiecki 7470dc5de2 condition checking and renaming 2025-01-31 16:47:42 +01:00
Thomas Nahuel Rusiecki 57954d66e2 stylish new popup for state change 2025-01-31 16:47:42 +01:00
Thomas Nahuel Rusiecki ede5d6a6c5 added Sortable js dependency for tables 2025-01-31 16:47:42 +01:00
Thomas Nahuel Rusiecki 62ccf46194 added form for state definition order update 2025-01-31 16:47:42 +01:00
Thomas Nahuel Rusiecki 3b0735faec minor cosmetic changes 2025-01-31 16:47:42 +01:00
Thomas Nahuel Rusiecki 3670fda2a3 changed delete button to icon 2025-01-31 16:47:42 +01:00
Thomas Nahuel Rusiecki 6d44aa855b send button hidden until changes are made 2025-01-31 16:47:42 +01:00
Thomas Nahuel Rusiecki 4485517221 sortable list now updates order of definitions 2025-01-31 16:47:42 +01:00
Thomas Nahuel Rusiecki b9ffd788a1 added Sortable js for state definitions list 2025-01-31 16:47:42 +01:00
Thomas Nahuel Rusiecki bad82965e9 added model level constraints 2025-01-31 16:47:42 +01:00
Thomas Nahuel Rusiecki eecaef7cff modals for state definition deletion 2025-01-31 16:47:42 +01:00
Thomas Nahuel Rusiecki fb6c243ee8 delete view added and some refactorig 2025-01-31 16:47:42 +01:00
Thomas Nahuel Rusiecki ff9a78ed23 added add state definition view 2025-01-31 16:47:42 +01:00
Thomas Nahuel Rusiecki 5fcd9ce7ca changed constrain on model 2025-01-31 16:47:42 +01:00
Thomas Nahuel Rusiecki 539f5b5bb7 fixed models confusion 2025-01-31 16:47:42 +01:00
Thomas Nahuel Rusiecki 5e2c8f2328 added model constraints 2025-01-31 16:47:42 +01:00
Thomas Nahuel Rusiecki 2451e843ac added admin state definition panel 2025-01-31 16:47:42 +01:00
Thomas Nahuel Rusiecki acbe2f6a75 initial orm state models 2025-01-31 16:47:42 +01:00
Thomas Nahuel Rusiecki 2bb9e8d035 centered popup modals 2025-01-31 16:47:42 +01:00
Thomas Nahuel Rusiecki 35622ff9c7 disabled lotPoperty field 2025-01-31 16:47:42 +01:00
Thomas Nahuel Rusiecki ff928a381b added logging for device operations 2025-01-31 16:47:42 +01:00
Thomas Nahuel Rusiecki 09bed0a904 renaming lotAnnotations to Lotproperty 2025-01-31 16:47:42 +01:00
Thomas Nahuel Rusiecki 9807cb56aa renaming of annotation to property 2025-01-31 16:47:42 +01:00
Thomas Nahuel Rusiecki e0e4fd862a change edit view to modal popup 2025-01-31 16:47:42 +01:00
Thomas Nahuel Rusiecki b4f0909199 added userproperty update view 2025-01-31 16:47:42 +01:00
Thomas Nahuel Rusiecki db59b099f5 added user_property 2025-01-31 16:47:42 +01:00
Thomas Nahuel Rusiecki 963858263a model constraints changed and moved url to /device 2025-01-31 16:47:42 +01:00
Thomas Nahuel Rusiecki 4bc423a979 fixed search and moved delete user property class 2025-01-31 16:47:42 +01:00
Thomas Nahuel Rusiecki 4d9f588ad7 renaming to new Property tables 2025-01-31 16:47:42 +01:00
Thomas Nahuel Rusiecki 42b13eec84 details view changed to now use properties 2025-01-31 16:47:42 +01:00
Thomas Nahuel Rusiecki fcefddb5a0 fixed user_properties list not working 2025-01-31 16:47:42 +01:00
Thomas Nahuel Rusiecki 8991faa423 renaming to property 2025-01-31 16:47:42 +01:00
Thomas Nahuel Rusiecki 9df611293a changed imports 2025-01-31 16:47:42 +01:00
Thomas Nahuel Rusiecki 9c27a30399 fixed self inflicted recursion 2025-01-31 16:47:42 +01:00
Thomas Nahuel Rusiecki 13d325105f renaming annotation to variable 2025-01-31 16:47:42 +01:00
Thomas Nahuel Rusiecki 09c3f96185 variables and function semantic renaming 2025-01-31 16:47:42 +01:00
Thomas Nahuel Rusiecki dad8e40ee8 split into system and user properties 2025-01-31 16:47:42 +01:00
Thomas Nahuel Rusiecki f7cd7bc3f2 annotations renaming on views 2025-01-31 16:47:42 +01:00
pedro 1f0a9a60ce add file snapshot_pre-verifiable-credential 2025-01-30 13:26:47 +01:00
pedro 01b7267dd8 docker: add DEMO env var to idhub 2025-01-30 13:11:55 +01:00
pedro 91c03cb990 Merge pull request 'add did document link to device details page' (#44) from diddocument into main
Reviewed-on: #44
2025-01-30 08:50:38 +00:00
pedro 9dafc51210 disable devicehub demo by default (part 2) 2025-01-30 09:27:55 +01:00
pedro 7f16552762 disable devicehub demo by default
(right now is not working, we are waiting open service feature)
2025-01-30 09:19:37 +01:00
pedro 829fb6e2a1 devicehub: don't rush on the vc signing 2025-01-30 09:05:06 +01:00
pedro 02a69e6994 devicehub: add error handling when waiting idhub 2025-01-30 08:59:01 +01:00
pedro 2ff630f212 docker: attempt to fix docker image deployment 2025-01-30 08:46:27 +01:00
pedro d7d6fb7bc6 make devicehub autosign a vc using idhub 2025-01-30 08:39:22 +01:00
pedro 096704935d better error message on receiving snapshot 2025-01-30 08:09:20 +01:00
pedro 0485604512 rename credentials according to last meeting
we found a way with cayo to generate a real credential on demo time,
and that's going to be done on following commits in this branch

related ereuse/projectes#131
2025-01-29 20:20:23 +01:00
pedro 40b0617a72 docker: add the missing predefined token config 2025-01-29 19:25:26 +01:00
pedro b1c4a2cec9 add the right SUPPORTED_CREDENTIALS 2025-01-29 19:19:57 +01:00
Cayo Puigdefabregas 9503a9a8b4 add did document to details page 2025-01-29 19:07:11 +01:00
pedro 9247f11c27 Merge pull request 'docker-add-idhub' (#43) from docker-add-idhub into main
Reviewed-on: #43
2025-01-29 17:57:48 +00:00
pedro 56d8aadf83 docker: docker for devicehub and idhub as profile 2025-01-27 17:52:24 +01:00
pedro 601da538bf add idhub to dockercompose and its .env.example 2025-01-23 12:56:55 +01:00
64 changed files with 1000 additions and 890 deletions

2
.dockerignore Normal file
View file

@ -0,0 +1,2 @@
db
.git

17
.editorconfig Normal file
View file

@ -0,0 +1,17 @@
# repository editor configuration normalization
# @see http://editorconfig.org/
# This is the top-most .editorconfig file; do not search in parent directories.
root = true
# All files.
[*]
end_of_line = LF
indent_style = space
indent_size = 4
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.sh]
indent_size = 8

View file

@ -1,5 +1,15 @@
DH_DOMAIN=localhost
DH_PORT=8000
####
# DEV OPTIONS
####
DEV_DOCKER_ALWAYS_BUILD=false
####
# DEVICEHUB
####
DEVICEHUB_DOMAIN=localhost
DEVICEHUB_PORT=8001
DEMO=true
# note that with DEBUG=true, logs are more verbose (include tracebacks)
DEBUG=true
@ -16,7 +26,48 @@ EMAIL_BACKEND="django.core.mail.backends.smtp.EmailBackend"
EMAIL_FILE_PATH="/tmp/app-messages"
ENABLE_EMAIL=false
PREDEFINED_TOKEN='5018dd65-9abd-4a62-8896-80f34ac66150'
DH_ALLOWED_HOSTS=${DH_DOMAIN},${DH_DOMAIN}:${DH_PORT},127.0.0.1,127.0.0.1:${DH_PORT}
DEVICEHUB_ALLOWED_HOSTS=${DEVICEHUB_DOMAIN},${DEVICEHUB_DOMAIN}:${DEVICEHUB_PORT},127.0.0.1,127.0.0.1:${DEVICEHUB_PORT}
# TODO review these vars
#SNAPSHOTS_DIR=/path/to/TODO
#EVIDENCES_DIR=/path/to/TODO
#DEMO_IDHUB_DOMAIN='idhub.example.org'
####
# IDHUB
####
IDHUB_ENABLED=false
IDHUB_DOMAIN=localhost
IDHUB_PORT=9001
IDHUB_ALLOWED_HOSTS=${IDHUB_DOMAIN},${IDHUB_DOMAIN}:${IDHUB_PORT},127.0.0.1,127.0.0.1:${IDHUB_PORT}
IDHUB_TIME_ZONE='Europe/Madrid'
#IDHUB_SECRET_KEY='uncomment-it-and-fill-this'
# enable dev flags when DEVELOPMENT deployment
# adapt to your domain in a production/reverse proxy env
IDHUB_CSRF_TRUSTED_ORIGINS='https://idhub.example.org'
# fill this section with your email credentials
IDHUB_DEFAULT_FROM_EMAIL="user@example.org"
IDHUB_EMAIL_HOST="smtp.example.org"
IDHUB_EMAIL_HOST_USER="smtp_user"
IDHUB_EMAIL_HOST_PASSWORD="smtp_passwd"
IDHUB_EMAIL_PORT=25
IDHUB_EMAIL_USE_TLS=True
IDHUB_EMAIL_BACKEND="django.core.mail.backends.smtp.EmailBackend"
# replace with production data
# this is used when IDHUB_DEPLOYMENT is not equal to DEVELOPMENT
IDHUB_ADMIN_USER='admin'
IDHUB_ADMIN_PASSWD='admin'
IDHUB_ADMIN_EMAIL='admin@example.org'
# this option needs to be set to 'n' to be able to make work idhub in docker
# by default it is set to 'y' to facilitate idhub dev when outside docker
IDHUB_SYNC_ORG_DEV='n'
# TODO that is only for testing
IDHUB_ENABLE_EMAIL=false
IDHUB_ENABLE_2FACTOR_AUTH=false
IDHUB_ENABLE_DOMAIN_CHECKER=false
IDHUB_PREDEFINED_TOKEN='27f944ce-3d58-4f48-b068-e4aa95f97c95'

5
.gitignore vendored
View file

@ -1,4 +1,7 @@
db.sqlite3
env/
__pycache__/
.env
# the following could be autogenerated by devicehub
db.sqlite3
example/snapshots/snapshot_workbench-script_verifiable-credential.json

View file

@ -22,6 +22,7 @@ class State(models.Model):
def __str__(self):
return f"{self.institution.name} - {self.state} - {self.snapshot_uuid}"
class StateDefinition(models.Model):
institution = models.ForeignKey(Institution, on_delete=models.CASCADE)

View file

@ -2,6 +2,7 @@ from django.views import View
from django.shortcuts import redirect, get_object_or_404
from django.contrib import messages
from action.forms import ChangeStateForm, AddNoteForm
from django.contrib.auth.mixins import LoginRequiredMixin
from django.views.generic.edit import DeleteView, CreateView, UpdateView, FormView
from django.urls import reverse_lazy
from django.utils.translation import gettext_lazy as _
@ -9,7 +10,7 @@ from action.models import State, StateDefinition, Note, DeviceLog
from device.models import Device
class ChangeStateView(FormView):
class ChangeStateView(LoginRequiredMixin, FormView):
form_class = ChangeStateForm
def form_valid(self, form):
@ -42,7 +43,7 @@ class ChangeStateView(FormView):
return self.request.META.get('HTTP_REFERER') or reverse_lazy('device:details')
class AddNoteView(FormView):
class AddNoteView(LoginRequiredMixin, FormView):
form_class = AddNoteForm
def form_valid(self, form):
@ -73,7 +74,7 @@ class AddNoteView(FormView):
return self.request.META.get('HTTP_REFERER') or reverse_lazy('device:details')
class UpdateNoteView(UpdateView):
class UpdateNoteView(LoginRequiredMixin, UpdateView):
model = Note
fields = ['description']
pk_url_kwarg = 'pk'
@ -105,7 +106,7 @@ class UpdateNoteView(UpdateView):
return self.request.META.get('HTTP_REFERER', reverse_lazy('device:details'))
class DeleteNoteView(View):
class DeleteNoteView(LoginRequiredMixin, View):
model = Note
def post(self, request, *args, **kwargs):

View file

@ -169,7 +169,8 @@ class AddStateDefinitionView(AdminView, StateDefinitionContextMixin, CreateView)
return self.form_invalid(form)
def form_invalid(self, form):
return super().form_invalid(form)
super().form_invalid(form)
return redirect(self.success_url)
class DeleteStateDefinitionView(AdminView, StateDefinitionContextMixin, SuccessMessageMixin, DeleteView):
@ -218,14 +219,21 @@ class UpdateStateDefinitionView(AdminView, UpdateView):
model = StateDefinition
template_name = 'states_panel.html'
fields = ['state']
success_url = reverse_lazy('admin:states_panel')
pk_url_kwarg = 'pk'
def get_queryset(self):
return StateDefinition.objects.filter(institution=self.request.user.institution)
def get_success_url(self):
messages.success(self.request, _("State definition updated successfully."))
return reverse_lazy('admin:states_panel')
def form_valid(self, form):
return super().form_valid(form)
try:
response = super().form_valid(form)
messages.success(self.request, _("State definition updated successfully."))
return response
except IntegrityError:
messages.error(self.request, _("State is already defined."))
return self.form_invalid(form)
def form_invalid(self, form):
super().form_invalid(form)
return redirect(self.get_success_url())

View file

@ -90,7 +90,7 @@ class NewSnapshotView(ApiMixing):
ev_uuid = data["credentialSubject"].get("uuid")
if not ev_uuid:
txt = "error: the snapshot not have uuid"
txt = "error: the snapshot does not have an uuid"
logger.error("%s", txt)
return JsonResponse({'status': txt}, status=500)
@ -118,7 +118,7 @@ class NewSnapshotView(ApiMixing):
prop = SystemProperty.objects.filter(
uuid=ev_uuid,
# TODO this is hardcoded, it should select the user preferred algorithm
key="hidalgo1",
key="ereuse24",
owner=self.tk.owner.institution
).first()

View file

@ -9,12 +9,6 @@
<h3>{{ subtitle }}</h3>
</div>
<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">
<i class="bi bi-reply"></i>
{% trans 'Exports' %}

View file

@ -71,17 +71,6 @@ class Device:
)
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):
for a in self.get_properties():
if a.uuid not in self.uuids:
@ -160,7 +149,7 @@ class Device:
ORDER BY
CASE
WHEN t1.key = 'CUSTOM_ID' THEN 1
WHEN t1.key = 'hidalgo1' THEN 2
WHEN t1.key = 'ereuse24' THEN 2
ELSE 3
END,
t1.created DESC
@ -206,7 +195,7 @@ class Device:
ORDER BY
CASE
WHEN t1.key = 'CUSTOM_ID' THEN 1
WHEN t1.key = 'hidalgo1' THEN 2
WHEN t1.key = 'ereuse24' THEN 2
ELSE 3
END,
t1.created DESC
@ -241,7 +230,7 @@ class Device:
ORDER BY
CASE
WHEN t1.key = 'CUSTOM_ID' THEN 1
WHEN t1.key = 'hidalgo1' THEN 2
WHEN t1.key = 'ereuse24' THEN 2
ELSE 3
END,
t1.created DESC
@ -305,7 +294,6 @@ class Device:
@property
def version(self):
if not self.last_evidence:
self.get_last_evidence()
return self.last_evidence.get_version()
@ -313,3 +301,8 @@ class Device:
def components(self):
self.get_last_evidence()
return self.last_evidence.get_components()
@property
def did_document(self):
self.get_last_evidence()
return self.last_evidence.get_did_document()

View file

@ -2,108 +2,6 @@
{% load i18n %}
{% block content %}
<div class="position-fixed" style="bottom: 2rem; right: 2rem; z-index: 9999; display: flex; gap: 0.5rem;">
<button class="btn btn-yellow d-flex align-items-center shadow" type="button"
data-bs-toggle="offcanvas" data-bs-target="#notesOffcanvas" aria-controls="notesOffcanvas"
data-bs-toggle="tooltip" data-bs-placement="left" title="{% trans 'View recent notes' %}">
<i class="bi bi-journal-text me-1"></i>
{% trans "Journal" %}
</button>
</div>
<!-- side panel for latest notes -->
<div class="offcanvas offcanvas-end" tabindex="-1" id="notesOffcanvas" aria-labelledby="notesOffcanvasLabel">
<div class="offcanvas-header">
<h5 id="notesOffcanvasLabel">{% trans "Latest Notes" %}</h5>
<button type="button" class="btn-close" data-bs-dismiss="offcanvas" aria-label="Close"></button>
</div>
<div class="offcanvas-body" style="margin-bottom: 5rem;">
{% for note in device_notes|slice:":4" %}
<div class="card mb-3 shadow-sm">
<div class="card-body">
<div>
<small class="text-muted">
{{ note.date|timesince }} {% trans "ago" %}
</small>
{% if user == note.user or user.is_admin %}
<span class="badge bg-yellow text-dark ms-2">{% trans "Editable" %}</span>
</div>
<blockquote
class="blockquote mt-2 p-2 bg-light fst-italic"
contenteditable="true"
style="font-size: 1.2em!important"
data-note-id="{{ note.id }}"
title="{% trans 'Click to edit this note' %}"
oninput="toggleSaveLink(this)">
{% else %}
</div>
<blockquote style="font-size: 1.2em!important" class="blockquote mt-2 p-2 fst-italic">
{% endif %}
<p data-note-id="{{ note.id }}">
{{ note.description }}
</p>
<footer class="blockquote-footer text-end mt-2" contenteditable="false">
<small>{{ note.user.get_full_name|default:note.user.username }}</small>
</footer>
</blockquote>
{% if user == note.user or user.is_admin %}
<div class="d-flex justify-content-end align-items-center">
<!-- update note button -->
<form
id="updateNoteForm{{ note.id }}"
method="post"
action="{% url 'action:update_note' note.id %}"
class="d-inline"
>
{% csrf_token %}
<input type="hidden" name="description" id="descriptionInput{{ note.id }}" value="">
<a
type="submit"
id="saveLink{{ note.id }}"
class="text-muted disabled me-4 border border-light rounded"
style="pointer-events: none;"
title="{% trans 'Save changes' %}"
onclick="submitUpdatedNote('{{ note.id }}'); return false;"
>
<i class="fas fa-save px-1"></i>
</a>
</form>
<!-- delete note button -->
<button type="button" class="btn btn-link btn-outline-danger btn-sm text-danger" id="deleteIcon{{ note.id }}" title="{% trans 'Delete note' %}" data-bs-toggle="collapse" data-bs-target="#confirmDelete{{ note.id }}">
<i class="bi bi-trash"></i>
</button>
</div>
<form class="d-inline" method="post" action="{% url 'action:delete_note' note.id %}">
{% csrf_token %}
<div class="collapse mt-2" id="confirmDelete{{ note.id }}">
<div class="card card-body border border-danger text-center">
<p class="mb-2">{% trans 'Are you sure you want to delete this note?' %}</p>
<a
href="#"
class="btn btn-sm btn-outline-danger"
onclick="submitDeleteForm({{ note.id }}); return false;"
>
{% trans 'Confirm delete' %}
</a>
</div>
</div>
</form>
{% endif %}
</div>
</div>
{% empty %}
<p>{% trans "No notes available." %}</p>
{% endfor %}
</div>
</div>
<!-- Top bar buttons -->
<div class="row">
<div class="col">
@ -166,13 +64,7 @@
<a href="#details" class="nav-link active" data-bs-toggle="tab" data-bs-target="#details">{% trans 'General details' %}</a>
</li>
<li class="nav-item">
<a href="#log" class="nav-link" data-bs-toggle="tab" data-bs-target="#log">{% trans 'Log' %}</a>
</li>
<li class="nav-item">
<a href="#user_properties" class="nav-link" data-bs-toggle="tab" data-bs-target="#user_properties">{% trans 'User properties' %}</a>
</li>
<li class="nav-item">
<a href="#documents" class="nav-link" data-bs-toggle="tab" data-bs-target="#documents">{% trans 'Documents' %}</a>
<a href="#user_properties" class="nav-link" data-bs-toggle="tab" data-bs-target="#user_properties">{% trans 'Properties' %}</a>
</li>
<li class="nav-item">
<a href="#lots" class="nav-link" data-bs-toggle="tab" data-bs-target="#lots">{% trans 'Lots' %}</a>
@ -191,6 +83,9 @@
<li class="nav-item">
<a class="nav-link" href="{% url 'device:device_web' object.id %}" target="_blank">Web</a>
</li>
<li class="nav-item">
<a href="#log" class="nav-link" data-bs-toggle="tab" data-bs-target="#log">{% trans 'Log' %}</a>
</li>
</ul>
</div>
</div>
@ -202,8 +97,6 @@
{% include 'tabs/user_properties.html' %}
{% include 'tabs/documents.html' %}
{% include 'tabs/lots.html' %}
{% include 'tabs/components.html' %}
@ -256,27 +149,5 @@
}
}
})
//Enable save button on note if changes are made to it
function toggleSaveLink(blockquoteElem) {
const saveLink = document.getElementById("saveLink" + blockquoteElem.dataset.noteId);
saveLink.classList.remove("disabled", "text-muted", "border-light");
saveLink.classList.add("text-success", "border-success");
saveLink.style.pointerEvents = "auto";
}
//updates note-update-form with new value from blockquote
function submitUpdatedNote(noteId) {
const noteParagraph = document.querySelector('p[data-note-id="' + noteId + '"]');
const newText = noteParagraph.innerText.trim();
const descriptionField = document.getElementById('descriptionInput' + noteId);
descriptionField.value = newText;
document.getElementById('updateNoteForm' + noteId).submit();
}
//simpler are u sure? confirmation message
function submitDeleteForm(noteId) {
document.getElementById('confirmDelete' + noteId).closest('form').submit();
}
</script>
{% endblock %}

View file

@ -36,7 +36,7 @@
{% endfor %}
</div>
<div class="container">
<a class="btn btn-grey" href="{% url 'dashboard:unassigned_devices' %}">{% translate "Cancel" %}</a>
<a class="btn btn-grey" href="{% url 'device:details' pk %}#user_properties">{% translate "Cancel" %}</a>
<input class="btn btn-green-admin" type="submit" name="submit" value="{% translate 'Save' %}" />
</div>

View file

@ -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 %}

View file

@ -1,49 +0,0 @@
{% load i18n %}
<div class="tab-pane fade" id="documents">
<div class="btn-group mt-1 mb-3">
<a href="{% url 'device:add_document' object.pk %}" class="btn btn-primary">
<i class="bi bi-plus">
</i>
{% trans 'Add new document' %}
</a>
</div>
<h5 class="card-title">{% trans 'Documents' %}
</h5>
<table class="table table-striped">
<thead>
<tr>
<th scope="col">
{% trans 'Key' %}
</th>
<th scope="col">
{% trans 'Value' %}
</th>
<th scope="col" data-type="date" data-format="YYYY-MM-DD HH:mm">
{% trans 'Created on' %}
</th>
<th>
</th>
<th>
</th>
</tr>
</thead>
<tbody>
{% for a in object.get_user_documents %}
<tr>
<td>{{ a.key }}
</td>
<td>{{ a.value }}
</td>
<td>{{ a.created }}
</td>
<td>
</td>
<td>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>

View file

@ -3,17 +3,32 @@
<div class="tab-pane fade" id="evidences">
<h5 class="card-title">{% trans 'List of evidences' %}</h5>
<div class="list-group col-6">
<div class="list-group col">
<table class="table">
<thead>
<tr>
<th scope="col">uuid</th>
<th scope="col">Did Document</th>
<th scope="col">{% trans "Date" %}</th>
</tr>
</thead>
<tbody>
{% for snap in object.evidences %}
<div class="list-group-item">
<div class="d-flex w-100 justify-content-between">
<small class="text-muted">{{ snap.created }}</small>
</div>
<p class="mb-1">
<tr>
<td>
<a href="{% url 'evidence:details' snap.uuid %}">{{ snap.uuid }}</a>
</p>
</div>
</td>
<td>
{% if snap.did_document %}
<a href="{{ snap.did_document }}" target="_blank">DID</a>
{% endif %}
</td>
<td>
<small class="text-muted">{{ snap.created }}</small>
</td>
</tr>
{% endfor %}
</div>
</tbody>
</table>
</div>
</div>

View file

@ -82,7 +82,7 @@
<div class="modal-footer justify-content-center">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">{% trans "Cancel" %}
</button>
<form method="post" action="{% url 'device:delete_user_property' a.id %}">
<form method="post" action="{% url 'device:delete_user_property' object.id a.id %}">
{% csrf_token %}
<button type="submit" class="btn btn-danger">{% trans "Delete" %}
</button>
@ -105,7 +105,7 @@
</button>
</div>
<div class="modal-body">
<form id="editForm{{ a.id }}" method="post" action="{% url 'device:update_user_property' a.id %}">
<form id="editForm{{ a.id }}" method="post" action="{% url 'device:update_user_property' object.id a.id %}">
{% csrf_token %}
<div class="mb-3">
<label for="key" class="form-label">{% trans "Key" %}

View file

@ -7,10 +7,11 @@ urlpatterns = [
path("add/", views.NewDeviceView.as_view(), name="add"),
path("edit/<str:pk>/", views.EditDeviceView.as_view(), name="edit"),
path("<str:pk>/", views.DetailsView.as_view(), name="details"),
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>/update", views.UpdateUserPropertyView.as_view(), name="update_user_property"),
path("<str:pk>/document/add", views.AddDocumentView.as_view(), name="add_document"),
path("<str:pk>/user_property/add",
views.AddUserPropertyView.as_view(), name="add_user_property"),
path("<str:device_id>/user_property/<int:pk>/delete",
views.DeleteUserPropertyView.as_view(), name="delete_user_property"),
path("<str:device_id>/user_property/<int:pk>/update",
views.UpdateUserPropertyView.as_view(), name="update_user_property"),
path("<str:pk>/public/", views.PublicDeviceWebView.as_view(), name="device_web"),
]

View file

@ -1,7 +1,9 @@
import json
import logging
from django.http import JsonResponse
from django.conf import settings
from django.db import IntegrityError
from django.urls import reverse_lazy
from django.contrib import messages
from django.shortcuts import get_object_or_404, redirect, Http404
@ -24,6 +26,16 @@ if settings.DPP:
from dpp.api_dlt import PROOF_TYPE
class DeviceLogMixin(DashboardView):
def log_registry(self, _uuid, msg):
DeviceLog.objects.create(
snapshot_uuid=_uuid,
event=msg,
user=self.request.user,
institution=self.request.user.institution
)
class NewDeviceView(DashboardView, FormView):
template_name = "new_device.html"
title = _("New Device")
@ -41,35 +53,6 @@ class NewDeviceView(DashboardView, FormView):
return response
# class AddToLotView(DashboardView, FormView):
# template_name = "list_lots.html"
# title = _("Add to lots")
# breadcrumb = "lot / add to lots"
# success_url = reverse_lazy('dashboard:unassigned_devices')
# form_class = LotsForm
# def get_context_data(self, **kwargs):
# context = super().get_context_data(**kwargs)
# lots = Lot.objects.filter(owner=self.request.user)
# lot_tags = LotTag.objects.filter(owner=self.request.user)
# context.update({
# 'lots': lots,
# 'lot_tags':lot_tags,
# })
# return context
# def get_form(self):
# form = super().get_form()
# form.fields["lots"].queryset = Lot.objects.filter(owner=self.request.user)
# return form
# def form_valid(self, form):
# form.devices = self.get_session_devices()
# form.save()
# response = super().form_valid(form)
# return response
class EditDeviceView(DashboardView, UpdateView):
template_name = "new_device.html"
title = _("Update Device")
@ -115,20 +98,24 @@ class DetailsView(DashboardView, TemplateView):
uuid__in=self.object.uuids,
type=PROOF_TYPE["IssueDPP"]
)
last_evidence= self.object.get_last_evidence(),
uuid=self.object.last_uuid()
last_evidence = self.object.get_last_evidence()
uuids = self.object.uuids
state_definitions = StateDefinition.objects.filter(
institution=self.request.user.institution
).order_by('order')
device_states = State.objects.filter(snapshot_uuid__in=uuids).order_by('-date')
device_logs = DeviceLog.objects.filter(
snapshot_uuid__in=uuids).order_by('-date')
device_notes = Note.objects.filter(snapshot_uuid__in=uuids).order_by('-date')
context.update({
'object': self.object,
'snapshot': last_evidence,
'lot_tags': lot_tags,
'dpps': dpps,
"state_definitions": state_definitions,
"device_states": State.objects.filter(snapshot_uuid=uuid).order_by('-date'),
"device_logs": DeviceLog.objects.filter(snapshot_uuid=uuid).order_by('-date'),
"device_notes": Note.objects.filter(snapshot_uuid=uuid).order_by('-date'),
"device_states": device_states,
"device_logs": device_logs,
"device_notes": device_notes,
})
return context
@ -189,7 +176,7 @@ class PublicDeviceWebView(TemplateView):
return JsonResponse(device_data)
class AddUserPropertyView(DashboardView, CreateView):
class AddUserPropertyView(DeviceLogMixin, CreateView):
template_name = "new_user_property.html"
title = _("New User Property")
breadcrumb = "Device / New Property"
@ -202,125 +189,107 @@ class AddUserPropertyView(DashboardView, CreateView):
form.instance.uuid = self.property.uuid
form.instance.type = UserProperty.Type.USER
message = _("<Created> UserProperty: {}: {}".format(form.instance.key, form.instance.value))
DeviceLog.objects.create(
snapshot_uuid=form.instance.uuid,
event=message,
user=self.request.user,
institution=self.request.user.institution
)
messages.success(self.request, _("User property successfully added."))
try:
response = super().form_valid(form)
messages.success(self.request, _("Property successfully added."))
log_message = _("<Created> UserProperty: {}: {}".format(
form.instance.key,
form.instance.value
))
self.log_registry(form.instance.uuid, log_message)
return response
except IntegrityError:
messages.error(self.request, _("Property is already defined."))
return self.form_invalid(form)
def get_form_kwargs(self):
pk = self.kwargs.get('pk')
institution = self.request.user.institution
self.property = get_object_or_404(SystemProperty, owner=institution, value=pk)
self.property = SystemProperty.objects.filter(
owner=institution, value=pk).first()
if not self.property:
raise Http404
return super().get_form_kwargs()
def get_success_url(self):
return reverse_lazy('device:details', args=[self.kwargs.get('pk')])
pk = self.kwargs.get('pk')
return reverse_lazy('device:details', args=[pk]) + "#user_properties"
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context['pk'] = self.kwargs.get('pk')
return context
class UpdateUserPropertyView(DashboardView, UpdateView):
class UpdateUserPropertyView(DeviceLogMixin, UpdateView):
template_name = "new_user_property.html"
title = _("Update User Property")
breadcrumb = "Device / Update Property"
model = UserProperty
fields = ("key", "value")
def get_queryset(self):
def get_form_kwargs(self):
pk = self.kwargs.get('pk')
institution = self.request.user.institution
return UserProperty.objects.filter(pk=pk, owner=institution)
self.object = get_object_or_404(UserProperty, owner=institution, pk=pk)
self.old_key = self.object.key
self.old_value = self.object.value
return super().get_form_kwargs()
def form_valid(self, form):
old_instance = self.get_object()
old_key = old_instance.key
old_value = old_instance.value
form.instance.owner = self.request.user.institution
form.instance.user = self.request.user
form.instance.type = UserProperty.Type.USER
new_key = form.cleaned_data['key']
new_value = form.cleaned_data['value']
message = _("<Updated> UserProperty: {}: {} to {}: {}".format(old_key, old_value, new_key, new_value))
DeviceLog.objects.create(
snapshot_uuid=form.instance.uuid,
event=message,
user=self.request.user,
institution=self.request.user.institution
)
try:
super().form_valid(form)
messages.success(self.request, _("Property updated successfully."))
log_message = _("<Updated> UserProperty: {}: {} to {}: {}".format(
self.old_key,
self.old_value,
new_key,
new_value
))
self.log_registry(form.instance.uuid, log_message)
# return response
return redirect(self.get_success_url())
except IntegrityError:
messages.error(self.request, _("Property is already defined."))
return self.form_invalid(form)
messages.success(self.request, _("User property updated successfully."))
return super().form_valid(form)
def form_invalid(self, form):
super().form_invalid(form)
return redirect(self.get_success_url())
def get_success_url(self):
return self.request.META.get('HTTP_REFERER', reverse_lazy('device:details', args=[self.object.pk]))
pk = self.kwargs.get('device_id')
return reverse_lazy('device:details', args=[pk]) + "#user_properties"
class DeleteUserPropertyView(DashboardView, DeleteView):
class DeleteUserPropertyView(DeviceLogMixin, DeleteView):
model = UserProperty
def get_queryset(self):
return UserProperty.objects.filter(owner=self.request.user.institution)
#using post() method because delete() method from DeleteView has some issues with messages framework
#using post() method because delete() method from DeleteView has some issues
# with messages framework
def post(self, request, *args, **kwargs):
self.object = self.get_object()
pk = self.kwargs.get('pk')
institution = self.request.user.institution
self.object = get_object_or_404(UserProperty, owner=institution, pk=pk)
self.object.delete()
message = _("<Deleted> User Property: {}:{}".format(self.object.key, self.object.value ))
DeviceLog.objects.create(
snapshot_uuid=self.object.uuid,
event=message,
user=self.request.user,
institution=self.request.user.institution
)
msg = _("<Deleted> User Property: {}:{}".format(
self.object.key,
self.object.value
))
self.log_registry(self.object.uuid, msg)
messages.info(self.request, _("User property deleted successfully."))
return self.handle_success()
def handle_success(self):
return redirect(self.get_success_url())
def get_success_url(self):
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
pk = self.kwargs.get('device_id')
return reverse_lazy('device:details', args=[pk]) + "#user_properties"

View file

@ -78,16 +78,13 @@ INSTALLED_APPS = [
'django_extensions',
'django_bootstrap5',
'django_tables2',
"rest_framework",
"login",
"user",
"device",
"evidence",
"action",
"tag",
"lot",
"documents",
"dashboard",
"action",
"admin",
"api",
]

View file

@ -1,18 +1,59 @@
services:
devicehub-django:
init: true
image: farga.pangea.org/ereuse/devicehub-django/latest
build:
context: .
dockerfile: docker/devicehub-django.Dockerfile
environment:
- DEBUG=${DEBUG:-false}
- DOMAIN=${DH_DOMAIN:-localhost}
- PORT=${DH_PORT:-8000}
- ALLOWED_HOSTS=${DH_ALLOWED_HOSTS:-$DH_DOMAIN}
- DOMAIN=${DEVICEHUB_DOMAIN:-localhost}
- PORT=${DEVICEHUB_PORT:-8000}
- ALLOWED_HOSTS=${DEVICEHUB_ALLOWED_HOSTS:-$DEVICEHUB_DOMAIN}
- DEMO=${DEMO:-false}
- DEMO_IDHUB_DOMAIN=${DEMO_IDHUB_DOMAIN:-}
- DEMO_IDHUB_PREDEFINED_TOKEN=${IDHUB_PREDEFINED_TOKEN:-}
- PREDEFINED_TOKEN=${PREDEFINED_TOKEN:-}
- DPP=${DPP:-false}
# TODO manage volumes dev vs prod
volumes:
- .:/opt/devicehub-django
ports:
- ${DH_PORT}:${DH_PORT}
- ${DEVICEHUB_PORT:-8000}:${DEVICEHUB_PORT:-8000}
# TODO add database service for idhub, meanwhile sqlite
idhub:
# https://docs.docker.com/compose/how-tos/profiles/
profiles: [idhub]
init: true
image: farga.pangea.org/ereuse/idhub/latest
environment:
- DOMAIN=${IDHUB_DOMAIN:-localhost}
- ALLOWED_HOSTS=${IDHUB_ALLOWED_HOSTS:-$IDHUB_DOMAIN}
- DEBUG=true
- DEMO=${DEMO:-false}
- INITIAL_ADMIN_EMAIL=${IDHUB_ADMIN_EMAIL}
- INITIAL_ADMIN_PASSWORD=${IDHUB_ADMIN_PASSWD}
- CREATE_TEST_USERS=true
- ENABLE_EMAIL=${IDHUB_ENABLE_EMAIL:-true}
- ENABLE_2FACTOR_AUTH=${IDHUB_ENABLE_2FACTOR_AUTH:-true}
- ENABLE_DOMAIN_CHECKER=${IDHUB_ENABLE_DOMAIN_CHECKER:-true}
- PREDEFINED_TOKEN=${IDHUB_PREDEFINED_TOKEN:-}
- SECRET_KEY=${IDHUB_SECRET_KEY:-publicsecretisnotsecureVtmKBfxpVV47PpBCF2Nzz2H6qnbd}
- STATIC_ROOT=${IDHUB_STATIC_ROOT:-/static/}
- MEDIA_ROOT=${IDHUB_MEDIA_ROOT:-/media/}
- PORT=${IDHUB_PORT:-9001}
- DEFAULT_FROM_EMAIL=${IDHUB_DEFAULT_FROM_EMAIL}
- EMAIL_HOST=${IDHUB_EMAIL_HOST}
- EMAIL_HOST_USER=${IDHUB_EMAIL_HOST_USER}
- EMAIL_HOST_PASSWORD=${IDHUB_EMAIL_HOST_PASSWORD}
- EMAIL_PORT=${IDHUB_EMAIL_PORT}
- EMAIL_USE_TLS=${IDHUB_EMAIL_USE_TLS}
- EMAIL_BACKEND=${IDHUB_EMAIL_BACKEND}
- SUPPORTED_CREDENTIALS=['Snapshot']
- SYNC_ORG_DEV=${IDHUB_SYNC_ORG_DEV}
ports:
- 9001:9001
# TODO add database service for idhub, meanwhile sqlite

View file

@ -19,12 +19,24 @@ main() {
cp -v .env.example .env
echo "WARNING: .env was not there, .env.example was copied, this only happens once"
fi
# load vars
. ./.env
if [ "${IDHUB_ENABLED:-}" = 'true' ]; then
export COMPOSE_PROFILES='idhub'
fi
# remove old database
rm -vfr ./db/*
# deactivate configured flag
rm -vfr ./already_configured
docker compose down -v
if [ "${DEV_DOCKER_ALWAYS_BUILD:-}" = 'true' ]; then
docker compose pull --ignore-buildable
docker compose build
else
docker compose pull
fi
docker compose up ${detach_arg:-}
}

View file

@ -6,6 +6,7 @@ RUN apt update && \
python3-xapian \
git \
sqlite3 \
curl \
jq \
time \
vim \
@ -37,6 +38,7 @@ RUN pip install -i https://test.pypi.org/simple/ ereuseapitest==0.0.14
# Set PYTHONPATH to include the directory with the xapian module
ENV PYTHONPATH="${PYTHONPATH}:/usr/lib/python3/dist-packages"
COPY . .
COPY docker/devicehub-django.entrypoint.sh /
RUN chown -R app:app /opt/devicehub-django

View file

@ -118,6 +118,51 @@ END
./manage.py dlt_register_user "${DATASET_FILE}"
}
# wait until idhub api is prepared to received requests
wait_idhub() {
echo "Start waiting idhub API"
while true; do
result="$(curl -s "${url}" \
| jq -r .error \
|| echo "Reported errors, idhub API is still not ready")"
if [ "${result}" = "Invalid request method" ]; then
break
sleep 2
else
echo "Waiting idhub API"
sleep 3
fi
done
}
demo__send_to_sign_credential() {
filepath="${1}"
# hashlib.sha3_256 of PREDEFINED_TOKEN for idhub
DEMO_IDHUB_PREDEFINED_TOKEN="${DEMO_IDHUB_PREDEFINED_TOKEN:-}"
auth_header="Authorization: Bearer ${DEMO_IDHUB_PREDEFINED_TOKEN}"
json_header='Content-Type: application/json'
curl -s -X POST \
-H "${json_header}" \
-H "${auth_header}" \
-d @"${filepath}" \
"${url}" \
| jq -r .data
}
run_demo() {
if [ "${DEMO_IDHUB_DOMAIN:-}" ]; then
DEMO_IDHUB_DOMAIN="${DEMO_IDHUB_DOMAIN:-}"
# this demo only works with FQDN domain (with no ports)
url="https://${DEMO_IDHUB_DOMAIN}/webhook/sign/"
wait_idhub
demo__send_to_sign_credential \
'example/demo-snapshots-vc/snapshot_pre-verifiable-credential.json' \
> 'example/snapshots/snapshot_workbench-script_verifiable-credential.json'
fi
/usr/bin/time ./manage.py up_snapshots example/snapshots/ "${INIT_USER}"
}
config_phase() {
# TODO review this flag file
init_flagfile="${program_dir}/already_configured"
@ -132,7 +177,7 @@ config_phase() {
# 12, 13, 14
config_dpp_part1
# cleanup other spnapshots and copy dlt/dpp snapshots
# cleanup other snapshots and copy dlt/dpp snapshots
# TODO make this better
rm example/snapshots/*
cp example/dpp-snapshots/*.json example/snapshots/
@ -140,7 +185,7 @@ config_phase() {
# # 15. Add inventory snapshots for user "${INIT_USER}".
if [ "${DEMO:-}" = 'true' ]; then
/usr/bin/time ./manage.py up_snapshots example/snapshots/ "${INIT_USER}"
run_demo
fi
# remain next command as the last operation for this if conditional

View file

View file

@ -1,3 +0,0 @@
from django.contrib import admin
# Register your models here.

View file

@ -1,6 +0,0 @@
from django.apps import AppConfig
class DocumentsConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "documents"

View file

@ -1,3 +0,0 @@
from django.db import models
# Create your models here.

View file

@ -1,3 +0,0 @@
from django.test import TestCase
# Create your tests here.

View file

@ -1,3 +0,0 @@
from django.shortcuts import render
# Create your views here.

View file

@ -30,8 +30,7 @@ class UploadForm(forms.Form):
try:
file_json = json.loads(file_data)
build = Build
snap = build(file_json, None, check=True)
snap = Build(file_json, None, check=True)
exists_property = SystemProperty.objects.filter(
uuid=snap.uuid
).first()
@ -72,7 +71,6 @@ class UserTagForm(forms.Form):
self.pk = None
self.uuid = kwargs.pop('uuid', None)
self.user = kwargs.pop('user')
instance = SystemProperty.objects.filter(
uuid=self.uuid,
key='CUSTOM_ID',
@ -90,7 +88,6 @@ class UserTagForm(forms.Form):
if not data:
return False
self.tag = data
self.instance = SystemProperty.objects.filter(
uuid=self.uuid,
key='CUSTOM_ID',
@ -106,16 +103,13 @@ class UserTagForm(forms.Form):
if self.instance:
old_value = self.instance.value
if not self.tag:
message = _("<Deleted> Evidence Tag. Old Value: '{}'").format(
old_value
)
message =_("<Deleted> Evidence Tag. Old Value: '{}'").format(old_value)
self.instance.delete()
else:
self.instance.value = self.tag
self.instance.save()
if old_value != self.tag:
msg = "<Updated> Evidence Tag. Old Value: '{}'. New Value: '{}'"
message=_(msg).format(old_value, self.tag)
message=_("<Updated> Evidence Tag. Old Value: '{}'. New Value: '{}'").format(old_value, self.tag)
else:
message =_("<Created> Evidence Tag. Value: '{}'").format(self.tag)
SystemProperty.objects.create(
@ -134,7 +128,6 @@ class UserTagForm(forms.Form):
)
class ImportForm(forms.Form):
file_import = forms.FileField(label=_("File to import"))
@ -183,8 +176,8 @@ class ImportForm(forms.Form):
table = []
for row in self.rows:
doc = create_doc(row)
prop = create_property(doc, self.user)
table.append((doc, prop))
property = create_property(doc, self.user)
table.append((doc, property))
if commit:
for doc, cred in table:

View file

@ -4,7 +4,6 @@ import logging
from django.core.management.base import BaseCommand
from django.contrib.auth import get_user_model
from django.conf import settings
from utils.save_snapshots import move_json, save_in_disk
from evidence.parse import Build

View 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
),
),
]

View file

@ -0,0 +1,20 @@
# Generated by Django 5.0.6 on 2025-01-30 17:52
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('evidence', '0005_alter_userproperty_type'),
('user', '0001_initial'),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.AddConstraint(
model_name='userproperty',
constraint=models.UniqueConstraint(fields=('key', 'uuid'), name='userproperty_unique_type_key_uuid'),
),
]

View file

@ -31,11 +31,13 @@ class BuildMix:
return hid
def generate_chids(self):
self.algorithms = {
'hidalgo1': self.get_hid('hidalgo1'),
}
if settings.DPP:
self.algorithms["legacy_dpp"] = self.get_hid("legacy_dpp")
self.algorithms = {}
for k in ALGOS.keys():
if not settings.DPP and k == 'ereuse22':
continue
self.algorithms[k] = self.get_hid(k)
def get_doc(self):
self._get_components()
@ -43,7 +45,7 @@ class BuildMix:
c.pop("actions", None)
components = sorted(self.components, key=lambda x: x.get("type"))
device = self.algorithms.get('legacy_dpp')
device = self.algorithms.get('ereuse22')
doc = [("computer", device)]
@ -51,7 +53,7 @@ class BuildMix:
doc.append((c.get("type"), self.get_id_hw_dpp(c)))
def get_id_hw_dpp(self, d):
algorithm = ALGOS.get("legacy_dpp", [])
algorithm = ALGOS.get("ereuse22", [])
hid = ""
for f in algorithm:
hid += d.get(f, '')

View file

@ -37,15 +37,20 @@ class SystemProperty(Property):
class UserProperty(Property):
uuid = models.UUIDField()
class Type(models.IntegerChoices):
USER = 1, "User"
DOCUMENT = 2, "Document"
ERASE_SERVER = 3, "EraseServer"
ERASE_SERVER = 2, "EraseServer"
uuid = models.UUIDField()
type = models.SmallIntegerField(choices=Type, default=Type.USER)
class Meta:
constraints = [
models.UniqueConstraint(
fields=["key", "uuid"], name="userproperty_unique_type_key_uuid")
]
class Evidence:
def __init__(self, uuid):
@ -204,7 +209,7 @@ class Evidence:
def get_all(cls, user):
return SystemProperty.objects.filter(
owner=user.institution,
key="hidalgo1",
key="ereuse24",
).order_by("-created").values_list("uuid", "created").distinct()
def set_components(self):
@ -218,3 +223,14 @@ class Evidence:
def is_web_snapshot(self):
return self.doc.get("type") == "WebSnapshot"
def did_document(self):
if not self.doc.get("credentialSubject"):
return ''
did = self.doc.get('issuer')
if not "did:web" in did:
return ''
return "https://{}/did.json".format(
did.split("did:web:")[1].replace(":", "/")
)

View file

@ -71,7 +71,7 @@ class Build:
)
if prop:
txt = "Warning: Snapshot %s already registered (property exists)"
txt = "Warning: Snapshot %s already registered (annotation exists)"
logger.warning(txt, self.uuid)
return
@ -88,7 +88,7 @@ class Build:
return hashlib.sha3_256(doc.encode()).hexdigest()
def register_device_dlt(self):
legacy_dpp = self.build.algorithms.get('legacy_dpp')
legacy_dpp = self.build.algorithms.get('ereuse22')
chid = self.sign(legacy_dpp)
phid = self.sign(json.dumps(self.build.get_doc()))
register_device_dlt(chid, phid, self.uuid, self.user)

View file

@ -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)

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View 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
),
),
]

View file

@ -0,0 +1,20 @@
# Generated by Django 5.0.6 on 2025-01-31 10:33
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('lot', '0005_alter_lotproperty_type'),
('user', '0001_initial'),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.AddConstraint(
model_name='lotproperty',
constraint=models.UniqueConstraint(fields=('key', 'lot'), name='property_unique_type_key_lot'),
),
]

View file

@ -51,6 +51,11 @@ class LotProperty (Property):
class Type(models.IntegerChoices):
SYSTEM = 0, "System"
USER = 1, "User"
DOCUMENT = 2, "Document"
type = models.SmallIntegerField(choices=Type.choices, default=Type.USER)
class Meta:
constraints = [
models.UniqueConstraint(
fields=["key", "lot"], name="property_unique_type_key_lot")
]

View file

@ -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 %}

View file

@ -36,7 +36,7 @@
{% endfor %}
</div>
<div class="container">
<a class="btn btn-grey" href="{% url 'dashboard:unassigned_devices' %}">{% translate "Cancel" %}</a>
<a class="btn btn-grey" href="{% url 'lot:properties' lot_id %}">{% translate "Cancel" %}</a>
<input class="btn btn-green-admin" type="submit" name="submit" value="{% translate 'Save' %}" />
</div>

View file

@ -10,8 +10,8 @@
<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_property' lot.pk %}" class="btn btn-primary">
<div class="d-flex justify-content-end mt-1 mb-3">
<a href="{% url 'lot:add_property' lot.pk %}" class="btn btn-green-admin d-flex align-items-center">
<i class="bi bi-plus"></i>
Add new lot Property
@ -20,14 +20,13 @@
</div>
<h5 class="card-title mt-2">Properties</h5>
<table class="table table-striped">
<thead>
<table class="table table-hover table-bordered table-responsive align-middle">
<thead class="table-light">
<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>
<th scope="col">{% trans 'Key' %}</th>
<th scope="col">{% trans 'Value' %}</th>
<th scope="col" data-type="date" class="text-end" data-format="YYYY-MM-DD HH:mm">{% trans 'Created on' %}</th>
<th scope="col" width="5%" class="text-end"></th>
</tr>
</thead>
<tbody>
@ -35,16 +34,18 @@
<tr>
<td>{{ a.key }}</td>
<td>{{ a.value }}</td>
<td>{{ a.created }}</td>
<td class="text-center">
<a href="#" class="text-info" data-bs-toggle="modal" data-bs-target="#editPropertyModal{{ a.id }}">
<i class="bi bi-pencil"></i>
</a>
</td>
<td class="text-center">
<a href="#" class="text-danger" data-bs-toggle="modal" data-bs-target="#deletePropertyModal{{ a.id }}">
<i class="bi bi-trash"></i>
</a>
<td class="text-end">{{ a.created }}</td>
<td>
<div class="btn-group ">
<button type="button" class="btn btn-sm btn-outline-info d-flex align-items-center" data-bs-toggle="modal" data-bs-target="#editPropertyModal{{ a.id }}">
<i class="bi bi-pencil me-1"></i>
{% trans 'Edit' %}
</button>
<button type="button" class="btn btn-sm btn-outline-danger d-flex align-items-center" data-bs-toggle="modal" data-bs-target="#deletePropertyModal{{ a.id }}">
<i class="bi bi-trash me-1"></i>
{% trans 'Delete' %}
</button>
</div>
</td>
</tr>

View file

@ -10,8 +10,6 @@ urlpatterns = [
path("add/devices/", views.AddToLotView.as_view(), name="add_devices"),
path("del/devices/", views.DelToLotView.as_view(), name="del_devices"),
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/add", views.AddLotPropertyView.as_view(), name="add_property"),
path("<int:pk>/property/update", views.UpdateLotPropertyView.as_view(), name="update_property"),

View file

@ -1,3 +1,4 @@
from django.db import IntegrityError
from django.urls import reverse_lazy
from django.shortcuts import get_object_or_404, redirect, Http404
from django.contrib import messages
@ -98,7 +99,8 @@ class AddToLotView(DashboardView, FormView):
def get_form(self):
form = super().get_form()
form.fields["lots"].queryset = Lot.objects.filter(owner=self.request.user.institution)
form.fields["lots"].queryset = Lot.objects.filter(
owner=self.request.user.institution)
return form
def form_valid(self, form):
@ -132,7 +134,9 @@ class LotsTagsView(DashboardView, TemplateView):
self.title += " {}".format(tag.name)
self.breadcrumb += " {}".format(tag.name)
show_closed = self.request.GET.get('show_closed', 'false') == 'true'
lots = Lot.objects.filter(owner=self.request.user.institution).filter(type=tag, closed=show_closed)
lots = Lot.objects.filter(owner=self.request.user.institution).filter(
type=tag, closed=show_closed
)
context.update({
'lots': lots,
'title': self.title,
@ -142,53 +146,6 @@ class LotsTagsView(DashboardView, TemplateView):
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):
template_name = "properties.html"
title = _("New Lot Property")
@ -225,8 +182,13 @@ class AddLotPropertyView(DashboardView, CreateView):
form.instance.user = self.request.user
form.instance.lot = self.lot
form.instance.type = LotProperty.Type.USER
try:
response = super().form_valid(form)
messages.success(self.request, _("Property successfully added."))
return response
except IntegrityError:
messages.error(self.request, _("Property is already defined."))
return self.form_invalid(form)
def get_form_kwargs(self):
pk = self.kwargs.get('pk')
@ -235,6 +197,11 @@ class AddLotPropertyView(DashboardView, CreateView):
kwargs = super().get_form_kwargs()
return kwargs
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context['lot_id'] = self.lot.id
return context
class UpdateLotPropertyView(DashboardView, UpdateView):
template_name = "properties.html"
@ -245,31 +212,33 @@ class UpdateLotPropertyView(DashboardView, UpdateView):
def get_form_kwargs(self):
pk = self.kwargs.get('pk')
lot_property = get_object_or_404(LotProperty, pk=pk, owner=self.request.user.institution)
lot_property = get_object_or_404(
LotProperty,
pk=pk,
owner=self.request.user.institution
)
if not lot_property:
raise Http404
lot_pk = lot_property.lot.pk
self.success_url = reverse_lazy('lot:properties', args=[lot_pk])
kwargs = super().get_form_kwargs()
kwargs['instance'] = lot_property
return kwargs
def form_valid(self, form):
old_key= self.object.key
old_value = self.object.value
new_key = form.cleaned_data['key']
new_value = form.cleaned_data['value']
form.instance.owner = self.request.user.institution
form.instance.user = self.request.user
form.instance.type = LotProperty.Type.USER
try:
response = super().form_valid(form)
messages.success(self.request, _("Lot property updated successfully."))
messages.success(self.request, _("Property updated successfully."))
return response
except IntegrityError:
messages.error(self.request, _("Property is already defined."))
return self.form_invalid(form)
def get_success_url(self):
return self.request.META.get('HTTP_REFERER', reverse_lazy('device:details', args=[self.object.pk]))
def form_invalid(self, form):
super().form_invalid(form)
return redirect(self.get_success_url())
class DeleteLotPropertyView(DashboardView, DeleteView):
@ -277,18 +246,15 @@ class DeleteLotPropertyView(DashboardView, DeleteView):
def post(self, request, *args, **kwargs):
self.pk = kwargs['pk']
referer = request.META.get('HTTP_REFERER')
if not referer:
raise Http404("No referer header found")
self.object = get_object_or_404(
self.model,
pk=self.pk,
owner=self.request.user.institution
)
old_value = self.object.key
lot_pk = self.object.lot.pk
self.object.delete()
messages.success(self.request, _("Lot property deleted successfully."))
self.success_url = reverse_lazy('lot:properties', args=[lot_pk])
# Redirect back to the original URL
return redirect(referer)
return redirect(self.success_url)

View file

View file

@ -1,3 +0,0 @@
from django.contrib import admin
# Register your models here.

View file

@ -1,6 +0,0 @@
from django.apps import AppConfig
class TagConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "tag"

View file

@ -1,3 +0,0 @@
from django.db import models
# Create your models here.

View file

@ -1,3 +0,0 @@
from django.test import TestCase
# Create your tests here.

View file

@ -1,3 +0,0 @@
from django.shortcuts import render
# Create your views here.

8
tests/end-to-end/.gitignore vendored Normal file
View file

@ -0,0 +1,8 @@
node_modules/
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
tests-examples
example.spec.ts

97
tests/end-to-end/package-lock.json generated Normal file
View file

@ -0,0 +1,97 @@
{
"name": "end-to-end",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "end-to-end",
"version": "1.0.0",
"license": "ISC",
"devDependencies": {
"@playwright/test": "^1.49.1",
"@types/node": "^22.10.7"
}
},
"node_modules/@playwright/test": {
"version": "1.49.1",
"resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.49.1.tgz",
"integrity": "sha512-Ky+BVzPz8pL6PQxHqNRW1k3mIyv933LML7HktS8uik0bUXNCdPhoS/kLihiO1tMf/egaJb4IutXd7UywvXEW+g==",
"dev": true,
"license": "Apache-2.0",
"dependencies": {
"playwright": "1.49.1"
},
"bin": {
"playwright": "cli.js"
},
"engines": {
"node": ">=18"
}
},
"node_modules/@types/node": {
"version": "22.10.7",
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.10.7.tgz",
"integrity": "sha512-V09KvXxFiutGp6B7XkpaDXlNadZxrzajcY50EuoLIpQ6WWYCSvf19lVIazzfIzQvhUN2HjX12spLojTnhuKlGg==",
"dev": true,
"license": "MIT",
"dependencies": {
"undici-types": "~6.20.0"
}
},
"node_modules/fsevents": {
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
"integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
"dev": true,
"hasInstallScript": true,
"license": "MIT",
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
}
},
"node_modules/playwright": {
"version": "1.49.1",
"resolved": "https://registry.npmjs.org/playwright/-/playwright-1.49.1.tgz",
"integrity": "sha512-VYL8zLoNTBxVOrJBbDuRgDWa3i+mfQgDTrL8Ah9QXZ7ax4Dsj0MSq5bYgytRnDVVe+njoKnfsYkH3HzqVj5UZA==",
"dev": true,
"license": "Apache-2.0",
"dependencies": {
"playwright-core": "1.49.1"
},
"bin": {
"playwright": "cli.js"
},
"engines": {
"node": ">=18"
},
"optionalDependencies": {
"fsevents": "2.3.2"
}
},
"node_modules/playwright-core": {
"version": "1.49.1",
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.49.1.tgz",
"integrity": "sha512-BzmpVcs4kE2CH15rWfzpjzVGhWERJfmnXmniSyKeRZUs9Ws65m+RGIi7mjJK/euCegfn3i7jvqWeWyHe9y3Vgg==",
"dev": true,
"license": "Apache-2.0",
"bin": {
"playwright-core": "cli.js"
},
"engines": {
"node": ">=18"
}
},
"node_modules/undici-types": {
"version": "6.20.0",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.20.0.tgz",
"integrity": "sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg==",
"dev": true,
"license": "MIT"
}
}
}

View file

@ -0,0 +1,15 @@
{
"name": "end-to-end",
"version": "1.0.0",
"main": "index.js",
"scripts": {},
"keywords": [],
"author": "",
"license": "ISC",
"type": "commonjs",
"description": "",
"devDependencies": {
"@playwright/test": "^1.49.1",
"@types/node": "^22.10.7"
}
}

View file

@ -0,0 +1,77 @@
import { defineConfig, devices } from '@playwright/test';
/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// require('dotenv').config();
/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: './tests',
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: 'html',
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
// baseURL: 'http://127.0.0.1:3000',
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
},
/* Configure projects for major browsers */
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},
{
name: 'firefox',
use: { ...devices['Desktop Firefox'] },
},
{
name: 'webkit',
use: { ...devices['Desktop Safari'] },
},
/* Test against mobile viewports. */
// {
// name: 'Mobile Chrome',
// use: { ...devices['Pixel 5'] },
// },
// {
// name: 'Mobile Safari',
// use: { ...devices['iPhone 12'] },
// },
/* Test against branded browsers. */
// {
// name: 'Microsoft Edge',
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
// },
// {
// name: 'Google Chrome',
// use: { ...devices['Desktop Chrome'], channel: 'chrome' },
// },
],
/* Run your local dev server before starting the tests */
// webServer: {
// command: 'npm run start',
// url: 'http://127.0.0.1:3000',
// reuseExistingServer: !process.env.CI,
// },
});

21
tests/end-to-end/run.sh Executable file
View file

@ -0,0 +1,21 @@
#!/bin/sh
# SPDX-License-Identifier: AGPL-3.0-or-later
set -e
set -u
# DEBUG
set -x
main() {
cd "$(dirname "${0}")"
browser="${browser:-firefox}"
project="${project:-firefox}"
headed="${headed:---headed}"
npx playwright test --project "${project}" "${headed}"
}
main "${@}"
# written in emacs
# -*- mode: shell-script; -*-

View file

@ -0,0 +1,237 @@
import { test, expect } from '@playwright/test';
// TODO after the tests, put again demo.ereuse.org as default
const TEST_SITE = process.env.TEST_SITE || 'https://lab1.ereuse.org'
const TEST_USER = process.env.TEST_USER || 'user@example.org'
const TEST_PASSWD = process.env.TEST_PASSWD || '1234'
async function login(page, date, time) {
await page.goto(TEST_SITE);
await page.getByPlaceholder('Email address').click();
await page.getByPlaceholder('Email address').fill(TEST_USER);
await page.getByPlaceholder('Password').fill(TEST_PASSWD);
await page.getByPlaceholder('Password').press('Enter');
}
// when introducing a new test, use only temporarily to just enable that test
//
//test.only('NEW example', async ({ page }) => {
// await login(page);
// test.setTimeout(0)
// await page.pause();
//});
test('Evidence: create and destroy tag (custom id)', async ({ page }) => {
await login(page);
await page.goto(`${TEST_SITE}/evidence/`);
await page.locator('table a').first().click();
await page.getByRole('link', { name: 'Tag' }).click();
// create tag
await page.getByPlaceholder('Tag').click();
await page.getByPlaceholder('Tag').fill('test');
await page.getByRole('button', { name: 'Save' }).click();
await expect(page.getByRole('alert')).toContainText('Tag mytag has been added.');
// delete tag
await page.getByRole('link', { name: 'Tag' }).click();
await page.getByRole('link', { name: 'Delete' }).click();
await expect(page.getByRole('alert')).toContainText('Tag mytag has been deleted.');
});
test('Property: create key-value, edit key, edit value, delete property property', async ({ page }) => {
const last_log = '#log tr:nth-child(1) td:nth-child(2)'
await login(page);
// assuming after login, we are in devices page, and there, there is a table with devices
await page.locator('table a').first().click();
// new property; key: init1, value: 1
await page.getByRole('link', { name: 'User properties' }).click();
await page.getByRole('link', { name: ' New user property' }).click();
await page.getByPlaceholder('Key').click();
await page.getByPlaceholder('Key').fill('init1');
await page.getByPlaceholder('Key').press('Tab');
await page.getByPlaceholder('Value').fill('1');
await page.getByRole('button', { name: 'Save' }).click();
// TODO uncomment
//await expect(page.getByRole('alert')).toContainText('User property init1 has been added.');
await page.getByRole('link', { name: 'Log' }).click();
await expect(page.locator(last_log)).toContainText('<Created> UserProperty: init1: 1');
// edit property; key: init2, value: 1
await page.getByRole('link', { name: 'User properties' }).click();
await page.getByRole('button', { name: ' Edit' }).first().click();
await page.getByLabel('Key').click();
await page.getByLabel('Key').fill('init2');
await page.getByRole('button', { name: 'Save changes' }).click();
// TODO uncomment
//await expect(page.getByRole('alert')).toContainText('User property init2 has been updated.');
await page.getByRole('link', { name: 'Log' }).click();
await expect(page.locator(last_log)).toContainText('<Updated> UserProperty: init1: 1 to init2: 1');
// edit property; key: init2, value: 2
await page.getByRole('link', { name: 'User properties' }).click();
await page.getByRole('button', { name: ' Edit' }).first().click();
await page.getByLabel('Value').fill('2');
await page.getByRole('button', { name: 'Save changes' }).click();
// TODO uncomment
//await expect(page.getByRole('alert')).toContainText('User property init2 has been updated.');
await page.getByRole('link', { name: 'Log' }).click();
await expect(page.locator(last_log)).toContainText('<Updated> UserProperty: init2: 1 to init2: 2');
// delete property; key: init2, value: 2
await page.getByRole('link', { name: 'User properties' }).click();
await page.getByRole('button', { name: ' Delete' }).click();
await page.getByRole('button', { name: 'Delete', exact: true }).click();
// TODO uncomment
//await expect(page.getByRole('alert')).toContainText('User property init2 has been updated.');
await page.getByRole('link', { name: 'Log' }).click();
await expect(page.locator(last_log)).toContainText('<Deleted> User Property: init2:2');
});
test('Property: duplication tests', async ({ page }) => {
await login(page);
// assuming after login, we are in devices page, and there, there is a table with devices
await page.locator('table a').first().click();
// new property; key: uniq1, value: 1
await page.getByRole('link', { name: 'User properties' }).click();
await page.getByRole('link', { name: ' New user property' }).click();
await page.getByPlaceholder('Key').click();
await page.getByPlaceholder('Key').fill('uniq1');
await page.getByPlaceholder('Key').press('Tab');
await page.getByPlaceholder('Value').fill('1');
await page.getByRole('button', { name: 'Save' }).click();
// TODO uncomment
//await expect(page.getByRole('alert')).toContainText('User property uniq1 has been added.');
// new property (duplicate); key: uniq1, value: 1
await page.getByRole('link', { name: 'User properties' }).click();
await page.getByRole('link', { name: ' New user property' }).click();
await page.getByPlaceholder('Key').click();
await page.getByPlaceholder('Key').fill('uniq1');
await page.getByPlaceholder('Key').press('Tab');
await page.getByPlaceholder('Value').fill('1');
await page.getByRole('button', { name: 'Save' }).click();
// TODO uncomment
//await expect(page.getByRole('alert')).toContainText('User property uniq1 already exists.');
// delete property; key: uniq1, value: 1
await page.getByRole('link', { name: 'User properties' }).click();
await page.getByRole('button', { name: ' Delete' }).first().click();
// TODO uncomment
//await expect(page.getByRole('alert')).toContainText('User property uniq1 deleted has been.');
});
test.only('States: duplication tests', async ({ page }) => {
await login(page);
await page.getByRole('link', { name: ' Admin' }).click();
await page.getByRole('link', { name: 'States' }).click();
// create state: TEST_STATE
await page.getByRole('button', { name: 'Add' }).click();
await page.getByRole('textbox', { name: 'State' }).click();
await page.getByRole('textbox', { name: 'State' }).fill('TEST_STATE');
await page.getByRole('button', { name: 'Add state definition' }).click();
// TODO uncomment
//await expect(page.getByRole('alert')).toContainText('State definition TEST_STATE has been added.');
// create state (duplicate): TEST_STATE
await page.getByRole('button', { name: 'Add' }).click();
await page.getByRole('textbox', { name: 'State' }).click();
await page.getByRole('textbox', { name: 'State' }).fill('TEST_STATE');
await page.getByRole('button', { name: 'Add state definition' }).click();
// TODO uncomment
//await expect(page.getByRole('alert')).toContainText('State definition TEST_STATE is already defined.');
// edit state: TEST_STATE -> TEST_STATE_EDIT
await page.getByRole('row', { name: 'TEST_STATE  Edit  Delete' }).getByRole('button').first().click();
await page.getByRole('textbox', { name: 'State' }).fill('TEST_STATE_EDIT');
await page.getByRole('button', { name: 'Save Changes' }).click();
// create state: TEST_STATE
await page.getByRole('button', { name: 'Add' }).click();
await page.getByRole('textbox', { name: 'State' }).click();
await page.getByRole('textbox', { name: 'State' }).fill('TEST_STATE');
await page.getByRole('button', { name: 'Add state definition' }).click();
// you edit state, and target name already exists
// TODO uncomment. "Cannot create key that already exists (UNIQUE constraint)"
// edit state (duplicated during edit): TEST_STATE_EDIT -> TEST_STATE
//await page.getByRole('row', { name: 'TEST_STATE  Edit  Delete' }).getByRole('button').first().click();
//await page.getByRole('textbox', { name: 'State' }).fill('TEST_STATE_EDIT');
//await page.getByRole('button', { name: 'Save Changes' }).click();
// delete state: TEST_STATE_EDIT
await page.getByRole('row', { name: 'TEST_STATE_EDIT  Edit  Delete' }).getByRole('button').nth(1).click();
await page.getByRole('button', { name: 'Delete', exact: true }).click();
// TODO uncomment
//await expect(page.getByRole('alert')).toContainText('State definition TEST_STATE has been deleted.');
// delete state: TEST_STATE
await page.getByRole('row', { name: 'TEST_STATE  Edit  Delete' }).getByRole('button').nth(1).click();
await page.getByRole('button', { name: 'Delete', exact: true }).click();
// TODO uncomment
//await expect(page.getByRole('alert')).toContainText('State definition TEST_STATE has been deleted.');
});
test('Lot: duplication tests', async ({ page }) => {
await login(page);
// add lot
await page.getByRole('link', { name: ' Lots' }).click();
await page.getByRole('link', { name: 'Entrada' }).click();
await page.getByRole('link', { name: ' Add new lot' }).click();
await page.getByLabel('Type').selectOption('1');
await page.getByPlaceholder('Name').click();
await page.getByPlaceholder('Name').fill('testlot');
await page.getByPlaceholder('Name').press('Tab');
await page.getByPlaceholder('Code').fill('testlot');
await page.getByPlaceholder('Code').press('Tab');
await page.getByPlaceholder('Description').fill('testlot');
await page.getByRole('button', { name: 'Save' }).click();
await expect(page.getByRole('alert')).toContainText('Lot testlot has been added.');
// add (duplicate) lot
await page.getByRole('link', { name: ' Lots' }).click();
await page.getByRole('link', { name: 'Entrada' }).click();
await page.getByRole('link', { name: ' Add new lot' }).click();
await page.getByLabel('Type').selectOption('1');
await page.getByPlaceholder('Name').click();
await page.getByPlaceholder('Name').fill('testlot');
await page.getByPlaceholder('Name').press('Tab');
await page.getByPlaceholder('Code').fill('testlot');
await page.getByPlaceholder('Code').press('Tab');
await page.getByPlaceholder('Description').fill('testlot');
await page.getByPlaceholder('Description').press('Enter');
await page.getByRole('button', { name: 'Save' }).click();
await expect(page.getByRole('alert')).toContainText('Lot testlot is already defined.');
// delete lot
await page.getByRole('link', { name: ' Lots' }).click();
await page.getByRole('link', { name: 'Entrada' }).click();
await page.getByRole('link', { name: '' }).nth(3).click();
await page.getByRole('link', { name: 'Cancel' }).click();
await page.getByRole('link', { name: ' Lots' }).click();
await page.getByRole('link', { name: 'Entrada' }).click();
await page.getByRole('link', { name: '' }).first().click();
await page.getByRole('button', { name: 'Delete' }).click();
await expect(page.getByRole('alert')).toContainText('Lot testlot has been deleted.');
});
// TODO falta probar la parte de notas
// falta vista https://lab1.ereuse.org/dashboard/ con columna de state actual; si no hay None pero con un estilo diferente (cursiva y gris?)
//test('Bug 4: Missing logs for actions', async ({ page }) => {
// await login(page);
// await page.goto(`${TEST_SITE}/device/7b769bd6e9191d5ff163fa4a206b9220dad10c47b45d210d3d4d31d586f6a4b6/#log`);
// // Add your assertions and steps to test if logs are missing
//});
//
//test('Bug 6: Log note is not visible', async ({ page }) => {
// await login(page);
// // Add the specific URL or steps for testing log note visibility
//});

View file

@ -9,7 +9,7 @@ STR_EXTEND_SIZE = 256
# Algorithms for build hids
HID_ALGO1 = [
EREUSE24 = [
"manufacturer",
"model",
"chassis",
@ -17,7 +17,8 @@ HID_ALGO1 = [
"sku"
]
LEGACY_DPP = [
# EREUSE22 is used for build the chid of DPP
EREUSE22 = [
"manufacturer",
"model",
"chassis",
@ -28,8 +29,8 @@ LEGACY_DPP = [
]
ALGOS = {
"hidalgo1": HID_ALGO1,
"legacy_dpp": LEGACY_DPP
"ereuse24": EREUSE24,
"ereuse22": EREUSE22
}