def network_account_users_add(request): ''' View to allow Network Admins to create new Users ''' from forms import NetworkUserForm from atrinsic.base.models import User, UserProfile from atrinsic.util.user import generate_username if request.method == 'POST': form = NetworkUserForm(request.POST) if form.is_valid(): u = User.objects.create(first_name=form.cleaned_data['first_name'], last_name=form.cleaned_data['last_name'], email=form.cleaned_data['email'], username=generate_username( form.cleaned_data['email'])) u.set_password(form.cleaned_data['password']) u.save() up = UserProfile.objects.create( admin_level=form.cleaned_data['admin_level'], user=u) return HttpResponseRedirect('/network/') else: form = NetworkUserForm() return AQ_render_to_response(request, 'network/users-add.html', { 'form': form, }, context_instance=RequestContext(request))
def network_account_users_add(request): ''' View to allow Network Admins to create new Users ''' from forms import NetworkUserForm from atrinsic.base.models import User,UserProfile from atrinsic.util.user import generate_username if request.method == 'POST': form = NetworkUserForm(request.POST) if form.is_valid(): u = User.objects.create(first_name=form.cleaned_data['first_name'], last_name=form.cleaned_data['last_name'], email=form.cleaned_data['email'], username=generate_username(form.cleaned_data['email'])) u.set_password(form.cleaned_data['password']) u.save() up = UserProfile.objects.create(admin_level=form.cleaned_data['admin_level'], user=u) return HttpResponseRedirect('/network/') else: form = NetworkUserForm() return AQ_render_to_response(request, 'network/users-add.html', { 'form' : form, }, context_instance=RequestContext(request))
def signup_publisher_step4(request): ''' Fourth step of publisher signup process, confirms the email''' from forms import PublisherSignupForm3,WebsiteForm,PaymentInfoForm,ContactInfoForm, ContactInfoFormSmallest from atrinsic.util.user import generate_username from atrinsic.base.models import PublisherApplication,Organization,Website,OrganizationContacts,OrganizationPaymentInfo,User,UserProfile if request.method == "GET": if request.GET.get("id",None) and request.GET.get("key",None): if PublisherApplication.objects.filter(validation_code=request.GET['key'],id=request.GET['id']).count() > 0: app = PublisherApplication.objects.filter(validation_code=request.GET['key'],id=request.GET['id'])[0] form = PublisherSignupForm3(False) website_form = WebsiteForm() payment_form = PaymentInfoForm() print app.email inits = { 'payeename':'', 'firstname':'', 'lastname':'', 'phone':'', 'email': app.email, } formCI = ContactInfoForm(initial=inits) inits = { 'xs_firstname':'', 'xs_lastname':'', 'xs_email': app.email, } formCIxs = ContactInfoFormSmallest(initial=inits) key = request.GET['key'] appid = request.GET['id'] return AQ_render_to_response(request, 'signup/publisher_newStep.html', { 'payment_form':payment_form, 'formCI' : formCI, 'formCIxs' : formCIxs, 'website_form':website_form, 'form' : form, 'key' : key, 'appid' : appid, }, context_instance=RequestContext(request)) else: #application could not be found return AQ_render_to_response(request, 'signup/appnotfound.html', { }, context_instance=RequestContext(request)) else: return AQ_render_to_response(request, 'signup/publisher_step4.html', { }, context_instance=RequestContext(request)) else: form = PublisherSignupForm3(False,request.POST) website_form = WebsiteForm(request.POST) payment_form = PaymentInfoForm(request.POST) formCI = ContactInfoForm(request.POST) formCIxs = ContactInfoFormSmallest(request.POST) key = request.POST['key'] appid = request.POST['appid'] if form.is_valid() and website_form.is_valid() and payment_form.is_valid(): useSmallContactForm = True if payment_form.cleaned_data['payment_method'] == PAYMENT_CHECK: if formCI.is_valid(): useSmallContactForm = False else: #1 or more forms are not valid return AQ_render_to_response(request, 'signup/publisher_newStep.html', { 'payment_form':payment_form, 'formCI' : formCI, 'formCIxs' : formCIxs, 'website_form':website_form, 'form' : form, 'key' : key, 'appid' : appid, }, context_instance=RequestContext(request)) else: if formCIxs.is_valid(): useSmallContactForm = True else: #1 or more forms are not valid return AQ_render_to_response(request, 'signup/publisher_newStep.html', { 'payment_form':payment_form, 'formCI' : formCI, 'formCIxs' : formCIxs, 'website_form':website_form, 'form' : form, 'key' : key, 'appid' : appid, }, context_instance=RequestContext(request)) #create Organization org = Organization.objects.create(org_type=ORGTYPE_PUBLISHER, status=ORGSTATUS_UNAPPROVED) org.company_name = form.cleaned_data['company_name'] org.address = form.cleaned_data['pub_address'] org.address2 = form.cleaned_data['pub_address2'] org.city = form.cleaned_data['pub_city'] org.state = form.cleaned_data['pub_state'] org.zipcode = form.cleaned_data['pub_zipcode'] org.country = form.cleaned_data['pub_country'] if str(website_form.cleaned_data['vertical']) == "Adult": org.is_adult = 1 org.save() if useSmallContactForm: org_contact = OrganizationContacts.objects.create(organization=org, firstname=formCIxs.cleaned_data['xs_firstname'],lastname=formCIxs.cleaned_data['xs_lastname'],email=formCIxs.cleaned_data['xs_email']) org_contact.save() else: org_contact = OrganizationContacts.objects.create(organization=org, **formCI.cleaned_data) org_contact.save() address = formCI.cleaned_data['address'] app = PublisherApplication.objects.filter(validation_code=key,id=appid)[0] try: term_log = Terms_Accepted_Log.objects.get(organization_id=app) term_log.organization_id = org.id term_log.save() except: pass address = "" website = Website.objects.create(publisher = org, is_default = True, **website_form.cleaned_data) website.save() org_payment = OrganizationPaymentInfo.objects.create(organization=org, **payment_form.cleaned_data) org_payment.save() first_name = app.first_name last_name = app.last_name password = app.password if useSmallContactForm: email=formCIxs.cleaned_data['xs_email'] else: email=formCI.cleaned_data['email'] if payment_form.cleaned_data['payment_method'] == PAYMENT_CHECK: payee_name = formCI.cleaned_data['payeename'] first_name = formCI.cleaned_data['firstname'] last_name = formCI.cleaned_data['lastname'] # Create User, Set Password, Map to Organization u = User.objects.create(first_name=first_name,last_name=last_name,password=password,email=email, username=generate_username(email)) up = UserProfile.objects.create(user=u) up.organizations.add(org) # Assign all ADMINLEVEL_ADMINISTRATOR to this for up in UserProfile.objects.filter(admin_level=ADMINLEVEL_ADMINISTRATOR): up.admin_assigned_organizations.add(org) up.save() #Emails from django.core.mail import EmailMultiAlternatives print "Sending mail" msg = EmailMultiAlternatives("Atrinsic Affiliate Network Publisher Application", u""" Dear """+first_name[0:1].upper()+first_name[1:]+""" """+last_name[0:1].upper()+last_name[1:]+""", Thank you for applying to become a publisher on the Atrinsic Affiliate Network. Your application has been placed in our queue and will be reviewed as quickly as possible. You will be contacted shortly by a member of the Atrinsic Affiliate Network Publisher team to verify some information on your application. If, at any time, you have questions or concerns, please contact us at [email protected]. We receive a large volume of applications each day and your application will be processed in the order in which it was received. Thank you for your interest in working with Atrinsic Affiliate Network! Sincerely, The Atrinsic Affiliate Network Publisher Team ""","*****@*****.**",[email]) msg.send() themessage = u"""Dear Admin! this is a glorious day, a new publisher has join our ranks. Name: """+first_name[0:1].upper()+first_name[1:]+""" """+last_name[0:1].upper()+last_name[1:] themessage += """ Address: """+address+""" Email: """+email+""" Website URL: """+website_form.cleaned_data['url']+""" please review this application, Sincerely, The Atrinsic Affiliate Network Robot that sends email""" msg2 = EmailMultiAlternatives("Atrinsic Affiliate Network Publisher Application",themessage,"*****@*****.**",['*****@*****.**']) msg2.send() return AQ_render_to_response(request, 'signup/publisher_complete.html', { }, context_instance=RequestContext(request)) else: #1 or more forms are not valid return AQ_render_to_response(request, 'signup/publisher_newStep.html', { 'payment_form':payment_form, 'formCI' : formCI, 'formCIxs' : formCIxs, 'website_form':website_form, 'form' : form, 'key' : key, 'appid' : appid, }, context_instance=RequestContext(request))
def signup_publisher_step4(request): ''' Fourth step of publisher signup process, confirms the email''' from forms import PublisherSignupForm3, WebsiteForm, PaymentInfoForm, ContactInfoForm, ContactInfoFormSmallest from atrinsic.util.user import generate_username from atrinsic.base.models import PublisherApplication, Organization, Website, OrganizationContacts, OrganizationPaymentInfo, User, UserProfile if request.method == "GET": if request.GET.get("id", None) and request.GET.get("key", None): if PublisherApplication.objects.filter( validation_code=request.GET['key'], id=request.GET['id']).count() > 0: app = PublisherApplication.objects.filter( validation_code=request.GET['key'], id=request.GET['id'])[0] form = PublisherSignupForm3(False) website_form = WebsiteForm() payment_form = PaymentInfoForm() print app.email inits = { 'payeename': '', 'firstname': '', 'lastname': '', 'phone': '', 'email': app.email, } formCI = ContactInfoForm(initial=inits) inits = { 'xs_firstname': '', 'xs_lastname': '', 'xs_email': app.email, } formCIxs = ContactInfoFormSmallest(initial=inits) key = request.GET['key'] appid = request.GET['id'] return AQ_render_to_response( request, 'signup/publisher_newStep.html', { 'payment_form': payment_form, 'formCI': formCI, 'formCIxs': formCIxs, 'website_form': website_form, 'form': form, 'key': key, 'appid': appid, }, context_instance=RequestContext(request)) else: #application could not be found return AQ_render_to_response( request, 'signup/appnotfound.html', {}, context_instance=RequestContext(request)) else: return AQ_render_to_response( request, 'signup/publisher_step4.html', {}, context_instance=RequestContext(request)) else: form = PublisherSignupForm3(False, request.POST) website_form = WebsiteForm(request.POST) payment_form = PaymentInfoForm(request.POST) formCI = ContactInfoForm(request.POST) formCIxs = ContactInfoFormSmallest(request.POST) key = request.POST['key'] appid = request.POST['appid'] if form.is_valid() and website_form.is_valid( ) and payment_form.is_valid(): useSmallContactForm = True if payment_form.cleaned_data['payment_method'] == PAYMENT_CHECK: if formCI.is_valid(): useSmallContactForm = False else: #1 or more forms are not valid return AQ_render_to_response( request, 'signup/publisher_newStep.html', { 'payment_form': payment_form, 'formCI': formCI, 'formCIxs': formCIxs, 'website_form': website_form, 'form': form, 'key': key, 'appid': appid, }, context_instance=RequestContext(request)) else: if formCIxs.is_valid(): useSmallContactForm = True else: #1 or more forms are not valid return AQ_render_to_response( request, 'signup/publisher_newStep.html', { 'payment_form': payment_form, 'formCI': formCI, 'formCIxs': formCIxs, 'website_form': website_form, 'form': form, 'key': key, 'appid': appid, }, context_instance=RequestContext(request)) #create Organization org = Organization.objects.create(org_type=ORGTYPE_PUBLISHER, status=ORGSTATUS_UNAPPROVED) org.company_name = form.cleaned_data['company_name'] org.address = form.cleaned_data['pub_address'] org.address2 = form.cleaned_data['pub_address2'] org.city = form.cleaned_data['pub_city'] org.state = form.cleaned_data['pub_state'] org.zipcode = form.cleaned_data['pub_zipcode'] org.country = form.cleaned_data['pub_country'] if str(website_form.cleaned_data['vertical']) == "Adult": org.is_adult = 1 org.save() if useSmallContactForm: org_contact = OrganizationContacts.objects.create( organization=org, firstname=formCIxs.cleaned_data['xs_firstname'], lastname=formCIxs.cleaned_data['xs_lastname'], email=formCIxs.cleaned_data['xs_email']) org_contact.save() else: org_contact = OrganizationContacts.objects.create( organization=org, **formCI.cleaned_data) org_contact.save() address = formCI.cleaned_data['address'] app = PublisherApplication.objects.filter(validation_code=key, id=appid)[0] try: term_log = Terms_Accepted_Log.objects.get(organization_id=app) term_log.organization_id = org.id term_log.save() except: pass address = "" website = Website.objects.create(publisher=org, is_default=True, **website_form.cleaned_data) website.save() org_payment = OrganizationPaymentInfo.objects.create( organization=org, **payment_form.cleaned_data) org_payment.save() first_name = app.first_name last_name = app.last_name password = app.password if useSmallContactForm: email = formCIxs.cleaned_data['xs_email'] else: email = formCI.cleaned_data['email'] if payment_form.cleaned_data['payment_method'] == PAYMENT_CHECK: payee_name = formCI.cleaned_data['payeename'] first_name = formCI.cleaned_data['firstname'] last_name = formCI.cleaned_data['lastname'] # Create User, Set Password, Map to Organization u = User.objects.create(first_name=first_name, last_name=last_name, password=password, email=email, username=generate_username(email)) up = UserProfile.objects.create(user=u) up.organizations.add(org) # Assign all ADMINLEVEL_ADMINISTRATOR to this for up in UserProfile.objects.filter( admin_level=ADMINLEVEL_ADMINISTRATOR): up.admin_assigned_organizations.add(org) up.save() #Emails from django.core.mail import EmailMultiAlternatives print "Sending mail" msg = EmailMultiAlternatives( "Atrinsic Affiliate Network Publisher Application", u""" Dear """ + first_name[0:1].upper() + first_name[1:] + """ """ + last_name[0:1].upper() + last_name[1:] + """, Thank you for applying to become a publisher on the Atrinsic Affiliate Network. Your application has been placed in our queue and will be reviewed as quickly as possible. You will be contacted shortly by a member of the Atrinsic Affiliate Network Publisher team to verify some information on your application. If, at any time, you have questions or concerns, please contact us at [email protected]. We receive a large volume of applications each day and your application will be processed in the order in which it was received. Thank you for your interest in working with Atrinsic Affiliate Network! Sincerely, The Atrinsic Affiliate Network Publisher Team """, "*****@*****.**", [email]) msg.send() themessage = u"""Dear Admin! this is a glorious day, a new publisher has join our ranks. Name: """ + first_name[0:1].upper() + first_name[ 1:] + """ """ + last_name[0:1].upper() + last_name[1:] themessage += """ Address: """ + address + """ Email: """ + email + """ Website URL: """ + website_form.cleaned_data['url'] + """ please review this application, Sincerely, The Atrinsic Affiliate Network Robot that sends email""" msg2 = EmailMultiAlternatives( "Atrinsic Affiliate Network Publisher Application", themessage, "*****@*****.**", ['*****@*****.**']) msg2.send() return AQ_render_to_response( request, 'signup/publisher_complete.html', {}, context_instance=RequestContext(request)) else: #1 or more forms are not valid return AQ_render_to_response( request, 'signup/publisher_newStep.html', { 'payment_form': payment_form, 'formCI': formCI, 'formCIxs': formCIxs, 'website_form': website_form, 'form': form, 'key': key, 'appid': appid, }, context_instance=RequestContext(request))