Exemplo n.º 1
0
def send_mails_list(post_request):
    receivers = json.loads(post_request['mail_list'])
    for receiver in receivers:
        mail = User.objects.values_list('email',
                                        flat=True).filter(id=receiver['id'])[0]
        body = create_mail_body(post_request, mail, False)
        send_email(mail, body)
Exemplo n.º 2
0
def send_reminders():
    if not testing:
        today = datetime.date.today()
        tomorrow = today + datetime.timedelta(days=1)

        calendar = Article_responsible.objects \
            .filter(article__deadline__lte=tomorrow) \
            .filter(done=False) \
            .filter(is_active=True) \
            .filter(article__is_active=True) \
            .filter(article__order__is_act=True)

        recipients = [{
            'name': item.employee_seat.employee.pip,
            'mail': item.employee_seat.employee.user.email,
            'order_id': item.article.order_id,
            'order_code': item.article.order.code,
            'order_name': item.article.order.name,
            'article': item.article.text,
            'deadline': item.article.deadline,
            'today': item.article.deadline == today,
            'tomorrow': item.article.deadline == tomorrow
        } for item in calendar]

        for recipient in recipients:
            body = create_reminder_body(recipient)
            send_email(recipient['mail'], body)

        secretary_mail = '*****@*****.**'
        secretary_body = create_body_for_secretary(recipients, secretary_mail)
        send_email(secretary_mail, secretary_body)
Exemplo n.º 3
0
def send_provider_mail(type, provider):
    addresses = UserProfile.objects.values_list('user__email', flat=True).filter(providers_add=True)
    if not testing:
        for address in addresses:
            if type == 'new':
                body = create_new_mail_body(provider, address)
            else:
                body = create_change_mail_body(provider, address)
            send_email(address, body)
Exemplo n.º 4
0
def send_acquaints_mails(post_request):
    if not testing:
        acquaints = json.loads(post_request['acquaints'])
        acquaints_mails = []
        for acquaint in acquaints:
            if acquaint['status'] == 'new':
                acquaints_mails.append(get_user_mail(acquaint['id']))

        for mail in acquaints_mails:
            body = create_mail_body(post_request, mail, 'acquaint')
            send_email(mail, body)
Exemplo n.º 5
0
def send_email_answer(doc_request, mail):
    message = MIMEMultipart("alternative")
    message["Subject"] = "Ви отримали відповідь на коментар"
    message["From"] = '*****@*****.**'
    message["To"] = mail

    link = 'Щоб переглянути, перейдіть за посиланням: http://10.10.10.22/edms/my_docs/{}' \
        .format(doc_request['document'])
    text = 'Ви отримали відповідь на коментар до документу № {} ({}). {}' \
        .format(doc_request['document'], doc_request['doc_type_name'], link)

    message.attach(MIMEText(text, "plain"))

    send_email(mail, message.as_string())
Exemplo n.º 6
0
def send_email_new(doc_request, mail, main_field):
    message = MIMEMultipart("alternative")
    message["Subject"] = 'Новий електронний документ – {} "{}"'.format(
        doc_request['doc_type_name'], main_field)
    message["From"] = '*****@*****.**'
    message["To"] = mail

    link = 'Щоб переглянути, перейдіть за посиланням: http://10.10.10.22/edms/my_docs/{}' \
        .format(doc_request['document'])
    text = 'Вашої реакції очікує новий документ ({} "{}", автор: {}). {}' \
        .format(doc_request['doc_type_name'], main_field, doc_request['doc_author_name'], link)

    message.attach(MIMEText(text, "plain"))

    send_email(mail, message.as_string())
Exemplo n.º 7
0
def send_mails(post_request, req_type):
    if not testing:
        correspondence_mail_query_list = list(UserProfile.objects.values_list('user__email').filter(is_correspondence_mail=True))
        correspondence_mail_list = list(sum(correspondence_mail_query_list, ()))

        author_mail = Request.objects.values_list('added_by__email', flat=True).filter(id=post_request['request'])[0]
        responsible_mail = Request.objects.values_list('responsible__email', flat=True).filter(id=post_request['request'])[0]
        answer_responsible_mail = Request.objects.values_list('responsible_id__email', flat=True).filter(id=post_request['request'])[0]

        mails = correspondence_mail_list + [author_mail, responsible_mail, answer_responsible_mail, '*****@*****.**']

        mails_without_duplicates = list(dict.fromkeys(mails))

        for mail in mails_without_duplicates:
            body = create_mail_body(post_request, mail, req_type)
            send_email(mail, body)
Exemplo n.º 8
0
def send_email_mark(doc_request, mail, main_field):
    message = MIMEMultipart("alternative")
    message[
        "Subject"] = 'Нова реакція на Ваш електронний документ – {} "{}"'.format(
            doc_request['doc_type_name'], main_field)
    message["From"] = '*****@*****.**'
    message["To"] = mail

    link = 'Щоб переглянути, перейдіть за посиланням: http://10.10.10.22/edms/my_docs/{}' \
        .format(doc_request['document'])
    text = 'Ваш документ #{} ({}) отримав позначку "{}". Автор позначки: {}. {}' \
        .format(doc_request['document'], doc_request['doc_type_name'],
                doc_request['mark_name'], doc_request['mark_author_name'], link)

    message.attach(MIMEText(text, "plain"))

    send_email(mail, message.as_string())
Exemplo n.º 9
0
def send_email_supervisor(stage, doc_request, mail):
    document_instance = get_object_or_404(Document, pk=doc_request['document'])
    main_field = get_main_field(document_instance)

    message = MIMEMultipart("alternative")
    message["Subject"] = "Створена нова заявка по 1С8. {}" if stage == 'new' \
        else 'Змінився статус заявки по 1С8 "{}" ({})'.format(main_field, stage)
    message["From"] = '*****@*****.**'
    message["To"] = mail

    link = 'Щоб переглянути, перейдіть за посиланням: http://10.10.10.22/edms/my_docs/{}' \
        .format(doc_request['document'])

    if stage == 'new':
        text = 'На внутрішньому сайті ПЛХК опубліковано нову заявку по 1С8 № {} "{}". Автор: {}. {}' \
            .format(doc_request['document'], main_field, doc_request['doc_author_name'], link)
    else:
        text = 'Новий статус заявки по 1С8 № {} "{}" (автор: {}) – "{}". {}' \
            .format(doc_request['document'], main_field, doc_request['doc_author_name'], stage, link)

    message.attach(MIMEText(text, "plain"))

    send_email(mail, message.as_string())
Exemplo n.º 10
0
def send_mails_default(post_request):
    author_mail = User.objects.values_list(
        'email', flat=True).filter(id=post_request['author'])[0]
    article_ids = Order_article.objects.values_list(
        'id', flat=True).filter(order_id=post_request['id'])

    author_body = create_mail_body(post_request, author_mail, False)
    send_email(author_mail, author_body)

    responsible_mails_with_duplicates = Article_responsible.objects.values_list('employee_seat__employee__user__email', flat=True) \
        .filter(article_id__in=article_ids).filter(is_active=True).filter(done=False)
    responsible_mails = list(
        set(responsible_mails_with_duplicates)
    )  # Видаляємо дублікати (якщо хтось є відповідальним по декілька пунктам.
    for mail in responsible_mails:
        responsible_body = create_mail_body(post_request, mail, True)
        send_email(mail, responsible_body)

    supervisory_mail = User.objects.values_list(
        'email', flat=True).filter(id=post_request['supervisory'])[0]
    if supervisory_mail != author_mail:
        supervisory_body = create_mail_body(post_request, supervisory_mail,
                                            False)
        send_email(supervisory_mail, supervisory_body)
Exemplo n.º 11
0
def send_mail(post_request):
    if not testing:
        body = create_mail_body(post_request)
        send_email("*****@*****.**", body)
Exemplo n.º 12
0
def send_mails_everyone(post_request):
    mail = '*****@*****.**'
    body = create_mail_body(post_request, mail, False)

    send_email(mail, body)