Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Config options added to make EULA process more thorough #550

Open
wants to merge 39 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
811c401
added ability to prompt users when adding to allocation and have eula…
rg663 Jun 14, 2023
d62428a
commit with comments
rg663 Jun 18, 2023
40b4eb8
done
rg663 Jun 18, 2023
499a9b8
fixed formatting and removed comments
rg663 Jun 18, 2023
761c0c3
fixed functionality when adding 0 users to allocation
rg663 Jun 18, 2023
1002059
fixed display for allocations without eula
rg663 Jun 18, 2023
b734649
fixed checkbox functionality
rg663 Jun 26, 2023
415ee2e
code cleanup
rg663 Jun 27, 2023
a72132a
started eula user functionality
rg663 Jun 27, 2023
7993708
made it so user status is pending when allocation has eula
rg663 Jun 27, 2023
cc81805
added email functionality
rg663 Jun 27, 2023
c1526fd
line deletion
rg663 Jun 27, 2023
a501057
add config variable check to each part
rg663 Jun 27, 2023
d298a0d
working through user statuses
rg663 Jun 29, 2023
c6c3c43
enabling checkbox functionality
rg663 Jun 29, 2023
eae5221
started selection functionality
rg663 Jul 1, 2023
07ce6e5
working on agree button
rg663 Jul 5, 2023
39821cf
fixed bug in eula display
rg663 Jul 5, 2023
07fd1e6
fixed html side of bug
rg663 Jul 5, 2023
1d51303
users can now accept/decline eulas
rg663 Jul 5, 2023
0c475e1
small change
rg663 Jul 5, 2023
d91379a
fixed email
rg663 Jul 5, 2023
163cda5
code cleanup
rg663 Jul 5, 2023
0f77152
email functionality close to working
rg663 Jul 5, 2023
90b14c0
functionality near complete
rg663 Jul 5, 2023
a9d604b
email functionality almost done
rg663 Jul 6, 2023
7d9902a
fixed functionality for when config is false
rg663 Jul 6, 2023
c9b15a5
bug fix
rg663 Jul 6, 2023
782b33d
emails work
rg663 Jul 7, 2023
900ff26
email updates
rg663 Jul 7, 2023
1849312
config fix
rg663 Jul 7, 2023
ae0abd8
small fixes
rg663 Jul 8, 2023
8fb470a
Update add_scheduled_tasks.py
rg663 Jul 8, 2023
3c415d1
Update allocation_agree_to_eula.txt
rg663 Jul 8, 2023
6b6b59f
refactored eula reminder emails
rg663 Jul 13, 2023
850566d
Update .gitignore
rg663 Jul 25, 2023
d246b8e
Update add_allocation_defaults.py
rg663 Jul 27, 2023
c426574
Update add_allocation_defaults.py
rg663 Jul 27, 2023
b3548e3
Merge branch '420-eula-add-users-and-alloc-detail' into 542-eula-comp…
rg663 Jul 30, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions coldfront/config/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
#------------------------------------------------------------------------------
PROJECT_ENABLE_PROJECT_REVIEW = ENV.bool('PROJECT_ENABLE_PROJECT_REVIEW', default=True)

#------------------------------------------------------------------------------
# Enable EULA force agreement
#------------------------------------------------------------------------------
EULA_AGREEMENT = ENV.bool('EULA_AGREEMENT', default=True)

#------------------------------------------------------------------------------
# Allocation related
#------------------------------------------------------------------------------
Expand All @@ -29,7 +34,6 @@
# This is in days
ALLOCATION_DEFAULT_ALLOCATION_LENGTH = ENV.int('ALLOCATION_DEFAULT_ALLOCATION_LENGTH', default=365)


#------------------------------------------------------------------------------
# Allow user to select account name for allocation
#------------------------------------------------------------------------------
Expand All @@ -38,7 +42,8 @@

SETTINGS_EXPORT += [
'ALLOCATION_ACCOUNT_ENABLED',
'CENTER_HELP_URL'
'CENTER_HELP_URL',
'EULA_AGREEMENT'
]

ADMIN_COMMENTS_SHOW_EMPTY = ENV.bool('ADMIN_COMMENTS_SHOW_EMPTY', default=True)
Expand Down
1 change: 1 addition & 0 deletions coldfront/config/email.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@
EMAIL_ALLOCATION_EXPIRING_NOTIFICATION_DAYS = ENV.list('EMAIL_ALLOCATION_EXPIRING_NOTIFICATION_DAYS', cast=int, default=[7, 14, 30])
EMAIL_SIGNATURE = ENV.str('EMAIL_SIGNATURE', default='', multiline=True)
EMAIL_ADMINS_ON_ALLOCATION_EXPIRE = ENV.bool('EMAIL_ADMINS_ON_ALLOCATION_EXPIRE', default=False)
EMAIL_EULA_REMINDERS = ENV.bool('EMAIL_EULA_REMINDERS', default=True)
3 changes: 3 additions & 0 deletions coldfront/core/allocation/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,3 +259,6 @@ class Meta:
def __init__(self, *args, **kwargs):
super(AllocationAttributeCreateForm, self).__init__(*args, **kwargs)
self.fields['allocation_attribute_type'].queryset = self.fields['allocation_attribute_type'].queryset.order_by(Lower('name'))

class AllocationEULAAgreeForm(forms.Form):
eula_choice = forms.ChoiceField(choices=[("agree", "I agree"), ("disagree", "I disagree")], label="", widget=forms.RadioSelect())
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def handle(self, *args, **options):
for choice in ('Pending', 'Approved', 'Denied',):
AllocationChangeStatusChoice.objects.get_or_create(name=choice)

for choice in ('Active', 'Error', 'Removed', ):
for choice in ('Active', 'Error', 'Removed', 'Pending', 'Declined'):
AllocationUserStatusChoice.objects.get_or_create(name=choice)

for name, attribute_type, has_usage, is_private in (
Expand Down
4 changes: 2 additions & 2 deletions coldfront/core/allocation/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
['-is_allocatable', 'name'])

class AllocationPermission(Enum):
""" A project permission stores the user and manager fields of a project. """
""" An allocation permission stores the user and manager fields of a project. """

USER = 'USER'
MANAGER = 'MANAGER'
Expand Down Expand Up @@ -321,7 +321,7 @@ def user_permissions(self, user):
if ProjectPermission.PI in project_perms or ProjectPermission.MANAGER in project_perms:
return [AllocationPermission.USER, AllocationPermission.MANAGER]

if self.allocationuser_set.filter(user=user, status__name__in=['Active', 'New', ]).exists():
if self.allocationuser_set.filter(user=user, status__name__in=['Active', 'New', 'Pending']).exists():
return [AllocationPermission.USER]

return []
Expand Down
28 changes: 27 additions & 1 deletion coldfront/core/allocation/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
import logging

from coldfront.core.allocation.models import (Allocation,
AllocationStatusChoice)
AllocationStatusChoice, AllocationUserStatusChoice)
from coldfront.core.allocation.utils import get_user_resources
from coldfront.core.user.models import User
from coldfront.core.utils.common import import_from_settings
from coldfront.core.utils.mail import send_email_template
Expand Down Expand Up @@ -38,7 +39,32 @@ def update_statuses():

logger.info('Allocations set to expired: {}'.format(
allocations_to_expire.count()))

def get_eula(alloc):
if alloc.get_resources_as_list:
for res in alloc.get_resources_as_list:
if res.get_attribute(name='eula'):
return True

def send_eula_reminders():
for allocation in Allocation.objects.all():
if get_eula(allocation):
email_receiver_list = []
for allocation_user in allocation.allocationuser_set.all():
if allocation_user.status == AllocationUserStatusChoice.objects.get(name='Pending'):
if allocation_user.user.email not in email_receiver_list:
email_receiver_list.append(allocation_user.user.email)

template_context = {
'center_name': CENTER_NAME,
'resource': allocation.get_parent_resource,
'url': f'{CENTER_BASE_URL.strip("/")}/{"allocation"}/{allocation.pk}/',
'signature': EMAIL_SIGNATURE
}

if email_receiver_list:
send_email_template(f'Reminder: Agree to EULA for {allocation}', 'email/allocation_eula_reminder.txt', template_context, EMAIL_SENDER, email_receiver_list)
logger.debug(f'Allocation(s) EULA reminder sent to users {email_receiver_list}.')

def send_expiry_emails():
#Allocations expiring soon
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ <h2>Add users to allocation for project: {{allocation.project.title}}</h2>
</div>
{{ formset.management_form }}
<div>
<button type="submit" class="btn btn-primary"><i class="fas
<button type="submit" class="btn btn-primary confirm-add"><i class="fas
fa-user-plus"></i> Add Selected Users to Allocation</button>
<a class="btn btn-secondary" href="{% url 'allocation-detail' allocation.pk %}" role="button"><i class="fas fa-long-arrow-left" aria-hidden="true"></i>
Back to Allocation</a>
Expand All @@ -74,5 +74,12 @@ <h2>Add users to allocation for project: {{allocation.project.title}}</h2>
$("#selectAll").prop('checked', false);
}
});
$(document).on('click', '.confirm-add', function(){
var eula = {{ resources_with_eula | length }};
var e = "Click OK below to agree to the EULA agreement(s) associated with the following resource(s):\n\n{{ compiled_eula | escapejs }}"
if (eula > 0 && ($("input[name^='userform-']").is(':checked')) == true) {
return confirm(e);
}
})
</script>
{% endblock %}
{% endblock %}
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,48 @@ <h3><i class="fas fa-list" aria-hidden="true"></i> Allocation Information</h3>
</div>
</div>

{% if eulas %}
<div class="card mb-3">
<div class="card-header">
<h3 class="d-inline"><i class="fas fa-info-circle" aria-hidden="true"></i> EULA Agreements </h3>
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table table-bordered table-sm">
<thead>
<tr>
<th scope="col">Resource</th>
<th scope="col">EULA</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<a href="{% url 'resource-detail' res %}">{{res_obj}}</a><br>
</td>
<td>
{{eulas}}
</td>
</tr>
</tbody>
</table>
{% if user_is_pending %}
<form action="{% url 'allocation-detail' allocation.pk %}" method="post">
{% csrf_token %}
<div class="d-inline-flex">
Agree to the above EULA to access this allocation:&#160&#160&#160{{ eula_form|crispy }}
</div>
&#160
<div class="float-right">
<button type="submit" class="btn btn-primary"><i class="fas fa-check-circle"></i>&#160Submit</button>
</div>
</form>
{% endif %}
</div>
</div>
</div>
{% endif %}

{% if attributes or attributes_with_usage or request.user.is_superuser %}
<div class="card mb-3">
<div class="card-header">
Expand Down Expand Up @@ -234,6 +276,7 @@ <h4 class="card-title">{{attribute}}</h4>
</div>
{% endif %}

{% if not user_is_pending %}
<!-- Start Allocation Change Requests -->
<div class="card mb-3">
<div class="card-header">
Expand Down Expand Up @@ -322,7 +365,9 @@ <h3 class="d-inline"><i class="fas fa-users" aria-hidden="true"></i> Users in Al
<td>{{ user.user.email }}</td>
{% if user.status.name == 'Active' %}
<td class="text-success">{{ user.status.name }}</td>
{% elif user.status.name == 'Denied' or user.status.name == 'Error' %}
{% elif user.status.name == 'Pending' %}
<td class="text-info">{{ user.status.name }}</td>
{% elif user.status.name == 'Denied' or user.status.name == 'Error' or user.status.name == 'Declined' %}
<td class="text-danger">{{ user.status.name }}</td>
{% else %}
<td class="text-info">{{ user.status.name }}</td>
Expand Down Expand Up @@ -380,6 +425,7 @@ <h3 class="d-inline"><i class="fas fa-users" aria-hidden="true"></i> Notificatio
{% endif %}
</div>
</div>
{% endif %}

<script>
$(document).ready(function () {
Expand Down
Loading