- 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 return srt
def editable(self, user): def editable(self, user):
return user.get_profile().get_level() == 'admin' or \ p = user.get_profile()
self.instances.filter(volume__user=user).count() > 0 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): def save_chunk(self, chunk, chunk_id=-1, done=False):
if not self.available: if not self.available:

View file

@ -263,6 +263,8 @@ def firefogg_upload(request):
'result': 1 'result': 1
} }
return render_to_json_response(response) 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') response = json_response(status=400, text='this request requires POST')
return render_to_json_response(response) return render_to_json_response(response)

View file

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