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

Staff Assistance Requests #222

Open
wants to merge 22 commits into
base: 6.1.0.dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
43dca1d
Initial commit for staff assistance requests
abuckles-uci May 8, 2024
56ab330
Formatting changes
abuckles-uci May 8, 2024
7e1c983
Allow staff assistance requests to be enabled/disabled
abuckles-uci May 8, 2024
f40466f
Remove email_new_staff_assistance_request_reply
abuckles-uci May 8, 2024
4478934
Add css for staff-assistance
abuckles-uci May 8, 2024
acbc49e
Display date and time of assistance request
abuckles-uci May 8, 2024
d5a6261
Added a button for resolving a request
abuckles-uci May 8, 2024
7b53364
Add word-break for buddy and staff assistance requests
abuckles-uci May 22, 2024
2e25ac1
Resolved staff assistance request section
abuckles-uci May 23, 2024
89ee216
Update NEMO/views/notifications.py
abuckles-uci May 23, 2024
c4f57e9
Hide create new request for staff
abuckles-uci May 23, 2024
0237066
Emails when creating staff assistance request
abuckles-uci May 23, 2024
fce213a
Update NEMO/forms.py
abuckles-uci May 31, 2024
45eda96
Update NEMO/templates/requests/staff_assistance_requests/staff_assist…
abuckles-uci May 31, 2024
ea69017
Merge in 6.0 changes
abuckles-uci Jun 7, 2024
e862fe3
Only show 'There are no open staff assistance requests' once
abuckles-uci Jun 7, 2024
7fb497f
Combine buddy and staff assistance css
abuckles-uci Jun 10, 2024
35847ef
Show unresolved staff assistance requests as notifications
abuckles-uci Jun 10, 2024
9163ae8
Table for resolved staff assistance requests
abuckles-uci Jun 10, 2024
c5fa9d9
Create/edit request modal
abuckles-uci Jun 17, 2024
5e8d9c5
Essentially remove expiration from staff assistance request notificat…
abuckles-uci Jun 17, 2024
d48e53b
Change expiration for staff assistance requests
abuckles-uci Jun 17, 2024
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
10 changes: 10 additions & 0 deletions NEMO/context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ def base_context(request):
buddy_notification_count += notification_counts.get(Notification.Types.BUDDY_REQUEST_REPLY, 0)
except:
buddy_notification_count = 0
try:
staff_assistance_notification_count = notification_counts.get(Notification.Types.STAFF_ASSISTANCE_REQUEST, 0)
staff_assistance_notification_count += notification_counts.get(
Notification.Types.STAFF_ASSISTANCE_REQUEST_REPLY, 0
)
except:
staff_assistance_notification_count = 0
try:
temporary_access_notification_count = notification_counts.get(Notification.Types.TEMPORARY_ACCESS_REQUEST, 0)
except:
Expand Down Expand Up @@ -75,8 +82,11 @@ def base_context(request):
"buddy_system_areas_exist": buddy_system_areas_exist,
"access_user_request_allowed_exist": access_user_request_allowed_exist,
"adjustment_request_allowed": customization_values.get("adjustment_requests_enabled", "") == "enabled",
"staff_assistance_request_allowed": customization_values.get("staff_assistance_requests_enabled", "")
== "enabled",
"notification_counts": notification_counts,
"buddy_notification_count": buddy_notification_count,
"staff_assistance_notification_count": staff_assistance_notification_count,
"temporary_access_notification_count": temporary_access_notification_count,
"adjustment_notification_count": adjustment_notification_count,
"safety_notification_count": safety_notification_count,
Expand Down
8 changes: 8 additions & 0 deletions NEMO/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
SafetyIssue,
ScheduledOutage,
StaffAbsence,
StaffAssistanceRequest,
Task,
TaskCategory,
TaskImages,
Expand Down Expand Up @@ -484,6 +485,13 @@ def clean(self):
return cleaned_data


class StaffAssistanceRequestForm(ModelForm):
class Meta:
model = StaffAssistanceRequest
fields = "__all__"



class TemporaryPhysicalAccessRequestForm(ModelForm):
class Meta:
model = TemporaryPhysicalAccessRequest
Expand Down
124 changes: 124 additions & 0 deletions NEMO/migrations/0087_staff_assistance_requests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
# Generated by Django 4.2.11 on 2024-05-08 18:05

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone


class Migration(migrations.Migration):

dependencies = [
("NEMO", "0086_adjustmentrequest_new_quantity"),
]

operations = [
migrations.AddField(
model_name="userpreferences",
name="email_send_staff_assistance_request_replies",
field=models.PositiveIntegerField(
choices=[(1, "Both emails"), (2, "Main email only")],
default=1,
help_text="Staff assistance request replies",
),
),
migrations.AlterField(
model_name="landingpagechoice",
name="notifications",
field=models.CharField(
blank=True,
choices=[
("news", "News creation and updates - notifies all users"),
("safetyissue", "New safety issues - notifies staff only"),
("buddyrequest", "New buddy request - notifies all users"),
(
"buddyrequestmessage",
"New buddy request reply - notifies request creator and users who have replied",
),
("staffassistancerequest", "New staff assistance request - notifies staff only"),
(
"staffassistancerequestmessage",
"New staff assistance request reply - notifies request creator and staff",
),
("adjustmentrequest", "New adjustment request - notifies reviewers only"),
(
"adjustmentrequestmessage",
"New adjustment request reply - notifies request creator and users who have replied",
),
(
"temporaryphysicalaccessrequest",
"New access request - notifies other users on request and reviewers",
),
],
help_text="Displays a the number of new notifications for the user. For example, if the user has two unread news notifications then the number '2' would appear for the news icon on the landing page.",
max_length=100,
null=True,
),
),
migrations.AlterField(
model_name="notification",
name="notification_type",
field=models.CharField(
choices=[
("news", "News creation and updates - notifies all users"),
("safetyissue", "New safety issues - notifies staff only"),
("buddyrequest", "New buddy request - notifies all users"),
(
"buddyrequestmessage",
"New buddy request reply - notifies request creator and users who have replied",
),
("staffassistancerequest", "New staff assistance request - notifies staff only"),
(
"staffassistancerequestmessage",
"New staff assistance request reply - notifies request creator and staff",
),
("adjustmentrequest", "New adjustment request - notifies reviewers only"),
(
"adjustmentrequestmessage",
"New adjustment request reply - notifies request creator and users who have replied",
),
(
"temporaryphysicalaccessrequest",
"New access request - notifies other users on request and reviewers",
),
],
max_length=100,
),
),
migrations.CreateModel(
name="StaffAssistanceRequest",
fields=[
("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
(
"creation_time",
models.DateTimeField(
default=django.utils.timezone.now, help_text="The date and time when the request was created."
),
),
("description", models.TextField(help_text="The description of the request.")),
(
"resolved",
models.BooleanField(
default=False, help_text="Indicates the request has been resolved and won't be shown anymore."
),
),
(
"deleted",
models.BooleanField(
default=False, help_text="Indicates the request has been deleted and won't be shown anymore."
),
),
(
"user",
models.ForeignKey(
help_text="The user who is submitting the request.",
on_delete=django.db.models.deletion.CASCADE,
to=settings.AUTH_USER_MODEL,
),
),
],
options={
"abstract": False,
},
),
]
40 changes: 40 additions & 0 deletions NEMO/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,11 @@ class UserPreferences(BaseModel):
choices=EmailNotificationType.on_choices(),
help_text="Buddy request replies",
)
email_send_staff_assistance_request_replies = models.PositiveIntegerField(
default=EmailNotificationType.BOTH_EMAILS,
choices=EmailNotificationType.on_choices(),
help_text="Staff assistance request replies",
)
email_send_access_request_updates = models.PositiveIntegerField(
default=EmailNotificationType.BOTH_EMAILS,
choices=EmailNotificationType.on_choices(),
Expand Down Expand Up @@ -3803,6 +3808,8 @@ class Types:
SAFETY = "safetyissue"
BUDDY_REQUEST = "buddyrequest"
BUDDY_REQUEST_REPLY = "buddyrequestmessage"
STAFF_ASSISTANCE_REQUEST = "staffassistancerequest"
STAFF_ASSISTANCE_REQUEST_REPLY = "staffassistancerequestmessage"
ADJUSTMENT_REQUEST = "adjustmentrequest"
ADJUSTMENT_REQUEST_REPLY = "adjustmentrequestmessage"
TEMPORARY_ACCESS_REQUEST = "temporaryphysicalaccessrequest"
Expand All @@ -3811,6 +3818,8 @@ class Types:
(SAFETY, "New safety issues - notifies staff only"),
(BUDDY_REQUEST, "New buddy request - notifies all users"),
(BUDDY_REQUEST_REPLY, "New buddy request reply - notifies request creator and users who have replied"),
(STAFF_ASSISTANCE_REQUEST, "New staff assistance request - notifies staff only"),
(STAFF_ASSISTANCE_REQUEST_REPLY, "New staff assistance request reply - notifies request creator and staff"),
(ADJUSTMENT_REQUEST, "New adjustment request - notifies reviewers only"),
(
ADJUSTMENT_REQUEST_REPLY,
Expand Down Expand Up @@ -4137,6 +4146,37 @@ def __str__(self):
return f"BuddyRequest [{self.id}]"


class StaffAssistanceRequest(BaseModel):
creation_time = models.DateTimeField(
default=timezone.now, help_text="The date and time when the request was created."
)
description = models.TextField(help_text="The description of the request.")
user = models.ForeignKey(User, help_text="The user who is submitting the request.", on_delete=models.CASCADE)
resolved = models.BooleanField(
default=False, help_text="Indicates the request has been resolved and won't be shown anymore."
)
deleted = models.BooleanField(
default=False, help_text="Indicates the request has been deleted and won't be shown anymore."
)

@property
def creator(self) -> User:
return self.user

@property
def replies(self) -> QuerySetType[RequestMessage]:
return RequestMessage.objects.filter(object_id=self.id, content_type=ContentType.objects.get_for_model(self))

def creator_and_reply_users(self) -> List[User]:
result = {self.user}
for reply in self.replies:
result.add(reply.author)
return list(result)

def __str__(self):
return f"StaffAssistanceRequest [{self.id}]"


class AdjustmentRequest(BaseModel):
creation_time = models.DateTimeField(auto_now_add=True, help_text="The date and time when the request was created.")
creator = models.ForeignKey("User", related_name="adjustment_requests_created", on_delete=models.CASCADE)
Expand Down
31 changes: 18 additions & 13 deletions NEMO/static/nemo.css
Original file line number Diff line number Diff line change
Expand Up @@ -801,57 +801,58 @@ li.area-tree-node a, li.area-tree-node a:hover, li.area-tree-node a:focus
padding-right: 10px;
}

.buddy-system-requests
.buddy-system-requests, .staff-assistance-requests
{
margin-top: 20px;
}

.buddy-list
.buddy-list, .staff-assistance-list
{
margin-top: 10px;
}

.buddy-list-item
.buddy-list-item, .staff-assistance-list-item
{
display: table;
width: 100%;
margin-bottom: 5px;
}

.buddy-list-item:first-child
.buddy-list-item:first-child, .staff-assistance-list-item:first-child
{
margin-top: 10px;
}

.buddy-list-item-reply
.buddy-list-item-reply, .staff-assistance-list-item-reply
{
margin-top: 5px;
}

.buddy-list-item-reply textarea
.buddy-list-item-reply textarea, .staff-assistance-list-item-reply textarea
{
padding: 10px;
}

.buddy-list-item-description, .buddy-list-item-buttons
.buddy-list-item-description, .buddy-list-item-buttons, .staff-assistance-list-item-description, .staff-assistance-list-item-buttons
{
display: table-cell;
word-break: break-word;
padding: 10px;
}

.buddy-list-item-reply textarea, .buddy-list .buddy-list-item.list-group-item-info
.buddy-list-item-reply textarea, .buddy-list .buddy-list-item.list-group-item-info, .staff-assistance-list-item-reply textarea, .staff-assistance-list .staff-assistance-list-item.list-group-item-info
{
border-radius: 8px;
}

.buddy-list-item-buttons
.buddy-list-item-buttons, .staff-assistance-list-item-buttons
{
vertical-align: middle;
text-align: right;
white-space: nowrap;
}

.buddy-list-item-reply, .buddy-list-item-message
.buddy-list-item-reply, .buddy-list-item-message, .staff-assistance-list-item-reply, .staff-assistance-list-item-message
{
float: right;
width: 90%;
Expand All @@ -871,13 +872,13 @@ li.area-tree-node a, li.area-tree-node a:hover, li.area-tree-node a:focus
top: 5px;
}

.buddy-list-item-reply-buttons
.buddy-list-item-reply-buttons, .staff-assistance-list-item-reply-buttons
{
margin: 15px 0;
padding: 0 10px;
}

.buddy-list-day
.buddy-list-day, .staff-assistance-list-day
{
margin-top: 20px;
padding-inline-start: 40px;
Expand Down Expand Up @@ -1216,4 +1217,8 @@ li.area-tree-node a, li.area-tree-node a:hover, li.area-tree-node a:focus
padding: inherit;
text-align: inherit;
border-top: inherit;
}
}

.modal-open[style] {
padding-right: 0 !important;
}
6 changes: 3 additions & 3 deletions NEMO/templates/base/navbar_base.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@
</li>
{% endif %}
{% endif %}
{% if buddy_system_areas_exist or access_user_request_allowed_exist and facility_managers_exist or adjustment_request_allowed and facility_managers_exist %}
{% if buddy_system_areas_exist or access_user_request_allowed_exist and facility_managers_exist or adjustment_request_allowed and facility_managers_exist or staff_assistance_request_allowed %}
<li>
<a href="{% url 'user_requests' %}">
{{ requests_page_title }}
abuckles-uci marked this conversation as resolved.
Show resolved Hide resolved
{% if buddy_notification_count or temporary_access_notification_count or adjustment_notification_count %}
<span class="badge active">{{ buddy_notification_count|add:temporary_access_notification_count|add:adjustment_notification_count }}</span>
{% if buddy_notification_count or temporary_access_notification_count or adjustment_notification_count or staff_assistance_notification_count %}
<span class="badge active">{{ buddy_notification_count|add:temporary_access_notification_count|add:adjustment_notification_count|add:staff_assistance_notification_count }}</span>
{% endif %}
</a>
</li>
Expand Down
Loading