Folder that holds database for future plans of all contentes of Plex

Library and system info.
This commit is contained in:
2016-12-08 11:47:48 +01:00
parent 94041dfc5b
commit 41000e69b9
39 changed files with 352 additions and 0 deletions

View File

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,6 @@
from django.contrib import admin
# Register your models here.
from .models import Address
admin.site.register(Address)

View File

@@ -0,0 +1,5 @@
from django.apps import AppConfig
class PlexConfig(AppConfig):
name = 'plex'

View File

@@ -0,0 +1,37 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.3 on 2016-11-23 20:16
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Address',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('ip_address', models.CharField(max_length=200)),
('first_connect', models.DateTimeField(verbose_name='date first accessed on address')),
],
),
migrations.CreateModel(
name='Location',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('ip_version', models.CharField(max_length=1)),
('country', models.CharField(max_length=100)),
('city', models.CharField(max_length=100)),
('region', models.CharField(max_length=100)),
('postal_code', models.IntegerField(max_length=6)),
('address', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='plex.Address')),
],
),
]

View File

@@ -0,0 +1,25 @@
from django.db import models
import datetime
from django.utils import timezone
# Create your models here.
class Address(models.Model):
ip_address = models.CharField(max_length=200)
first_connect = models.DateTimeField('date first accessed on address')
def created_recently(self):
return self.first_connect >= timezone.now() - datetime.timedelta(days=1)
def __str__(self):
return self.ip_address
class Location(models.Model):
address = models.ForeignKey(Address, on_delete=models.CASCADE)
ip_version = models.IntegerField(default=4)
country = models.CharField(max_length=100)
city = models.CharField(max_length=100)
region = models.CharField(max_length=100)
postal_code = models.IntegerField(default=0)
def __str__(self):
return str([self.country, self.city, self.region])

View File

@@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

View File

@@ -0,0 +1,14 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# @Author: KevinMidboe
# @Date: 2016-11-23 20:43:37
# @Last Modified by: KevinMidboe
# @Last Modified time: 2016-11-23 20:43:50
from django.conf.urls import url
from . import views
urlpatterns = [
url(r'^$', views.index, name='index'),
]

View File

@@ -0,0 +1,7 @@
from django.shortcuts import render
# Create your views here.
from django.http import HttpResponse
def index(request):
return HttpResponse("Hello, world. You're at the plex index.")