Permalink
Browse files

added delete alert error and dom deletion

  • Loading branch information...
sweemeng committed Nov 11, 2012
1 parent 47b41f5 commit 5c6a47b026ec8530ccdcebb18289b935c058016f
Showing with 20 additions and 1 deletion.
  1. +18 −1 scrapedump/frontend/templates/entry_view.html
  2. +2 −0 scrapedump/project/model.py
@@ -45,6 +45,7 @@
</div>
<div id="files" class="tab-pane fade">
<div class="page-header"><h3>Files</h3></div>
+ <div id="file_error"></div>
<div id="upload_control">
{% if permission.can() %}
<input id="fileupload" type="file" name="files[]" data-url="/upload/{{ project.project.id }}/{{ entry_id }}/" multiple>
@@ -70,7 +71,7 @@
<td>
<a class="btn btn-primary" href="{{project.get_datafile_metadata(entry_id,key)['download']}}">download</a>
{% if permission.can() %}
- <a class="btn btn-danger" href="{{project.get_datafile_metadata(entry_id,key)['delete']}}">delete</a>
+ <a class="btn btn-danger" class="delete_file" data-divid="{{project.get_datafile_metadata(entry_id,key)['name']}}" data-delete="{{project.get_datafile_metadata(entry_id,key)['delete']}}">delete</a>
{% endif %}
</td>
<tr>
@@ -219,6 +220,22 @@ <h5>Delete</h5>
$('body').append(html);
}
});
+ $('.delete_file').click(function(event){
+ event.preventDefault();
+ var divid = $(this).data('divid');
+ var url = $(this).data('delete');
+ $.getJSON(url,function(data){
+ if(data.status == 'Success'){
+ $('#'+divid).remove();
+ }
+ else{
+ $('#file_error').addClass('alert');
+ $('#file_error').addClass('alert-error');
+ $('#file_error').text(data.message);
+ }
+
+ });
+ });
$('.export_file').click(function(event){
event.preventDefault();
var file_format = $(this).data('format');
@@ -272,6 +272,8 @@ def set_exporter_task(self,entry_id,format_,task_id):
def export_completed(self,entry_id,format_):
if not self.project.export[entry_id]:
return False
+ if not format_ in self.project.export[entry_id]:
+ return False
print self.project.export
task_id = self.project.export[entry_id][format_]['task_id']

0 comments on commit 5c6a47b

Please sign in to comment.