Added error to add_owner for when the new owner is already an owner
parent
b744385a23
commit
0cda503d6c
|
@ -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 discord_uuid: Discord UUID of the current owner
|
||||||
:param mc_uuid: MC UUID of the current owner
|
:param mc_uuid: MC UUID of the current owner
|
||||||
:return: Updated Location
|
:return: Updated Location
|
||||||
:raises: PlayerNotFound, LocationLookupError
|
:raises: PlayerNotFound, LocationLookupError, PlayerInDBError
|
||||||
'''
|
'''
|
||||||
owner = get_player(discord_uuid, mc_uuid)
|
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)
|
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.owner.add(new_owner)
|
||||||
|
|
||||||
location.save()
|
location.save()
|
||||||
|
|
|
@ -166,3 +166,5 @@ class CommandsAPITestCase(TestCase):
|
||||||
shop = Shop.objects.get(owner__name__icontains="Vakky")
|
shop = Shop.objects.get(owner__name__icontains="Vakky")
|
||||||
|
|
||||||
self.assertEquals(shop.id, self.shop.id)
|
self.assertEquals(shop.id, self.shop.id)
|
||||||
|
|
||||||
|
self.assertRaises(PlayerInDBError, add_owner, new_owner.name, self.shop.name, discord_uuid=DISCORD_UUID)
|
||||||
|
|
Loading…
Reference in New Issue