Skip to content

Commit

Permalink
feat: display project with domain context
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohamed-Hacene committed Apr 3, 2024
1 parent f99d422 commit c526d39
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 13 deletions.
8 changes: 3 additions & 5 deletions backend/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ def overall_compliance(self):
return round(count * 100 / total)

def __str__(self):
return self.name
return self.folder.name + '/' + self.name


class Asset(NameDescriptionMixin, FolderMixin, PublishInRootFolderMixin):
Expand Down Expand Up @@ -806,7 +806,7 @@ class Meta:
verbose_name_plural = _("Risk assessments")

def __str__(self) -> str:
return f"{self.project.folder}/{self.project}/{self.name} - {self.version}"
return f"{self.project}/{self.name} - {self.version}"

@property
def path_display(self) -> str:
Expand Down Expand Up @@ -1237,9 +1237,7 @@ def get_strength_of_knowledge(self):

def __str__(self):
return (
str(self.parent_project().folder)
+ _("/")
+ str(self.parent_project())
str(self.parent_project())
+ _(": ")
+ str(self.name)
)
Expand Down
12 changes: 9 additions & 3 deletions frontend/src/lib/components/Forms/ModelForm.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,10 @@
{:else if URLModel === 'risk-assessments'}
<AutocompleteSelect
{form}
options={getOptions({ objects: model.foreignKeys['project'] })}
options={getOptions({
objects: model.foreignKeys['project'],
extra_fields: [["folder","str"]]
})}
field="project"
label={m.project()}
hide={initialData.project}
Expand Down Expand Up @@ -270,7 +273,7 @@
{form}
options={getOptions({
objects: model.foreignKeys['risk_scenarios'],
extra_fields: [["project","folder","str"],["project","str"]]
extra_fields: [["project","str"]]
})}
field="risk_scenarios"
label={m.riskScenarios()}
Expand Down Expand Up @@ -315,7 +318,10 @@
{:else if URLModel === 'compliance-assessments'}
<AutocompleteSelect
{form}
options={getOptions({ objects: model.foreignKeys['project'] })}
options={getOptions({
objects: model.foreignKeys['project'],
extra_fields: [["folder","str"]]
})}
field="project"
label={m.project()}
hide={initialData.project}
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/routes/(app)/analytics/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@
<div class="flex flex-col items-center">
{#if project.compliance_assessments && project.compliance_assessments.length > 1}
<div class="flex flex-row space-x-2 w-1/2 justify-between items-center">
<span class="text-xl font-semibold">{project.name}</span>
<a class="text-xl font-bold mb-1 hover:underline text-primary-600" href="/projects/{project.id}">{project.folder.str}/{project.name}</a>
<div class="flex flex-1 bg-gray-200 rounded-full overflow-hidden h-4 shrink">
{#each project.overallCompliance.values as sp}
<div
Expand All @@ -293,7 +293,7 @@
<div class="w-1/5 flex flex-col space-y-2">
<div>
<p class="text-sm font-semibold">{m.name()}</p>
<p>{compliance_assessment.name}</p>
<a class="anchor" href="compliance-assessments/{compliance_assessment.id}">{compliance_assessment.name}</a>
</div>
<div>
<p class="text-sm font-semibold">{m.framework()}</p>
Expand Down
7 changes: 4 additions & 3 deletions frontend/src/routes/(app)/x-rays/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@
{@const compliance_assessments = Object.values(project.compliance_assessments.objects)}
{@const risk_assessments = Object.values(project.risk_assessments.objects)}
<div>
<h1 class="text-2xl font-bold mb-1">
&#128161; {project.project.name}
</h1>
<span class="text-2xl">&#128161;</span>
<a class="text-2xl font-bold mb-1 hover:underline text-blue-600" href="/projects/{project.project.id}">
{project.project.folder.str}/{project.project.name}
</a>
<TabGroup>
<Tab bind:group={project.tabSet} name="compliance_assessments_tab" value={0}
>{m.complianceAssessments()}
Expand Down

0 comments on commit c526d39

Please sign in to comment.