Skip to content

Commit

Permalink
Merge branch 'master' into 793-add-lnl-contact-field-to-events
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamin-antupit committed Aug 31, 2023
2 parents b3ee042 + 26c197b commit e8a8f39
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 26 deletions.
2 changes: 0 additions & 2 deletions docs/help/getting-started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ Depending on your level of involvement with LNL the following Quick Links may be
+------------+------------------------------------------------+--------------------+
| Snipe | LNL's equipment inventory management system | Active LNL members |
+------------+------------------------------------------------+--------------------+
| RT | LNL's ticketing system for tracking repairs | Executive Officers |
+------------+------------------------------------------------+--------------------+


Where to Find Help
Expand Down
7 changes: 5 additions & 2 deletions events/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,16 +369,19 @@ def __init__(self, *args, **kwargs):
self.helper.form_class = "form-horizontal"
self.helper.layout = Layout(
Field('cancelled_reason', label="Reason For Cancellation (optional)", css_class="col-md-6"),
HTML('Please note that the reason will be included in the cancellation email to the client. <p />'),
Field('send_email', css_class=""),
HTML('Please note that the reason will be included in the cancellation email to the event contact. <p />'),
FormActions(
Submit('save', 'Deny Event'),
),
)
super(EventDenialForm, self).__init__(*args, **kwargs)

send_email = forms.BooleanField(required=False, label="Send Cancellation Email to Event Contact")

class Meta:
model = BaseEvent
fields = ('cancelled_reason',)
fields = ['cancelled_reason', 'send_email']
widgets = {
'cancelled_reason': PagedownWidget()
}
Expand Down
42 changes: 25 additions & 17 deletions events/views/flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@
DefaultLNLEmailGenerator as DLEG, send_survey_if_necessary)
from slack.views import cc_report_reminder
from slack.api import lookup_user, slack_post
from events.forms import (AttachmentForm, BillingForm, BillingUpdateForm, MultiBillingForm,
from events.forms import (
AttachmentForm, BillingForm, BillingUpdateForm, MultiBillingForm,
MultiBillingUpdateForm, CCIForm, CrewAssign, EventApprovalForm,
EventDenialForm, EventReviewForm, ExtraForm, InternalReportForm, MKHoursForm,
BillingEmailForm, MultiBillingEmailForm, ServiceInstanceForm, WorkdayForm, CrewCheckinForm,
CrewCheckoutForm, CheckoutHoursForm, BulkCheckinForm)
CrewCheckoutForm, CheckoutHoursForm, BulkCheckinForm
)
from events.models import (BaseEvent, Billing, MultiBilling, BillingEmail, MultiBillingEmail, Category, CCReport, Event,
Event2019, EventArbitrary, EventAttachment, EventCCInstance, ExtraInstance, Hours,
ReportReminder, ServiceInstance, PostEventSurvey, CCR_DELTA, CrewAttendanceRecord)
Expand Down Expand Up @@ -80,12 +82,13 @@ def approval(request, id):
e.org.get().associated_users.add(e.contact)
else:
set_revision_comment("Approved", form)

# confirm with user and notify VP
messages.add_message(request, messages.INFO, 'Approved Event: No longer auto notifying clients. Please give them the good news!')
email_body = '"%s" has been approved!' % event.event_name
email = DLEG(subject="Event Approved", to_emails=[settings.EMAIL_TARGET_VP_DB], body=email_body)
email.send()

return HttpResponseRedirect(reverse('events:detail', args=(e.id,)))
else:
context['form'] = form
Expand Down Expand Up @@ -142,15 +145,17 @@ def denial(request, id):
e.save()
# confirm with user
messages.add_message(request, messages.INFO, 'Denied Event')
if e.contact and e.contact.email:
if e.contact and e.contact.email and form.cleaned_data['send_email']:
email_body = 'Sorry, but your event "%s" has been denied. \n Reason: "%s"' % (
event.event_name, event.cancelled_reason)
email = DLEG(subject="Event Denied", to_emails=[e.contact.email], body=email_body,
bcc=[settings.EMAIL_TARGET_VP_DB])
email.send()
else:
elif (not e.contact or not e.contact.email):
messages.add_message(request, messages.INFO,
'No contact info on file for denial. Please give them the bad news.')
'Event Denied. No contact info on file for denial. Please give them the bad news.')
else:
messages.add_message(request, messages.INFO, 'Event Denied. No email sent.')
return HttpResponseRedirect(reverse('events:detail', args=(e.id,)))
form = EventDenialForm(instance=event)
context['form'] = form
Expand Down Expand Up @@ -326,18 +331,21 @@ def cancel(request, id):
event.cancelled_on = timezone.now()
event.save()

if event.contact and event.contact.email:
targets = [event.contact.email]
if request.POST.get('notify', '') == "on":
if event.contact and event.contact.email:
targets = [event.contact.email]
email_body = 'The event "%s" has been cancelled by %s. If this is incorrect, please contact our vice president ' \
'at lnl-vp@wpi.edu.' % (event.event_name, str(request.user))
if request.user.email:
email_body = email_body[:-1]
email_body += " or try them at %s." % request.user.email
email = DLEG(subject="Event Cancelled", to_emails=targets, body=email_body, bcc=[settings.EMAIL_TARGET_VP])
email.send()
messages.add_message(request, messages.INFO, 'Event Closed and Client Notification Sent')
else:
messages.add_message(request, messages.INFO, 'Event Closed. Client email not found. Client has not been notified.')
else:
targets = []

email_body = 'The event "%s" has been cancelled by %s. If this is incorrect, please contact our vice president ' \
'at lnl-vp@wpi.edu.' % (event.event_name, str(request.user))
if request.user.email:
email_body = email_body[:-1]
email_body += " or try them at %s." % request.user.email
email = DLEG(subject="Event Cancelled", to_emails=targets, body=email_body, bcc=[settings.EMAIL_TARGET_VP])
email.send()
messages.add_message(request, messages.INFO, 'Event Closed. Client has not been notified.')
return HttpResponseRedirect(reverse('events:detail', args=(event.id,)))


Expand Down
1 change: 1 addition & 0 deletions requirements_base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,4 @@ django-multiselectfield==0.1.12
drf-spectacular==0.21.0
spotipy==2.19.0
qrcode==7.3.1
levenshtein==0.21.1
3 changes: 0 additions & 3 deletions site_tmpl/admin.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ <h3 class="panel-title">Quick Links</h3>
<a class="btn btn-success" href="https://wpi0.sharepoint.com/sites/gr-lnl-exec/">Exec Sharepoint</a>
{% endif %}
<a class="btn btn-primary" href="https://wpilnl.slack.com/">Slack</a>
{% if request.user.group_str == 'Officer' %}
<a class="btn btn-primary" href="https://lnl-rt.wpi.edu/rt/">RT</a>
{% endif %}
{% permission request.user has 'inventory.view_equipment' %}
<a class="btn btn-primary" href="https://lnl-rt.wpi.edu/snipe/">Snipe</a>
{% endpermission %}
Expand Down
7 changes: 5 additions & 2 deletions site_tmpl/uglydetail.html
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,11 @@ <h3 id="cancelModalLabel">Confirm Cancel Event</h3>
setups/rentals were done.</p>
</div>
<div class="modal-footer">
<button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Go Back</button>
<button class="btn btn-default" style="float:left" data-dismiss="modal" aria-hidden="true">Go Back</button>
<form class="form-inline" action="{% url 'events:cancel' event.id %}" method="post">
{% csrf_token %}
<button class="btn btn-primary" type="submit">Cancel Event</button>
<input type="checkbox" name="notify" id="notify" /> <label for="notify">Notify event contact via email</label>
<button class="btn btn-primary" type="submit" style="margin-left: 12px;">Cancel Event</button>
</form>
</div>
</div>
Expand Down Expand Up @@ -217,7 +218,9 @@ <h3 id="reopenModalLabel">Confirm Reopen Event</h3>
</tr>
<tr>
<th>Event Contact Email</th>

<td><a href="mailto:{{ event.contact.email }}">{{ event.contact.email }}</a></td>

</tr>
<tr>
<th>Location</th>
Expand Down

0 comments on commit e8a8f39

Please sign in to comment.