IP last used date & IP info
Added last_used to IP model Created page to view an IP and last dates for any associated playersreminder
parent
a9862ae778
commit
bfe310f636
|
@ -1,6 +1,6 @@
|
|||
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 import update_session_auth_hash
|
||||
from django.apps import apps
|
||||
|
@ -261,11 +261,13 @@ class PluginAPI(View):
|
|||
player.application = test_app
|
||||
player.save()
|
||||
test_ip = IP.objects.filter(ip=post['ip'], player=player).exists()
|
||||
last_used = datetime.date.today()
|
||||
if not test_ip:
|
||||
ip = IP(ip=post['ip'], player=player)
|
||||
ip.save()
|
||||
else:
|
||||
ip = IP.objects.get(ip=post['ip'], player=player)
|
||||
ip.last_used = last_used
|
||||
ip.save()
|
||||
player = Player.objects.get(uuid=post['uuid'])
|
||||
player.last_seen = timezone.now().strftime("%Y-%m-%d")
|
||||
player.save()
|
||||
|
|
|
@ -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),
|
||||
),
|
||||
]
|
|
@ -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',
|
||||
),
|
||||
]
|
|
@ -369,6 +369,7 @@ class Warning(models.Model):
|
|||
class IP(models.Model):
|
||||
player = models.ForeignKey(Player, on_delete=models.CASCADE)
|
||||
ip = models.CharField(max_length=30)
|
||||
last_used = models.DateField(null=True, blank=True)
|
||||
|
||||
class Meta:
|
||||
verbose_name = "IP"
|
||||
|
|
|
@ -3994,7 +3994,8 @@ select[multiple].input-group-sm > .input-group-btn > .btn {
|
|||
padding: 10px 15px;
|
||||
}
|
||||
.nav > li > a:hover,
|
||||
.nav > li > a:focus {
|
||||
.nav > li > a:focus,
|
||||
.nav > li.active > a {
|
||||
text-decoration: none;
|
||||
background-color: #303030;
|
||||
}
|
||||
|
|
|
@ -3990,7 +3990,8 @@ select[multiple].input-group-sm > .input-group-btn > .btn {
|
|||
padding: 10px 15px;
|
||||
}
|
||||
.nav > li > a:hover,
|
||||
.nav > li > a:focus {
|
||||
.nav > li > a:focus,
|
||||
.nav > li.active > a {
|
||||
text-decoration: none;
|
||||
background-color: #ecf0f1;
|
||||
}
|
||||
|
|
|
@ -3993,7 +3993,8 @@ select[multiple].input-group-sm > .input-group-btn > .btn {
|
|||
padding: 10px 15px;
|
||||
}
|
||||
.nav > li > a:hover,
|
||||
.nav > li > a:focus {
|
||||
.nav > li > a:focus,
|
||||
.nav > li.active > a {
|
||||
text-decoration: none;
|
||||
background-color: #3e444c;
|
||||
}
|
||||
|
|
|
@ -3990,7 +3990,8 @@ select[multiple].input-group-sm > .input-group-btn > .btn {
|
|||
padding: 10px 15px;
|
||||
}
|
||||
.nav > li > a:hover,
|
||||
.nav > li > a:focus {
|
||||
.nav > li > a:focus,
|
||||
.nav > li.active > a {
|
||||
text-decoration: none;
|
||||
background-color: #222222;
|
||||
}
|
||||
|
|
|
@ -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 %}
|
|
@ -52,14 +52,14 @@
|
|||
</tbody>
|
||||
</table>
|
||||
<br/>
|
||||
<table class="table table-striped">
|
||||
<table class="table table-striped table-hover link-table">
|
||||
<h4>IPs</h4>
|
||||
<tbody>
|
||||
{% if form.ips %}
|
||||
{% for ip in form.ips %}
|
||||
<tr class="default">
|
||||
<tr class="default" data-id="" data-url="{% url 'ip' ip.id %}">
|
||||
<!-- {{ ip.id }} -->
|
||||
<td>{{ ip.ip }}</td>
|
||||
<td>{{ ip.ip }} ({{ ip.last_used }})</td>
|
||||
{% if ip.associated %}
|
||||
<td>
|
||||
{% for assoc in ip.associated %}
|
||||
|
|
2
urls.py
2
urls.py
|
@ -28,6 +28,8 @@ urlpatterns = [
|
|||
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/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
|
||||
url(r'^report/$', login_required(mcm.Report.as_view()), name="report"),
|
||||
#Chat
|
||||
|
|
11
views.py
11
views.py
|
@ -380,6 +380,17 @@ class WarningAdd(View):
|
|||
{'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):
|
||||
|
||||
def get(self, request):
|
||||
|
|
Loading…
Reference in New Issue