- fix upload for non admin users

- fix https test
- give permission denied warning if upload is not working
This commit is contained in:
j 2012-09-08 17:03:59 +02:00
parent 084fde7b67
commit e5107d8610
3 changed files with 15 additions and 5 deletions

View File

@ -182,8 +182,10 @@ class File(models.Model):
return srt
def editable(self, user):
return user.get_profile().get_level() == 'admin' or \
self.instances.filter(volume__user=user).count() > 0
p = user.get_profile()
return p.get_level() in ('admin', 'staff') or \
self.instances.filter(volume__user=user).count() > 0 or \
self.item.user == user
def save_chunk(self, chunk, chunk_id=-1, done=False):
if not self.available:

View File

@ -263,6 +263,8 @@ def firefogg_upload(request):
'result': 1
}
return render_to_json_response(response)
else:
response = json_response(status=404, text='permission denied')
response = json_response(status=400, text='this request requires POST')
return render_to_json_response(response)

View File

@ -39,14 +39,20 @@ pandora.ui.upload = function(oshash, file) {
that.progress = -1;
done();
}
if (response.status && response.status.code != 200) {
that.status = response.status.text;
that.progress = -1;
done();
response = {};
}
if (response.maxRetry) {
maxRetry = response.maxRetry;
}
chunkUrl = response.uploadUrl;
if (document.location.protocol == 'https:') {
chunkUrl = chunkUrl.replace(/http:\/\//, 'https://');
}
if (chunkUrl) {
if (document.location.protocol == 'https:') {
chunkUrl = chunkUrl.replace(/http:\/\//, 'https://');
}
that.status = 'uploading';
that.progress = 0.0;
//start upload