Skip to content

Commit

Permalink
ubccr#294: Created new ColdFront config vars that allow users to deci…
Browse files Browse the repository at this point in the history
…de whether or not to allow allocation change requests by default and to customize the list of days users can request allocation extensions
  • Loading branch information
brisco17 committed Nov 11, 2021
1 parent 0f57306 commit 44abfbf
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions coldfront/config/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#------------------------------------------------------------------------------
# Allocation related
#------------------------------------------------------------------------------
ALLOCATION_ENABLE_CHANGE_REQUESTS_BY_DEFAULT = ENV.bool('ALLOCATION_ENABLE_CHANGE_REQUESTS', default=True)
ALLOCATION_CHANGE_REQUEST_EXTENSION_DAYS = ENV.list('ALLOCATION_CHANGE_REQUEST_EXTENSION_DAYS', cast=int, default=[30, 60, 90])
ALLOCATION_ENABLE_ALLOCATION_RENEWAL = ENV.bool('ALLOCATION_ENABLE_ALLOCATION_RENEWAL', default=True)
ALLOCATION_FUNCS_ON_EXPIRE = ['coldfront.core.allocation.utils.test_allocation_function', ]

Expand Down
7 changes: 6 additions & 1 deletion coldfront/core/allocation/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

ALLOCATION_ACCOUNT_ENABLED = import_from_settings(
'ALLOCATION_ACCOUNT_ENABLED', False)
ALLOCATION_CHANGE_REQUEST_EXTENSION_DAYS = import_from_settings(
'ALLOCATION_CHANGE_REQUEST_EXTENSION_DAYS', [])


class AllocationForm(forms.Form):
Expand Down Expand Up @@ -198,8 +200,11 @@ def clean(self):

class AllocationChangeForm(forms.Form):
EXTENSION_CHOICES = [
(0, "----"), (30, "30 days"), (60, "60 days"), (90, "90 days")
(0, "----")
]
for choice in ALLOCATION_CHANGE_REQUEST_EXTENSION_DAYS:
EXTENSION_CHOICES.append((choice, "{} days".format(choice)))

end_date_extension = forms.TypedChoiceField(
label='Request End Date Extension',
choices = EXTENSION_CHOICES,
Expand Down
3 changes: 3 additions & 0 deletions coldfront/core/allocation/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@
'ALLOCATION_ENABLE_ALLOCATION_RENEWAL', True)
ALLOCATION_DEFAULT_ALLOCATION_LENGTH = import_from_settings(
'ALLOCATION_DEFAULT_ALLOCATION_LENGTH', 365)
ALLOCATION_ENABLE_CHANGE_REQUESTS_BY_DEFAULT = import_from_settings(
'ALLOCATION_ENABLE_CHANGE_REQUESTS_BY_DEFAULT', True)

EMAIL_ENABLED = import_from_settings('EMAIL_ENABLED', False)
if EMAIL_ENABLED:
Expand Down Expand Up @@ -1060,6 +1062,7 @@ def get(self, request, pk):
allocation_obj.status = allocation_status_active_obj
allocation_obj.start_date = start_date
allocation_obj.end_date = end_date
if ALLOCATION_ENABLE_CHANGE_REQUESTS_BY_DEFAULT: allocation_obj.is_changeable = True
allocation_obj.save()

messages.success(request, 'Allocation to {} has been ACTIVATED for {} {} ({})'.format(
Expand Down
2 changes: 2 additions & 0 deletions docs/pages/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ The following settings are ColdFront specific settings related to the core appli
| PROJECT_ENABLE_PROJECT_REVIEW | Enable or disable project reviews. Default True|
| ALLOCATION_ENABLE_ALLOCATION_RENEWAL | Enable or disable allocation renewals. Default True |
| ALLOCATION_DEFAULT_ALLOCATION_LENGTH | Default number of days an allocation is active for. Default 365 |
| ALLOCATION_ENABLE_CHANGE_REQUESTS_BY_DEFAULT | Enable or disable allocation change requests. Default True |
| ALLOCATION_CHANGE_REQUEST_EXTENSION_DAYS | List of days users can request extensions in an allocation change request. Default 30,60,90 |
| ALLOCATION_ACCOUNT_ENABLED | Allow user to select account name for allocation. Default False |
| INVOICE_ENABLED | Enable or disable invoices. Default True |
| ONDEMAND_URL | The URL to your Open OnDemand installation |
Expand Down

0 comments on commit 44abfbf

Please sign in to comment.