Skip to content

Commit

Permalink
Extend Organisation model with a property and setter.
Browse files Browse the repository at this point in the history
  • Loading branch information
byrman committed Sep 14, 2020
1 parent d0f82cd commit d26de1c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Changelog of lizard-auth-client
3.0.4 (unreleased)
------------------

- Nothing changed yet.
- Extended the Organisation model with a `uuid` property and setter.


3.0.3 (2020-06-25)
Expand Down
9 changes: 9 additions & 0 deletions lizard_auth_client/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
from lizard_auth_client.conf import settings
from uuid import UUID


class RoleManager(models.Manager):
Expand Down Expand Up @@ -82,6 +83,14 @@ class Meta:
def __str__(self):
return self.name

@property
def uuid(self):
return UUID(self.unique_id)

@uuid.setter
def uuid(self, value):
self.unique_id = UUID(str(value)).hex

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

Expand Down

0 comments on commit d26de1c

Please sign in to comment.