summaryrefslogtreecommitdiff
path: root/mirrors/models.py
diff options
context:
space:
mode:
authorNicolás Reynolds <fauno@kiwwwi.com.ar>2011-05-21 02:11:13 -0300
committerNicolás Reynolds <fauno@kiwwwi.com.ar>2011-05-21 02:11:13 -0300
commita30350ac6e76c66d14f6d78ed2b5ae4e5799c79c (patch)
treea2b7127366a1b9d8d5be9fcda5abefacef7d2579 /mirrors/models.py
parentd8f82d9d72eec6042536797f75e06a9296f4cc71 (diff)
parent2470c543d60c96343a5b0fefe04464b5b445b859 (diff)
Merge branch 'master' of git://projects.archlinux.org/archweb
Conflicts: devel/views.py feeds.py templates/devel/index.html templates/packages/flag.html templates/public/index.html todolists/views.py urls.py
Diffstat (limited to 'mirrors/models.py')
-rw-r--r--mirrors/models.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/mirrors/models.py b/mirrors/models.py
index 401821a8..bcde210c 100644
--- a/mirrors/models.py
+++ b/mirrors/models.py
@@ -12,9 +12,9 @@ TIER_CHOICES = (
)
class Mirror(models.Model):
- name = models.CharField(max_length=255)
+ name = models.CharField(max_length=255, unique=True)
tier = models.SmallIntegerField(default=2, choices=TIER_CHOICES)
- upstream = models.ForeignKey('self', null=True)
+ upstream = models.ForeignKey('self', null=True, on_delete=models.SET_NULL)
country = models.CharField(max_length=255, db_index=True)
admin_email = models.EmailField(max_length=255, blank=True)
public = models.BooleanField(default=True)
@@ -54,10 +54,12 @@ class MirrorProtocol(models.Model):
ordering = ('protocol',)
class MirrorUrl(models.Model):
- url = models.CharField(max_length=255)
+ url = models.CharField(max_length=255, unique=True)
protocol = models.ForeignKey(MirrorProtocol, related_name="urls",
- editable=False)
+ editable=False, on_delete=models.PROTECT)
mirror = models.ForeignKey(Mirror, related_name="urls")
+ country = models.CharField(max_length=255, blank=True, null=True,
+ db_index=True)
has_ipv4 = models.BooleanField("IPv4 capable", default=True,
editable=False)
has_ipv6 = models.BooleanField("IPv6 capable", default=False,
@@ -73,6 +75,10 @@ class MirrorUrl(models.Model):
def hostname(self):
return urlparse(self.url).hostname
+ @property
+ def real_country(self):
+ return self.country or self.mirror.country
+
def clean(self):
try:
# Auto-map the protocol field by looking at the URL