summaryrefslogtreecommitdiffstats
path: root/main
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2010-05-24 21:07:09 -0500
committerDan McGee <dan@archlinux.org>2010-06-08 08:35:58 -0500
commit8bf0bfeac7f1cdfee19432b3eb77c48f4fedef08 (patch)
treec47a39014eee247428dd471f1897aabdccae64c6 /main
parentbad2825fab9f45f468414ed551bad9d987923600 (diff)
downloadarchweb-8bf0bfeac7f1cdfee19432b3eb77c48f4fedef08.tar.gz
archweb-8bf0bfeac7f1cdfee19432b3eb77c48f4fedef08.zip
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.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/main/models.py b/main/models.py
index 7ccb9245..e106313c 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(