diff --git a/requirements.txt b/requirements.txt index 3051422..83bd470 100755 --- a/requirements.txt +++ b/requirements.txt @@ -23,8 +23,11 @@ git+git://github.com/spookylukey/django-paypal.git#django-paypal git+git://github.com/llazzaro/django-scheduler.git#django-scheduler git+git://github.com/cyberdelia/django-pipeline.git#django-pipeline git+git://github.com/disqus/django-bitfield.git#django-bitfield +git+git://github.com/fergalmoran/azure-sdk-for-python.git#azure django-templated-email django-grappelli +django-nose +djangorestframework humanize mandrill django-debug-toolbar @@ -60,4 +63,3 @@ python-shout django-dirtyfields django-storages django-user-sessions -apache-libcloud \ No newline at end of file diff --git a/spa/api/v1/UserResource.py b/spa/api/v1/UserResource.py index 7152ae3..adb823c 100755 --- a/spa/api/v1/UserResource.py +++ b/spa/api/v1/UserResource.py @@ -1,5 +1,5 @@ from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned -from django.db.models import Count, Q +from django.db.models import Count, Q, F from tastypie import fields from tastypie.authentication import Authentication from tastypie.authorization import Authorization @@ -74,10 +74,6 @@ class UserResource(BaseResource): return super(UserResource, self).obj_create(bundle, **kwargs) def obj_update(self, bundle, skip_errors=False, **kwargs): - update_geo_info_task.delay( - ip_address=bundle.request.META['REMOTE_ADDR'], - profile_id=bundle.request.user.get_profile().id - ) return super(UserResource, self).obj_update(bundle, skip_errors, **kwargs) def _create_playlist(self, request): @@ -150,7 +146,7 @@ class UserResource(BaseResource): likes = UserProfile.ACTIVITY_SHARE_LIKES if bundle.data['activity_sharing_likes'] else 0 favourites = UserProfile.ACTIVITY_SHARE_FAVOURITES if bundle.data['activity_sharing_favourites'] else 0 comments = UserProfile.ACTIVITY_SHARE_COMMENTS if bundle.data['activity_sharing_comments'] else 0 - bundle.data['activity_sharing'] = (likes | favourites | comments) + bundle.data['activity_sharing'] = (plays | likes | favourites | comments) del bundle.data['activity_sharing_plays'] del bundle.data['activity_sharing_likes'] del bundle.data['activity_sharing_favourites'] @@ -165,6 +161,13 @@ class UserResource(BaseResource): del bundle.data['activity_sharing_networks_facebook'] del bundle.data['activity_sharing_networks_twitter'] + bundle.data['email_notifications'] = \ + UserProfile.email_notifications.plays if bundle.data['email_notification_plays'] else False | \ + UserProfile.email_notifications.likes if bundle.data['email_notification_likes'] else False | \ + UserProfile.email_notifications.favourites if bundle.data['email_notification_favourites'] else False | \ + UserProfile.email_notifications.follows if bundle.data['email_notification_follows'] else False | \ + UserProfile.email_notifications.comments if bundle.data['email_notification_comments'] else False + return bundle def get_followers(self, request, **kwargs): diff --git a/spa/audio.py b/spa/audio.py index c00b4f7..a4d859e 100755 --- a/spa/audio.py +++ b/spa/audio.py @@ -8,6 +8,7 @@ import json from django.http import Http404, HttpResponse, HttpResponseForbidden, HttpResponseNotFound, HttpResponseRedirect from django.core.servers.basehttp import FileWrapper from django.shortcuts import redirect +from django.utils import simplejson from django.utils.encoding import smart_str from nginx_signing.signing import UriSigner from sendfile import sendfile @@ -39,25 +40,19 @@ def download(request, mix_id): mix = Mix.objects.get(pk=mix_id) if mix is not None: if mix.download_allowed: + response = { + 'url': '', + 'filename': smart_str('Deep South Sounds - %s.%s' % (mix.title, mix.filetype)), + 'mime_type': 'application/octet-stream' + } if mix.archive_path in [None, '']: audio_file = mix.get_absolute_path() - filename, extension = os.path.splitext(audio_file) if os.path.exists(audio_file): - return sendfile( - request, - audio_file, - attachment=True, - attachment_filename='Deep South Sounds - %s%s' % ( - mix.title, extension - ) - ) + response['url'] = audio_file.name else: - response = HttpResponseRedirect(mix.archive_path) - """ - response['Content-Disposition'] = 'attachment; filename=' + \ - smart_str('Deep South Sounds - %s%s' % (mix.title, mix.filetype)) - """ - return response + response['url'] = mix.archive_path + + return HttpResponse(json.dumps(response)) else: return HttpResponse('Downloads not allowed for this mix', status=401) diff --git a/spa/management/commands/azure_util.py b/spa/management/commands/azure_util.py index 2e8b7f8..b1ddced 100644 --- a/spa/management/commands/azure_util.py +++ b/spa/management/commands/azure_util.py @@ -23,7 +23,7 @@ class Command(NoArgsCommand): x_ms_blob_content_type='application/octet-stream', x_ms_blob_content_disposition='attachment;filename="%s"' % download_name ) - print "Processed: %s" % download_name + print "Processed: %s" % mix.uid else: print "No blob found for: %s" % mix.uid except WindowsAzureMissingResourceError: diff --git a/spa/models/userprofile.py b/spa/models/userprofile.py index 4c0636a..fea76ce 100755 --- a/spa/models/userprofile.py +++ b/spa/models/userprofile.py @@ -151,6 +151,9 @@ class UserProfile(BaseModel): try: if self.avatar_type == 'custom': image = self.avatar_image + if image.name.startswith('http'): + return image.name + image = "%s%s" % (settings.MEDIA_URL, get_thumbnail(image, "32x32", crop='center').name) return image except SuspiciousOperation, ex: diff --git a/spa/signals.py b/spa/signals.py index c75686c..a06b8d5 100755 --- a/spa/signals.py +++ b/spa/signals.py @@ -57,16 +57,15 @@ def create_profile(sender, **kw): post_save.connect(create_profile, sender=User) -""" - Doing signals for notifications here. - I like this method because I have a single signal - and just check for a hook method on the sender -""" - def post_save_handler(**kwargs): + """ + Doing signals for notifications here. + I like this method because I have a single signal + and just check for a hook method on the sender + """ instance = kwargs['instance'] - #should save generate a notification to a target user + # should save generate a notification to a target user if hasattr(instance, 'post_social'): instance.post_social() if hasattr(instance, 'create_notification'): diff --git a/spa/storage.py b/spa/storage.py index fd07d59..2f2a4b3 100644 --- a/spa/storage.py +++ b/spa/storage.py @@ -2,8 +2,8 @@ from django.conf import settings from django.core.files.storage import Storage from django.core.files.base import ContentFile -import azure -from azure.storage import * +import azure_util +from azure_util.storage import * from datetime import datetime import os, mimetypes diff --git a/static/js/dss/apps/user/views/userEditView.coffee b/static/js/dss/apps/user/views/userEditView.coffee index f90020e..2412877 100644 --- a/static/js/dss/apps/user/views/userEditView.coffee +++ b/static/js/dss/apps/user/views/userEditView.coffee @@ -31,6 +31,7 @@ ref = this @_saveChanges success: -> + """ if ref.model.get('avatar_type') is "custom" $.ajaxFileUpload url: "ajax/upload_avatar_image/" @@ -51,12 +52,13 @@ utils.showError e else - toastr.info "Successfully updated yourself" - alert("What to do") - """ - Backbone.history.navigate "/", - trigger: true - """ + """ + toastr.info "Successfully updated yourself" + alert("What to do") + """ + Backbone.history.navigate "/", + trigger: true + """ true error: -> toastr.error "There was an error updating your info. Please try again later." diff --git a/static/js/dss/lib/utils.coffee b/static/js/dss/lib/utils.coffee index a848e87..2a1fe33 100644 --- a/static/js/dss/lib/utils.coffee +++ b/static/js/dss/lib/utils.coffee @@ -108,26 +108,42 @@ v.toString 16 downloadURL: (url) -> - """ - $.getJSON url, (data) => - $.fileDownload(data.url) - successCallback: (url) -> - alert "You just got a file download dialog or ribbon for this URL :" + url - return - - failCallback: (html, url) -> - alert "Your file download just failed for this URL:" + url + "\r\n" + "Here was the resulting error HTML: \r\n" + html - return - """ - iframe = document.getElementById("if_dl_misecure") - if iframe is null - iframe = document.createElement("iframe") - iframe.id = "if_dl_misecure" - iframe.style.visibility = "hidden" - document.body.appendChild iframe - iframe.src = url + $.getJSON url, (response) -> + utils.download(response.url, response.filename, response.mime_type) true + download: (strData, strFileName, strMimeType) -> + D = document + a = D.createElement("a") + strMimeType = strMimeType or "application/octet-stream" + if navigator.msSaveBlob # IE10 + return navigator.msSaveBlob(new Blob([strData], + type: strMimeType + ), strFileName) + # end if(navigator.msSaveBlob) + if "download_ignore" of a #html5 A[download] + a.href = "data:" + strMimeType + "," + encodeURIComponent(strData) + a.setAttribute "download", strFileName + a.innerHTML = "downloading..." + D.body.appendChild a + setTimeout (-> + a.click() + #D.body.removeChild a + return + ), 66 + return true + # end if('download' in a) + + #do iframe dataURL download (old ch+FF): + f = D.createElement("iframe") + D.body.appendChild f + #f.src = "data:" + strMimeType + "," + encodeURIComponent(strData) + f.src = strData + setTimeout (-> + D.body.removeChild f + return + ), 333 + true isAuth: -> com.podnoms.settings.currentUser != -1 @@ -161,7 +177,7 @@ $(document).ready -> -1 $.extend $.gritter.options, - position: "bottom-left" + position: "bottom-left" return diff --git a/static/js/dss/templates/usereditview.jst b/static/js/dss/templates/usereditview.jst index 2adcde6..205afce 100644 --- a/static/js/dss/templates/usereditview.jst +++ b/static/js/dss/templates/usereditview.jst @@ -93,7 +93,8 @@
@@ -156,21 +157,21 @@
@@ -181,6 +182,7 @@
+