def send_verification_passed_email(self, email, company_rek_id):
        action = create_action_id(actions.INVOICE_VERIFICATION_PASSED, company_rek_id)

        plain_text = render_to_string('mails/verified_through_invoice.txt')
        html = render_to_string('mails/verified_through_invoice.html')

        notification_manager.add(action, email, 'Ваша компания успешно прошла верификацию в Реквизитке', plain_text, html, 1)
Exemple #2
0
    def post(self, request):
        form = FeedbackForm(request.POST, request.FILES)
        if form.is_valid():
            user_email = form.cleaned_data['email']
            msg = form.cleaned_data['msg']

            if form.cleaned_data['extra_field'] == get_token(request):
                mail_to = '*****@*****.**'

                browser_info = u'IP адрес: %s, браузер: %s, дата: %s' % (request.META['HTTP_HOST'], request.META['HTTP_USER_AGENT'], date.today().strftime("%d.%m.%Y"))
                user_info=''
                if request.user.is_authenticated():
                    user_info=u'Пользователь ID:%s %s' % (unicode(request.user.id), request.user.email)

                plain_text = render_to_string('mail/feedback.txt', { 'text':msg,
                                                                     'user_email':user_email,
                                                                     'browser_info':browser_info,
                                                                     'user_info':user_info },
                                              context_instance=RequestContext(request))

                subject, from_email, to, bcc = 'Сообщение в службу поддержки Rekvizitka.Ru', settings.EMAIL_HOST_USER, [mail_to,],[]

                action = create_action_id(FEEDBACK_SENT, randint(1, 10000))
                notification_manager.add(action, mail_to, subject, plain_text, plain_text, 10)

                result_json = simplejson.dumps({'error' : False})
                return HttpResponse(mark_safe(result_json))

        result_json = simplejson.dumps({'error' : True})
        return HttpResponse(mark_safe(result_json))
Exemple #3
0
    def test_deferred_notifications_task_send_two(self):
        action = create_action_id(actions.CONFIRM_NEW_EMPLOYEE, 123)
        notification_manager.add(action, '*****@*****.**', 'subj',
                                 'text', 'html', 0)
        notification_manager.add(action, '*****@*****.**', 'subj2',
                                 'text', 'html', 0)

        notifications = Notification.objects.get({
            'is_sent': False,
            'send_date': {
                '$lte': timezone.now()
            }
        })
        self.assertEqual(len(notifications), 2)

        mail.outbox = []

        task = DeferredNotificationsTask()
        task.execute()

        notifications = Notification.objects.get({
            'is_sent': False,
            'send_date': {
                '$lte': timezone.now()
            }
        })
        self.assertEqual(len(notifications), 0)
        self.assertEqual(len(mail.outbox), 2)
        notifications = Notification.objects.get({'is_sent': True})
        self.assertEqual(len(notifications), 2)
Exemple #4
0
    def send_email(self, user, link_id):
        email = user.email

        mail_context = {'SITE_DOMAIN_NAME' : settings.SITE_DOMAIN_NAME, 'link_id' : unicode(link_id)}

        text = render_to_string('mails/password_reset.txt', dictionary=mail_context)
        html = render_to_string('mails/password_reset.html', dictionary=mail_context)

        action_id = create_action_id(actions.PASSWORD_RECOVERY, email)
        subject = 'Восстановление пароля на Rekvizitka.Ru'
        notification_manager.add(action_id, email, subject, text, html, 0)
    def send_rotten_invoice_notification(self, email, invoice_number, invoice_name, amount, date):
        action = create_action_id(actions.INVOICE_ROTTEN, invoice_number)

        data = {'name' : invoice_name,
                'number' : unicode(invoice_number),
                'amount' : unicode(amount),
                'date' : date.strftime('%d-%m-%Y')}

        plain_text = render_to_string('mails/invoice_rotten.txt', dictionary=data)
        html = render_to_string('mails/invoice_rotten.html', dictionary=data)

        notification_manager.add(action, email, u'Окончание срока действия счета', plain_text, html, 1)
Exemple #6
0
    def send_invitation_message(self, email, invite_id, message, brand_name, cookie_code):
        mail_context = {'text' : message,
                        'brand_name' : brand_name,
                        'join_url' : u"http://%s/invites/join/%s/" % (settings.SITE_DOMAIN_NAME, cookie_code),
                        'main_page_link' : u"http://%s/" % settings.SITE_DOMAIN_NAME }

        subject = 'Вас пригласили в деловую сеть Реквизитка'

        plain_text = render_to_string('mail/invite.txt', dictionary=mail_context)
        html = render_to_string('mail/invite.html', dictionary=mail_context)

        action = create_action_id(INVITATION, invite_id)
        notification_manager.add(action, email, subject, plain_text, html, 0)
Exemple #7
0
    def send_rec_message(self, email, message, rec_id, recipient_rek_id, requester_brand_name):
        mail_context = {'text': message,
                        'company_name' : requester_brand_name,
                        'our_recommendations_url' : "http://%s%s" % (settings.SITE_DOMAIN_NAME,
                                                                     reverse('we_recommend_view', kwargs={'code' : recipient_rek_id}))}
        plain_text_template = get_template('mails/recommended.txt')
        plain_text = plain_text_template.render(Context(mail_context))
        html_template = get_template('mails/recommended.html')
        html = html_template.render(Context(mail_context))
        subject = 'Запрос рекомендации на сайте Rekvizitka.Ru'

        action = create_action_id(RECOMMENDATION_ASKED, rec_id)
        notification_manager.add(action, email, subject, plain_text, html, 120)
Exemple #8
0
    def send_deposit_transaction_msg(self, email, transaction_id, amount):
        action = create_action_id(actions.DEPOSIT_TRANSACTION, transaction_id)

        data = {
            'amount': unicode(amount),
            'SITE_DOMAIN_NAME': settings.SITE_DOMAIN_NAME
        }
        plain_text = render_to_string('mails/popolnenie_deposita.txt', data)
        html = render_to_string('mails/popolnenie_deposita.html', data)

        notification_manager.add(action, email,
                                 'Начисление средств на депозит', plain_text,
                                 html, 1)
Exemple #9
0
    def execute(self):
        print >> sys.stdout, '%s Executing UnreadDialogNotificationTask' % unicode(datetime.now())

        search_ts = get_cts() - cts_from_timedelta(timedelta(hours = 3))
        ts_min = search_ts - cts_from_timedelta(timedelta(days = 3))
        result = self.make_employee_op_collection(search_ts, ts_min)
        if result['ok'] != 1:
            print >> sys.stderr, u'Failed to perform map_reduce during checking unread messages: %s' % repr(result)
            return

        result = self.make_employee_last_ops()
        if result['ok'] != 1:
            print >> sys.stderr, u'Failed to perform map_reduce step 2 during checking unread messages: %s' % repr(result)
            return

        unread_dialogs_cursor = self.find_unsent_messages()

        for unread_data in unread_dialogs_cursor:
            try:
                employee = unread_data['_id']
                if self.is_online(employee):
                    mark_as_sent = Operation({'owner' : employee,
                                              'operation_type' : OperationTypeEnum.OT_EMAIL_SENT,
                                              'data' : {'fake' : True},
                                              'listeners' : [employee],
                                              'is_service' : True})
                    mark_as_sent.save()
                    continue
                email = self.get_employee_email(employee)

                if not email or not is_valid_email(email):
                    continue

                action = create_action_id(actions.UNREAD_DIALOGS, employee)
                subj = u'Непрочитанные сообщения в Реквизитке'

                data = {'SITE_DOMAIN_NAME' : settings.SITE_DOMAIN_NAME}
                text = render_to_string('mail/chat/unread_dialogs.txt', data)
                html = render_to_string('mail/chat/unread_dialogs.html', data)

                notification_manager.remove(action)
                notification_manager.add(action, email, subj, text, html, settings.UNREAD_MESSAGE_EMAIL_NOTIFY_TIMEOUT)
                mark_as_sent = Operation({'owner' : employee,
                                          'operation_type' : OperationTypeEnum.OT_EMAIL_SENT,
                                          'data' : {},
                                          'listeners' : [employee],
                                          'is_service' : True})
                mark_as_sent.save()
            except Exception:
                pass
Exemple #10
0
    def generate_verification_letters(self, email, company_id):
        letters_count = SettingsManager.get_property('verifylettercount')
        interval_days = SettingsManager.get_property('verifyletterdelaydays')
        subject = u"Пройдите верификацию вашей компании в Реквизитке"

        mail_context = {'SITE_DOMAIN_NAME' : settings.SITE_DOMAIN_NAME}

        text = render_to_string('mails/periodic_verify_letter.txt', dictionary=mail_context)
        html = render_to_string('mails/periodic_verify_letter.html', dictionary=mail_context)

        action_id = create_action_id(actions.VERIFICATION_PERIODIC, unicode(company_id))
        for day in xrange(letters_count):
            delay = interval_days * (day + 1) * 60 * 24
            notification_manager.add(action_id, email, subject, text, html, delay)
    def test_deferred_notifications_task_send_one(self):
        action = create_action_id(actions.CONFIRM_NEW_EMPLOYEE, 123)
        notification_manager.add(action, '*****@*****.**', 'subj', 'text', 'html', 0)

        notifications = Notification.objects.get({'is_sent': False, 'send_date': {'$lte': timezone.now()}})
        self.assertEqual(len(notifications), 1)

        mail.outbox = []

        task = DeferredNotificationsTask()
        task.execute()

        notifications = Notification.objects.get({'is_sent': False, 'send_date': {'$lte': timezone.now()}})
        self.assertEqual(len(notifications), 0)
        self.assertEqual(len(mail.outbox), 1)
Exemple #12
0
def send_staff_confirmation_email(email, sender, code):
    mail_context = {'code': code,
                    'sender': sender.full_name,
                    'company' : sender.company.get_name()}

    plain_text_template = get_template('mails/staff_confirm.txt')
    html_template = get_template('mails/staff_confirm.html')

    plain_text = plain_text_template.render(Context(mail_context))
    html = html_template.render(Context(mail_context))

    subject = u'Вас добавили в сотрудники компании %s в деловой сети Rekvizitka.Ru' % mail_context['company']

    action = create_action_id(actions.CONFIRM_NEW_EMPLOYEE, code)
    notification_manager.add(action, email, subject, plain_text, html, 10)
Exemple #13
0
    def send_email(self, user, link_id):
        email = user.email

        mail_context = {
            'SITE_DOMAIN_NAME': settings.SITE_DOMAIN_NAME,
            'link_id': unicode(link_id)
        }

        text = render_to_string('mails/password_reset.txt',
                                dictionary=mail_context)
        html = render_to_string('mails/password_reset.html',
                                dictionary=mail_context)

        action_id = create_action_id(actions.PASSWORD_RECOVERY, email)
        subject = 'Восстановление пароля на Rekvizitka.Ru'
        notification_manager.add(action_id, email, subject, text, html, 0)
Exemple #14
0
    def send_rotten_invoice_notification(self, email, invoice_number,
                                         invoice_name, amount, date):
        action = create_action_id(actions.INVOICE_ROTTEN, invoice_number)

        data = {
            'name': invoice_name,
            'number': unicode(invoice_number),
            'amount': unicode(amount),
            'date': date.strftime('%d-%m-%Y')
        }

        plain_text = render_to_string('mails/invoice_rotten.txt',
                                      dictionary=data)
        html = render_to_string('mails/invoice_rotten.html', dictionary=data)

        notification_manager.add(action, email,
                                 u'Окончание срока действия счета', plain_text,
                                 html, 1)
Exemple #15
0
    def generate_verification_letters(self, email, company_id):
        letters_count = SettingsManager.get_property('verifylettercount')
        interval_days = SettingsManager.get_property('verifyletterdelaydays')
        subject = u"Пройдите верификацию вашей компании в Реквизитке"

        mail_context = {'SITE_DOMAIN_NAME': settings.SITE_DOMAIN_NAME}

        text = render_to_string('mails/periodic_verify_letter.txt',
                                dictionary=mail_context)
        html = render_to_string('mails/periodic_verify_letter.html',
                                dictionary=mail_context)

        action_id = create_action_id(actions.VERIFICATION_PERIODIC,
                                     unicode(company_id))
        for day in xrange(letters_count):
            delay = interval_days * (day + 1) * 60 * 24
            notification_manager.add(action_id, email, subject, text, html,
                                     delay)
Exemple #16
0
def send_staff_confirmation_email(email, sender, code):
    mail_context = {
        'code': code,
        'sender': sender.full_name,
        'company': sender.company.get_name()
    }

    plain_text_template = get_template('mails/staff_confirm.txt')
    html_template = get_template('mails/staff_confirm.html')

    plain_text = plain_text_template.render(Context(mail_context))
    html = html_template.render(Context(mail_context))

    subject = u'Вас добавили в сотрудники компании %s в деловой сети Rekvizitka.Ru' % mail_context[
        'company']

    action = create_action_id(actions.CONFIRM_NEW_EMPLOYEE, code)
    notification_manager.add(action, email, subject, plain_text, html, 10)
    def test_deferred_notifications_task_send_timeout(self):
        action = create_action_id(actions.CONFIRM_NEW_EMPLOYEE, 123)
        notification_manager.add(action, '*****@*****.**', 'subj', 'text', 'html', 10)
        notification_manager.add(action, '*****@*****.**', 'subj2', 'text', 'html', 10)

        notifications = Notification.objects.get({'is_sent': False})
        self.assertEqual(len(notifications), 2)

        mail.outbox = []

        task = DeferredNotificationsTask()
        task.execute()

        notifications = Notification.objects.get({'is_sent': False})
        self.assertEqual(len(notifications), 2)
        self.assertEqual(len(mail.outbox), 0)
        notifications = Notification.objects.get({'is_sent': True})
        self.assertEqual(len(notifications), 0)
Exemple #18
0
    def post(self, request):
        form = FeedbackForm(request.POST, request.FILES)
        if form.is_valid():
            user_email = form.cleaned_data['email']
            msg = form.cleaned_data['msg']

            if form.cleaned_data['extra_field'] == get_token(request):
                mail_to = '*****@*****.**'

                browser_info = u'IP адрес: %s, браузер: %s, дата: %s' % (
                    request.META['HTTP_HOST'], request.META['HTTP_USER_AGENT'],
                    date.today().strftime("%d.%m.%Y"))
                user_info = ''
                if request.user.is_authenticated():
                    user_info = u'Пользователь ID:%s %s' % (unicode(
                        request.user.id), request.user.email)

                plain_text = render_to_string(
                    'mail/feedback.txt', {
                        'text': msg,
                        'user_email': user_email,
                        'browser_info': browser_info,
                        'user_info': user_info
                    },
                    context_instance=RequestContext(request))

                subject, from_email, to, bcc = 'Сообщение в службу поддержки Rekvizitka.Ru', settings.EMAIL_HOST_USER, [
                    mail_to,
                ], []

                action = create_action_id(FEEDBACK_SENT, randint(1, 10000))
                notification_manager.add(action, mail_to, subject, plain_text,
                                         plain_text, 10)

                result_json = simplejson.dumps({'error': False})
                return HttpResponse(mark_safe(result_json))

        result_json = simplejson.dumps({'error': True})
        return HttpResponse(mark_safe(result_json))