Fixed issue in add_location() and fixed tests
parent
39302bb136
commit
723124f26e
|
@ -84,13 +84,12 @@ def get_location(owner, name=None, loc_type=Location):
|
|||
|
||||
def add_location(x_pos, z_pos, name=None, discord_uuid=None, mc_uuid=None, loc_type=Location):
|
||||
player = get_player(discord_uuid, mc_uuid)
|
||||
try:
|
||||
get_location(player, name, loc_type=loc_type)
|
||||
raise EntryNameNotUniqueError
|
||||
except (Location.DoesNotExist, NoLocationsInDatabase, LocationLookUpError):
|
||||
if name is None:
|
||||
name = "{}'s {}".format(player.name, loc_type.__name__)
|
||||
|
||||
if Location.objects.filter(name__iexact=name).all().count() > 0:
|
||||
raise EntryNameNotUniqueError
|
||||
else:
|
||||
location = loc_type.objects.create(name=name, x_coord=x_pos, z_coord=z_pos)
|
||||
location.owner.add(player)
|
||||
location.save()
|
||||
|
|
Loading…
Reference in New Issue