diff --git a/embark/dashboard/urls.py b/embark/dashboard/urls.py index 6c4b4d48..4742b7a9 100644 --- a/embark/dashboard/urls.py +++ b/embark/dashboard/urls.py @@ -16,5 +16,6 @@ path('dashboard/log/', views.show_log, name='embark-show-log'), path('dashboard/logviewer/', views.show_logviewer, name='embark-show-logviewer'), path('dashboard/report/createlabel/', views.create_label, name='embark-dashboard-create-label'), - path('dashboard/report/addlabel/', views.add_label, name='embark-dashboard-add-label') + path('dashboard/report/addlabel/', views.add_label, name='embark-dashboard-add-label'), + path('dashboard/report/rmlabel/', views.rm_label, name='embark-dashboard-remove-label'), ] diff --git a/embark/dashboard/views.py b/embark/dashboard/views.py index 2dbb38f0..41eae02d 100644 --- a/embark/dashboard/views.py +++ b/embark/dashboard/views.py @@ -283,3 +283,18 @@ def add_label(request, analysis_id): logger.error("label form invalid %s ", request.POST) messages.error(request, 'Adding Label failed') return redirect('..') + + +@csrf_protect +@require_http_methods(["POST"]) +@login_required(login_url='/' + settings.LOGIN_URL) +def rm_label(request, analysis_id, label_name): + req_logger.info("User %s called rm label", request.user.username) + + logger.info("User %s tryied to rm label %s", request.user.username, label_name) + # get analysis obj + analysis = FirmwareAnalysis.objects.get(id=analysis_id) + analysis.label.remove(label_name) + analysis.save() + messages.info(request, 'removing successful of ' + str(label_name)) + return redirect('..') diff --git a/embark/templates/dashboard/label.html b/embark/templates/dashboard/label.html index 36c15249..d205e941 100644 --- a/embark/templates/dashboard/label.html +++ b/embark/templates/dashboard/label.html @@ -1,5 +1,15 @@ {% load django_bootstrap5 %} +
+ {% csrf_token %} +
+ {% load filters %} + {% bootstrap_form label_select_form %} + {% bootstrap_button "Add" button_type="submit" button_class="btn-primary" %} +
+
+ +
{% csrf_token %}
@@ -7,4 +17,4 @@ {% bootstrap_form label_form layout='grid' %} {% bootstrap_button "Create" button_type="submit" button_class="btn-primary" %}
-
\ No newline at end of file + diff --git a/embark/templates/dashboard/reportDashboard.html b/embark/templates/dashboard/reportDashboard.html index 46881266..33c18c8b 100644 --- a/embark/templates/dashboard/reportDashboard.html +++ b/embark/templates/dashboard/reportDashboard.html @@ -61,6 +61,13 @@ {% for label in firmware.label.all %}
+ + +
+ {% csrf_token %} +
+ + {{ label.label_name }}
{% endfor %} {% endif %} @@ -194,15 +201,6 @@