Beispiel #1
0
    def test_email_report_form(self):
        data = {'multiple_email': '[email protected],xyzlocalhost.com'}
        form = EmailReportForm(self.user, data)
        self.assertFalse(form.is_valid())
        self.assertEqual(form["multiple_email"].errors,
            ['xyzlocalhost.com is not a valid e-mail address.'])

        data = {'multiple_email': '[email protected],[email protected]'}
        form = EmailReportForm(self.user, data)
        self.assertTrue(form.is_valid())
Beispiel #2
0
def mail_report(request):
    """Mail Report Template

    **Attributes**:

        * ``template`` - cdr/mail_report.html
        * ``form`` - MailreportForm

    **Logic Description**:

        get top 10 calls Postgresql & hangup / country analytic
        to generate mail report
    """
    logging.debug('CDR mail report view start')

    msg = ''
    if not hasattr(request.user, 'userprofile'):
        form = None
    else:
        form = EmailReportForm(request.user,
                               request.POST or None,
                               instance=request.user.userprofile)
        if form.is_valid():
            form.save()
            msg = _('email ids are saved successfully.')

    mail_data = get_cdr_mail_report(request.user)

    data = {
        'yesterday_date': mail_data['yesterday_date'],
        'rows': mail_data['rows'],
        'form': form,
        'total_duration': mail_data['total_duration'],
        'total_calls': mail_data['total_calls'],
        'total_buy_cost': mail_data['total_buy_cost'],
        'total_sell_cost': mail_data['total_sell_cost'],
        'metric_aggr': mail_data['metric_aggr'],
        'country_data': mail_data['country_data'],
        'hangup_cause_data': mail_data['hangup_cause_data'],
        'msg': msg,
    }
    return render_to_response('cdr/mail_report.html',
                              data,
                              context_instance=RequestContext(request))
Beispiel #3
0
def mail_report(request):
    """Mail Report Template

    **Attributes**:

        * ``template`` - cdr/mail_report.html
        * ``form`` - MailreportForm

    **Logic Description**:

        get top 10 calls Postgresql & hangup / country analytic
        to generate mail report
    """
    logging.debug('CDR mail report view start')

    msg = ''
    if not hasattr(request.user, 'userprofile'):
        form = None
    else:
        form = EmailReportForm(request.user, request.POST or None, instance=request.user.userprofile)
        if form.is_valid():
            form.save()
            msg = _('email ids are saved successfully.')

    mail_data = get_cdr_mail_report(request.user)

    data = {
        'yesterday_date': mail_data['yesterday_date'],
        'rows': mail_data['rows'],
        'form': form,
        'total_duration': mail_data['total_duration'],
        'total_calls': mail_data['total_calls'],
        'total_buy_cost': mail_data['total_buy_cost'],
        'total_sell_cost': mail_data['total_sell_cost'],
        'metric_aggr': mail_data['metric_aggr'],
        'country_data': mail_data['country_data'],
        'hangup_cause_data': mail_data['hangup_cause_data'],
        'msg': msg,
    }
    return render_to_response('cdr/mail_report.html', data, context_instance=RequestContext(request))
Beispiel #4
0
    def test_cdr_mail_report(self):
        """Test Function to check mail report"""
        response = self.client.get('/mail_report/')
        self.assertTrue(response.context['form'], EmailReportForm(self.user))
        self.assertTemplateUsed(response, 'frontend/cdr_mail_report.html')
        self.assertEqual(response.status_code, 200)

        data = {'multiple_email': '[email protected],xyzlocalhost.com'}
        request = self.factory.post('/mail_report/', data)
        request.user = self.user
        request.session = {}
        response = mail_report(request)
        self.assertEqual(response.status_code, 200)
Beispiel #5
0
    def test_email_report_form(self):
        data = {'multiple_email': '[email protected],xyzlocalhost.com'}
        form = EmailReportForm(self.user, data)
        self.assertFalse(form.is_valid())
        self.assertEqual(form["multiple_email"].errors,
                         ['xyzlocalhost.com is not a valid e-mail address.'])

        data = {'multiple_email': '[email protected],[email protected]'}
        form = EmailReportForm(self.user, data)
        self.assertTrue(form.is_valid())