def done(self, form_list, **kwargs): # return HttpResponse([form.cleaned_data for form in form_list]) event = Event.event_mg.consume_workorder_formwiz(form_list, self) # return HttpResponseRedirect(reverse('events.views.my.myeventdetail',args=(event.id,))) email_body = "You have successfully submitted an event titled %s" % event.event_name email = DLEG(subject="New Event Submitted", to_emails=[event.contact.email], body=email_body, bcc=[settings.EMAIL_TARGET_VP]) email.send() if event.projection: email_bodyp = 'The event "%s" has a request for projection' % event.event_name emailp = DLEG(subject="New Event Submitted w/ Projection", to_emails=[settings.EMAIL_TARGET_HP], body=email_bodyp) emailp.send() context = RequestContext(self.request) return render(self.request, 'wizard_finished.html', context)
def reviewremind(request, id, uid): context = {} event = get_object_or_404(Event, pk=id) if event.closed or event.reviewed: return HttpResponse("Event Closed") cci = event.ccinstances.filter(crew_chief_id=uid) if cci: # only do heavy lifting if we need to pdf_handle = generate_pdfs_standalone([event.id]) filename = "%s.workorder.pdf" % slugify(event.event_name) attachments = [{"file_handle": pdf_handle, "name": filename}] cci = cci[0] ReportReminder.objects.create(event=cci.event, crew_chief=cci.crew_chief) email_body = 'This is a reminder that you have a pending crew chief report for "%s" \n' \ ' Please Visit %s%s to complete it' % (event.event_name, request.get_host(), reverse("my-ccreport", args=[event.id])) email = DLEG(subject="LNL Crew Chief Report Reminder Email", to_emails=[cci.crew_chief.email], body=email_body, attachments=attachments) email.send() messages.add_message(request, messages.INFO, 'Reminder Sent') return HttpResponseRedirect(reverse('event-review', args=(event.id,))) else: return HttpResponse("Bad Call")
def email_cc_notification(sender, instance, created, raw=False, **kwargs): """ Sends an email to a crew cheif to notify them of being made one """ if created and not raw: i = instance # generate our pdf event = i.event pdf_handle = generate_pdfs_standalone([event.id]) filename = "%s.workorder.pdf" % slugify(event.event_name) attachments = [{"file_handle": pdf_handle, "name": filename}] local = timezone.localtime(i.setup_start) local_formatted = local.strftime("%A %B %d at %I:%M %p") email_body = """ You\'ve been added as a crew chief to the event "%s". \n You have signed up to be crew chief for %s, with your setup starting on %s in the %s \n \n Please note that the attached Workorder PDF contains all services relating to the event, not just your assigned service. """ % ( i.event.event_name, i.service, local_formatted, i.setup_location, ) e = DLEG(subject="Crew Chief Add Notification", to_emails=[instance.crew_chief.email], body=email_body, attachments=attachments) e.send()
def initial_user_create_notify(sender, instance, created, raw=False, **kwargs): if created and not raw: i = instance email_body = """ A new user has joined LNLDB: %s (%s) """ % (i.username, i.email) e = DLEG(subject="LNL User Joined", to_emails=[settings.EMAIL_TARGET_S], body=email_body) e.send()
def email_billing_create(sender, instance, created, raw=False, **kwargs): """ Sends an email to the client to notify of a bill being created """ if created and not instance.opt_out_initial_email and not raw: i = instance email_body = """ A New LNL bill has been posted for "%s" on %s for the amount of $%s """ % (i.event.event_name, i.date_billed, i.amount) e = DLEG(subject="LNL Billing Create Notification", to_emails=[i.event.contact.email], body=email_body, bcc=[settings.EMAIL_TARGET_T]) e.send()
def email_billing_marked_paid(sender, instance, created, raw=False, **kwargs): """ Sends an email to the client to notify of a bill having been paid """ if not created and not raw: if instance.date_paid and not instance.opt_out_update_email: i = instance email_body = """ Thank you for paying the bill for "%s" on %s for the amount of $%s """ % (i.event.event_name, i.date_paid, i.amount) e = DLEG(subject="LNL Billing Paid Notification", to_emails=[i.event.contact.email], body=email_body, bcc=[settings.EMAIL_TARGET_T]) e.send()
def email_billing_delete(sender, instance, **kwargs): if not instance.opt_out_update_email: i = instance email_body = """ The bill for the amount of $%s on "%s" has been deleted """ % ( i.amount, i.event.event_name, ) e = DLEG(subject="LNL Billing Deletion Notification", to_emails=[i.event.contact.email], body=email_body, bcc=[settings.EMAIL_TARGET_T]) e.send()
def denial(request, id): context = {} context['msg'] = "Deny Event" event = get_object_or_404(Event, pk=id) if not request.user.has_perm('events.deny_event', event): raise PermissionDenied if event.cancelled: messages.add_message(request, messages.INFO, 'Event has already been cancelled!') return HttpResponseRedirect(reverse('events.views.flow.viewevent', args=(event.id,))) if request.method == 'POST': form = EventDenialForm(request.POST, instance=event) if form.is_valid(): e = form.save(commit=False) e.cancelled = True e.cancelled_on = timezone.now() e.cancelled_by = request.user e.closed_by = request.user e.closed_on = timezone.now() e.save() # confirm with user messages.add_message(request, messages.INFO, 'Denied Event') if e.contact and e.contact.email: email_body = '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]) email.send() else: messages.add_message(request, messages.INFO, 'No contact info on file for denial. Please give them the bad news.') return HttpResponseRedirect(reverse('events.views.flow.viewevent', args=(e.id,))) else: context['formset'] = form else: form = EventDenialForm(instance=event) context['formset'] = form return render(request, 'form_crispy.html', context)