euscanwww: don't delete packages when deleting related versions

Signed-off-by: Corentin Chary <corentincj@iksaif.net>
This commit is contained in:
Corentin Chary 2012-03-14 14:07:28 +01:00
parent 2effd34b01
commit 5062f29e3c
5 changed files with 35 additions and 10 deletions

4
TODO
View File

@ -17,7 +17,9 @@ euscan
- <upsteam><watch options="quirck1 quirck2">http://my.soft/tar-(\d+).ball</watch></upstream>
- cleaner code to separate gentoo mangled version and upstream unmangled versions
- try to import $PV -> $MY_PV transformations from ebuilds ?
- Add a way to how we failled to find a new version
- add a HTTP cache (1day, configurable)
- add a way to enable/disable methods: other_distributions,remote_euscan,handlers, etc....
Site Handlers
-------------
@ -37,6 +39,8 @@ euscanwww
- add an /about/config page that describe the current config (overlays, stuff in make.conf, euscan default settings, etc..) [0.2.0]
- add a table for overlays, change euscan_versions [0.2.0]
- rss scan world + post ?
- always keep in db the last upstream version (could be marked as packaged without overlay ?)
- store euscan status (and used methods ?)
### Commands [0.2.0]

View File

@ -7,6 +7,11 @@ from django.forms.models import model_to_dict
from euscan.models import Version, Package, Herd, Maintainer, EuscanResult, VersionLog
from euscan.forms import WorldForm, PackagesForm
from api.emitters import EuscanXMLEmitter
# replace default XMLEmitter with ours
from piston.emitters import Emitter
Emitter.register('xml', EuscanXMLEmitter, 'text/xml; charset=utf-8')
def xint(i):
try:
@ -75,7 +80,7 @@ class MaintainersHandler(AnonymousBaseHandler):
maintainers = renameFields(maintainers, [('maintainers__id', 'id'),
('maintainers__name', 'name'),
('maintainers__email', 'email')])
return maintainers
return { 'maintainers' : maintainers }
# /api/1.0/herds
class HerdsHandler(AnonymousBaseHandler):
@ -89,7 +94,7 @@ class HerdsHandler(AnonymousBaseHandler):
n_versions=Sum('n_versions'))
herds = renameFields(herds, [('herds__herd', 'herd')])
return herds
return { 'herds' : herds }
# /api/1.0/categories
class CategoriesHandler(AnonymousBaseHandler):
@ -101,7 +106,7 @@ class CategoriesHandler(AnonymousBaseHandler):
n_overlay=Sum('n_overlay'),
n_versions=Sum('n_versions'))
return categories
return { 'categories' : categories }
# /api/1.0/packages/by-maintainer/
# /api/1.0/packages/by-category/
@ -189,4 +194,3 @@ class PackageHandler(AnonymousBaseHandler):
package['log'] = model_to_dict(log, ['result', 'datetime'])
return package

View File

@ -32,11 +32,14 @@ class Package(models.Model):
' And we also pre-compute last versions '
last_version_gentoo = models.ForeignKey('Version', blank=True, null=True,
related_name="last_version_gentoo")
related_name="last_version_gentoo",
on_delete=models.SET_NULL)
last_version_overlay = models.ForeignKey('Version', blank=True, null=True,
related_name="last_version_overlay")
related_name="last_version_overlay",
on_delete=models.SET_NULL)
last_version_upstream = models.ForeignKey('Version', blank=True, null=True,
related_name="last_version_upstream")
related_name="last_version_upstream",
on_delete=models.SET_NULL)
def __unicode__(self):
return '%s/%s' % (self.category, self.name)

View File

@ -101,10 +101,25 @@ def overlay(request, overlay):
@render_to('euscan/package.html')
def package(request, category, package):
def version_key(version):
from distutils.version import StrictVersion, LooseVersion
version = version.version
try:
return StrictVersion(version)
# in case of abnormal version number, fall back to LooseVersion
except ValueError:
return LooseVersion(version)
package = get_object_or_404(Package, category=category, name=package)
package.homepages = package.homepage.split(' ')
packaged = Version.objects.filter(package=package, packaged=True).order_by('version', 'revision')
upstream = Version.objects.filter(package=package, packaged=False).order_by('version', 'revision')
packaged = Version.objects.filter(package=package, packaged=True)
upstream = Version.objects.filter(package=package, packaged=False)
packaged = sorted(packaged, key=version_key)
upstream = sorted(upstream, key=version_key)
log = EuscanResult.objects.filter(package=package).order_by('-datetime')[:1]
log = log[0] if log else None
vlog = VersionLog.objects.filter(package=package).order_by('-id')

View File

@ -22,7 +22,6 @@ def filter_versions(cp, versions):
for url, version in versions:
''' Try to keep the most specific urls (determinted by the length) '''
if version in filtered and len(url) < len(filtered[version]):
continue