Skip to content
Snippets Groups Projects

Dev

Merged Jean-Philippe Laverdure requested to merge dev into master
1 file
+ 20
13
Compare changes
  • Side-by-side
  • Inline
@@ -102,8 +102,17 @@ class DataFilesJSONListView(LoginRequiredMixin, JSONListView):
def get_rows(self):
rows = []
objs = self.get_queryset().annotate(ds_count=Count('datasets'), ds_names=ArrayAgg('datasets__name'))
ds_token = ugettext('DataSets')
dwnl_token = ugettext('Download File')
annot_token = ugettext('Download Annotation')
view_token = ugettext('View details')
edit_token = ugettext('Edit')
delete_token = ugettext('Delete')
pi_or_manager = False
if self.request.user.profile.is_pi_or_data_manager:
pi_or_manager = True
objs = self.get_queryset().annotate(
ds_count=Count('datasets'),
@@ -115,28 +124,26 @@ class DataFilesJSONListView(LoginRequiredMixin, JSONListView):
)
).values(
'id', 'filename', 'filesize', 'iric_data_id', 'upload_timestamp',
'file', 'lab__name', 'ds_count', 'ds_names' ,'uploaded_by_fullname'
'file', 'lab__name', 'ds_count', 'ds_names', 'uploaded_by_fullname'
)
ds_token = ugettext('DataSets')
dwnl_token = ugettext('Download File')
annot_token = ugettext('Download Annotation')
view_token = ugettext('View details')
edit_token = ugettext('Edit')
delete_token = ugettext('Delete')
for o in objs:
ds_str = ''
if o['ds_count'] > 0 :
ds_str = ', '.join(o['ds_names'])
if o['ds_count']:
if o['ds_count'] > 1:
ds_str = '<span title="{0}">{1} {2}</span>'.format(ds_str, o['ds_count'], ds_token)
else:
ds_str = ', '.join(o['ds_names'])
row = {
'id': o['id'],
'sel': '',
'name': '<a href="{0}" class="details" title="{2}">{1}</a>'.format(
reverse('user.datafile-details-iric-data-id', args=[o['iric_data_id']]),
o['filename'], view_token),
o['filename'],
view_token
),
'ext': os.path.splitext(o['filename'])[-1][1:].upper(),
'iric_data_id': '<span class="text-monospace">{}</span>'.format(o['iric_data_id']),
'hash': '<span class="text-monospace">{}</span>'.format(o['file'][4:12]),
@@ -154,7 +161,7 @@ class DataFilesJSONListView(LoginRequiredMixin, JSONListView):
]})
}
if self.request.user.profile.is_pi_or_data_manager:
if pi_or_manager:
row.update({'uploaded_by': o['uploaded_by_fullname']})
rows.append(row)
@@ -174,7 +181,7 @@ class SharedWithMeDataFilesJSONListView(LoginRequiredMixin, JSONListView):
def get_rows(self):
rows = []
objs = self.get_queryset().annotate(
ds_count=Count('datasets'),
ds_names=ArrayAgg('datasets__name'),
Loading