Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added natural key to proposal types via manager which fixtures now use #526

Merged
merged 1 commit into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading