Skip to content

Commit

Permalink
active users only on projectuser table
Browse files Browse the repository at this point in the history
  • Loading branch information
claire-peters committed Nov 22, 2023
1 parent 100392a commit 8a35f56
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 31 deletions.
35 changes: 5 additions & 30 deletions coldfront/core/project/templates/project/project_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ <h3 class="d-inline"><i class="fas fa-file-invoice-dollar" aria-hidden="true"></
<th scope="col">Resource Type</th>
<th scope="col">Location</th>
<th scope="col">User Count</th>
<th scope="col">Space (TB)</th>
<th scope="col">Used (TB)</th>
<th scope="col">Space</th>
<th scope="col">Used</th>
<th scope="col">Monthly Cost</th>
<th scope="col" class="nosort">Actions</th>
</tr>
Expand Down Expand Up @@ -642,36 +642,11 @@ <h3 class="d-inline" id="research_outputs"><i class="far fa-newspaper" aria-hidd
});

$('#projectuser_table').DataTable({
'lengthMenu': [[10, 25, 50, -1], [10, 25, 50, 'All']],
'pageLength': 25,
'aoColumnDefs': [{
'bSortable': false,
'aTargets': ['nosort']
}],
"lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]],
"pageLength": 25,
dom: 'B<"clear">lfrtip',
order: [[ 3, "desc" ]],
buttons: [
{
name: 'toggleusers',
text: function() {
return $('#projectuser_table').attr('filter') == "on" ? 'Show All Users' : "Show Active Users"
},
action: function(e, dt, node, config) {
var table = $('#projectuser_table');
var filter = table.attr('filter') === "on" ? 'off' : "on";
document.querySelector('#projectuser_table').setAttribute('filter', filter);
if (filter == 'on') {
$.fn.dataTable.ext.search.push(
function(settings, data, dataIndex) {
return $(dt.row(dataIndex).node()).attr('status') == "Active";
});
} else {$.fn.dataTable.ext.search.pop();}
table.DataTable().draw();
this.text(filter == 'on' ? 'Show All Users' : "Show Active Users")
}
}
]}
);
});

$('#invoice_table').DataTable({
'aoColumnDefs': [{
Expand Down
3 changes: 2 additions & 1 deletion coldfront/core/project/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ def get_context_data(self, **kwargs):
attributes_with_usage.remove(a)

# Only show 'Active Users'
project_users = self.object.projectuser_set.order_by('user__username')
project_users = self.object.projectuser_set.filter(
status__name='Active').order_by('user__username')

context['mailto'] = 'mailto:' + ','.join([u.user.email for u in project_users])

Expand Down

0 comments on commit 8a35f56

Please sign in to comment.