Couple small improvement in templates and models

+ Updated README.md
+ Moved links property to the Location Model for every location type
+ Updated templates
+ Added footer
doc_update
Joey Hines 2019-04-10 17:31:52 -05:00
parent 35de6f9316
commit 03f4080bbe
8 changed files with 46 additions and 34 deletions

View File

@ -1,4 +1,4 @@
# Geoffrey: A Discord Bot for Minecraft Servers # Geoffrey: A Location Database for Minecraft Servers
Geoffrey was created to be an information source for base and shop locations on Minecraft severs. The bot mainly tracks Geoffrey was created to be an information source for base and shop locations on Minecraft severs. The bot mainly tracks
base, shop, and tunnel locations. This allows for users to quickly find each other's builds and find shops selling base, shop, and tunnel locations. This allows for users to quickly find each other's builds and find shops selling
goods. goods.

View File

@ -83,6 +83,8 @@ class Player(models.Model):
class Location(models.Model): class Location(models.Model):
info_page = None
"""Model of a Location""" """Model of a Location"""
DIMENSIONS = ( DIMENSIONS = (
@ -194,8 +196,10 @@ class Location(models.Model):
""" """
child = self.loc_child_obj child = self.loc_child_obj
if child != self: if child is not self:
return self.loc_child_obj.link return reverse(child.info_page, kwargs={"id": child.id})
else:
return reverse(self.info_page, kwargs={"id": self.id})
@property @property
def loc_child_obj(self): def loc_child_obj(self):
@ -233,30 +237,22 @@ class Location(models.Model):
class Shop(Location): class Shop(Location):
info_page = "GeoffreyShopInfo"
def __str__(self): def __str__(self):
return "Shop: %s" % self.name return "Shop: %s" % self.name
@property
def link(self):
"""
Link to the shop's page
"""
return reverse("GeoffreyShopInfo", kwargs={"id": self.id})
class Base(Location): class Base(Location):
info_page = "GeoffreyBaseInfo"
def __str__(self): def __str__(self):
return "Base: %s" % self.name return "Base: %s" % self.name
@property
def link(self):
"""
Link to the base's page
"""
return reverse("GeoffreyBaseInfo", kwargs={"id": self.id})
class Town(Location): class Town(Location):
info_page = "GeoffreyTownInfo"
residents = models.ManyToManyField(Player) residents = models.ManyToManyField(Player)
""" """
Players who are members of the town Players who are members of the town
@ -301,21 +297,13 @@ class Town(Location):
return json return json
@property
def link(self): class Market(Location):
""" info_page = "GeoffreyMarketInfo"
Link to the town's page
"""
return reverse("GeoffreyTownInfo", kwargs={"id": self.id})
class PublicFarm(Location): class PublicFarm(Location):
@property info_page = "GeoffreyPublicFarmInfo"
def link(self):
"""
Link to the Farms's page
"""
return reverse("GeoffreyPublicFarmInfo", kwargs={"id": self.id})
class Resource(models.Model): class Resource(models.Model):

View File

@ -0,0 +1,16 @@
html {
position: relative;
min-height: 100%;
}
body {
margin-bottom: 60px;
}
.footer {
position: absolute;
bottom: 0;
width: 100%;
height: 30px;
line-height: 30px;
}

View File

@ -26,6 +26,8 @@
<script type="text/javascript" language="javascript" <script type="text/javascript" language="javascript"
src="https://cdn.datatables.net/1.10.19/js/dataTables.bootstrap4.min.js"></script> src="https://cdn.datatables.net/1.10.19/js/dataTables.bootstrap4.min.js"></script>
<link href="{% static 'GeoffreyApp/css/geoffrey.css' %}" rel="stylesheet">
</head> </head>
<body> <body>
@ -54,5 +56,13 @@
<h1>{% block header %}{% endblock %}</h1> <h1>{% block header %}{% endblock %}</h1>
{% block content %}{% endblock %} {% block content %}{% endblock %}
</div> </div>
<footer class="footer navbar navbar-expand-lg navbar-dark bg-dark ">
<div class="container">
<span class="text-muted">
Made with :sed: by <a href="https://www.zerohighdef.com/" class="text-info">ZeroHD</a>
</span>
</div>
</footer>
</body> </body>
</html> </html>

View File

@ -27,6 +27,4 @@
</tbody> </tbody>
</table> </table>
{% endblock %} {% endblock %}

View File

@ -17,7 +17,7 @@
</p> </p>
{% endif %} {% endif %}
<p>Location: {{ loc.location }}</p> <p>Location: {{ loc.position }}</p>
<hr class="my-4"> <hr class="my-4">
{% block info %}{% endblock %} {% block info %}{% endblock %}
<iframe src="{{ loc.dynmap_url }}" width="100%" height="500"> <iframe src="{{ loc.dynmap_url }}" width="100%" height="500">

View File

@ -1,4 +1,3 @@
<h2>Locations</h2>
<table id="loc_table" class="table table-hover link-table"> <table id="loc_table" class="table table-hover link-table">
<thead class="bg-dark"> <thead class="bg-dark">
<tr> <tr>

View File

@ -4,5 +4,6 @@
{{ player.name }} {{ player.name }}
{% endblock %} {% endblock %}
{% block content %} {% block content %}
<h2>Locations</h2>
{% include "GeoffreyApp/location_table.html" with loc_list=loc_list %} {% include "GeoffreyApp/location_table.html" with loc_list=loc_list %}
{% endblock %} {% endblock %}