Added error to add_owner for when the new owner is already an owner

doc_update
Joey Hines 2019-02-02 10:21:44 -06:00
parent b744385a23
commit 0cda503d6c
2 changed files with 6 additions and 1 deletions

View File

@ -530,7 +530,7 @@ def add_owner(new_owner_name, location_name, discord_uuid=None, mc_uuid=None):
:param discord_uuid: Discord UUID of the current owner
:param mc_uuid: MC UUID of the current owner
:return: Updated Location
:raises: PlayerNotFound, LocationLookupError
:raises: PlayerNotFound, LocationLookupError, PlayerInDBError
'''
owner = get_player(discord_uuid, mc_uuid)
@ -541,6 +541,9 @@ def add_owner(new_owner_name, location_name, discord_uuid=None, mc_uuid=None):
location = get_location(owner, location_name, Location)
if location.owner.filter(location__owner__name__iexact=new_owner_name):
raise PlayerInDBError
location.owner.add(new_owner)
location.save()

View File

@ -166,3 +166,5 @@ class CommandsAPITestCase(TestCase):
shop = Shop.objects.get(owner__name__icontains="Vakky")
self.assertEquals(shop.id, self.shop.id)
self.assertRaises(PlayerInDBError, add_owner, new_owner.name, self.shop.name, discord_uuid=DISCORD_UUID)