Beispiel #1
0
def add_post_data(request, add_type):
    """
    Add Type is passed via the URI
    Valid Types and actions are:
        campaign - new, update
        template - new, update
        recipient - new, update
    """

    # Add Campaign
    if add_type == 'campaign':
        action = request.POST['action']
        campaign_name = request.POST['c_name']
        campaign_description = request.POST['c_desc']
        campaign_template = request.POST['c_template']

        if action == 'new':
            campaign = Campaign()
        elif action == 'update':
            campaign = Campaign.objects.get(pk=campaign_id)
        else:
            error_line = "Not a Valid Campaign Action"

        campaign.name = campaign_name
        campaign.description = campaign_description
        campaign.template_id = campaign_template
        campaign.created = timezone.now()

        campaign.save()
        campaign_id = campaign.id
        return redirect('/campaign/{0}'.format(campaign_id))

    # Add Recipients
    if add_type == 'recipient':
        action = request.POST['action']
        campaign_id = request.POST['c_id']
        campaign = Campaign.objects.get(pk=campaign_id)
        csv_file = request.FILES
        real_name = request.POST['real_name']
        email_add = request.POST['email_add']

        # check for CSV File - Override single email add
        if csv_file and action == 'new':
            csv_file = csv_file['css_import']
            recipients = []
            try:
                csv_data = csv_file.read()
                csv_date = csv_data.replace('\r', '')
                lines = csv_data.split('\n')
                with transaction.commit_on_success():
                    for line in lines:
                        if len(line) > 10:
                            uid = ''.join([
                                random.choice(string.ascii_letters +
                                              string.digits) for n in xrange(8)
                            ])
                            real_name, email_add = line.split(',')
                            recipient = Recipient(real_name=real_name,
                                                  email_address=email_add,
                                                  campaign=campaign,
                                                  uid=uid)
                            recipient.save()
            except Exception as e:
                error_line = "Unable to parse CSV File - {0}".format(e)
                return render(request, 'error.html', {'error': error_line})
        # Check for single Entry
        elif real_name and email_add:
            uid = ''.join([
                random.choice(string.ascii_letters + string.digits)
                for n in xrange(8)
            ])
            recipient = Recipient(real_name=real_name,
                                  email_address=email_add,
                                  campaign=campaign,
                                  uid=uid)
            recipient.save()
        else:
            error = "Unable to Add recipients"
            return render(request, 'error.html', {'error': error_line})
        return redirect('/campaign/{0}/#tracking'.format(campaign_id))

    # Add / Update Templates
    if add_type == 'template':
        # Details
        template_id = request.POST['id']
        title = request.POST['title']
        description = request.POST['description']

        # Email
        display_name = request.POST['display_name']
        email_address = request.POST['email_address']
        subject_line = request.POST['subject_line']
        smtp_id = request.POST['smtp_id']
        email_design = request.POST['email_design']

        # Word Document
        document_name = request.POST['document_name']
        try:
            document_enable = request.POST['document_enable']
            document_enable = 1
        except:
            document_enable = 0
        document_design = request.POST['document_design']

        # Portal
        portal_uri = request.POST['portal_uri']
        try:
            portal_plugins = request.POST['portal_plugin']
            portal_plugins = 1
        except:
            portal_plugins = 0
        portal_design = request.POST['portal_design']
        portal_redirect = request.POST['portal_redirect']

        action = request.POST['action']

        # Process The Post Data
        if action == 'delete':
            # return here
            pass

        if action == 'new':
            template = Template()
        if action == 'update':
            template = Template.objects.get(pk=template_id)

        smtp_server = SMTPServer.objects.get(pk=smtp_id)

        template.title = title
        template.description = description
        template.display_name = display_name
        template.email_address = email_address
        template.subject_line = subject_line
        template.smtpServer = smtp_server
        template.email_design = email_design
        template.portal_uri = portal_uri
        template.portal_plugins = portal_plugins
        template.portal_design = portal_design
        template.portal_redirect = portal_redirect
        template.document_enable = document_enable
        template.document_name = document_name
        template.document_design = document_design
        template.save()
        template_id = template.id
        return redirect('/template/{0}'.format(template_id))

    error_line = "Not a Valid POST Request"
    return render(request, 'error.html', {'error': error_line})
Beispiel #2
0
company_domain = 'companyname.com' # This forms the email address
company_size = 452

os_list = ['Android', 'BlackBerry OS', 'IOS', 'Windows XP', 'Windows 7', 'Windows 8.1']
browser_list = ['Chrome 27.0.1453', 'Chrome 43.0.2357', 'Chrome 32.0.1489', 'IE 6.0.0', 'IE 7.0.0', 'IE 8.0.0', 'IE 9.0.0', 'IE 10.0.0', 'IE 11.0.0']
reader_list = ['null', '', '10.1.13', '11.0.8', '9.3.0', '9.2.3', '11.0.4', '10.1.2', '9.0.0']
flash_list = ['null', '', '18.0.0.161', '13.0.0.292', '15.0.0.189', '16.0.0.257']
java_list = ['null', '', '1.7.0.60', '1.7.0.13', '1.6.0.22', '1.6.0.37', '1.7.0.15', '1.8.0.22']
silver_list = ['null', '', '', '3.0', '3.5', '4.5.1', '', '']
shock_list = ['null', '', '', '12.0.0.112', '12.0.6.147', '8.0.205', '9.0.432', '10.1.1.016']
doc_list = ['Office 2003', 'Office 2007', 'Office 2010', 'Office 2013']
email_list = ['Outlook 2003', 'Outlook 2007', 'Outlook 2010', 'Outlook 2013']

# Create a Campaign
campaign = Campaign()
campaign.name = 'This is another test campaign'
campaign.description = 'This is another test description'
campaign.template_id = '2'
campaign.created = fake.date_time_between(start_date="-3d", end_date="-2d")
campaign.start_data = fake.date_time_between(start_date="-3d", end_date="-2d")
campaign.save()

# Create Recipients
for i in range(company_size):

    full_name = fake.name()
    email_add = '{0}@{1}'.format(full_name.replace(' ', '.'), company_domain)
    uid = ''.join([random.choice(string.ascii_letters + string.digits) for n in xrange(8)])
    
    # Create a recipient
    recipient = Recipient()
Beispiel #3
0
]
java_list = [
    'null', '', '1.7.0.60', '1.7.0.13', '1.6.0.22', '1.6.0.37', '1.7.0.15',
    '1.8.0.22'
]
silver_list = ['null', '', '', '3.0', '3.5', '4.5.1', '', '']
shock_list = [
    'null', '', '', '12.0.0.112', '12.0.6.147', '8.0.205', '9.0.432',
    '10.1.1.016'
]
doc_list = ['Office 2003', 'Office 2007', 'Office 2010', 'Office 2013']
email_list = ['Outlook 2003', 'Outlook 2007', 'Outlook 2010', 'Outlook 2013']

# Create a Campaign
campaign = Campaign()
campaign.name = 'This is another test campaign'
campaign.description = 'This is another test description'
campaign.template_id = '2'
campaign.created = fake.date_time_between(start_date="-3d", end_date="-2d")
campaign.start_data = fake.date_time_between(start_date="-3d", end_date="-2d")
campaign.save()

# Create Recipients
for i in range(company_size):

    full_name = fake.name()
    email_add = '{0}@{1}'.format(full_name.replace(' ', '.'), company_domain)
    uid = ''.join([
        random.choice(string.ascii_letters + string.digits) for n in xrange(8)
    ])
Beispiel #4
0
def add_post_data(request, add_type):
    """
    Add Type is passed via the URI
    Valid Types and actions are:
        campaign - new, update
        template - new, update
        recipient - new, update
    """
    
    # Add Campaign
    if add_type == 'campaign':
        action = request.POST['action']
        campaign_name = request.POST['c_name']
        campaign_description = request.POST['c_desc']
        campaign_template = request.POST['c_template']

        if action == 'new':
            campaign = Campaign()
        elif action == 'update':
            campaign = Campaign.objects.get(pk=campaign_id)
        else:
            error_line = "Not a Valid Campaign Action"
            
        campaign.name = campaign_name
        campaign.description = campaign_description
        campaign.template_id = campaign_template
        campaign.created = timezone.now()

        campaign.save()
        campaign_id = campaign.id
        return redirect('/campaign/{0}'.format(campaign_id))
        
    # Add Recipients
    if add_type == 'recipient':
        action = request.POST['action']
        campaign_id = request.POST['c_id']
        campaign = Campaign.objects.get(pk=campaign_id)
        csv_file = request.FILES
        real_name = request.POST['real_name']
        email_add = request.POST['email_add']
        
        # check for CSV File - Override single email add
        if csv_file and action == 'new':
            csv_file = csv_file['css_import']
            recipients = []
            try:
                csv_data = csv_file.read()
                csv_date = csv_data.replace('\r', '')
                lines = csv_data.split('\n')
                with transaction.commit_on_success():
                    for line in lines:
                        if len(line) > 10:
                            uid = ''.join([random.choice(string.ascii_letters + string.digits) for n in xrange(8)])
                            real_name, email_add = line.split(',')
                            recipient = Recipient(real_name=real_name, email_address=email_add, campaign=campaign, uid=uid)
                            recipient.save()
            except Exception as e:
                error_line = "Unable to parse CSV File - {0}".format(e)
                return render(request, 'error.html', {'error':error_line})
        # Check for single Entry
        elif real_name and email_add:
            uid = ''.join([random.choice(string.ascii_letters + string.digits) for n in xrange(8)])
            recipient = Recipient(real_name=real_name, email_address=email_add, campaign=campaign, uid=uid)
            recipient.save()
        else:
            error = "Unable to Add recipients"
            return render(request, 'error.html', {'error':error_line})
        return redirect('/campaign/{0}/#tracking'.format(campaign_id))
            
        
    
    # Add / Update Templates
    if add_type == 'template':
        # Details
        template_id = request.POST['id']
        title = request.POST['title']
        description = request.POST['description']
        
        # Email
        display_name = request.POST['display_name']
        email_address = request.POST['email_address']
        subject_line = request.POST['subject_line']
        smtp_id = request.POST['smtp_id']
        email_design = request.POST['email_design']
        
        # Word Document
        document_name = request.POST['document_name']
        try:
            document_enable = request.POST['document_enable']
            document_enable = 1
        except:
            document_enable = 0
        document_design = request.POST['document_design']
        
        # Portal
        portal_uri = request.POST['portal_uri']
        try:
            portal_plugins = request.POST['portal_plugin']
            portal_plugins = 1
        except:
            portal_plugins = 0
        portal_design = request.POST['portal_design']
        portal_redirect = request.POST['portal_redirect']
        
        action = request.POST['action']
        
        # Process The Post Data
        if action == 'delete':
            # return here
            pass
        
        if action == 'new':
            template = Template()
        if action == 'update':
            template = Template.objects.get(pk=template_id)
        
        smtp_server = SMTPServer.objects.get(pk=smtp_id)
        
        template.title = title
        template.description = description
        template.display_name = display_name
        template.email_address = email_address
        template.subject_line = subject_line
        template.smtpServer = smtp_server
        template.email_design = email_design
        template.portal_uri = portal_uri
        template.portal_plugins = portal_plugins
        template.portal_design = portal_design
        template.portal_redirect = portal_redirect
        template.document_enable = document_enable
        template.document_name = document_name
        template.document_design = document_design
        template.save()
        template_id = template.id
        return redirect('/template/{0}'.format(template_id))

    error_line = "Not a Valid POST Request"
    return render(request, 'error.html', {'error':error_line})