diff options
author | Georgy Redkozubov <georgy.redkozubov@linaro.org> | 2012-08-06 15:53:16 +0400 |
---|---|---|
committer | Georgy Redkozubov <georgy.redkozubov@linaro.org> | 2012-08-06 15:53:16 +0400 |
commit | cd1b0bf6959d842d71d2efdf573b75a1e065a4d0 (patch) | |
tree | 63097e9cfdd648992fd75617303f604cef9df950 /license_protected_downloads | |
parent | c9ee18c9f388243c97e34e1c1d2d2fbc84022562 (diff) |
Removed not used SITE_ID. Can be added later if there will be a real need.
Diffstat (limited to 'license_protected_downloads')
-rw-r--r-- | license_protected_downloads/models.py | 9 | ||||
-rw-r--r-- | license_protected_downloads/tests/test_models.py | 10 | ||||
-rw-r--r-- | license_protected_downloads/views.py | 17 | ||||
-rw-r--r-- | license_protected_downloads/wsgi_releases.py | 3 | ||||
-rw-r--r-- | license_protected_downloads/wsgi_snapshots.py | 3 |
5 files changed, 14 insertions, 28 deletions
diff --git a/license_protected_downloads/models.py b/license_protected_downloads/models.py index 8cff7e2..a0a71a8 100644 --- a/license_protected_downloads/models.py +++ b/license_protected_downloads/models.py @@ -1,6 +1,4 @@ from django.db import models -from django.contrib.sites.models import Site -from django.contrib.sites.managers import CurrentSiteManager class LicenseManager(models.Manager): @@ -10,22 +8,19 @@ class LicenseManager(models.Manager): Provides additional convenience method """ - def all_with_hashes(self, hash_list, site_id): + def all_with_hashes(self, hash_list): """ Produce a list of licenses that match the specified list of hashes. The main use case is to convert license digest to something the user can relate to. """ - return self.all().filter( - digest__in=hash_list, sites__id__exact=site_id) + return self.all().filter(digest__in=hash_list) class License(models.Model): digest = models.CharField(max_length=40) text = models.TextField() theme = models.CharField(max_length=60) - sites = models.ForeignKey(Site) - on_site = CurrentSiteManager() objects = LicenseManager() diff --git a/license_protected_downloads/tests/test_models.py b/license_protected_downloads/tests/test_models.py index 86fab09..c49fb3e 100644 --- a/license_protected_downloads/tests/test_models.py +++ b/license_protected_downloads/tests/test_models.py @@ -4,7 +4,6 @@ import unittest import hashlib from django.test import TestCase from license_protected_downloads.models import License -from django.conf import settings class LicenseTestCase(TestCase): @@ -16,11 +15,11 @@ class LicenseTestCase(TestCase): digest2 = hashlib.md5(lic2_text).hexdigest() digest3 = hashlib.md5(lic2_text).hexdigest() self.lic1 = License.objects.create(digest=digest1, text=lic1_text, - theme='samsung', sites_id=settings.SITE_ID) + theme='samsung') self.lic2 = License.objects.create(digest=digest2, text=lic2_text, - theme='stericsson', sites_id=settings.SITE_ID) + theme='stericsson') self.lic3 = License.objects.create(digest=digest3, text=lic3_text, - theme='linaro', sites_id=settings.SITE_ID) + theme='linaro') def test_add_license_to_database(self): self.assertEquals(self.lic1.theme, 'samsung') @@ -30,15 +29,12 @@ class LicenseTestCase(TestCase): lic1 = License.objects.get(pk=1) self.assertEquals(lic1.theme, 'samsung') self.assertEquals(lic1.text, 'Samsung License') - self.assertEquals(lic1.sites_id, settings.SITE_ID) lic2 = License.objects.get(pk=2) self.assertEquals(lic2.theme, 'stericsson') self.assertEquals(lic2.text, 'Stericsson License') - self.assertEquals(lic2.sites_id, settings.SITE_ID) lic3 = License.objects.get(pk=3) self.assertEquals(lic3.theme, 'linaro') self.assertEquals(lic3.text, 'Linaro License') - self.assertEquals(lic3.sites_id, settings.SITE_ID) if __name__ == '__main__': diff --git a/license_protected_downloads/views.py b/license_protected_downloads/views.py index 00013e1..2fc3815 100644 --- a/license_protected_downloads/views.py +++ b/license_protected_downloads/views.py @@ -69,8 +69,7 @@ def dir_list(url, path): pathname = os.path.join(path, name) license_digest_list = is_protected(pathname) - license_list = License.objects.all_with_hashes(license_digest_list, - settings.SITE_ID) + license_list = License.objects.all_with_hashes(license_digest_list) listing.append({'name': name, 'size': size, 'type': type, @@ -94,12 +93,8 @@ def test_path(path): def _insert_license_into_db(digest, text, theme): - if not License.objects.filter(digest=digest, - sites__id__exact=settings.SITE_ID): - l = License(digest=digest, - text=text, - theme=theme, - sites_id=settings.SITE_ID) + if not License.objects.filter(digest=digest): + l = License(digest=digest, text=text, theme=theme) l.save() @@ -209,8 +204,7 @@ def license_accepted(request, digest): def accept_license(request): if "accept" in request.POST: - lic = License.objects.filter(digest=request.GET['lic'], - sites__id__exact=settings.SITE_ID).get() + lic = License.objects.filter(digest=request.GET['lic']).get() file_url = request.GET['url'] listing_url = os.path.dirname(file_url) response = HttpResponseRedirect(listing_url + @@ -231,8 +225,7 @@ def show_license(request): if 'lic' not in request.GET or 'url' not in request.GET: raise Http404 - lic = License.objects.filter(digest=request.GET['lic'], - sites__id__exact=settings.SITE_ID).get() + lic = License.objects.filter(digest=request.GET['lic']).get() return render_to_response('licenses/' + lic.theme + '.html', {'license': lic, diff --git a/license_protected_downloads/wsgi_releases.py b/license_protected_downloads/wsgi_releases.py index a9c0208..2d30fff 100644 --- a/license_protected_downloads/wsgi_releases.py +++ b/license_protected_downloads/wsgi_releases.py @@ -20,7 +20,8 @@ sys.path.append("/usr/lib/pymodules/python2.7") sys.path.append("/usr/lib/python2.7") # NOTE: Set actual path to directory containing linaro-license-protection app -#sys.path.append("linaro-license-protection") +sys.path.append("/srv/releases.linaro.org") +sys.path.append("/srv/releases.linaro.org/linaro-license-protection") os.environ.setdefault( "DJANGO_SETTINGS_MODULE", diff --git a/license_protected_downloads/wsgi_snapshots.py b/license_protected_downloads/wsgi_snapshots.py index 01ea29b..08b585c 100644 --- a/license_protected_downloads/wsgi_snapshots.py +++ b/license_protected_downloads/wsgi_snapshots.py @@ -20,7 +20,8 @@ sys.path.append("/usr/lib/pymodules/python2.7") sys.path.append("/usr/lib/python2.7") # NOTE: Set actual path to directory containing linaro-license-protection app -#sys.path.append("linaro-license-protection") +sys.path.append("/srv/snapshots.linaro.org") +sys.path.append("/srv/snapshots.linaro.org/linaro-license-protection") os.environ.setdefault( "DJANGO_SETTINGS_MODULE", |