-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Jesse Lisser <[email protected]> Co-authored-by: ammar92 <[email protected]> Co-authored-by: Donny Peeters <[email protected]>
- Loading branch information
1 parent
e0c6422
commit bc6867e
Showing
11 changed files
with
188 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
*** Settings *** | ||
Resource robot.resource | ||
|
||
Test Setup Setup Test | ||
Test Teardown Teardown Test | ||
|
||
|
||
*** Test Cases *** | ||
Rerun bits | ||
Insert Observation tests/fixtures/normalizer_output.json | ||
Await Sync | ||
${response} Post ${OCTOPOES_URI}/bits/recalculate | ||
Should Be Equal As Integers ${response.status_code} 200 | ||
Should Be Equal As Integers ${response.content} 19 | ||
|
||
|
||
*** Keywords *** | ||
Setup Test | ||
Start Monitoring ${QUEUE_URI} | ||
|
||
Teardown Test | ||
Cleanup | ||
Await Sync | ||
Stop Monitoring |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,38 @@ | ||
from datetime import datetime | ||
from enum import Enum | ||
|
||
from account.mixins import OrganizationPermissionRequiredMixin | ||
from django.contrib import messages | ||
from django.core.exceptions import PermissionDenied | ||
from django.http import HttpRequest, HttpResponse, HttpResponseBadRequest | ||
from django.utils.translation import gettext_lazy as _ | ||
from django.views.generic import TemplateView | ||
from django_otp.decorators import otp_required | ||
from tools.view_helpers import OrganizationDetailBreadcrumbsMixin | ||
from two_factor.views.utils import class_view_decorator | ||
|
||
|
||
class PageActions(Enum): | ||
RECALCULATE = "recalculate" | ||
|
||
|
||
@class_view_decorator(otp_required) | ||
class OrganizationSettingsView(OrganizationPermissionRequiredMixin, OrganizationDetailBreadcrumbsMixin, TemplateView): | ||
template_name = "organizations/organization_settings.html" | ||
permission_required = "tools.view_organization" | ||
|
||
def post(self, request: HttpRequest, *args, **kwargs) -> HttpResponse: | ||
"""Perform actions based on action type""" | ||
action = request.POST.get("action") | ||
if not self.request.user.has_perm("tools.can_recalculate_bits"): | ||
raise PermissionDenied() | ||
if action == PageActions.RECALCULATE.value: | ||
connector = self.octopoes_api_connector | ||
|
||
start_time = datetime.now() | ||
number_of_bits = connector.recalculate_bits() | ||
duration = datetime.now() - start_time | ||
messages.add_message(request, messages.INFO, _(f"Recalculated {number_of_bits} bits. Duration: {duration}")) | ||
return self.get(request, *args, **kwargs) | ||
else: | ||
raise HttpResponseBadRequest("Unknown action") |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Generated by Django 3.2.19 on 2023-05-09 12:13 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("tools", "0036_merge_20230504_1629"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterModelOptions( | ||
name="organization", | ||
options={ | ||
"permissions": ( | ||
("can_switch_organization", "Can switch organization"), | ||
("can_scan_organization", "Can scan organization"), | ||
("can_enable_disable_boefje", "Can enable or disable boefje"), | ||
("can_set_clearance_level", "Can set clearance level"), | ||
("can_delete_oois", "Can delete oois"), | ||
("can_recalculate_bits", "Can recalculate bits"), | ||
) | ||
}, | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters