IP last used date & IP info

Added last_used to IP model
Created page to view an IP and last dates for any associated players
reminder
Etzelia 2018-09-21 23:35:51 -05:00
parent a9862ae778
commit bfe310f636
12 changed files with 88 additions and 9 deletions

View File

@ -1,6 +1,6 @@
from __future__ import absolute_import from __future__ import absolute_import
import logging, random, string, discord import logging, random, string, datetime
from django.contrib.auth.forms import PasswordChangeForm from django.contrib.auth.forms import PasswordChangeForm
from django.contrib.auth import update_session_auth_hash from django.contrib.auth import update_session_auth_hash
from django.apps import apps from django.apps import apps
@ -261,11 +261,13 @@ class PluginAPI(View):
player.application = test_app player.application = test_app
player.save() player.save()
test_ip = IP.objects.filter(ip=post['ip'], player=player).exists() test_ip = IP.objects.filter(ip=post['ip'], player=player).exists()
last_used = datetime.date.today()
if not test_ip: if not test_ip:
ip = IP(ip=post['ip'], player=player) ip = IP(ip=post['ip'], player=player)
ip.save()
else: else:
ip = IP.objects.get(ip=post['ip'], player=player) ip = IP.objects.get(ip=post['ip'], player=player)
ip.last_used = last_used
ip.save()
player = Player.objects.get(uuid=post['uuid']) player = Player.objects.get(uuid=post['uuid'])
player.last_seen = timezone.now().strftime("%Y-%m-%d") player.last_seen = timezone.now().strftime("%Y-%m-%d")
player.save() player.save()

View File

@ -0,0 +1,18 @@
# Generated by Django 2.1 on 2018-09-22 03:46
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('minecraft_manager', '0008_auto_20180820_1406'),
]
operations = [
migrations.AddField(
model_name='ip',
name='last_seen',
field=models.DateField(blank=True, null=True),
),
]

View File

@ -0,0 +1,18 @@
# Generated by Django 2.1 on 2018-09-22 04:06
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('minecraft_manager', '0009_ip_last_seen'),
]
operations = [
migrations.RenameField(
model_name='ip',
old_name='last_seen',
new_name='last_used',
),
]

View File

@ -369,6 +369,7 @@ class Warning(models.Model):
class IP(models.Model): class IP(models.Model):
player = models.ForeignKey(Player, on_delete=models.CASCADE) player = models.ForeignKey(Player, on_delete=models.CASCADE)
ip = models.CharField(max_length=30) ip = models.CharField(max_length=30)
last_used = models.DateField(null=True, blank=True)
class Meta: class Meta:
verbose_name = "IP" verbose_name = "IP"

View File

@ -3994,7 +3994,8 @@ select[multiple].input-group-sm > .input-group-btn > .btn {
padding: 10px 15px; padding: 10px 15px;
} }
.nav > li > a:hover, .nav > li > a:hover,
.nav > li > a:focus { .nav > li > a:focus,
.nav > li.active > a {
text-decoration: none; text-decoration: none;
background-color: #303030; background-color: #303030;
} }

View File

@ -3990,7 +3990,8 @@ select[multiple].input-group-sm > .input-group-btn > .btn {
padding: 10px 15px; padding: 10px 15px;
} }
.nav > li > a:hover, .nav > li > a:hover,
.nav > li > a:focus { .nav > li > a:focus,
.nav > li.active > a {
text-decoration: none; text-decoration: none;
background-color: #ecf0f1; background-color: #ecf0f1;
} }

View File

@ -3993,7 +3993,8 @@ select[multiple].input-group-sm > .input-group-btn > .btn {
padding: 10px 15px; padding: 10px 15px;
} }
.nav > li > a:hover, .nav > li > a:hover,
.nav > li > a:focus { .nav > li > a:focus,
.nav > li.active > a {
text-decoration: none; text-decoration: none;
background-color: #3e444c; background-color: #3e444c;
} }

View File

@ -3990,7 +3990,8 @@ select[multiple].input-group-sm > .input-group-btn > .btn {
padding: 10px 15px; padding: 10px 15px;
} }
.nav > li > a:hover, .nav > li > a:hover,
.nav > li > a:focus { .nav > li > a:focus,
.nav > li.active > a {
text-decoration: none; text-decoration: none;
background-color: #222222; background-color: #222222;
} }

View File

@ -0,0 +1,23 @@
{% extends "minecraft_manager/dashboard.html" %}
{% load static %}
{% block after_h1 %}{{ ip.ip }}{% endblock %}
{% block section %}
<div id="content">
<table id="model-table" class="table table-striped">
<thead>
<tr>
<th>Player</th>
<th>Last Used</th>
</tr>
</thead>
<tbody>
{% for i in ips %}
<tr>
<td><a href="{% url "player" %}{{ i.player.id }}">{{ i.player.username }}</a></td>
<td>{{ i.last_used }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endblock section %}

View File

@ -52,14 +52,14 @@
</tbody> </tbody>
</table> </table>
<br/> <br/>
<table class="table table-striped"> <table class="table table-striped table-hover link-table">
<h4>IPs</h4> <h4>IPs</h4>
<tbody> <tbody>
{% if form.ips %} {% if form.ips %}
{% for ip in form.ips %} {% for ip in form.ips %}
<tr class="default"> <tr class="default" data-id="" data-url="{% url 'ip' ip.id %}">
<!-- {{ ip.id }} --> <!-- {{ ip.id }} -->
<td>{{ ip.ip }}</td> <td>{{ ip.ip }} ({{ ip.last_used }})</td>
{% if ip.associated %} {% if ip.associated %}
<td> <td>
{% for assoc in ip.associated %} {% for assoc in ip.associated %}

View File

@ -28,6 +28,8 @@ urlpatterns = [
url(r'^dashboard/warning/$', login_required(mcm.Warning.as_view()), name="warning"), url(r'^dashboard/warning/$', login_required(mcm.Warning.as_view()), name="warning"),
url(r'^dashboard/warning/(?P<warning_id>[0-9]{1,5})/$', login_required(mcm.WarningInfo.as_view())), url(r'^dashboard/warning/(?P<warning_id>[0-9]{1,5})/$', login_required(mcm.WarningInfo.as_view())),
url(r'^dashboard/warning/add$', login_required(mcm.WarningAdd.as_view()), name="warning_add"), url(r'^dashboard/warning/add$', login_required(mcm.WarningAdd.as_view()), name="warning_add"),
#IP
url(r'^dashboard/ip/(?P<ip_id>[0-9]{1,5})/$', login_required(mcm.IP.as_view()), name="ip"),
#Report #Report
url(r'^report/$', login_required(mcm.Report.as_view()), name="report"), url(r'^report/$', login_required(mcm.Report.as_view()), name="report"),
#Chat #Chat

View File

@ -380,6 +380,17 @@ class WarningAdd(View):
{'current_app': 'warning', 'form': form}) {'current_app': 'warning', 'form': form})
class IP(View):
def get(self, request, ip_id):
ip = IPModel.objects.get(id=ip_id)
ips = IPModel.objects.filter(ip=ip.ip)
return render(request, 'minecraft_manager/ip.html', {'ip': ip, 'ips': ips})
def post(self, request, ip_id):
pass
class Report(View): class Report(View):
def get(self, request): def get(self, request):