diff options
-rw-r--r-- | mirrors/models.py | 15 | ||||
-rw-r--r-- | mirrors/views.py | 4 | ||||
-rw-r--r-- | packages/models.py | 13 |
3 files changed, 15 insertions, 17 deletions
diff --git a/mirrors/models.py b/mirrors/models.py index 9a545b51..06b483d5 100644 --- a/mirrors/models.py +++ b/mirrors/models.py @@ -6,15 +6,14 @@ from django.core.exceptions import ValidationError from django_countries import CountryField -TIER_CHOICES = ( - (0, 'Tier 0'), - (1, 'Tier 1'), - (2, 'Tier 2'), - (-1, 'Untiered'), -) - - class Mirror(models.Model): + TIER_CHOICES = ( + (0, 'Tier 0'), + (1, 'Tier 1'), + (2, 'Tier 2'), + (-1, 'Untiered'), + ) + name = models.CharField(max_length=255, unique=True) tier = models.SmallIntegerField(default=2, choices=TIER_CHOICES) upstream = models.ForeignKey('self', null=True, on_delete=models.SET_NULL) diff --git a/mirrors/views.py b/mirrors/views.py index 400c084d..2c2577f4 100644 --- a/mirrors/views.py +++ b/mirrors/views.py @@ -12,7 +12,7 @@ from django.shortcuts import get_object_or_404, render from django.views.decorators.csrf import csrf_exempt from django_countries.countries import COUNTRIES -from .models import Mirror, MirrorUrl, MirrorProtocol, TIER_CHOICES +from .models import Mirror, MirrorUrl, MirrorProtocol from .utils import get_mirror_statuses, get_mirror_errors COUNTRY_LOOKUP = dict(COUNTRIES) @@ -186,7 +186,7 @@ def mirror_details(request, name): def status(request, tier=None): if tier is not None: tier = int(tier) - if tier not in [t[0] for t in TIER_CHOICES]: + if tier not in [t[0] for t in Mirror.TIER_CHOICES]: raise Http404 bad_timedelta = timedelta(days=3) status_info = get_mirror_statuses() diff --git a/packages/models.py b/packages/models.py index 5b48b30f..1d538cce 100644 --- a/packages/models.py +++ b/packages/models.py @@ -196,13 +196,6 @@ class FlagRequest(models.Model): return u'%s from %s on %s' % (self.pkgbase, self.who(), self.created) -UPDATE_ACTION_CHOICES = ( - (ADDITION, 'Addition'), - (CHANGE, 'Change'), - (DELETION, 'Deletion'), -) - - class UpdateManager(models.Manager): def log_update(self, old_pkg, new_pkg): '''Utility method to help log an update. This will determine the type @@ -249,6 +242,12 @@ class UpdateManager(models.Manager): class Update(models.Model): + UPDATE_ACTION_CHOICES = ( + (ADDITION, 'Addition'), + (CHANGE, 'Change'), + (DELETION, 'Deletion'), + ) + package = models.ForeignKey(Package, related_name="updates", null=True, on_delete=models.SET_NULL) repo = models.ForeignKey(Repo, related_name="updates") |