diff --git a/core/utils/url.py b/core/utils/url.py index 3583a9f..4c59ab5 100755 --- a/core/utils/url.py +++ b/core/utils/url.py @@ -5,19 +5,21 @@ from django.template.defaultfilters import slugify __author__ = 'fergalm' + def url_path_join(*parts): """Join and normalize url path parts with a slash.""" schemes, netlocs, paths, queries, fragments = zip(*(urlparse.urlsplit(part) for part in parts)) # Use the first value for everything but path. Join the path on '/' - scheme = next((x for x in schemes if x), '') - netloc = next((x for x in netlocs if x), '') - path = '/'.join(x.strip('/') for x in paths if x) - query = next((x for x in queries if x), '') + scheme = next((x for x in schemes if x), '') + netloc = next((x for x in netlocs if x), '') + path = '/'.join(x.strip('/') for x in paths if x) + query = next((x for x in queries if x), '') fragment = next((x for x in fragments if x), '') return urlparse.urlunsplit((scheme, netloc, path, query, fragment)) + def urlclean(url): - #remove double slashes + # remove double slashes ret = urlparse.urljoin(url, urlparse.urlparse(url).path.replace('//', '/')) return ret @@ -90,11 +92,13 @@ def _slug_strip(value, separator='-'): value = re.sub(r'^%s+|%s+$' % (re_sep, re_sep), '', value) return value + def is_absolute(url): return bool(urlparse.urlparse(url).scheme) + def wrap_full(url): if not is_absolute(url): url = "http://%s%s" % (Site.objects.get_current().domain, url) - return url \ No newline at end of file + return url diff --git a/dss/urls.py b/dss/urls.py index 4625528..99d9603 100755 --- a/dss/urls.py +++ b/dss/urls.py @@ -9,10 +9,11 @@ admin.autodiscover() urlpatterns = patterns( '', url(r'^admin/', include(admin.site.urls)), - url(r'^api/v2/', include('api.urls')), url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')), (r'^grappelli/', include('grappelli.urls')), (r'^social/', include('spa.social.urls')), + (r'^arges/', include('spa.social.urls')), + url(r'^', include('api.urls')), ) if settings.DEBUG: diff --git a/spa/management/commands/azure_util.py b/spa/management/commands/azure_util.py index 40a22ab..aa66717 100755 --- a/spa/management/commands/azure_util.py +++ b/spa/management/commands/azure_util.py @@ -1,9 +1,28 @@ +import os from django.core.management.base import BaseCommand from core.utils import cdn from spa.models import Mix +def _check_missing_mixes(): + ms = Mix.objects.all() + found = 0 + for m in ms: + url = m.get_download_url() + if not cdn.file_exists(url): + file = '/mnt/dev/deepsouthsounds.com/media/mixes/{0}.mp3'.format(m.uid) + if os.path.isfile(file): + print '* {0}'.format(file) + cdn.upload_file_to_azure(file, '{0}.mp3'.format(m.uid), 'mixes') + found += 1 + else: + found += 1 + print '({0}){1} - {2}'.format(found, m.slug, m.uid) + + print '{0} of {1} missing'.format(found, Mix.objects.count()) + + class Command(BaseCommand): def add_arguments(self, parser): parser.add_argument( @@ -26,4 +45,9 @@ class Command(BaseCommand): print "Fatal error, bailing. {0}".format(ex.message) def handle(self, *args, **options): - pass + if len(args) == 0: + print "Commands are \n\t_check_missing_mixes" + elif args[0] == 'check_missing_mix': + _check_missing_mixes() + else: + print "Commands are \n\tcheck_missing_mix"