Skip to content

Commit

Permalink
minor code fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
claire-peters committed Dec 13, 2023
1 parent 44ddeae commit c9739b5
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
13 changes: 11 additions & 2 deletions coldfront/core/allocation/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,19 +152,25 @@ def get_context_data(self, **kwargs):
)
except ValueError:
logger.error(
f"Allocation attribute '%s' is not an int but has a usage",
"Allocation attribute '%s' is not an int but has a usage",
attribute.allocation_attribute_type.name,
)
invalid_attributes.append(attribute)

for a in invalid_attributes:
attributes_with_usage.remove(a)

user_sync_task = None
if 'django_q' in settings.INSTALLED_APPS:
# get last successful runs of djangoq task responsible for allocationuser data pull
if allocation_obj.get_parent_resource.resource_type.name == "Storage":
sync_task_name = "pullsf_pushcf_redash"
elif allocation_obj.get_parent_resource.resource_type.name == "Cluster":
sync_task_name = "xdmod_usage"
user_sync_task = Task.objects.filter(
func__contains="pullsf_pushcf_redash", success=True
func__contains=sync_task_name, 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
Expand Down Expand Up @@ -1817,6 +1823,7 @@ def post(self, request, *args, **kwargs):
if new_value != attribute_change.new_value:
attribute_change.new_value = new_value
attribute_change.save()

if action == 'update':
message = 'Allocation change request updated!'
if action == 'approve':
Expand Down Expand Up @@ -2053,6 +2060,8 @@ def post(self, request, *args, **kwargs):
for a in attribute_changes_to_make
if a[0].allocation_attribute_type.name == 'Storage Quota (TB)'
]
# if requested resource is on NESE, add to vars
nese = bool(allocation_obj.resources.filter(name__contains="nesetape"))

email_vars = {'justification': justification}
if quantity:
Expand Down
4 changes: 4 additions & 0 deletions coldfront/core/department/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
from django.conf import settings
from ifxuser.models import Organization, OrgRelation, UserAffiliation
from model_utils.models import TimeStampedModel
from simple_history.models import HistoricalRecords

from coldfront.core.project.models import Project
from coldfront.plugins.ifx.models import ProjectOrganization


class DepartmentSelector(models.Manager):

def get_queryset(self):
"""
collect non-lab Organization objects that are in the Research
Expand Down Expand Up @@ -43,6 +45,7 @@ class Department(Organization):
Billing org_tree.
"""
objects = DepartmentSelector()
history = HistoricalRecords()


class Meta:
Expand Down Expand Up @@ -127,6 +130,7 @@ class DepartmentMember(UserAffiliation):
"""subset of UserAffiliation records that are related to Department records.
"""
objects = DepartmentMemberManager()
history = HistoricalRecords()

class Meta:
proxy = True
Expand Down
7 changes: 0 additions & 7 deletions coldfront/core/project/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,6 @@
ALLOCATION_DEFAULT_ALLOCATION_LENGTH = import_from_settings(
'ALLOCATION_DEFAULT_ALLOCATION_LENGTH', 365)

ALLOCATION_ENABLE_ALLOCATION_RENEWAL = import_from_settings(
'ALLOCATION_ENABLE_ALLOCATION_RENEWAL', True
)
ALLOCATION_DEFAULT_ALLOCATION_LENGTH = import_from_settings(
'ALLOCATION_DEFAULT_ALLOCATION_LENGTH', 365
)


EMAIL_DIRECTOR_EMAIL_ADDRESS = import_from_settings('EMAIL_DIRECTOR_EMAIL_ADDRESS')
EMAIL_SENDER = import_from_settings('EMAIL_SENDER')
Expand Down
2 changes: 0 additions & 2 deletions container_startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ service redis-server start
python ./manage.py qcluster &
python ./manage.py add_scheduled_tasks
python ./manage.py collectstatic --noinput
# initial_setup does not appear to work as requested.
python ./manage.py initial_setup &

if [ "$BUILD_ENV" == 'dev' ]; then
python ./manage.py runserver 0.0.0.0:80 --insecure
Expand Down

0 comments on commit c9739b5

Please sign in to comment.