Skip to content
This repository has been archived by the owner on Mar 30, 2024. It is now read-only.

Commit

Permalink
fix: unit test folder name used checking
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohamed-Hacene committed Oct 2, 2023
1 parent 160dcb2 commit a7dc99e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
11 changes: 10 additions & 1 deletion core/base_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,16 @@ class Meta:

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


def clean(self) -> None:
scope = self.get_scope()
field_errors = {}
_fields_to_check = self.fields_to_check if hasattr(self, 'fields_to_check') else ['name']
if not self.is_unique_in_scope(scope=scope, fields_to_check=_fields_to_check):
field_errors['name'] = _('This name is already in use.')
super().clean()
if field_errors:
raise ValidationError(field_errors)

class AbstractBaseModel(models.Model):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
Expand Down
17 changes: 17 additions & 0 deletions core/migrations/0018_alter_evidence_options.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 4.2.5 on 2023-10-02 11:51

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('core', '0017_remove_evidence_ref_url'),
]

operations = [
migrations.AlterModelOptions(
name='evidence',
options={'verbose_name': 'Evidence', 'verbose_name_plural': 'Evidences'},
),
]
2 changes: 1 addition & 1 deletion iam/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def _get_root_folder():
return None


class Folder(AbstractBaseModel, I18nMixin, NameDescriptionMixin):
class Folder(I18nMixin, NameDescriptionMixin, AbstractBaseModel):
""" A folder is a container for other folders or any object
Folders are organized in a tree structure, with a single root folder
Folders are the base perimeter for role assignments
Expand Down

0 comments on commit a7dc99e

Please sign in to comment.