Beispiel #1
0
def network_account_advertiser_applications_create(request, id=None):
    ''' View to allow Network Admins the ability to create a new Advertiser Organization
        using their AdvertiserApplication as a base template.  This view creates the
        initial User login as well. '''
    from atrinsic.base.models import AdvertiserApplication,Currency,Organization,UserProfile,User,OrganizationContacts,OrganizationPaymentInfo,OrganizationCurrency
    from forms import NetworkAdvertiserEditForm,UserForm
    application = get_object_or_404(AdvertiserApplication, id=id)
    application.company_name = application.organization_name

    if request.method == 'POST':
        form = NetworkAdvertiserEditForm(request.POST)
        user_form = UserForm(request.POST)

        if form.is_valid() and user_form.is_valid():
            if form.cleaned_data["country"] == "CA":
                form.cleaned_data["state"] = form.cleaned_data['province']
            del form.cleaned_data['province']
            del form.cleaned_data['salesperson']
            
            curID = form.cleaned_data['currency']
            del form.cleaned_data['currency']
            org = Organization.objects.create(org_type = ORGTYPE_ADVERTISER, status = ORGSTATUS_TEST, **form.cleaned_data)
            org.save()

            orgCur = OrganizationCurrency.objects.create(advertiser = org, currency = Currency.objects.get(order=curID))
            
            u = User.objects.create(username=user_form.cleaned_data['email'], email=user_form.cleaned_data['email'],
                        first_name=user_form.cleaned_data['first_name'], last_name=user_form.cleaned_data['last_name'])

            u.set_password(user_form.cleaned_data['password'])
            u.save()

            up = UserProfile.objects.create(user=u)
            up.organizations.add(org)
            up.save()

            del form.cleaned_data['show_alias']
            del form.cleaned_data['company_name']
            del form.cleaned_data['company_alias']
            del form.cleaned_data['ticker']
            del form.cleaned_data['is_private']
            del form.cleaned_data['ticker_symbol']
            del form.cleaned_data['vertical']
            del form.cleaned_data['brandlock_key']
            del form.cleaned_data['brandlock']
            
            org_contacts = OrganizationContacts.objects.create(organization=org,firstname=application.contact_firstname, lastname=application.contact_lastname,email=application.contact_email,phone=application.contact_phone,fax=application.contact_fax)
            org_contacts.save()
            
            orgPayeeInfo = OrganizationPaymentInfo(organization=org)
            orgPayeeInfo.save()
            
            # Assign all ADMINLEVEL_ADMINISTRATOR to this
            for up in UserProfile.objects.filter(admin_level=ADMINLEVEL_ADMINISTRATOR):
                up.admin_assigned_organizations.add(org)
                up.save()


            application.delete()
            
            #ACE INSERT IF NO MATCHES ARE FOUND
            matches = search_company(application.organization_name)
            if len(matches) > 0:
                #redirect to new url and template to display list. Chose or create
                return AQ_render_to_response(request, 'network/search-ace.html', {'matches':matches,'orgId':org.id}, context_instance=RequestContext(request))         
            else:
                create_company(org)
                
            #args = {}
            #args["salesrep"] = form.cleaned_data['salesperson']
            #createIO(advertiser, args)
            
            
                                                
            return HttpResponseRedirect('/network/account/advertiser/applications/')
    else:
        #form = OrganizationForm(initial=application.__dict__)
        form = NetworkAdvertiserEditForm(initial=application.__dict__)
        user_form = UserForm(initial= {
                            'first_name' : application.contact_firstname,
                            'last_name' : application.contact_lastname,
                            'email' : application.contact_email,
                        })

    return AQ_render_to_response(request, 'network/advertiser-applications-create.html', {
            'application' : application,
            'form' : form,
            'user_form' :  user_form,
        }, context_instance=RequestContext(request))
Beispiel #2
0
def network_account_publisher_applications_approve(request, id=None):
    ''' View to allow Network Admins the ability to approve a publisher Application '''
    from atrinsic.base.models import Organization,OrganizationContacts
    from django.core.mail import EmailMultiAlternatives
    from forms import TickerForm
    publisher = get_object_or_404(Organization, id=id)
    
    no_email_sent = False
    if publisher.status != ORGSTATUS_LIVE:
        try:
            pubContact = OrganizationContacts.objects.get(email__isnull=False, organization=publisher)
            subject, from_email, to = 'Atrinsic Affiliate Network Publisher Application Status', '*****@*****.**', pubContact.email
            text_content = """
        Dear """ + pubContact.firstname + ' ' + pubContact.lastname + """,
        
        Congratulations!  Your application to the Atrinsic Affiliate Network has been approved.
        
        You may now login to the Atrinsic Affiliate Network http://network.atrinsic.com/accounts/login/ with your username and password created at the time of sign up.  Your username is your email address used at time of sign-up.  If you have forgotten your login password, please visit our login page to reset the password for your account.
        
        You may reset your password at any time by visiting "Settings" and updating your individual password in the "Users" section of the interface.
        
        When you are ready, just follow the three easy steps below:
        
        1.  Join Programs
        Visit "Manage Advertisers" and "Find New Advertisers" to location programs that interest you. Apply for any and all programs that you would like to join. Advertisers will notify you with approval via email.
        
        2.  Create Links
        Once you are approved to partner with Advertiser, log in to your account again. Find the merchant on the "Manage Advertisers" section of the interface.  Select "Get Links" and then, the type of link you would like to place on your website, and copy and paste the appropriate code directly into your site.
        
        3.  Run Reports
        Once Advertiser links are placed in your website, you can login to check your reports at any time to see how your links are performing.
        
        Choose to partner with Advertisers who offer products and services that are most likely to be of interest to your visitors. Once you have chosen appropriate Advertisers, you can increase the likelihood of purchase from your site by placing product, text, banners, product links and content on your site to provide more relevance for visitors.  Use our reports to evaluate your successes, so that you can focus on making all your partnerships work.
        
        Please contact us at [email protected] with any questions as they may arise.
        
        We look forward to a long and successful partnership with you!
        
        
        Warm Regards,
        
        The Atrinsic Affiliate Network Publisher Team
        [email protected]
        """
            html_content = """
        Dear """ + pubContact.firstname + ' ' + pubContact.lastname + """,<br>
        <br>
        Congratulations!  Your application to the Atrinsic Affiliate Network has been approved.<br>
        <br>
        You may now <a href="http://network.atrinsic.com/accounts/login/">login to the Atrinsic Affiliate Network</a> with your username and password created at the time of sign up.  Your username is your email address used at time of sign-up.  If you have forgotten your login password, please visit our login page to reset the password for your account.<br>
        <br>
        You may reset your password at any time by visiting "Settings" and updating your individual password in the "Users" section of the interface.<br>
        <br>
        When you are ready, just follow the three easy steps below:<br>
        <br>
        1.  Join Programs<br>
        Visit "Manage Advertisers" and "Find New Advertisers" to location programs that interest you. Apply for any and all programs that you would like to join. Advertisers will notify you with approval via email.<br>
        <br>
        2.  Create Links<br>
        Once you are approved to partner with Advertiser, log in to your account again. Find the merchant on the "Manage Advertisers" section of the interface.  Select "Get Links" and then, the type of link you would like to place on your website, and copy and paste the appropriate code directly into your site.<br>
        <br>
        3.  Run Reports<br>
        Once Advertiser links are placed in your website, you can login to check your reports at any time to see how your links are performing.<br>
        <br>
        Choose to partner with Advertisers who offer products and services that are most likely to be of interest to your visitors. Once you have chosen appropriate Advertisers, you can increase the likelihood of purchase from your site by placing product, text, banners, product links and content on your site to provide more relevance for visitors.  Use our reports to evaluate your successes, so that you can focus on making all your partnerships work.<br>
        <br>
        Please contact us at <a href="mailto:[email protected]">[email protected]</a> with any questions as they may arise.<br>
        <br>
        We look forward to a long and successful partnership with you!<br>
        <br>
        <br>
        Warm Regards,<br>
        <br>
        The Atrinsic Affiliate Network Publisher Team<br>
        <a href="mailto:[email protected]">[email protected]</a>"""
            
            msg = EmailMultiAlternatives(subject, text_content, from_email, [to])
            msg.attach_alternative(html_content, "text/html")
            msg.send()
        except:
            no_email_sent = True
    
        #create_company(publisher)
        
        publisher.status = ORGSTATUS_LIVE
        publisher.date_joined = datetime.datetime.now()
        publisher.save()
    
    #ACE INSERT IF NO MATCHES ARE FOUND
    matches = search_company(publisher.company_name)
    if len(matches) > 0:
        
        if request.method == 'POST':
            form = TickerForm(request.POST)

        if form.is_valid():
            publisher.ticker = form.cleaned_data['ticker']
            publisher.save()
            
        #redirect to new url and template to display list. Chose or create
        if no_email_sent == True:
            error_msg = 'An error occured when trying to contact the publisher automaticly to advise him of the approval. Please attempt this manualy. This is likely cause by the publisher not entering valid contact info.'
        else:
            error_msg = ''
        
        return AQ_render_to_response(request, 'network/search-ace.html', {
                'matches':matches,
                'orgId':publisher.id,
                'error':error_msg,
            }, context_instance=RequestContext(request))         
    else:
        create_company(publisher)


    if request.method == 'POST':
        form = TickerForm(request.POST)

        if form.is_valid():
            publisher.ticker = form.cleaned_data['ticker']
            publisher.save()

            return HttpResponseRedirect('/network/account/publisher/applications/')

    else:
        form = TickerForm(initial={ 'ticker' : publisher.ticker, })


    if no_email_sent == True:
       return AQ_render_to_response(request, 'network/publisher-applications-deny.html', {
                'publisher' : publisher,
                'error':'An error occured when trying to contact the publisher automaticly to advise him of the approval. Please attempt this manualy. This is likely cause by the publisher not entering valid contact info.',
            }, context_instance=RequestContext(request))
    else:
        return AQ_render_to_response(request, 'network/publisher-applications-approve.html', {
                'publisher' : publisher,
                'form' : form,
            }, context_instance=RequestContext(request))
Beispiel #3
0
def network_account_advertiser_applications_create(request, id=None):
    ''' View to allow Network Admins the ability to create a new Advertiser Organization
        using their AdvertiserApplication as a base template.  This view creates the
        initial User login as well. '''
    from atrinsic.base.models import AdvertiserApplication, Currency, Organization, UserProfile, User, OrganizationContacts, OrganizationPaymentInfo, OrganizationCurrency
    from forms import NetworkAdvertiserEditForm, UserForm
    application = get_object_or_404(AdvertiserApplication, id=id)
    application.company_name = application.organization_name

    if request.method == 'POST':
        form = NetworkAdvertiserEditForm(request.POST)
        user_form = UserForm(request.POST)

        if form.is_valid() and user_form.is_valid():
            if form.cleaned_data["country"] == "CA":
                form.cleaned_data["state"] = form.cleaned_data['province']
            del form.cleaned_data['province']
            del form.cleaned_data['salesperson']

            curID = form.cleaned_data['currency']
            del form.cleaned_data['currency']
            org = Organization.objects.create(org_type=ORGTYPE_ADVERTISER,
                                              status=ORGSTATUS_TEST,
                                              **form.cleaned_data)
            org.save()

            orgCur = OrganizationCurrency.objects.create(
                advertiser=org, currency=Currency.objects.get(order=curID))

            u = User.objects.create(
                username=user_form.cleaned_data['email'],
                email=user_form.cleaned_data['email'],
                first_name=user_form.cleaned_data['first_name'],
                last_name=user_form.cleaned_data['last_name'])

            u.set_password(user_form.cleaned_data['password'])
            u.save()

            up = UserProfile.objects.create(user=u)
            up.organizations.add(org)
            up.save()

            del form.cleaned_data['show_alias']
            del form.cleaned_data['company_name']
            del form.cleaned_data['company_alias']
            del form.cleaned_data['ticker']
            del form.cleaned_data['is_private']
            del form.cleaned_data['ticker_symbol']
            del form.cleaned_data['vertical']
            del form.cleaned_data['brandlock_key']
            del form.cleaned_data['brandlock']

            org_contacts = OrganizationContacts.objects.create(
                organization=org,
                firstname=application.contact_firstname,
                lastname=application.contact_lastname,
                email=application.contact_email,
                phone=application.contact_phone,
                fax=application.contact_fax)
            org_contacts.save()

            orgPayeeInfo = OrganizationPaymentInfo(organization=org)
            orgPayeeInfo.save()

            # Assign all ADMINLEVEL_ADMINISTRATOR to this
            for up in UserProfile.objects.filter(
                    admin_level=ADMINLEVEL_ADMINISTRATOR):
                up.admin_assigned_organizations.add(org)
                up.save()

            application.delete()

            #ACE INSERT IF NO MATCHES ARE FOUND
            matches = search_company(application.organization_name)
            if len(matches) > 0:
                #redirect to new url and template to display list. Chose or create
                return AQ_render_to_response(
                    request,
                    'network/search-ace.html', {
                        'matches': matches,
                        'orgId': org.id
                    },
                    context_instance=RequestContext(request))
            else:
                create_company(org)

            #args = {}
            #args["salesrep"] = form.cleaned_data['salesperson']
            #createIO(advertiser, args)

            return HttpResponseRedirect(
                '/network/account/advertiser/applications/')
    else:
        #form = OrganizationForm(initial=application.__dict__)
        form = NetworkAdvertiserEditForm(initial=application.__dict__)
        user_form = UserForm(
            initial={
                'first_name': application.contact_firstname,
                'last_name': application.contact_lastname,
                'email': application.contact_email,
            })

    return AQ_render_to_response(request,
                                 'network/advertiser-applications-create.html',
                                 {
                                     'application': application,
                                     'form': form,
                                     'user_form': user_form,
                                 },
                                 context_instance=RequestContext(request))