From 7ff26556d1cdcaf937bd7c50803876473237b830 Mon Sep 17 00:00:00 2001 From: Corentin Chary Date: Wed, 23 Nov 2011 18:03:07 +0100 Subject: [PATCH] euscan: add basic overlay support Signed-off-by: Corentin Chary --- .../euscan/migrations/0008_index_overlay.py | 110 ++++++++++++++++++ euscanwww/euscan/models.py | 2 +- euscanwww/euscan/urls.py | 6 + euscanwww/euscan/views.py | 17 +++ euscanwww/templates/_base.html | 1 + euscanwww/templates/euscan/overlay.html | 12 ++ euscanwww/templates/euscan/overlays.html | 26 +++++ 7 files changed, 173 insertions(+), 1 deletion(-) create mode 100644 euscanwww/euscan/migrations/0008_index_overlay.py create mode 100644 euscanwww/templates/euscan/overlay.html create mode 100644 euscanwww/templates/euscan/overlays.html diff --git a/euscanwww/euscan/migrations/0008_index_overlay.py b/euscanwww/euscan/migrations/0008_index_overlay.py new file mode 100644 index 0000000..c77ccd0 --- /dev/null +++ b/euscanwww/euscan/migrations/0008_index_overlay.py @@ -0,0 +1,110 @@ +# encoding: utf-8 +import datetime +from south.db import db +from south.v2 import SchemaMigration +from django.db import models + +class Migration(SchemaMigration): + + def forwards(self, orm): + + # Adding index on 'Version', fields ['overlay'] + db.create_index('euscan_version', ['overlay']) + + + def backwards(self, orm): + + # Removing index on 'Version', fields ['overlay'] + db.delete_index('euscan_version', ['overlay']) + + + models = { + 'euscan.categorylog': { + 'Meta': {'object_name': 'CategoryLog', '_ormbases': ['euscan.Log']}, + 'category': ('django.db.models.fields.CharField', [], {'max_length': '128'}), + 'log_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['euscan.Log']", 'unique': 'True', 'primary_key': 'True'}) + }, + 'euscan.euscanresult': { + 'Meta': {'object_name': 'EuscanResult'}, + 'datetime': ('django.db.models.fields.DateTimeField', [], {}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'package': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['euscan.Package']"}), + 'result': ('django.db.models.fields.TextField', [], {'blank': 'True'}) + }, + 'euscan.herd': { + 'Meta': {'object_name': 'Herd'}, + 'email': ('django.db.models.fields.CharField', [], {'max_length': '128', 'null': 'True', 'blank': 'True'}), + 'herd': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '128'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}) + }, + 'euscan.herdlog': { + 'Meta': {'object_name': 'HerdLog', '_ormbases': ['euscan.Log']}, + 'herd': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['euscan.Herd']"}), + 'log_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['euscan.Log']", 'unique': 'True', 'primary_key': 'True'}) + }, + 'euscan.log': { + 'Meta': {'object_name': 'Log'}, + 'datetime': ('django.db.models.fields.DateTimeField', [], {}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'n_packages_gentoo': ('django.db.models.fields.IntegerField', [], {'default': '0'}), + 'n_packages_outdated': ('django.db.models.fields.IntegerField', [], {'default': '0'}), + 'n_packages_overlay': ('django.db.models.fields.IntegerField', [], {'default': '0'}), + 'n_versions_gentoo': ('django.db.models.fields.IntegerField', [], {'default': '0'}), + 'n_versions_overlay': ('django.db.models.fields.IntegerField', [], {'default': '0'}), + 'n_versions_upstream': ('django.db.models.fields.IntegerField', [], {'default': '0'}) + }, + 'euscan.maintainer': { + 'Meta': {'object_name': 'Maintainer'}, + 'email': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '128'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '128'}) + }, + 'euscan.maintainerlog': { + 'Meta': {'object_name': 'MaintainerLog', '_ormbases': ['euscan.Log']}, + 'log_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['euscan.Log']", 'unique': 'True', 'primary_key': 'True'}), + 'maintainer': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['euscan.Maintainer']"}) + }, + 'euscan.package': { + 'Meta': {'unique_together': "(['category', 'name'],)", 'object_name': 'Package'}, + 'category': ('django.db.models.fields.CharField', [], {'max_length': '128'}), + 'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}), + 'herds': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['euscan.Herd']", 'symmetrical': 'False', 'blank': 'True'}), + 'homepage': ('django.db.models.fields.CharField', [], {'max_length': '256', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'maintainers': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['euscan.Maintainer']", 'symmetrical': 'False', 'blank': 'True'}), + 'n_overlay': ('django.db.models.fields.IntegerField', [], {'default': '0'}), + 'n_packaged': ('django.db.models.fields.IntegerField', [], {'default': '0'}), + 'n_versions': ('django.db.models.fields.IntegerField', [], {'default': '0'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '128'}) + }, + 'euscan.version': { + 'Meta': {'unique_together': "(['package', 'slot', 'revision', 'version', 'overlay'],)", 'object_name': 'Version'}, + 'alive': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'db_index': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'overlay': ('django.db.models.fields.CharField', [], {'default': "'gentoo'", 'max_length': '128', 'db_index': 'True'}), + 'package': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['euscan.Package']"}), + 'packaged': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'revision': ('django.db.models.fields.CharField', [], {'max_length': '128'}), + 'slot': ('django.db.models.fields.CharField', [], {'max_length': '128'}), + 'urls': ('django.db.models.fields.TextField', [], {'blank': 'True'}), + 'version': ('django.db.models.fields.CharField', [], {'max_length': '128'}) + }, + 'euscan.versionlog': { + 'Meta': {'object_name': 'VersionLog'}, + 'action': ('django.db.models.fields.IntegerField', [], {}), + 'datetime': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(2011, 11, 23, 17, 13, 34, 785901)'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'overlay': ('django.db.models.fields.CharField', [], {'default': "'gentoo'", 'max_length': '128'}), + 'package': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['euscan.Package']"}), + 'packaged': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'revision': ('django.db.models.fields.CharField', [], {'max_length': '128'}), + 'slot': ('django.db.models.fields.CharField', [], {'max_length': '128'}), + 'version': ('django.db.models.fields.CharField', [], {'max_length': '128'}) + }, + 'euscan.worldlog': { + 'Meta': {'object_name': 'WorldLog', '_ormbases': ['euscan.Log']}, + 'log_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['euscan.Log']", 'unique': 'True', 'primary_key': 'True'}) + } + } + + complete_apps = ['euscan'] diff --git a/euscanwww/euscan/models.py b/euscanwww/euscan/models.py index 6ebe325..1adfd2a 100644 --- a/euscanwww/euscan/models.py +++ b/euscanwww/euscan/models.py @@ -42,7 +42,7 @@ class Version(models.Model): revision = models.CharField(max_length=128) version = models.CharField(max_length=128) packaged = models.BooleanField() - overlay = models.CharField(max_length=128, default='gentoo') + overlay = models.CharField(max_length=128, default='gentoo', db_index=True) urls = models.TextField(blank=True) alive = models.BooleanField(default=True, db_index=True) diff --git a/euscanwww/euscan/urls.py b/euscanwww/euscan/urls.py index 30ce1a0..c825d4a 100644 --- a/euscanwww/euscan/urls.py +++ b/euscanwww/euscan/urls.py @@ -27,6 +27,11 @@ maintainers_patterns = patterns('euscan.views', (r'^$', 'maintainers'), ) +overlays_patterns = patterns('euscan.views', + (r'^(?P[\w+][\w+.-]*)/(view/)?$', 'overlay'), + (r'^$', 'overlays'), +) + urlpatterns = patterns('euscan.views', # Global stuff (r'^$', 'index'), @@ -42,5 +47,6 @@ urlpatterns = patterns('euscan.views', (r'^categories/', include(categories_patterns)), (r'^herds/', include(herds_patterns)), (r'^maintainers/', include(maintainers_patterns)), + (r'^overlays/', include(overlays_patterns)), (r'^package/', include(package_patterns)), ) diff --git a/euscanwww/euscan/views.py b/euscanwww/euscan/views.py index cca8694..57fb115 100644 --- a/euscanwww/euscan/views.py +++ b/euscanwww/euscan/views.py @@ -73,6 +73,23 @@ def maintainer(request, maintainer_id): packages = Package.objects.filter(maintainers__id=maintainer.id) return { 'maintainer' : maintainer, 'packages' : packages } +@render_to('euscan/overlays.html') +def overlays(request): + overlays = Package.objects.values('version__overlay') + overlays = overlays.exclude(version__overlay='') + overlays = overlays.distinct() + return { 'overlays' : overlays } + +@render_to('euscan/overlay.html') +def overlay(request, overlay): + packages = Package.objects.values('id', 'name', 'category', + 'n_versions', 'n_packaged', + 'n_overlay') + packages = packages.filter(version__overlay=overlay).distinct() + if not packages: + raise Http404 + return { 'overlay' : overlay, 'packages' : packages } + @render_to('euscan/package.html') def package(request, category, package): package = get_object_or_404(Package, category=category, name=package) diff --git a/euscanwww/templates/_base.html b/euscanwww/templates/_base.html index a69a4c3..a2eacdf 100644 --- a/euscanwww/templates/_base.html +++ b/euscanwww/templates/_base.html @@ -31,6 +31,7 @@
  • Categories
  • Herds
  • Maintainers
  • +
  • Overlays
  • Scan World
  • Statistics