Skip to content

Commit

Permalink
Merge pull request #526 from awf-dbca/fixture-natural-keys
Browse files Browse the repository at this point in the history
Added natural key to proposal types via manager which fixtures now use
  • Loading branch information
xzzy authored Jan 24, 2025
2 parents 806af19 + 69e26b4 commit c53e54c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions mooringlicensing/components/proposals/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,17 +146,25 @@ class Meta:
('ria', 'By Rottnest Island Authority for a mooring allocated by the Authority'),
)

class ProposalTypeManager(models.Manager):
def get_by_natural_key(self, code):
return self.get(code=code)

class ProposalType(models.Model):
code = models.CharField(max_length=30, blank=True, null=True, unique=True)
description = models.CharField(max_length=200, blank=True, null=True)

def __str__(self):
return self.description if self.description else ''

objects = ProposalTypeManager()

class Meta:
app_label = 'mooringlicensing'

def natural_key(self):
return (self.code,)


class ProposalProofOfIdentityDocument(models.Model):
proof_of_identity_document = models.ForeignKey('ProofOfIdentityDocument', on_delete=models.CASCADE)
Expand Down
Loading

0 comments on commit c53e54c

Please sign in to comment.