def CompanyContact(request): import string, random if request.method == "POST": form = CompanyContactForm(request.POST, request.FILES) if form.is_valid(): company = Company(**form.cleaned_data) # set slug slug = slugify(request.POST["name"]) company.slug = slug # set randomin password chars = string.ascii_uppercase + string.digits + string.ascii_lowercase company.password = "".join(random.choice(chars) for x in range(15)) company.save() # create user from django.contrib.auth.models import User user = User.objects.create_user(company.contact_email, company.contact_email, company.password) user.first_name = company.name user.save() user = User.objects.filter(username=company.contact_email) user = user[0] user.set_password(company.password) user.save() # send email with login info try: plaintext = get_template("email/registrook.txt") htmly = get_template("email/registrook.html") d = Context( { "contact_name": request.POST["contact_name"], "empresa": request.POST["name"], "contact_email": request.POST["contact_email"], "password": company.password, } ) subject, from_email, to = ( "Registro de empresa en Meguz.com", "*****@*****.**", request.POST["contact_email"], ) text_content = plaintext.render(d) html_content = htmly.render(d) msg = EmailMultiAlternatives(subject, text_content, from_email, [to]) msg.attach_alternative(html_content, "text/html") msg.send() # redirect to 'register ok' page return HttpResponseRedirect("/empresa/registro/ok") except Exception, e: return render_to_response("company/contact.html", {"e": e}, context_instance=RequestContext(request))
def addResume(request): if (request.method == 'POST'): parsed_json = json.loads(request.body.decode("utf-8")) resume = Resume(name=parsed_json['name'], email=parsed_json['email'], post=parsed_json['post'], phone=parsed_json['phone'], about=parsed_json['about'], resume_user_id=parsed_json['id'], city=parsed_json['city'], education=parsed_json['education'], institution=parsed_json['institution'], profession=parsed_json['profession']) resume.save() for skill in parsed_json['skills']: skill = Skill(skill=skill['skill'], text=skill['description'], skill_user_id=parsed_json['id'], post=parsed_json['post']) skill.save() for company in parsed_json['companies']: company = Company(company=company['company'], expirience=company['expirience'], skill_user_id=parsed_json['id'], post=parsed_json['post'], date=company['date']) company.save() return redirect('/')
def root_url_shows_all_companies(self): company1 = Company(name='Boring Company', permalink='boringcompany') company1.save() company2 = Company(name='Exciting Company', permalink='excitingcompany') company2.save() client = Client() response = client.get('/') template_names_used = [t.name for t in response.templates] self.assertIn('home.html', template_names_used) #Check we've passed the companies to the template companies_in_context = response.context['companies'] self.assertEquals(list(companies_in_context), [company1, company2]) #Check that the company names appear on the page self.assertIn(company1.name, response.content) self.assertIn(company2.name, response.content)
def Profile(request): user_email = request.user.email company = Company.objects.get(contact_email=user_email) if company is None: HttpResponseRedirect("/epanel") else: if request.method == 'POST': # Proceso form form = CompanyEditForm(request.POST, request.FILES) if(form.is_valid()): edit_company = Company(**form.cleaned_data) edit_company.id = company.id edit_company.slug = company.slug edit_company.contact_email = company.contact_email if 'logo' not in request.FILES: edit_company.logo = company.logo edit_company.save() # TODO: Check contact_email change and update userinfo return HttpResponseRedirect("/epanel/perfil") else: form = CompanyEditForm(initial={ 'name': company.name, 'slogan': company.slogan, 'logo': company.logo, 'rut': company.rut, 'address': company.address, 'phone': company.phone, 'email': company.email, 'website': company.website, 'contact_name': company.contact_name, 'contact_email': company.contact_email, 'contact_phone': company.contact_phone, }) context = {'form':form} return render_to_response('epanel/profile.html', context, context_instance=RequestContext(request))
def editResume(request): if (request.method == 'POST'): parsed_json = json.loads(request.body.decode("utf-8")) resume = Resume.objects.get(id=parsed_json['resumeId']) resume.name = parsed_json['data']['name'] resume.email = parsed_json['data']['email'] resume.post = parsed_json['data']['post'] resume.phone = parsed_json['data']['phone'] resume.about = parsed_json['data']['about'] resume.education = parsed_json['data']['education'] resume.institution = parsed_json['data']['institution'] resume.profession = parsed_json['data']['profession'] resume.save() Skill.objects.filter(post=parsed_json['data']['post'], skill_user_id=parsed_json['data']['id']).delete() Company.objects.filter(post=parsed_json['data']['post'], skill_user_id=parsed_json['data']['id']).delete() for skill in parsed_json['data']['skills']: skill = Skill(skill=skill['skill'], text=skill['description'], skill_user_id=parsed_json['data']['id'], post=parsed_json['data']['post']) skill.save() for company in parsed_json['data']['companies']: company = Company(company=company['company'], expirience=company['expirience'], skill_user_id=parsed_json['data']['id'], post=parsed_json['data']['post'], date=company['date']) company.save() return redirect('/')
def setUp(self): newco = Company() #start by creating the required fields #name newco.name = "SuperStartup" #permalink newco.permalink = "superstartup" #category_code newco.category_code ="software" #number of employees newco.number_of_employees = 3 #founded year newco.founded_year = 2001 #founded_month newco.founded_month = None #deadpooled_year newco.deadpooled_year = None #deadpooled_month newco.deadpooled_month = None #deadpooled_url #newco.deadpooled_url = '' #description newco.description = "newco makes widgets that automate productivity of efficient social features in the health, retail, industry, banking, telecommunications, construction and small business accounting industries" #overview newco.overview = "We are revolution to market" #total_money_raised newco.total_money_raised = "\u20ac183M" #save to database before adding manytomanyfields newco.save() #adding ManyToManyField values #ipo ipo1 = ipo() ipo1.save() newco.ipo.add(ipo1) #tag_list tag1 = tag(tag = "venture-capital-company") tag1.save() tag2 = tag(tag = "disruptive-technology-start-ups") tag2.save() newco.tag_list.add(tag1) newco.tag_list.add(tag2) #funding rounds #financial organization financial1 = financial_org() financial1.name = "Open Ocean" financial1.permalink = "openocean" financial1.save() #investment investment1 = investments() investment1.save() investment1.financial_org.add(financial1) #round round1 = funding_rounds() round1.round_code = "a" round1.raised_amount = 21640000 round1.raised_currency_code = "EUR" round1.funded_year = 2008 round1.funded_month = 10 round1.funded_day = 30 round1.save() print("Saved the easy funding round...") round1.investments.add(investment1) #Add the funding round newco.funding_rounds.add(round1)