Fixed output logging

This commit is contained in:
Fergal Moran
2014-08-31 20:34:19 +01:00
parent 7ddb18f250
commit 442a8efede
10 changed files with 83 additions and 61 deletions

View File

@@ -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

View File

@@ -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):

View File

@@ -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)

View File

@@ -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:

View File

@@ -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:

View File

@@ -57,16 +57,15 @@ def create_profile(sender, **kw):
post_save.connect(create_profile, sender=User)
"""
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
"""
def post_save_handler(**kwargs):
"""
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'):

View File

@@ -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

View File

@@ -31,6 +31,7 @@
ref = this
@_saveChanges
success: ->
"""
if ref.model.get('avatar_type') is "custom"
$.ajaxFileUpload
url: "ajax/upload_avatar_image/"
@@ -51,6 +52,7 @@
utils.showError e
else
"""
toastr.info "Successfully updated yourself"
alert("What to do")
"""

View File

@@ -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

View File

@@ -93,7 +93,8 @@
</div>
<div class="checkbox">
<label>
<input type="checkbox" name="activity_sharing_favourites" class="ace"
<input type="checkbox" name="activity_sharing_favourites"
class="ace"
id="activity_sharing_favourites" <%= renderCheckbox(activity_sharing_favourites) %>>
<span class="lbl"> Favourites</span>
</label>
@@ -156,21 +157,21 @@
</div>
<div class="checkbox">
<label>
<input type="checkbox" name="email_notification_plays" class="ace"
<input type="checkbox" name="email_notification_likes" class="ace"
id="email_notification_likes" <%= renderCheckbox(email_notification_likes) %>>
<span class="lbl"> Likes</span>
</label>
</div>
<div class="checkbox">
<label>
<input type="checkbox" name="email_notification_plays" class="ace"
<input type="checkbox" name="email_notification_favourites" class="ace"
id="email_notification_favourites" <%= renderCheckbox(email_notification_favourites) %>>
<span class="lbl"> Favourites</span>
</label>
</div>
<div class="checkbox">
<label>
<input type="checkbox" name="email_notification_plays" class="ace"
<input type="checkbox" name="email_notification_comments" class="ace"
id="email_notification_comments" <%= renderCheckbox(email_notification_comments) %>>
<span class="lbl"> Comments</span>
</label>
@@ -181,6 +182,7 @@
</div>
</div>
</div>
</div>
</fieldset>
</form>
</div>