Cleanup
This commit is contained in:
parent
b2246f6a8b
commit
aeaa0d18e2
@ -1,3 +0,0 @@
|
||||
table {
|
||||
transition: all 0.3s ease;
|
||||
}
|
@ -54,24 +54,4 @@ describe('AuditLogComponent', () => {
|
||||
fixture.detectChanges()
|
||||
expect(getAuditLogSpy).toHaveBeenCalledWith(1)
|
||||
})
|
||||
|
||||
it('should toggle entry', () => {
|
||||
const entry = {
|
||||
id: 1,
|
||||
actor: {
|
||||
id: 1,
|
||||
username: 'user1',
|
||||
},
|
||||
action: AuditLogAction.Create,
|
||||
timestamp: '2021-01-01T00:00:00Z',
|
||||
remote_addr: '1.2.3.4',
|
||||
changes: {
|
||||
title: ['old title', 'new title'],
|
||||
},
|
||||
}
|
||||
component.toggleEntry(entry)
|
||||
expect(component.openEntries.has(1)).toBe(true)
|
||||
component.toggleEntry(entry)
|
||||
expect(component.openEntries.has(1)).toBe(false)
|
||||
})
|
||||
})
|
||||
|
@ -19,7 +19,6 @@ export class AuditLogComponent implements OnInit {
|
||||
|
||||
public loading: boolean = true
|
||||
public entries: AuditLogEntry[] = []
|
||||
public openEntries: Set<number> = new Set()
|
||||
|
||||
constructor(private documentService: DocumentService) {}
|
||||
|
||||
@ -30,21 +29,8 @@ export class AuditLogComponent implements OnInit {
|
||||
.getAuditLog(this._documentId)
|
||||
.subscribe((auditLogEntries) => {
|
||||
this.entries = auditLogEntries
|
||||
.map((entry) => {
|
||||
delete entry.changes['modified']
|
||||
return entry
|
||||
})
|
||||
.filter((entry) => Object.keys(entry.changes).length > 0)
|
||||
this.loading = false
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
toggleEntry(entry: AuditLogEntry) {
|
||||
if (this.openEntries.has(entry.id)) {
|
||||
this.openEntries.delete(entry.id)
|
||||
} else {
|
||||
this.openEntries.add(entry.id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -882,7 +882,12 @@ class CustomFieldInstance(models.Model):
|
||||
|
||||
|
||||
if settings.AUDIT_LOG_ENABLED:
|
||||
auditlog.register(Document, m2m_fields={"tags"}, mask_fields=["content"])
|
||||
auditlog.register(
|
||||
Document,
|
||||
m2m_fields={"tags"},
|
||||
mask_fields=["content"],
|
||||
exclude_fields=["modified"],
|
||||
)
|
||||
auditlog.register(Correspondent)
|
||||
auditlog.register(Tag)
|
||||
auditlog.register(DocumentType)
|
||||
|
@ -317,6 +317,14 @@ class TestDocumentApi(DirectoriesMixin, DocumentConsumeDelayMixin, APITestCase):
|
||||
self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)
|
||||
|
||||
def test_document_audit_action(self):
|
||||
"""
|
||||
GIVEN:
|
||||
- Document
|
||||
WHEN:
|
||||
- Document is updated
|
||||
THEN:
|
||||
- Audit log contains changes
|
||||
"""
|
||||
doc = Document.objects.create(
|
||||
title="First title",
|
||||
checksum="123",
|
||||
@ -388,6 +396,15 @@ class TestDocumentApi(DirectoriesMixin, DocumentConsumeDelayMixin, APITestCase):
|
||||
|
||||
@override_settings(AUDIT_LOG_ENABLED=False)
|
||||
def test_document_audit_action_disabled(self):
|
||||
"""
|
||||
GIVEN:
|
||||
- Audit log is disabled
|
||||
WHEN:
|
||||
- Document is updated
|
||||
- Audit log is requested
|
||||
THEN:
|
||||
- Audit log returns HTTP 400 Bad Request
|
||||
"""
|
||||
doc = Document.objects.create(
|
||||
title="First title",
|
||||
checksum="123",
|
||||
|
Loading…
x
Reference in New Issue
Block a user