Got all tests passing again
+Added json property to ItemListing +Fixed a typo +Updated Django the Geoffrey settings to have Geoffrey in front of themdoc_update
parent
4aadb3b185
commit
00fe2d72ab
|
@ -78,12 +78,7 @@ def add_location(x_pos, z_pos, name=None, discord_uuid=None, mc_uuid=None, loc_t
|
|||
if name is None:
|
||||
name = "{}'s {}".format(player.name, loc_type.__name__)
|
||||
|
||||
if loc_type == Base:
|
||||
location = Base.objects.create(owner=player, name=name, x_coord=x_pos, z_coord=z_pos)
|
||||
elif loc_type == Shop:
|
||||
location = Shop.objects.create(owner=player, name=name, x_coord=x_pos, z_coord=z_pos)
|
||||
else:
|
||||
raise DataBaseError
|
||||
location = loc_type.objects.create(owner=player, name=name, x_coord=x_pos, z_coord=z_pos)
|
||||
|
||||
return location.json
|
||||
|
||||
|
@ -305,7 +300,7 @@ def tunnel(player_name):
|
|||
if len(tunnels) == 0:
|
||||
raise LocationLookUpError
|
||||
|
||||
return objects_list_to_json(tunnel)
|
||||
return objects_list_to_json(tunnels)
|
||||
|
||||
|
||||
@command("POST")
|
||||
|
@ -328,7 +323,7 @@ def edit_pos(x, z, loc_name, discord_uuid=None, mc_uuid=None):
|
|||
location.z_coord = z
|
||||
location.save()
|
||||
|
||||
return location.jsone
|
||||
return location.json
|
||||
|
||||
|
||||
@command("POST")
|
||||
|
|
|
@ -2,7 +2,7 @@ from django.conf import settings
|
|||
from GeoffreyApp.errors import ExternalLookupFailed
|
||||
import requests
|
||||
|
||||
base_url = getattr(settings, 'MCM_BASE_URL', 'localhost')
|
||||
base_url = getattr(settings, 'GEOFFREY_MCM_BASE_URL', 'localhost')
|
||||
|
||||
player_url = base_url + '/api/model/player/'
|
||||
|
||||
|
@ -12,7 +12,7 @@ def add_dashes_to_uuid(uuid):
|
|||
|
||||
|
||||
def get_token():
|
||||
api_token = getattr(settings, 'MCM_API_TOKEN')
|
||||
api_token = getattr(settings, 'GEOFFREY_MCM_API_TOKEN')
|
||||
if api_token is not None:
|
||||
return api_token
|
||||
else:
|
||||
|
|
29
models.py
29
models.py
|
@ -26,7 +26,10 @@ class Player(models.Model):
|
|||
|
||||
@property
|
||||
def json(self):
|
||||
return {"Name": self.name, "MC UUID": self.mc_uuid, "Discord UUID": self.discord_uuid}
|
||||
return {"Name": self.name,
|
||||
"MC UUID": self.mc_uuid,
|
||||
"Discord UUID": self.discord_uuid
|
||||
}
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
@ -49,8 +52,13 @@ class Location(models.Model):
|
|||
|
||||
@property
|
||||
def json(self):
|
||||
return {"Type": self.__class__.__name__, "Name": self.name, "x_coord": self.x_coord, "z_coord": self.z_coord,
|
||||
"dimension": self.dimension, "Owner": self.owner.json}
|
||||
return {"Type": self.__class__.__name__,
|
||||
"Name": self.name,
|
||||
"x_coord": self.x_coord,
|
||||
"z_coord": self.z_coord,
|
||||
"dimension": self.dimension,
|
||||
"Owner": self.owner.json
|
||||
}
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
@ -80,6 +88,15 @@ class ItemListing(models.Model):
|
|||
else:
|
||||
return self.price/self.amount
|
||||
|
||||
@property
|
||||
def json(self):
|
||||
return {"item_name": self.item_name,
|
||||
"price": self.price,
|
||||
"amount": self.amount,
|
||||
"normalized_price": self.normalized_price,
|
||||
"shop": self.shop.json,
|
||||
}
|
||||
|
||||
def __str__(self):
|
||||
return "Item: %d %s for %d" % (self.amount, self.item_name, self.amount)
|
||||
|
||||
|
@ -102,5 +119,7 @@ class Tunnel(models.Model):
|
|||
|
||||
@property
|
||||
def json(self):
|
||||
return {"Location_name": self.location.name, "tunnel_direction": self.tunnel_direction,
|
||||
"tunnel_number": self.tunnel_number}
|
||||
return {"Location_name": self.location.name,
|
||||
"tunnel_direction": self.tunnel_direction,
|
||||
"tunnel_number": self.tunnel_number
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue