diff --git a/templatetags/reverse_player.py b/templatetags/reverse_player.py
new file mode 100644
index 0000000..b4f9cf1
--- /dev/null
+++ b/templatetags/reverse_player.py
@@ -0,0 +1,21 @@
+from django.template import Library
+
+from minecraft_manager.models import Player
+from django.urls import reverse
+from django.utils.html import mark_safe
+
+register = Library()
+
+
+@register.simple_tag(name="player_reverse_name")
+def reverse_name(username):
+ player = Player.objects.get(username=username)
+ url = "{}{}".format(reverse('player'), player.id)
+ return mark_safe('
{}'.format(url, player.username))
+
+
+@register.simple_tag(name="player_reverse_id")
+def reverse_id(player_id):
+ player = Player.objects.get(id=player_id)
+ url = "{}{}".format(reverse('player'), player.id)
+ return mark_safe('
{}'.format(url, player.username))
diff --git a/views.py b/views.py
index 46be592..e04b457 100644
--- a/views.py
+++ b/views.py
@@ -12,6 +12,7 @@ from django.utils.decorators import method_decorator
from django.conf import settings
from django.views.generic import View
from django.contrib.auth.models import User
+from django.forms.widgets import HiddenInput
from minecraft_manager.models import Application as AppModel, Player as PlayerModel, Ticket as TicketModel, Warning as WarningModel, IP as IPModel, Alert as AlertModel, Note as NoteModel, UserSettings as UserSettingsModel
from minecraft_manager.forms import WarningForm, NoteForm
from minecraft_manager.overview import overview_data
@@ -199,11 +200,17 @@ class PlayerInfo(View):
tickets = TicketModel.objects.filter(player=player)
warnings = WarningModel.objects.filter(player=player)
form = {'ips': ips, 'tickets': tickets, 'warnings': warnings}
- return render(request, 'minecraft_manager/player_info.html', {'current_app': 'player', 'player': player, 'form': form})
+ return render(request, 'minecraft_manager/player_info.html',
+ {'current_app': 'player', 'player': player, 'form': form})
def post(self, request, player_id):
player = PlayerModel.objects.get(id=player_id)
- return render(request, 'minecraft_manager/player_info.html', {'current_app': 'player', 'player': player})
+ ips = IPModel.api.filter(player=player)
+ tickets = TicketModel.objects.filter(player=player)
+ warnings = WarningModel.objects.filter(player=player)
+ form = {'ips': ips, 'tickets': tickets, 'warnings': warnings}
+ return render(request, 'minecraft_manager/player_info.html',
+ {'current_app': 'player', 'player': player, 'form': form})
class Ticket(View):
@@ -337,9 +344,12 @@ class WarningAdd(View):
@method_decorator(csrf_protect)
def get(self, request):
- form = WarningForm().as_p()
+ get = request.GET
+ form = WarningForm()
+ if 'player' in get:
+ form.initial = {'player': get['player']}
return render(request, 'minecraft_manager/warning_add.html',
- {'current_app': 'warning', 'form': form})
+ {'current_app': 'warning', 'form': form.as_p()})
def post(self, request):
post = request.POST