Skip to content

Commit

Permalink
updating vis catalogue item (#3410)
Browse files Browse the repository at this point in the history
* updating vis catalogue item

* update failing tests
  • Loading branch information
lluli authored Jan 14, 2025
1 parent 5201fa3 commit 75bbe23
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 6 deletions.
4 changes: 2 additions & 2 deletions cypress/e2e/tools/tools-access.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ describe('Tools access', () => {
});

it('should error when the declaration has NOT been checked and date is in the future', () => {
setCertificateDate('01', '01', '2025');
setCertificateDate('01', '01', '3000');
cy.findByRole('button', { name: 'Submit' }).click();
cy.findByRole('link', {
name: 'Check the box to agree with the declaration statement'
Expand Down Expand Up @@ -224,7 +224,7 @@ describe('Tools access', () => {
});

it('should error when certifcate date is in the future', () => {
setCertificateDate('01', '01', '2025');
setCertificateDate('01', '01', '3000');
acceptDeclaration();
cy.findByRole('button', { name: 'Submit' }).click();
assertErrorMessages([
Expand Down
3 changes: 3 additions & 0 deletions dataworkspace/dataworkspace/apps/datasets/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -844,13 +844,15 @@ def clone_quicksight_dataset(self, obj):
@admin.register(VisualisationCatalogueItem)
class VisualisationCatalogueItemAdmin(CSPRichTextEditorMixin, DeletableTimeStampedUserAdmin):
form = VisualisationCatalogueItemForm
prepopulated_fields = {"slug": ("name",)}
list_display = (
"name",
"short_description",
"published",
"get_tags",
"get_bookmarks",
"get_average_unique_users_daily",
"slug",
)
list_filter = ("tags",)
search_fields = ["name"]
Expand All @@ -874,6 +876,7 @@ class VisualisationCatalogueItemAdmin(CSPRichTextEditorMixin, DeletableTimeStamp
"tags",
"short_description",
"description",
"notes",
"enquiries_contact",
"secondary_enquiries_contact",
"information_asset_owner",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Generated by Django 4.2.15 on 2025-01-14 09:31

import dataworkspace.apps.core.models
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("datasets", "0181_alter_visualisationcatalogueitem_short_description"),
]

operations = [
migrations.AddField(
model_name="visualisationcatalogueitem",
name="notes",
field=dataworkspace.apps.core.models.RichTextField(blank=True, null=True),
),
migrations.AlterField(
model_name="visualisationcatalogueitem",
name="government_security_classification",
field=models.IntegerField(
choices=[(1, "OFFICIAL"), (2, "OFFICIAL-SENSITIVE")], null=True
),
),
migrations.AlterField(
model_name="visualisationcatalogueitem",
name="name",
field=models.TextField(max_length=128),
),
migrations.AlterField(
model_name="visualisationcatalogueitem",
name="personal_data",
field=models.TextField(blank=True, max_length=128, null=True),
),
]
7 changes: 4 additions & 3 deletions dataworkspace/dataworkspace/apps/datasets/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2564,11 +2564,12 @@ class VisualisationCatalogueItem(DeletableTimestampedUserModel):
visualisation_template = models.OneToOneField(
VisualisationTemplate, on_delete=models.CASCADE, null=True, blank=True
)
name = models.CharField(max_length=255, null=False, blank=False)
name = models.TextField(max_length=128, null=False, blank=False)
slug = models.SlugField(max_length=50, db_index=True, unique=True, null=False, blank=False)
tags = models.ManyToManyField(Tag, related_name="+", blank=True)
short_description = models.TextField(null=True, blank=False, max_length=255)
description = RichTextField(null=True, blank=False)
notes = RichTextField(null=True, blank=True)
enquiries_contact = models.ForeignKey(
settings.AUTH_USER_MODEL,
on_delete=models.CASCADE,
Expand All @@ -2585,7 +2586,7 @@ class VisualisationCatalogueItem(DeletableTimestampedUserModel):
)
licence = models.CharField(null=False, blank=True, max_length=256)
retention_policy = models.TextField(null=True, blank=True)
personal_data = models.CharField(null=True, blank=True, max_length=128)
personal_data = models.TextField(null=True, blank=True, max_length=128)
restrictions_on_usage = RichLinkField(null=True, blank=True)
published = models.BooleanField(default=False)

Expand Down Expand Up @@ -2644,7 +2645,7 @@ class VisualisationCatalogueItem(DeletableTimestampedUserModel):
government_security_classification = models.IntegerField(
choices=SecurityClassificationAndHandlingInstructionType.choices,
null=True,
blank=True,
blank=False,
)
sensitivity = models.ManyToManyField(
SensitivityType,
Expand Down
2 changes: 2 additions & 0 deletions dataworkspace/dataworkspace/tests/applications/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def test_successful_post_data(self, staff_client):
"short_description": "summary",
"user_access_type": UserAccessType.OPEN,
"enquiries_contact": user.email,
"government_security_classification": 1,
},
follow=True,
)
Expand Down Expand Up @@ -118,6 +119,7 @@ def test_can_set_user_access_type(self, staff_client, start_type, expected_type)
"short_description": "summary",
"user_access_type": expected_type,
"enquiries_contact": user.email,
"government_security_classification": 1,
},
follow=True,
)
Expand Down
9 changes: 8 additions & 1 deletion dataworkspace/dataworkspace/tests/datasets/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1538,6 +1538,7 @@ class TestDescriptionChangeEventLog(TestCase):
def setUp(self):
self.user = factories.UserFactory.create(is_superuser=False)
self.client = Client(**get_http_sso_data(self.user))
self.government_security_classification = 2
self.description = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla ex ex, vulputate vel condimentum a, ornare quis felis. Proin ut bibendum arcu. Donec a ligula eros. Mauris pellentesque nisi eu." # pylint: disable=line-too-long
self.new_description = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam fringilla non ante et lobortis. Nam mollis sagittis facilisis. Nam suscipit, leo et condimentum sagittis, dolor risus bibendum massa, a luctus mauris." # pylint: disable=line-too-long
self.dataset = factories.DataSetFactory.create(
Expand Down Expand Up @@ -1598,6 +1599,7 @@ def test_eventlog_runs_when_vis_description_changed(self, mock_log_permission_ch
"name": self.dataset.name,
"short_description": "test",
"description": self.new_description,
"government_security_classification": 2,
},
)
assert response.status_code == 302
Expand All @@ -1615,7 +1617,12 @@ def test_eventlog_does_not_runs_when_vis_description_has_not_changed(
eventlog_count = EventLog.objects.count()
response = self.client.post(
reverse("datasets:edit_visualisation_catalogue_item", args=(self.visualisation.id,)),
data={"name": "test", "short_description": "test", "description": self.description},
data={
"name": "test",
"short_description": "test",
"government_security_classification": 2,
"description": self.description,
},
)
assert response.status_code == 302
assert (
Expand Down

0 comments on commit 75bbe23

Please sign in to comment.