diff options
author | Dan McGee <dan@archlinux.org> | 2010-05-25 04:07:09 +0200 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2010-06-08 15:35:58 +0200 |
commit | 8bf0bfeac7f1cdfee19432b3eb77c48f4fedef08 (patch) | |
tree | c47a39014eee247428dd471f1897aabdccae64c6 /main | |
parent | bad2825fab9f45f468414ed551bad9d987923600 (diff) | |
download | archweb-8bf0bfeac7f1cdfee19432b3eb77c48f4fedef08.tar.gz archweb-8bf0bfeac7f1cdfee19432b3eb77c48f4fedef08.tar.xz |
Use Sites framework instead of hardcoded domain name
Instead of putting 'www.archlinux.org' all over the place, use the Django
sites framework to pull the site name out of the database. Now these
amazing things will work if you are running locally and decide to change the
site!
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'main')
-rw-r--r-- | main/models.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/main/models.py b/main/models.py index 7ccb924..e106313 100644 --- a/main/models.py +++ b/main/models.py @@ -1,6 +1,7 @@ from django.db import models from django.db.models import Q from django.contrib.auth.models import User +from django.contrib.sites.models import Site from main.middleware import get_user from packages.models import PackageRelation @@ -176,6 +177,7 @@ class Package(models.Model): last_update = models.DateTimeField(null=True, blank=True) files_last_update = models.DateTimeField(null=True, blank=True) license = models.CharField(max_length=255, null=True) + objects = PackageManager() class Meta: db_table = 'packages' @@ -190,6 +192,11 @@ class Package(models.Model): return '/packages/%s/%s/%s/' % (self.repo.name.lower(), self.arch.name, self.pkgname) + def get_full_url(self, proto='http'): + '''get a URL suitable for things like email including the domain''' + domain = Site.objects.get_current().domain + return '%s://%s%s' % (proto, domain, self.get_absolute_url()) + @property def maintainers(self): return User.objects.filter( |