diff --git a/euscanwww/.gitignore b/euscanwww/.gitignore new file mode 100644 index 0000000..5e26552 --- /dev/null +++ b/euscanwww/.gitignore @@ -0,0 +1,4 @@ +var/cache/*/ +var/charts/*.png +var/rrd/*.rrd +var/db/euscan.db \ No newline at end of file diff --git a/euscanwww/api/emitters.py b/euscanwww/api/emitters.py new file mode 100644 index 0000000..f7b6ab7 --- /dev/null +++ b/euscanwww/api/emitters.py @@ -0,0 +1,50 @@ +from piston.emitters import Emitter, XMLEmitter + +class EuscanXMLEmitter(XMLEmitter): + _parent = [] + _known_parents = { + 'vlog' : 'version', + 'herds' : 'herd', + 'maintainers' : 'maintainer', + 'packaged' : 'version', + 'upstream' : 'version', + 'packages' : 'package', + 'categories' : 'category' + } + + def _push_parent(self, parent): + self._parent.append(parent) + + def _pop_parent(self): + if self._parent: + return self._parent.pop() + else: + return None + + def _current_parent(self): + if self._parent: + return self._parent[-1] + else: + return None + + def _name_from_parent(self): + return self._known_parents.get(self._current_parent(), 'resource') + + def _to_xml(self, xml, data): + def recurse(name, xml, item): + attrs = {} + xml.startElement(name, attrs) + self._push_parent(name) + self._to_xml(xml, item) + self._pop_parent() + xml.endElement(name) + + if isinstance(data, (list, tuple)): + for item in data: + name = self._name_from_parent() + recurse(name, xml, item) + elif isinstance(data, dict): + for key, value in data.iteritems(): + recurse(key, xml, value) + else: + super(EuscanXMLEmitter, self)._to_xml(xml, data) diff --git a/euscanwww/euscan/charts.py b/euscanwww/euscan/charts.py index c7b8b2c..4f0fd03 100644 --- a/euscanwww/euscan/charts.py +++ b/euscanwww/euscan/charts.py @@ -12,8 +12,8 @@ import rrdtool import pylab import matplotlib -CHARTS_ROOT = os.path.join(settings.MEDIA_ROOT, "charts") -CHARTS_URL = os.path.join(settings.MEDIA_URL, "charts") +CHARTS_ROOT = os.path.join(settings.EUSCAN_ROOT, 'var', 'charts') +CHARTS_URL = os.path.join(settings.EUSCAN_ROOT, 'var', 'charts') CHARTS_TTL = (24 * 60 * 60) pylab.rcParams['font.size'] = 10.0 diff --git a/euscanwww/euscan/management/commands/scan-metadata.py b/euscanwww/euscan/management/commands/scan-metadata.py index ad7b7d4..4366601 100644 --- a/euscanwww/euscan/management/commands/scan-metadata.py +++ b/euscanwww/euscan/management/commands/scan-metadata.py @@ -48,18 +48,18 @@ class Command(BaseCommand): def scan(self, query=None, obj=None): matches = Query(query).find( - include_masked=True, - in_installed=False, + include_masked=True, + in_installed=False, ) if not matches: - sys.stderr.write(self.style.ERROR("Unknown package '%s'\n" % query)) - return + sys.stderr.write(self.style.ERROR("Unknown package '%s'\n" % query)) + return matches = sorted(matches) pkg = matches.pop() if '9999' in pkg.version and len(matches): - pkg = matches.pop() + pkg = matches.pop() if not obj: obj, created = Package.objects.get_or_create(category=pkg.category, name=pkg.name) diff --git a/euscanwww/euscan/models.py b/euscanwww/euscan/models.py index cf6e1ec..9652747 100644 --- a/euscanwww/euscan/models.py +++ b/euscanwww/euscan/models.py @@ -1,5 +1,4 @@ from django.db import models -from datetime import datetime class Herd(models.Model): herd = models.CharField(max_length=128, unique=True) @@ -74,7 +73,7 @@ class VersionLog(models.Model): ) package = models.ForeignKey(Package) - datetime = models.DateTimeField(default=datetime.now()) + datetime = models.DateTimeField(auto_now_add=True) slot = models.CharField(max_length=128) revision = models.CharField(max_length=128) version = models.CharField(max_length=128) diff --git a/euscanwww/euscan/templatetags/timedelta.py b/euscanwww/euscan/templatetags/timedelta.py index 486ceeb..6307575 100644 --- a/euscanwww/euscan/templatetags/timedelta.py +++ b/euscanwww/euscan/templatetags/timedelta.py @@ -1,5 +1,7 @@ from django import template from django.utils.timesince import timesince +from django.conf import settings +from django.utils.timezone import make_aware, get_default_timezone from datetime import datetime register = template.Library() @@ -11,6 +13,8 @@ def timedelta(value, arg=None): cmp = arg else: cmp = datetime.now() + if settings.USE_TZ: + cmp = make_aware(cmp, get_default_timezone()) if value > cmp: return "in %s" % timesince(cmp,value) else: diff --git a/euscanwww/euscan/views.py b/euscanwww/euscan/views.py index 6c0d920..4d253f7 100644 --- a/euscanwww/euscan/views.py +++ b/euscanwww/euscan/views.py @@ -3,8 +3,8 @@ from django.http import HttpResponse, Http404 from django.shortcuts import get_object_or_404 from django.db.models import Sum, Max -from euscan.models import Version, Package, Herd, Maintainer, EuscanResult, VersionLog -from euscan.forms import WorldForm, PackagesForm +from models import Version, Package, Herd, Maintainer, EuscanResult, VersionLog +from forms import WorldForm, PackagesForm import charts diff --git a/euscanwww/media/css/style.css b/euscanwww/htdocs/css/style.css similarity index 100% rename from euscanwww/media/css/style.css rename to euscanwww/htdocs/css/style.css diff --git a/euscanwww/media/css/table.css b/euscanwww/htdocs/css/table.css similarity index 100% rename from euscanwww/media/css/table.css rename to euscanwww/htdocs/css/table.css diff --git a/euscanwww/media/favicon.ico b/euscanwww/htdocs/favicon.ico similarity index 100% rename from euscanwww/media/favicon.ico rename to euscanwww/htdocs/favicon.ico diff --git a/euscanwww/media/img/back_disabled.jpg b/euscanwww/htdocs/img/back_disabled.jpg similarity index 100% rename from euscanwww/media/img/back_disabled.jpg rename to euscanwww/htdocs/img/back_disabled.jpg diff --git a/euscanwww/media/img/back_enabled.jpg b/euscanwww/htdocs/img/back_enabled.jpg similarity index 100% rename from euscanwww/media/img/back_enabled.jpg rename to euscanwww/htdocs/img/back_enabled.jpg diff --git a/euscanwww/media/img/django.png b/euscanwww/htdocs/img/django.png similarity index 100% rename from euscanwww/media/img/django.png rename to euscanwww/htdocs/img/django.png diff --git a/euscanwww/media/img/feed.png b/euscanwww/htdocs/img/feed.png similarity index 100% rename from euscanwww/media/img/feed.png rename to euscanwww/htdocs/img/feed.png diff --git a/euscanwww/media/img/forward_disabled.jpg b/euscanwww/htdocs/img/forward_disabled.jpg similarity index 100% rename from euscanwww/media/img/forward_disabled.jpg rename to euscanwww/htdocs/img/forward_disabled.jpg diff --git a/euscanwww/media/img/forward_enabled.jpg b/euscanwww/htdocs/img/forward_enabled.jpg similarity index 100% rename from euscanwww/media/img/forward_enabled.jpg rename to euscanwww/htdocs/img/forward_enabled.jpg diff --git a/euscanwww/media/img/freshness-icon.png b/euscanwww/htdocs/img/freshness-icon.png similarity index 100% rename from euscanwww/media/img/freshness-icon.png rename to euscanwww/htdocs/img/freshness-icon.png diff --git a/euscanwww/media/img/gentoo-header-bar-bg.png b/euscanwww/htdocs/img/gentoo-header-bar-bg.png similarity index 100% rename from euscanwww/media/img/gentoo-header-bar-bg.png rename to euscanwww/htdocs/img/gentoo-header-bar-bg.png diff --git a/euscanwww/media/img/gentoo-icon.png b/euscanwww/htdocs/img/gentoo-icon.png similarity index 100% rename from euscanwww/media/img/gentoo-icon.png rename to euscanwww/htdocs/img/gentoo-icon.png diff --git a/euscanwww/media/img/gentoo.png b/euscanwww/htdocs/img/gentoo.png similarity index 100% rename from euscanwww/media/img/gentoo.png rename to euscanwww/htdocs/img/gentoo.png diff --git a/euscanwww/media/img/gentoo_org.png b/euscanwww/htdocs/img/gentoo_org.png similarity index 100% rename from euscanwww/media/img/gentoo_org.png rename to euscanwww/htdocs/img/gentoo_org.png diff --git a/euscanwww/media/img/linux.png b/euscanwww/htdocs/img/linux.png similarity index 100% rename from euscanwww/media/img/linux.png rename to euscanwww/htdocs/img/linux.png diff --git a/euscanwww/media/img/overlay-icon.png b/euscanwww/htdocs/img/overlay-icon.png similarity index 100% rename from euscanwww/media/img/overlay-icon.png rename to euscanwww/htdocs/img/overlay-icon.png diff --git a/euscanwww/media/img/python.png b/euscanwww/htdocs/img/python.png similarity index 100% rename from euscanwww/media/img/python.png rename to euscanwww/htdocs/img/python.png diff --git a/euscanwww/media/img/sort_asc.png b/euscanwww/htdocs/img/sort_asc.png similarity index 100% rename from euscanwww/media/img/sort_asc.png rename to euscanwww/htdocs/img/sort_asc.png diff --git a/euscanwww/media/img/sort_asc_disabled.png b/euscanwww/htdocs/img/sort_asc_disabled.png similarity index 100% rename from euscanwww/media/img/sort_asc_disabled.png rename to euscanwww/htdocs/img/sort_asc_disabled.png diff --git a/euscanwww/media/img/sort_both.png b/euscanwww/htdocs/img/sort_both.png similarity index 100% rename from euscanwww/media/img/sort_both.png rename to euscanwww/htdocs/img/sort_both.png diff --git a/euscanwww/media/img/sort_desc.png b/euscanwww/htdocs/img/sort_desc.png similarity index 100% rename from euscanwww/media/img/sort_desc.png rename to euscanwww/htdocs/img/sort_desc.png diff --git a/euscanwww/media/img/sort_desc_disabled.png b/euscanwww/htdocs/img/sort_desc_disabled.png similarity index 100% rename from euscanwww/media/img/sort_desc_disabled.png rename to euscanwww/htdocs/img/sort_desc_disabled.png diff --git a/euscanwww/media/img/upstream-icon.png b/euscanwww/htdocs/img/upstream-icon.png similarity index 100% rename from euscanwww/media/img/upstream-icon.png rename to euscanwww/htdocs/img/upstream-icon.png diff --git a/euscanwww/media/js/jquery.dataTables.js b/euscanwww/htdocs/js/jquery.dataTables.js similarity index 100% rename from euscanwww/media/js/jquery.dataTables.js rename to euscanwww/htdocs/js/jquery.dataTables.js diff --git a/euscanwww/media/js/jquery.dataTables.min.js b/euscanwww/htdocs/js/jquery.dataTables.min.js similarity index 100% rename from euscanwww/media/js/jquery.dataTables.min.js rename to euscanwww/htdocs/js/jquery.dataTables.min.js diff --git a/euscanwww/media/js/jquery.dataTables.min.js.gz b/euscanwww/htdocs/js/jquery.dataTables.min.js.gz similarity index 100% rename from euscanwww/media/js/jquery.dataTables.min.js.gz rename to euscanwww/htdocs/js/jquery.dataTables.min.js.gz diff --git a/euscanwww/media/js/jquery.js b/euscanwww/htdocs/js/jquery.js similarity index 100% rename from euscanwww/media/js/jquery.js rename to euscanwww/htdocs/js/jquery.js diff --git a/euscanwww/manage.py b/euscanwww/manage.py index 5e78ea9..3d31e2b 100755 --- a/euscanwww/manage.py +++ b/euscanwww/manage.py @@ -1,11 +1,9 @@ #!/usr/bin/env python -from django.core.management import execute_manager -try: - import settings # Assumed to be in the same directory. -except ImportError: - import sys - sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__) - sys.exit(1) +import os, sys if __name__ == "__main__": - execute_manager(settings) + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "euscanwww.settings") + + from django.core.management import execute_from_command_line + + execute_from_command_line(sys.argv) diff --git a/euscanwww/settings.py b/euscanwww/settings.py deleted file mode 100644 index 04b3557..0000000 --- a/euscanwww/settings.py +++ /dev/null @@ -1,156 +0,0 @@ -# Django settings for euscanwww project. - -import os.path - -DEBUG = True -TEMPLATE_DEBUG = DEBUG - -ADMINS = ( - ('admin', 'admin@example.com'), -) - -MANAGERS = ADMINS - -""" -# MySQL Example: - 'default': { - 'ENGINE': 'django.db.backends.mysql', - 'NAME': 'euscan', - 'USER': 'euscan', - 'PASSWORD': 'password', - 'HOST': 'localhost', - 'PORT': '', - 'OPTIONS': { - 'init_command': 'SET storage_engine=INNODB', - } - }, - -# PostGreSQL Example: - 'default': { - 'ENGINE': 'django.db.backends.postgresql_psycopg2', - 'NAME': 'euscan', - 'USER': 'euscan', - 'PASSWORD': '', - 'HOST': 'localhost', - 'PORT': '', - }, -""" - -EUSCAN_ROOT = os.path.dirname(os.path.abspath(__file__)) - -DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': os.path.join(EUSCAN_ROOT, 'euscan.db') - }, -} - -CACHES = { - 'default': { - 'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache', - 'LOCATION': os.path.join(EUSCAN_ROOT, 'euscan.cache'), - } -} - -RRD_ROOT = os.path.join(EUSCAN_ROOT, 'rrd') - -# Local time zone for this installation. Choices can be found here: -# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name -# although not all choices may be available on all operating systems. -# On Unix systems, a value of None will cause Django to use the same -# timezone as the operating system. -# If running in a Windows environment this must be set to the same as your -# system time zone. -TIME_ZONE = 'Europe/Paris' - -# Language code for this installation. All choices can be found here: -# http://www.i18nguy.com/unicode/language-identifiers.html -LANGUAGE_CODE = 'en-us' - -SITE_ID = 1 - -# If you set this to False, Django will make some optimizations so as not -# to load the internationalization machinery. -USE_I18N = True - -# If you set this to False, Django will not format dates, numbers and -# calendars according to the current locale -USE_L10N = True - -# Absolute filesystem path to the directory that will hold user-uploaded files. -# Example: "/home/media/media.lawrence.com/" -MEDIA_ROOT = os.path.join(EUSCAN_ROOT, 'media/') - -# URL that handles the media served from MEDIA_ROOT. Make sure to use a -# trailing slash if there is a path component (optional in other cases). -# Examples: "http://media.lawrence.com", "http://example.com/media/" -MEDIA_URL = '/media/' - -# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a -# trailing slash. -# Examples: "http://foo.com/media/", "/media/". -ADMIN_MEDIA_PREFIX = '/admin-media/' - -# Make this unique, and don't share it with anybody. -SECRET_KEY = '00000000000000000000000000000000000000000000000000' - -# List of callables that know how to import templates from various sources. -TEMPLATE_LOADERS = ( - 'django.template.loaders.filesystem.Loader', - 'django.template.loaders.app_directories.Loader', -# 'django.template.loaders.eggs.Loader', -) - -MIDDLEWARE_CLASSES = ( - 'django.middleware.common.CommonMiddleware', - 'django.middleware.cache.UpdateCacheMiddleware', - 'django.middleware.cache.FetchFromCacheMiddleware', - 'django.contrib.sessions.middleware.SessionMiddleware', - 'django.contrib.auth.middleware.AuthenticationMiddleware', -# 'django.middleware.csrf.CsrfViewMiddleware', - 'django.contrib.messages.middleware.MessageMiddleware', -) - -CACHE_MIDDLEWARE_SECONDS=3600 -CACHE_MIDDLEWARE_ANONYMOUS_ONLY=True - -ROOT_URLCONF = 'euscanwww.urls' - -FORCE_SCRIPT_NAME="" - -TEMPLATE_DIRS = ( - os.path.join(EUSCAN_ROOT, 'templates'), -) - -TEMPLATE_CONTEXT_PROCESSORS = ( - "django.contrib.auth.context_processors.auth", - "django.core.context_processors.debug", - "django.core.context_processors.i18n", - "django.core.context_processors.media", - "django.core.context_processors.static", - "django.contrib.messages.context_processors.messages", - "django.core.context_processors.request", -) - -INSTALLED_APPS = ( - 'django.contrib.auth', - 'django.contrib.contenttypes', - 'django.contrib.sessions', - 'django.contrib.sites', - 'django.contrib.messages', - 'django.contrib.admin', - 'south', - 'euscan', - # Uncomment the next line to enable admin documentation: - # 'django.contrib.admindocs', -) - -try: - from local_settings import * -except ImportError, ex: - import sys - sys.stderr.write(\ - ("settings.py: error importing local settings file:\n" + \ - "\t%s\n" + \ - "Do you have a local_settings.py module?\n") % str(ex)) - raise diff --git a/euscanwww/templates/_base.html b/euscanwww/templates/_base.html index 36b8420..2d50183 100644 --- a/euscanwww/templates/_base.html +++ b/euscanwww/templates/_base.html @@ -7,7 +7,7 @@ {% endblock %} {% block css %} - + {% endblock %} {% block javascript %} {% endblock %} @@ -15,7 +15,7 @@ @@ -42,7 +42,7 @@
  • ---
  • {% block menu_feed %}
  • - feed + feed Global Feed
  • {% endblock %} diff --git a/euscanwww/templates/euscan/_datatable.html b/euscanwww/templates/euscan/_datatable.html index 72f5056..32163cf 100644 --- a/euscanwww/templates/euscan/_datatable.html +++ b/euscanwww/templates/euscan/_datatable.html @@ -2,13 +2,13 @@ {% block css %} {{ block.super }} - + {% endblock %} {% block javascript %} {{ block.super }} - - + +