summaryrefslogtreecommitdiffstats
path: root/mirrors/models.py
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2013-03-06 19:40:24 -0600
committerDan McGee <dan@archlinux.org>2013-03-06 19:40:24 -0600
commitd158ce71e4ec489ee3ec1a73c41c9b9dc8d34a23 (patch)
tree5dcbbba71ab98bb1c7ae36e06ce56fccbf7c5367 /mirrors/models.py
parent538c5014e2b55081a7774fa41cc16e8d18a4c9b6 (diff)
downloadarchweb-d158ce71e4ec489ee3ec1a73c41c9b9dc8d34a23.tar.gz
archweb-d158ce71e4ec489ee3ec1a73c41c9b9dc8d34a23.zip
Add mirror check locations model
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'mirrors/models.py')
-rw-r--r--mirrors/models.py23
1 files changed, 22 insertions, 1 deletions
diff --git a/mirrors/models.py b/mirrors/models.py
index ec4a044d..c7a0a93f 100644
--- a/mirrors/models.py
+++ b/mirrors/models.py
@@ -1,10 +1,13 @@
import socket
from urlparse import urlparse
-from django.db import models
from django.core.exceptions import ValidationError
+from django.db import models
+from django.db.models.signals import pre_save
from django_countries import CountryField
+from main.utils import set_created_field
+
class Mirror(models.Model):
TIER_CHOICES = (
@@ -109,6 +112,20 @@ class MirrorRsync(models.Model):
verbose_name = 'mirror rsync IP'
+class CheckLocation(models.Model):
+ hostname = models.CharField(max_length=255)
+ source_ip = models.GenericIPAddressField(verbose_name='source IP',
+ unpack_ipv4=True, unique=True)
+ country = CountryField()
+ created = models.DateTimeField(editable=False)
+
+ class Meta:
+ ordering = ('hostname', 'source_ip')
+
+ def __unicode__(self):
+ return self.hostname
+
+
class MirrorLog(models.Model):
url = models.ForeignKey(MirrorUrl, related_name="logs")
check_time = models.DateTimeField(db_index=True)
@@ -124,4 +141,8 @@ class MirrorLog(models.Model):
verbose_name = 'mirror check log'
get_latest_by = 'check_time'
+
+pre_save.connect(set_created_field, sender=CheckLocation,
+ dispatch_uid="mirrors.models")
+
# vim: set ts=4 sw=4 et: