Skip to content
Snippets Groups Projects
Commit bf794548 authored by Jonathan Seguin's avatar Jonathan Seguin
Browse files

Add hash in datafile table

parent 03833bd7
No related branches found
No related tags found
1 merge request!43Resolve "Expose unique ID for files"
......@@ -158,6 +158,10 @@ class DataFile(models.Model):
ext = os.path.splitext(self.filename)[-1][1:].lower()
return ext
@property
def hash(self):
return self.file.name[4:]
@property
def name(self):
return self.filename
......
......@@ -13,6 +13,7 @@ $(function() {
order: [[ 3, 'desc' ]],
columns: [
{ "data": "name" },
{ "data": "hash" },
{ "data": "ext" },
{ "data": "size" },
{ "data": "upload_date" },
......
......@@ -127,6 +127,7 @@ $(function() {
columns: [
{ "data": "sel" },
{ "data": "name" },
{ "data": "hash" },
{ "data": "ext" },
{ "data": "size" },
{ "data": "upload_date" },
......
......@@ -5,6 +5,7 @@
columns: [
{ "data": "sel" },
{ "data": "name" },
{ "data": "hash" },
{ "data": "ext" },
{ "data": "size" },
{ "data": "upload_date" },
......@@ -15,4 +16,4 @@ columnDefs: [
{ orderable: false, className: 'select-checkbox', targets: 0 },
{ orderable: false, targets: "{{ is_pi|yesno:'8,7,7' }}" }
],
{% endblock %}
\ No newline at end of file
{% endblock %}
......@@ -39,7 +39,7 @@ class DataFilesView(LoginRequiredMixin, ActivePageViewMixin, AjaxDatatableBackbo
api_url = reverse_lazy('user.datafiles-json-list')
dt_struct = {
'id': 'all-datafile',
'headers': ['', _('Name'), _('File Type'), _('Size'), _('Uploaded On'), _('Lab'), _('In Datasets')]
'headers': ['', _('Name'), _('Hash'), _('File Type'), _('Size'), _('Uploaded On'), _('Lab'), _('In Datasets')]
}
def get_context_data(self, **kwargs):
......@@ -63,7 +63,7 @@ class SharedWithMeDataFilesView(DataFilesView):
template_name = 'portal/secure/user/shared_datafile_list.html'
dt_struct = {
'id': 'all-datafile',
'headers': ['', _('Name'), _('File Type'), _('Size'), _('Uploaded On'), _('In Datasets')]
'headers': ['', _('Name'), _('Hash'), _('File Type'), _('Size'), _('Uploaded On'), _('In Datasets')]
}
......@@ -99,6 +99,7 @@ class DataFilesJSONListView(LoginRequiredMixin, JSONListView):
reverse('user.datafile-details', args=[o.id]),
o.filename, ugettext('View details')),
'ext': o.filext.upper(),
'hash': '<span class="text-monospace">{}</span>'.format(o.hash[:8]),
'size': filters.filesizeformat(o.file.size),
'upload_date': timezone.localtime(o.upload_timestamp).strftime('%y-%m-%d %H:%M:%S %Z'),
'lab': str(o.lab),
......@@ -148,6 +149,7 @@ class SharedWithMeDataFilesJSONListView(DataFilesJSONListView):
'name': '<a href="{0}" class="details" title="{2}">{1}</a>'.format(
reverse('user.datafile-details', args=[o.id]),
o.filename, ugettext('View details')),
'hash': '<span class="text-monospace">{}</span>'.format(o.hash[:8]),
'ext': o.filext.upper(),
'size': filters.filesizeformat(o.file.size),
'upload_date': timezone.localtime(o.upload_timestamp).strftime('%y-%m-%d %H:%M:%S %Z'),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment