Small fixed and improvements

+ removed player_link template
+ gave the player model a link property
+ fixed some web-page display issues
doc_update
Joey Hines 2019-04-12 20:04:13 -05:00
parent a47ea55fd6
commit d149e39b84
7 changed files with 19 additions and 10 deletions

View File

@ -78,6 +78,13 @@ class Player(models.Model):
"discord_uuid": self.discord_uuid
}
@property
def link(self):
"""
href to the player page
"""
return reverse("GeoffreyPlayerInfo", kwargs={"id": self.id})
def __str__(self):
return self.name

View File

@ -12,7 +12,8 @@
Owner:
{% endif %}
{{ loc.owner.all.first }}{% for owner in loc.owner.all|slice:"1:" %}, {{ owner }}
<a class="text-light" href="{{ loc.owner.all.first.link }}">{{ loc.owner.all.first }}</a>
{% for owner in loc.owner.all|slice:"1:" %}, <a href="{{ owner.link }}">{{ owner.name }}</a>
{% endfor %}
</p>
@ -20,7 +21,7 @@
<p>Location: {{ loc.position }}</p>
{% if loc.tunnel %}
<p>Tunnel: {{ loc.tunnel.get_tunnel_direction_display }} {{ loc.tunnel.tunnel_number }}</p>
<p>Tunnel: {{ loc.tunnel.tunnel_str }}</p>
{% endif %}
<hr class="my-4">
{% block info %}{% endblock %}

View File

@ -2,7 +2,8 @@
<thead class="bg-dark">
<tr>
<th>Location Name</th>
<th>Coordinates</th>
<th>Position</th>
<th>Tunnel</th>
{% if show_owner %}
<th>Owner</th>
{% endif %}
@ -12,12 +13,13 @@
{% for loc in loc_list %}
<tr>
<td><a href="{{ loc.link }}">{{ loc.name }}</a></td>
<td>{{ loc.location }}</td>
<td>{{ loc.position }}</td>
<td>{% if loc.tunnel %} {{ loc.tunnel.tunnel_str }}{% else %}n/a{% endif %}</td>
{% if show_owner %}
<td>
{% include "GeoffreyApp/player_link.html" with player=loc.owner.first %}
<a href="{{ loc.owner.first.link }}">{{ loc.owner.first }}</a>
{% for owner in loc.owner.all|slice:"1:3" %},
{% include "GeoffreyApp/player_link.html" with player=owner %}
<a href="{{ owner.link }}">{{ owner }}</a>
{% endfor %}
</td>
{% endif %}

View File

@ -1 +0,0 @@
<a href="{% url 'GeoffreyPlayerInfo' player.id %}">{{ player.name }}</a>

View File

@ -8,7 +8,7 @@
<tbody>
{% for player in player_list %}
<tr>
<td>{% include "GeoffreyApp/player_link.html" %}</td>
<td><a class="" href="{{ player.link }}">{{ player }}</a></td>
<td>{{ player.loc_count }} </td>
</tr>
{% endfor %}

View File

@ -1,7 +1,7 @@
{% extends "GeoffreyApp/base.html" %}
{% block header %}
Bases
Points of Interest
{% endblock %}
{% block content %}

View File

@ -95,7 +95,7 @@ class ModelInfoView(View):
def get(self, request, id):
try:
return render(request, 'GeoffreyApp/%s' % self.template, context=self.context(id))
return render(request, 'GeoffreyApp/%s' % self.template, context=self.get_context(id))
except Player.DoesNotExist:
return render(request, 'GeoffreyApp/error.html')