Skip to content

Commit

Permalink
Merge pull request #235 from fasrc/cp_syncdates
Browse files Browse the repository at this point in the history
add sync dates to AllocationDetail and ProjectDetail pages
  • Loading branch information
claire-peters authored Jun 29, 2023
2 parents 4004673 + 6e0dd86 commit 1304e83
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ <h3><i class="fas fa-list" aria-hidden="true"></i> Allocation Information</h3>
</tr>
<tr>
<th scope="row" class="text-nowrap">Total Usage (TB):</th>
<td>{{ allocation_usage_tb|floatformat:2 }}</td>
<td>{{ allocation_usage_tb|floatformat:2 }}
<span class="float-right">Last Synced {{user_sync_dt}}</span>
</td>
</tr>
<tr>
<th scope="row" class="text-nowrap">Quota (TB):</th>
Expand Down Expand Up @@ -335,6 +337,8 @@ <h3 class="d-inline"><i class="fas fa-info-circle" aria-hidden="true"></i> Alloc
<div class="card-header">
<h3 class="d-inline"><i class="fas fa-users" aria-hidden="true"></i> Users in Allocation</h3>
<span class="badge badge-secondary">{{allocation_users.count}}</span>
<!--show user_sync_dt on the right side of the div header-->
<span class="float-right">Last Sync: {{user_sync_dt}}</span>
<div class="float-right">

{% comment %}
Expand Down
15 changes: 15 additions & 0 deletions coldfront/core/allocation/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from dateutil.relativedelta import relativedelta
from django import forms
from django.conf import settings
from django.contrib import messages
from django.contrib.auth import get_user_model
from django.contrib.auth.mixins import LoginRequiredMixin, UserPassesTestMixin
Expand Down Expand Up @@ -64,6 +65,9 @@
from coldfront.core.utils.common import get_domain_url, import_from_settings
from coldfront.core.utils.mail import send_allocation_admin_email, send_allocation_customer_email

if 'django_q' in settings.INSTALLED_APPS:
from django_q.tasks import Task

ALLOCATION_ENABLE_ALLOCATION_RENEWAL = import_from_settings(
'ALLOCATION_ENABLE_ALLOCATION_RENEWAL', True)
ALLOCATION_DEFAULT_ALLOCATION_LENGTH = import_from_settings(
Expand Down Expand Up @@ -203,6 +207,17 @@ def get_context_data(self, **kwargs):
attributes_with_usage, allocation_obj.allocationuser_set.all()
)


if 'django_q' in settings.INSTALLED_APPS:
# get last successful runs of djangoq task responsible for allocationuser data pull
user_sync_task = Task.objects.filter(
func__contains="pull_sf_push_cf_redash", success=True
).order_by('started').last()
user_sync_dt = None if not user_sync_task else user_sync_task.started
else:
user_sync_dt = None
context['user_sync_dt'] = user_sync_dt

context['allocation_quota_bytes'] = quota_bytes
context['allocation_usage_bytes'] = usage_bytes
quota_tb = 0 if not quota_bytes else quota_bytes / 1099511627776
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ <h3 class="d-inline"><i class="fas fa-file-invoice-dollar" aria-hidden="true"></
<div class="card mb-3">
<div class="card-header">
<h3 class="d-inline" id="users"><i class="fas fa-users" aria-hidden="true"></i> Users</h3> <span class="badge badge-secondary">{{project_users.count}}</span>
<span class="float-right">Last Sync: {{user_sync_dt}}</span>
<div class="float-right">
{% comment %}
{% if project.status.name != 'Archived' and is_allowed_to_update_project %}
Expand Down
13 changes: 13 additions & 0 deletions coldfront/core/project/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@
from coldfront.core.utils.common import get_domain_url, import_from_settings
from coldfront.core.utils.mail import send_email, send_email_template

if 'django_q' in settings.INSTALLED_APPS:
from django_q.tasks import Task

ALLOCATION_ENABLE_ALLOCATION_RENEWAL = import_from_settings(
'ALLOCATION_ENABLE_ALLOCATION_RENEWAL', True)
Expand Down Expand Up @@ -218,6 +220,17 @@ def get_context_data(self, **kwargs):
if not time_chart_data['groups'][0]:
time_chart_data = None


if 'django_q' in settings.INSTALLED_APPS:
# get last successful runs of djangoq task responsible for projectuser data pull
user_sync_task = Task.objects.filter(
func__contains="update_group_membership_ldap", success=True
).order_by('started').last()
user_sync_dt = None if not user_sync_task else user_sync_task.started
else:
user_sync_dt = None
context['user_sync_dt'] = user_sync_dt

context['notes'] = self.return_visible_notes()

context['allocation_history_records'] = allocation_history_records
Expand Down

0 comments on commit 1304e83

Please sign in to comment.