diff --git a/api/views.py b/api/views.py
index 387f32d..a2fe855 100644
--- a/api/views.py
+++ b/api/views.py
@@ -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()
diff --git a/migrations/0009_ip_last_seen.py b/migrations/0009_ip_last_seen.py
new file mode 100644
index 0000000..2cdb0dc
--- /dev/null
+++ b/migrations/0009_ip_last_seen.py
@@ -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),
+ ),
+ ]
diff --git a/migrations/0010_auto_20180921_2306.py b/migrations/0010_auto_20180921_2306.py
new file mode 100644
index 0000000..3ce4e35
--- /dev/null
+++ b/migrations/0010_auto_20180921_2306.py
@@ -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',
+ ),
+ ]
diff --git a/models.py b/models.py
index 6d0a43f..dacd021 100644
--- a/models.py
+++ b/models.py
@@ -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"
diff --git a/static/minecraft_manager/css/bootswatch-darkly.css b/static/minecraft_manager/css/bootswatch-darkly.css
index b68012a..9a5e710 100644
--- a/static/minecraft_manager/css/bootswatch-darkly.css
+++ b/static/minecraft_manager/css/bootswatch-darkly.css
@@ -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;
}
diff --git a/static/minecraft_manager/css/bootswatch-flatly.css b/static/minecraft_manager/css/bootswatch-flatly.css
index 162b767..ba7e9e9 100644
--- a/static/minecraft_manager/css/bootswatch-flatly.css
+++ b/static/minecraft_manager/css/bootswatch-flatly.css
@@ -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;
}
diff --git a/static/minecraft_manager/css/bootswatch-slate.css b/static/minecraft_manager/css/bootswatch-slate.css
index 0f09828..eb90344 100644
--- a/static/minecraft_manager/css/bootswatch-slate.css
+++ b/static/minecraft_manager/css/bootswatch-slate.css
@@ -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;
}
diff --git a/static/minecraft_manager/css/bootswatch-solar.css b/static/minecraft_manager/css/bootswatch-solar.css
index 653ff06..3beb663 100644
--- a/static/minecraft_manager/css/bootswatch-solar.css
+++ b/static/minecraft_manager/css/bootswatch-solar.css
@@ -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;
}
diff --git a/templates/minecraft_manager/ip.html b/templates/minecraft_manager/ip.html
new file mode 100644
index 0000000..ec1023e
--- /dev/null
+++ b/templates/minecraft_manager/ip.html
@@ -0,0 +1,23 @@
+{% extends "minecraft_manager/dashboard.html" %}
+{% load static %}
+{% block after_h1 %}{{ ip.ip }}{% endblock %}
+{% block section %}
+
+
+
+
+ Player |
+ Last Used |
+
+
+
+ {% for i in ips %}
+
+ {{ i.player.username }} |
+ {{ i.last_used }} |
+
+ {% endfor %}
+
+
+
+{% endblock section %}
\ No newline at end of file
diff --git a/templates/minecraft_manager/player_info.html b/templates/minecraft_manager/player_info.html
index 7602fd9..ed33468 100644
--- a/templates/minecraft_manager/player_info.html
+++ b/templates/minecraft_manager/player_info.html
@@ -52,14 +52,14 @@
-
+
IPs
{% if form.ips %}
{% for ip in form.ips %}
-
+
- {{ ip.ip }} |
+ {{ ip.ip }} ({{ ip.last_used }}) |
{% if ip.associated %}
{% for assoc in ip.associated %}
diff --git a/urls.py b/urls.py
index 5d193e4..b56c2ae 100644
--- a/urls.py
+++ b/urls.py
@@ -28,6 +28,8 @@ urlpatterns = [
url(r'^dashboard/warning/$', login_required(mcm.Warning.as_view()), name="warning"),
url(r'^dashboard/warning/(?P[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[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
diff --git a/views.py b/views.py
index b2576c8..88dfdb1 100644
--- a/views.py
+++ b/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):
|