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 %}GeoffreyApp{% endblock %} + {% load static %} + + @@ -15,8 +18,14 @@ - {% load static %} - + + + + + + + @@ -32,15 +41,17 @@ +
- + {% block search %}{% endblock %}
-
+
+

{% 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 %} - - {% else %} -

There are no bases in the database :pepethonk:

- {% endif %} - +{% block header %} + Bases +{% endblock %} + +{% block content %} + + + + + + + + + + {% for base in base_list %} + + + + + + {% 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:

- + +

Current Database Counts

+ + + + + + + + + + {% for stat in stat_list %} + + + + + {% 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 %} - - {% else %} -

There are no items for sale in the database :pepethonk:

- {% endif %} + + + + + + + + + + + + {% for item in itemlisting_list %} + + + + + + + + {% 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 %} - - {% else %} -

There are no players in the database :pepethonk:

- {% endif %} - + + + + + + + + + {% for player in player_list %} + + + + + {% 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

+ + + + + + + + + {% for player in player_list %} + + + + + {% endfor %} + + - {% if player_list %} -
Players
- - {% else %} - {% endif %} +
- {% if base_list %} -
Bases
- - {% else %} - {% endif %} +

Locations

+ + + + + + + + + + {% for loc in loc_list %} + + + + + + {% endfor %} - {% if shop_list %} -
Shops
- - {% 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 %} - - {% else %} -

There are no shops in the database :pepethonk:

- {% endif %} - +{% block header %} + Shops {% endblock %} + +{% block content %} + + + + + + + + + + {% for shop in shop_list %} + + + + + + {% 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)