diff --git a/spa/ajax.py b/spa/ajax.py index 4d22861..c42ee08 100644 --- a/spa/ajax.py +++ b/spa/ajax.py @@ -72,7 +72,6 @@ def header(request): def get_mix_stream_url(request, mix_id): try: mix = Mix.objects.get(pk=mix_id) - mix.add_play(request.user) data = { 'stream_url': mix.get_stream_path(), 'description': mix.description, diff --git a/spa/api/v1/MixResource.py b/spa/api/v1/MixResource.py index a03aec1..e5c9228 100644 --- a/spa/api/v1/MixResource.py +++ b/spa/api/v1/MixResource.py @@ -74,6 +74,7 @@ class MixResource(BackboneCompatibleResource): bundle.data['item_url'] = 'mix/%s' % bundle.obj.id bundle.data['play_count'] = bundle.obj.plays.count() + bundle.data['download_count'] = bundle.obj.downloadS.COUNT() bundle.data['like_count'] = bundle.obj.likes.count() bundle.data['mode'] = 'mix' bundle.data['tooltip'] = render_to_string('inc/player_tooltip.html', {'item': bundle.obj}) diff --git a/spa/audio.py b/spa/audio.py index a0b4108..1872c49 100644 --- a/spa/audio.py +++ b/spa/audio.py @@ -24,6 +24,7 @@ def download(request, mix_id): mix = Mix.objects.get(pk=mix_id) if mix is not None: if mix.download_allowed: + mix.add_download(request.user) filename = mix.local_file.path # Select your file here. file, ext = os.path.splitext(filename) response = sendfile(request, filename, attachment=True, attachment_filename="%s.%s" % (mix.title, ext)) @@ -38,6 +39,7 @@ def start_streaming(request, mix_id): try: mix = Mix.objects.get(pk=mix_id) if mix is not None: + mix.add_play(request.user) #logger.debug('Found the mix (old method): %s' % mix.uid) #filename = mix.local_file.path logger.debug('Found the mix (new method) %s' % mix.uid) diff --git a/spa/models/Mix.py b/spa/models/Mix.py index d86aca1..ad1f6c1 100644 --- a/spa/models/Mix.py +++ b/spa/models/Mix.py @@ -1,14 +1,15 @@ -from django.contrib.sites.models import Site import os import rfc822 -from sorl.thumbnail import get_thumbnail -from sorl.thumbnail.helpers import ThumbnailError from core.utils import url from datetime import datetime +from sorl.thumbnail import get_thumbnail +from django.contrib.sites.models import Site +from sorl.thumbnail.helpers import ThumbnailError from django.db import models from django.db.models import Count from spa.models.Genre import Genre from spa.models.MixPlay import MixPlay +from spa.models.MixDownload import MixDownload from dss import settings, localsettings from spa.models.UserProfile import UserProfile from spa.models._BaseModel import _BaseModel @@ -21,6 +22,7 @@ def mix_image_name(instance, filename): ret = generate_save_file_name(instance.uid, 'mix-images', filename) return ret + class Mix(_BaseModel): class Meta: app_label = 'spa' @@ -144,6 +146,12 @@ class Mix(_BaseModel): "latest_mix_list": None, } + def add_download(self, user): + try: + self.downloads.add(MixDownload(user = user if user.is_authenticated() else None)) + except Exception, e: + self.logger.exception("Error adding mix download") + def add_play(self, user): try: self.plays.add(MixPlay(user = user if user.is_authenticated() else None)) diff --git a/spa/models/__init__.py b/spa/models/__init__.py index e73c597..aa5b904 100644 --- a/spa/models/__init__.py +++ b/spa/models/__init__.py @@ -10,8 +10,9 @@ from Label import Label from Mix import Mix from MixLike import MixLike from MixPlay import MixPlay +from MixFavourite import MixFavourite +from MixDownload import MixDownload from Genre import Genre from Tracklist import Tracklist from PurchaseLink import PurchaseLink from Release import Release -from MixFavourite import MixFavourite diff --git a/static/js/app/app.js b/static/js/app/app.js index cd77055..4898215 100644 --- a/static/js/app/app.js +++ b/static/js/app/app.js @@ -265,4 +265,4 @@ com.podnoms.utils.loadTemplate(['HeaderView', 'SidebarView', 'UserView', 'MixLis pushState:true }); }); -var _eventAggregator = _.extend({}, Backbone.Events); \ No newline at end of file +var _eventAggregator = _.extend({}, Backbone.Events); diff --git a/static/js/app/chat.js b/static/js/app/chat.js index 6806b0b..6e24747 100644 --- a/static/js/app/chat.js +++ b/static/js/app/chat.js @@ -117,8 +117,8 @@ function startChat(content, input, status, user) { */ function addMessage(author, message, color, dt) { content.append( - '' + author + ' @ ' + +(dt.getHours() < 10 ? '0' + dt.getHours() : dt.getHours()) + ':' + '' + author + ' @ ' + (dt.getHours() < 10 ? '0' + dt.getHours() : dt.getHours()) + ':' + (dt.getMinutes() < 10 ? '0' + dt.getMinutes() : dt.getMinutes()) + "" + '' + message + ''); } -} \ No newline at end of file +} diff --git a/static/js/app/views/mix.js b/static/js/app/views/mix.js index 64f6024..db07305 100644 --- a/static/js/app/views/mix.js +++ b/static/js/app/views/mix.js @@ -65,7 +65,6 @@ window.MixListItemView = Backbone.View.extend({ return false; }, mixLink:function (e) { - $(e.currentTarget).popover('hide'); }, likeMix:function (e) { var parent = this; diff --git a/static/js/com.podnoms.utils.js b/static/js/com.podnoms.utils.js index 4267fe5..c2bc436 100644 --- a/static/js/com.podnoms.utils.js +++ b/static/js/com.podnoms.utils.js @@ -99,13 +99,6 @@ com.podnoms.utils = { document.body.appendChild(iframe); } iframe.src = url; - }, - indeterminateProgress:function (bar) { - /* - $(bar).css({ "padding-left": "0%", "padding-right": "90%" }); - $(bar).animate({ paddingLeft: "90%", paddingRight: "0%" }, 1000, "linear", - function () { this.indeterminateProgress(bar); }); - */ } }; diff --git a/templates/base.html b/templates/base.html index cf0be1a..11fc3f9 100644 --- a/templates/base.html +++ b/templates/base.html @@ -69,18 +69,18 @@ - - + + - - + + + - - - {% compress js %} + + @@ -121,10 +121,5 @@ {% endcompress %} {% block footerscripts %} {% endblock %} - diff --git a/templates/inc/_MixItemInsert.html b/templates/inc/_MixItemInsert.html index bbe8f7d..58ae954 100644 --- a/templates/inc/_MixItemInsert.html +++ b/templates/inc/_MixItemInsert.html @@ -2,7 +2,7 @@
- mix-logo + mix-logo
@@ -50,18 +50,18 @@
{% if user.is_authenticated %} {% endif %}