diff --git a/models.py b/models.py
index daaebd7..0cd7da1 100644
--- a/models.py
+++ b/models.py
@@ -46,6 +46,10 @@ class Player(models.Model):
Discord UUID
'''
+ @property
+ def loc_count(self):
+ return Location.objects.filter(owner=self).count()
+
@property
def json(self):
return {"name": self.name,
@@ -86,6 +90,10 @@ class Location(models.Model):
Owner of Location
'''
+ @property
+ def location(self):
+ return "(x={}, z={}".format(self.x_coord, self.z_coord)
+
@property
def json(self):
return {"type": self.__class__.__name__,
diff --git a/templates/GeoffreyApp/base.html b/templates/GeoffreyApp/base.html
index 8d22577..9f44fd4 100644
--- a/templates/GeoffreyApp/base.html
+++ b/templates/GeoffreyApp/base.html
@@ -7,6 +7,9 @@
{% block title %}
+
+
{% block header %}{% endblock %}
{% block content %}{% endblock %}
diff --git a/templates/GeoffreyApp/base_list.html b/templates/GeoffreyApp/base_list.html
index e062039..a9f348d 100644
--- a/templates/GeoffreyApp/base_list.html
+++ b/templates/GeoffreyApp/base_list.html
@@ -1,17 +1,32 @@
{% extends "GeoffreyApp/base.html" %}
-{% block content %}
-
Bases
- {% if base_list %}
-
- {% for base in base_list %}
- -
- {{ base.name }} {{ base.owner }} {{ base.x_coord }} {{ base.z_coord }}
-
- {% endfor %}
-
- {% else %}
-
There are no bases in the database :pepethonk:
- {% endif %}
-
+{% block header %}
+ Bases
+{% endblock %}
+
+{% block content %}
+
+
+
+ Base Name |
+ Location |
+ Owner |
+
+
+
+ {% for base in base_list %}
+
+ {{ base.name }} |
+ {{ base.location }} |
+ {{ base.owner }} |
+
+ {% endfor %}
+
+
+
+
{% endblock %}
diff --git a/templates/GeoffreyApp/home.html b/templates/GeoffreyApp/home.html
index 9fdba0c..0a8ed24 100644
--- a/templates/GeoffreyApp/home.html
+++ b/templates/GeoffreyApp/home.html
@@ -1,13 +1,32 @@
{% extends "GeoffreyApp/base.html" %}
+{% block header %}
+ Geoffrey
+{% endblock %}
+
{% block content %}
-
Geoffrey Minecraft Database Home
+
About
Geoffrey is a database for storing information on Players, Bases, Shops, Towns, and more!
-
Current Database Count:
-
- - Players: {{ num_players }}
- - Shops: {{ num_shops }}
- - Items for Sale: {{ num_items }}
- - Bases: {{ num_bases }}
-
+
+
Current Database Counts
+
+
+
+
+ Type |
+ Count |
+
+
+
+ {% for stat in stat_list %}
+
+ {{ stat.0 }} |
+ {{ stat.1 }} |
+
+ {% endfor %}
+
+
+
+
+
{% endblock %}
\ No newline at end of file
diff --git a/templates/GeoffreyApp/itemlisting_list.html b/templates/GeoffreyApp/itemlisting_list.html
index 645b5dc..4a9e33d 100644
--- a/templates/GeoffreyApp/itemlisting_list.html
+++ b/templates/GeoffreyApp/itemlisting_list.html
@@ -1,16 +1,37 @@
{% extends "GeoffreyApp/base.html" %}
+{% block header %}
+ Item Listings
+{% endblock %}
+
{% block content %}
- {% if itemlisting_list %}
-
- {% for item in itemlisting_list %}
- -
- {{ item.item_name}} {{ item.amount }} for {{ item.price }}D
-
- {% endfor %}
-
- {% else %}
-
There are no items for sale in the database :pepethonk:
- {% endif %}
+
+
+
+ Item Name |
+ Amount |
+ Price |
+ Price Per Item |
+ Shop |
+
+
+
+ {% for item in itemlisting_list %}
+
+ {{ item.item_name }} |
+ {{ item.amount }} |
+ {{ item.price }}D |
+ {{ item.normalized_price }}D |
+ {{ item.shop.name }} @ {{ item.shop.location }} |
+
+ {% endfor %}
+
+
+
+
{% endblock %}
diff --git a/templates/GeoffreyApp/player_list.html b/templates/GeoffreyApp/player_list.html
index ec322dd..0951d60 100644
--- a/templates/GeoffreyApp/player_list.html
+++ b/templates/GeoffreyApp/player_list.html
@@ -1,17 +1,29 @@
{% extends "GeoffreyApp/base.html" %}
+{% block header %}
+ Players
+{% endblock %}
+
{% block content %}
-
- {% if player_list %}
-
- {% for player in player_list %}
- -
- {{ player.name }}
-
- {% endfor %}
-
- {% else %}
-
There are no players in the database :pepethonk:
- {% endif %}
-
+
+
+
+ Player Username |
+ # of Locations |
+
+
+
+ {% for player in player_list %}
+
+ {{ player.name }} |
+ {{ player.loc_count }} |
+
+ {% endfor %}
+
+
+
{% endblock %}
\ No newline at end of file
diff --git a/templates/GeoffreyApp/search.html b/templates/GeoffreyApp/search.html
index dbea639..d911362 100644
--- a/templates/GeoffreyApp/search.html
+++ b/templates/GeoffreyApp/search.html
@@ -1,42 +1,56 @@
{% extends "GeoffreyApp/base.html" %}
+{% block header %}
+ Search results for {{ search }}...
+{% endblock %}
+
{% block content %}
-
Search results for {{ search }}...
+
Players
+
+
+
+ Player Username |
+ # of Locations |
+
+
+
+ {% for player in player_list %}
+
+ {{ player.name }} |
+ {{ player.loc_count }} |
+
+ {% endfor %}
+
+
- {% if player_list %}
-
Players
-
- {% for player in player_list %}
- -
- {{ player.name }}
-
- {% endfor %}
-
- {% else %}
- {% endif %}
+
- {% if base_list %}
-
Bases
-
- {% for base in base_list %}
- -
- {{ base.name }}
-
- {% endfor %}
-
- {% else %}
- {% endif %}
+
Locations
+
+
+
+ Location Name |
+ Coordinates |
+ Owner |
+
+
+
+ {% for loc in loc_list %}
+
+ {{ loc.name }} |
+ {{ loc.location }} |
+ {{ loc.owner }} |
+
+ {% endfor %}
- {% if shop_list %}
- Shops
-
- {% for shop in shop_list %}
- -
- {{ shop.name }}
-
- {% endfor %}
-
- {% else %}
- {% endif %}
+
+
+
+
{% endblock %}
\ No newline at end of file
diff --git a/templates/GeoffreyApp/shop_list.html b/templates/GeoffreyApp/shop_list.html
index f99ba6b..cc4c845 100644
--- a/templates/GeoffreyApp/shop_list.html
+++ b/templates/GeoffreyApp/shop_list.html
@@ -1,18 +1,33 @@
{% extends "GeoffreyApp/base.html" %}
-{% block content %}
-
Shops
-
- {% if shop_list %}
-
- {% for shop in shop_list %}
- -
- {{ shop.name }} {{ shop.owner }} {{ shop.x_coord }} {{ shop.z_coord }}
-
- {% endfor %}
-
- {% else %}
-
There are no shops in the database :pepethonk:
- {% endif %}
-
+{% block header %}
+ Shops
{% endblock %}
+
+{% block content %}
+
+
+
+ Shop Name |
+ Location |
+ Owner |
+
+
+
+ {% for shop in shop_list %}
+
+ {{ shop.name }} |
+ {{ shop.location }} |
+ {{ shop.owner }} |
+
+ {% endfor %}
+
+
+
+
+{% endblock %}
+
diff --git a/views.py b/views.py
index a636548..1e944a1 100644
--- a/views.py
+++ b/views.py
@@ -9,17 +9,14 @@ from django.db.models import Q
class Home(View):
def get(self, request):
-
- base_num = Base.objects.count()
- shop_num = Shop.objects.count()
- player_num = Player.objects.count()
- item_num = ItemListing.objects.count()
+ stats = []
+ stats.append(("Players", Player.objects.count()))
+ stats.append(("Bases", Base.objects.count()))
+ stats.append(("Shops", Shop.objects.count()))
+ stats.append(("Items for Sale", Player.objects.count()))
context = {
- "num_players": player_num,
- "num_bases": base_num,
- "num_shops": shop_num,
- "num_items": item_num,
+ "stat_list": stats,
"current_page": "Home",
}
@@ -34,9 +31,7 @@ class SearchList(View):
context["player_list"] = Player.objects.filter(Q(name__icontains=query)).all()
- context["base_list"] = Base.objects.filter(Q(name__icontains=query) | Q(owner__name__icontains=query)).all()
-
- context["shop_list"] = Shop.objects.filter(Q(name__icontains=query) | Q(owner__name__icontains=query)).all()
+ context["loc_list"] = Location.objects.filter(Q(name__icontains=query) | Q(owner__name__icontains=query)).all()
return render(request, 'GeoffreyApp/search.html', context=context)