Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance/requirement assessment edit #164

Merged
merged 4 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backend/core/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def get_sorted_requirement_nodes_rec(
"parent_urn": node.parent_urn,
"ref_id": node.ref_id,
"name": node.name,
"node_content": node.display_long(),
"node_content": node.display_long,
"style": "node",
"assessable": node.assessable,
"description": node.description,
Expand Down
8 changes: 5 additions & 3 deletions backend/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class ReferentialObjectMixin(NameDescriptionMixin, FolderMixin):
class Meta:
abstract = True

@property
def display_short(self) -> str:
_name = (
self.ref_id
Expand All @@ -67,8 +68,9 @@ def display_short(self) -> str:
_name = "" if not _name else _name
return _name

@property
def display_long(self) -> str:
_name = self.display_short()
_name = self.display_short
_display = (
_name
if not self.description
Expand All @@ -79,7 +81,7 @@ def display_long(self) -> str:
return _display

def __str__(self) -> str:
return self.display_short()
return self.display_short


class Library(ReferentialObjectMixin):
Expand Down Expand Up @@ -1503,7 +1505,7 @@ class Status(models.TextChoices):
)

def __str__(self) -> str:
return self.requirement.display_short()
return self.requirement.display_short

class Meta:
verbose_name = _("Requirement assessment")
Expand Down
2 changes: 1 addition & 1 deletion backend/core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1494,7 +1494,7 @@ def generate_html_rec(requirement_node: RequirementNode):
req for req in requirement_nodes if req.parent_urn == requirement_node.urn
]
if not requirement_node.assessable:
_display = requirement_node.display_long()
_display = requirement_node.display_long
table += f'<p class="font-semibold">{_display} </p>'
if children_nodes:
table += bar_graph(requirement_node)
Expand Down
6 changes: 5 additions & 1 deletion backend/iam/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,11 @@ def get_accessible_object_ids(
folders_with_local_view = set()
permissions_per_object_id = defaultdict(set)
ref_permission = Permission.objects.get(codename="view_folder")
all_objects = object_type.objects.all()
all_objects = (
object_type.objects.select_related("folder")
if hasattr(object_type, "folder")
else object_type.objects.all()
)
folder_for_object = {x: Folder.get_folder(x) for x in all_objects}
perimeter = set()
perimeter.add(folder)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,13 @@ export const load = (async ({ fetch, params }) => {

const model = getModelInfo(URLModel);

const objectEndpoint = `${BASE_API_URL}/${URLModel}/${params.id}/object/`;
const object = await fetch(objectEndpoint).then((res) => res.json());
const object = { ...requirementAssessment };
for (const key in object) {
if (object[key] instanceof Object && 'id' in object[key]) {
object[key] = object[key].id;
}
}

const schema = modelSchema(URLModel);
const form = await superValidate(object, schema, { errors: true });

Expand Down Expand Up @@ -245,7 +250,7 @@ export const actions: Actions = {
}
const object = await res.json();
const model: string = urlParamModelVerboseName(URLModel);
setFlash({ type: 'success', message: m.successfullySavedObject({object: model}) }, event);
setFlash({ type: 'success', message: m.successfullySavedObject({ object: model }) }, event);
redirect(
302,
event.url.searchParams.get('next') ||
Expand Down Expand Up @@ -304,7 +309,13 @@ export const actions: Actions = {
}

const model: string = urlParamModelVerboseName(URLModel);
setFlash({ type: 'success', message: m.successfullyUpdatedObject({object: model, name:form.data.name}) }, event);
setFlash(
{
type: 'success',
message: m.successfullyUpdatedObject({ object: model, name: form.data.name })
},
event
);
return { form };
},
createEvidence: async (event) => {
Expand Down Expand Up @@ -362,7 +373,13 @@ export const actions: Actions = {
}

const model: string = urlParamModelVerboseName(URLModel);
setFlash({ type: 'success', message: m.successfullyUpdatedObject({object: model, name:form.data.name}) }, event);
setFlash(
{
type: 'success',
message: m.successfullyUpdatedObject({ object: model, name: form.data.name })
},
event
);
return { form };
}
};
Loading