Example #1
0
def send_new_ticket_reminder(ticket, support_plan, notify_email=False):

    context = {
        'ticket': ticket,
        'ticket_link': generate_ticket_url(ticket),
        'support_plan': support_plan
    }

    log_message = 'New Ticket Reminder to Staff Sent, Ticket: {}, Support Plan: {}, Issue Type: {}, Time passed: {}'

    log_emails(log_message.format(
        ticket.id, support_plan, ticket.issue_type, timezone.now() - ticket.last_updated_at
    ))

    if notify_email:

        send_email(
            subject_template_name='emails/reminders/new_ticket_reminder_subject.txt',
            email_template_name='emails/reminders/new_ticket_reminder.txt',
            to_email=settings.RECIPIENT_NEW_NOTIFICATIONS,
            context=context,
            html_email_template_name='emails/reminders/new_ticket_reminder.html',
            bcc=settings.DEFAULT_RECIPIENT_IDLE_TICKET_REMINDERS
        )

        ticket.last_notification_sent = timezone.now()
        ticket.save()
Example #2
0
def notify_company_admin(new_user):

    company_emails = UserProfile.objects.filter(
        is_company_admin=True).values_list('email', flat=True)
    email_suffixes = {email.split('@')[1]: email for email in company_emails}

    if new_user.email.split('@')[1] in email_suffixes.keys(
    ) and new_user.email.split('@')[1] not in [
            'gmail.com', 'yahoo.com', 'hotmail.com'
    ]:

        to_email = email_suffixes[new_user.email.split('@')[1]]
        admin = UserProfile.objects.get(email=to_email)

        send_mail(
            subject_template_name=
            'emails/new_user/new_user_company_admin_subject.txt',
            email_template_name='emails/new_user/new_user_company_admin.txt',
            to_email=to_email,
            context={
                'user': new_user,
                'admin': admin
            },
            html_email_template_name=
            'emails/new_user/new_user_company_admin.html',
            bcc=settings.BCC)

        log_emails(
            u'Alert Sent: Notify Company Admin about new user, New user: {}, Admin: {}, Added: {}'
            .format(new_user, to_email, timezone.now()))
Example #3
0
def send_idle_ticket_reminder_user(ticket, notify_email=False):

    context = {
        'ticket': ticket,
        'ticket_link': generate_ticket_url(ticket),
        'time_passed': format_timedelta(timezone.now() - ticket.date_modified),
        'unsubscribe_link': generate_unubscribe_link(ticket),
        'close_ticket_link': '{}{}'.format(get_base_url(), reverse('close_ticket', kwargs={'id': ticket.id}))
    }

    log_message = u'Idle Ticket Reminder to User Sent, Ticket: {}, Recipient: {}, Time passed: {}'

    log_emails(log_message.format(ticket.id, ticket.owned_by, timezone.now() - ticket.last_updated_at))

    if notify_email:

        send_email(
            subject_template_name='emails/reminders/idle_ticket_reminder_user_subject.txt',
            email_template_name='emails/reminders/idle_ticket_reminder_user.txt',
            to_email=ticket.owned_by.email,
            context=context,
            html_email_template_name='emails/reminders/idle_ticket_reminder_user.html',
            bcc=settings.DEFAULT_RECIPIENT_IDLE_TICKET_REMINDERS
        )

        ticket.last_notification_sent = timezone.now()
        ticket.save()
Example #4
0
def track_sent_emails(user, alert_type, emails):

    if not isinstance(emails, list):
        emails = [emails]

    log_message = 'Alert Sent: {}, User: {}, Recipient(s): {}, Added: {}'

    log_message = log_message.format(alert_type, user.id, emails,
                                     timezone.now())

    log_emails(log_message)
Example #5
0
def send_new_partner_notification(partner, client, company_admin):

    company_members = partner.named_users.all().values_list('email', flat=True)

    to_emails = [c for c in company_members]

    context = {'company': client.name, 'company_admin': company_admin}

    send_mail(
        subject_template_name='emails/partnership/new_partnership_subject.txt',
        email_template_name='emails/partnership/new_partnership.txt',
        to_email=to_emails,
        context=context,
        html_email_template_name='emails/partnership/new_partnership.html')
    log_emails(
        u'Alert Sent: send_new_partner_notification, Recipient(s): {}, Added: {}'
        .format(to_emails, timezone.now()))
Example #6
0
def send_invitation(invitation):

    existing = email_exists(invitation.email)

    if existing:

        invitation_link = '{}://{}{}?next={}'.format(
            settings.PROTOCOL,
            Site.objects.get_current().domain,
            reverse('social:begin', args=['gluu']),
            reverse('profile:accept-invite',
                    kwargs={'activation_key': invitation.activation_key}))

    else:

        invitation_link = '{}://{}{}'.format(
            settings.PROTOCOL,
            Site.objects.get_current().domain,
            reverse('profile:register-named',
                    kwargs={'activation_key': invitation.activation_key}),
        )

    context = {
        'name': invitation.invited_by.get_full_name(),
        'invited_by': invitation.invited_by.get_full_name(),
        'company': invitation.invited_by.company_association.name,
        'invitation_link': invitation_link,
        'existing': existing
    }
    try:
        account = UserProfile.objects.get(email=invitation.email)
        if (account.first_name != ""):
            context['fname'] = account.first_name
    except UserProfile.DoesNotExist:
        pass
    send_mail(subject_template_name='emails/invite/invite_named_subject.txt',
              email_template_name='emails/invite/invite_named.txt',
              to_email=invitation.email,
              context=context,
              html_email_template_name='emails/invite/invite_named.html',
              bcc=settings.BCC)
    log_emails(
        u'Alert Sent: send_invitation, Recipient(s): {}, Added: {}'.format(
            invitation.email, timezone.now()))
Example #7
0
    def handle(self, *args, **options):

        if options['notify_email']:
            notify_email = True
        else:
            notify_email = False

        tickets = Ticket.objects.filter(status__in=['new', 'assigned'],
                                        is_deleted=False,
                                        issue_type='')

        for ticket in tickets:

            if not ticket.owned_by.is_basic:
                log_emails(
                    'New Ticket Reminder Basic: Ticket not owned by basic user {}'
                    .format(ticket.id), 'ERROR')
                continue

            if ticket.last_updated_at < timezone.now() - timedelta(hours=96):
                send_new_ticket_reminder_basic(ticket, notify_email)
Example #8
0
    def handle(self, *args, **options):

        if options['notify_email']:
            notify_email = True
        else:
            notify_email = False

        tickets = Ticket.objects.filter(
            status__in=['new', 'assigned'],
            issue_type='outage',
            is_deleted=False
        )

        for ticket in tickets:

            if ticket.owned_by.is_admin:
                continue

            if ticket.owned_by.is_basic:
                log_emails('New Ticket Reminder: Ticket with issue type by basic user {}'.format(
                    ticket.id), 'ERROR')
                continue

            support_plan = get_support_plan(ticket.owned_by)

            if not support_plan or not support_plan['support_plan']:
                log_emails('New Ticket Reminder Outage: No support plan found for {}'.format(
                    ticket.owned_by.get_company()), 'ERROR')
                continue

            if support_plan['managed_service'] == 1:
                support_plan = 'Enterprise'
            else:
                support_plan = support_plan['support_plan']

            sla_time_delta = SLA_MATRIX_NEW[support_plan]['outage']

            if ticket.last_updated_at < timezone.now() - timedelta(minutes=sla_time_delta):
                send_new_ticket_reminder(ticket, support_plan, notify_email)
Example #9
0
def send_new_ticket_reminder_basic(ticket, notify_email=False):

    context = {
        'ticket': ticket,
        'ticket_link': generate_ticket_url(ticket)
    }

    log_message = 'New Ticket Reminder for community user to Staff Sent, Ticket: {}, Time passed: {}'

    log_emails(log_message.format(ticket.id, timezone.now() - ticket.last_updated_at))

    if notify_email:

        send_email(
            subject_template_name='emails/reminders/new_ticket_reminder_basic_subject.txt',
            email_template_name='emails/reminders/new_ticket_reminder_basic.txt',
            to_email=settings.RECIPIENT_NEW_NOTIFICATIONS,
            context=context,
            html_email_template_name='emails/reminders/new_ticket_reminder_basic.html',
            bcc=settings.DEFAULT_RECIPIENT_IDLE_TICKET_REMINDERS
        )

        ticket.last_notification_sent = timezone.now()
        ticket.save()