def get_result(listable_companies: List[str] = None) -> dict: """ Address book """ result = {"companies": []} for comp in Company.get_companies()["companies"]: if listable_companies is not None and len(listable_companies) > 0: if comp["name"] not in listable_companies: continue comp_obj = Company(comp["name"]) comp["address"] = comp_obj.address comp["phone"] = comp_obj.phone comp["email"] = comp_obj.email result["companies"].append(comp) for comp in result["companies"]: if "locations" not in comp: comp["locations"] = [] if "ibans" not in comp: comp["ibans"] = [] if len(comp["ibans"]) > 0: comp["default_iban"] = comp["ibans"][0]["name"] + " - " + comp[ "ibans"][0]["number"] else: comp["default_iban"] = "" if "activity_emails" not in comp: comp["activity_emails"] = [] if "tax_number" in comp: comp["tax_number"] = comp["tax_number"].replace(" ", "") return result
def post(self): email = self['email'] company_id = int(str(self['company_id'])) if not Company.get_by_id(company_id): self.write('no company') return if not util.isAdminAccess(self): return curr_session = get_current_session() if InvitedMember.for_(email, company_id): curr_session['invite_error'] = "Invite already sent" else: company = Company.get_by_id(company_id) InvitedMember.create_(email, company_id) mail.send_mail(sender="Pirates Admin <*****@*****.**>", to=email, subject="Invitation to join " + company.name, body=""" Hello! Please follow this link to add yourself: http://hirepirates.com/member/finish_invite?company_id={0}&email={1} Thanks! """.format(self['company_id'], self['email'])) curr_session['invite_success'] = True rd_url = curr_session['rd_url'] curr_session.pop('rd_url') self.redirect(rd_url)
def create_company(): content = request.get_json(force=True) Company.register(content.get('name'), content.get('password'), content.get('image_link'), content.get('event_id')) return jsonify({"register": True})
def __init__(self, client_name: str, project_name: str): all_projects = Project.get_projects() self._project = {} for prj in all_projects["projects"]: if prj["client_name"] == client_name and prj[ "project_name"] == project_name: self._project = prj break self._client = Company(self._project["client_name"]) self._payer = Company(self._project["payer_name"])
def create_company(self, image_key): c = Company() c.name = self['company_name'] c.website = self['website'] c.profile = self['profile'] c.hello = self['hello'] tags = re.findall(r"[\w']+", str(self['tags'])) c.tags = tags[0:3] if len(tags)>3 else tags c.image = image_key c.put() return c
def create_checkout_session(): company_id = request.get_json(force=True).get('company_id') event = Event.find(Company.find(company_id).event_id) checkout_session = stripe.checkout.Session.create( payment_method_types=['card'], line_items=[ { 'price_data': { 'currency': 'bgn', 'unit_amount': event.payment * 100, 'product_data': { 'name': event.name, # 'images': ['https://i.imgur.com/EHyR2nP.png'], }, }, 'quantity': 1, }, ], mode='payment', success_url="http://localhost:3000/view-company/" + str(current_user.id) + '?success=true', cancel_url="http://localhost:3000/view-company/" + str(current_user.id) + '?canceled=true', ) return jsonify({"id": checkout_session.id})
def get(self): path = 'list_member.html' company_id = int(str(self['company_id'])) c = Company.get_by_id(company_id) if not c: self.write('no company') return session = get_current_session() user_id = session['me_email'] access_type = self.get_access_type(c, user_id) q = CompanyMember.all().ancestor(c) users = [{'name': User.get_by_key_name(company_member.user_id).name, 'influence': company_member.influence, 'expertise': company_member.expertise} for company_member in q] donuts = 2 donuts -= 1 donut_size = 80-(5*donuts) score_font_size = 40-(3*donuts) tooltip_font_size = 14-donuts template_values = {'company_id': company_id, 'name': c.name, 'influence': c.influence_avg if c.influence_avg else 0.0, 'expertise': c.expertise_avg if c.expertise_avg else [], 'users': users, 'access_type': access_type, 'admin_id': user_id, 'donut_size': donut_size, 'score_font_size': score_font_size, 'tooltip_font_size': tooltip_font_size} self.write(self.get_rendered_html(path, template_values), 200)
def get(self): company_id = str(self['company_id']) if not Company.get_by_id(int(company_id)): self.write('no company') return if not isAdminAccess(self): return path = 'invite_member.html' rd_url = '/member/invite?company_id=' + self['company_id'] breadcrumb_idx = 2 template_values = prepare_template_values_for_invite(rd_url) template_values[ 'form_url'] = '/api/members/invite?company_id=' + company_id template_values['breadcrumbs'] = registration_breadcrumbs[startups] template_values['breadcrumb_idx'] = breadcrumb_idx template_values['breadcrumbs_len'] = len( registration_breadcrumbs[startups]) template_values['breadcrumb'] = registration_breadcrumbs[startups][ breadcrumb_idx - 1] template_values['progress'] = ( 100 / len(registration_breadcrumbs[startups])) * breadcrumb_idx template_values[ 'done_redirect'] = '/member/expose_third_party?company_id=' + self[ 'company_id'] self.write(self.get_rendered_html(path, template_values), 200)
def get(self): path = 'list_member.html' company_id = int(str(self['company_id'])) c = Company.get_by_id(company_id) if not c: self.write('no company') return session = get_current_session() user_id = session['me_email'] access_type = self.get_access_type(c, user_id) q = CompanyMember.all().ancestor(c) users = [{ 'name': User.get_by_key_name(company_member.user_id).name, 'influence': company_member.influence, 'expertise': company_member.expertise } for company_member in q] donuts = 2 donuts -= 1 donut_size = 80 - (5 * donuts) score_font_size = 40 - (3 * donuts) tooltip_font_size = 14 - donuts template_values = { 'company_id': company_id, 'name': c.name, 'influence': c.influence_avg if c.influence_avg else 0.0, 'expertise': c.expertise_avg if c.expertise_avg else [], 'users': users, 'access_type': access_type, 'admin_id': user_id, 'donut_size': donut_size, 'score_font_size': score_font_size, 'tooltip_font_size': tooltip_font_size } self.write(self.get_rendered_html(path, template_values), 200)
def subscribe_company(): company_id = request.get_json(force=True).get('company_id') event_id = Company.find(company_id).event_id Payment.make_payment(company_id, event_id) return jsonify({"subscription": True})
def get_company(): user_id = request.args.get('user_id') print(user_id) company_id = User.find_company_id(user_id) company = Company.get_company(company_id) print(company.to_dict()) return company.to_dict()
def payment_status(): company_id = request.args.get('company_id') event_id = Company.find(company_id).event_id flag = Payment.check_for_payment(event_id, company_id) return jsonify({"payment": flag})
def _company_selected(self): obj_array = [] selected_companies = self._listbox.selected_company_names for selected_company in selected_companies: company_obj = Company(selected_company) obj_array.append(company_obj) if len(obj_array) <= 0: return self._close_handler(obj_array)
def get(self): path = 'startups_latest.html' q = Company.all() logging.info(q.count()) companies = [self.make_dict(company) for company in q] companies.insert(0, {'image': '/assets/img/new_startup.png', 'name': 'Your Startup', 'url': '/startups/registration/queue'}) sorted_company_rows = [companies[i: i+3] for i in range(0, len(companies), 3)] template_values = {'startups' : sorted_company_rows, 'nav_color':'dark-nav'} self.write(self.get_rendered_html(path, template_values), 200)
def get(self): #InputName=a&InputEmail=a%40b.com&InputEmail=a%40b.com&InputMessage=a&submit=Submit c = Company() c.name = self['InputName'] c.email = self['InputEmail'] c.details = self['InputMessage'] c.put() self.redirect('/add_member')
def __init__(self, parent: tkinter.Toplevel, label_text: str, x_pos: int, y_pos: int): self._companies = Company.get_companies() self._combo_val = [] for cmp in self._companies["companies"]: self._combo_val.append(cmp["name"]) self._combo = LabeledCombobox(parent, label_text, self._combo_val, x_pos, y_pos)
def _excel_click(self): selected_activity_objects = self._selected_activities xlsx_report = activity_xlsx_report.Report() xlsx_report.generate_with_activity_objects(selected_activity_objects) activity_company = Company(config.CONSTANTS["COMPANY_NAME_1E1"]) popup_email(recipients=activity_company.activity_emails, subject="Bu ayki aktivitelerim", attachment=xlsx_report.last_saved_files[0])
def get_company(self, id): client = Client(self.url, faults=True) try: response = client.service.GetCompany(id) except WebFault as e: return (False, None, e.fault) company = Company().update_from_soap(response) return (True, company, None)
def add_employees_to_company(self, company_id, employees_id): client = Client(self.url, faults=True) try: response = client.service.AddEmployeesToCompany(company_id, employees_id) except WebFault as e: return (False, None, e.fault) company = Company().update_from_soap(response) return (True, company, None)
def add_company(self, name): client = Client(self.url, faults=True) try: response = client.service.AddCompany(name) except WebFault as e: return (False, None, e.fault) company = Company().update_from_soap(response) return (True, company, None)
def get_companies_without_payment() -> List[Company]: """ Companies without payment Those may be considered deletable, in case they won't be needed in the future """ output = [] all_companies = Company.get_companies() all_payments = get_payments() for com in all_companies["companies"]: has_payment = False for pay in all_payments["payments"]: if pay["company"] == com["name"]: has_payment = True break if has_payment: continue com_obj = Company(com["name"]) output.append(com_obj) return output
def get(self): company = Company.get_by_id(int(str(self['company_id']))) if not company: self.write('no company') return members = CompanyMember.all().ancestor(company) ret_val = [] for member in members.fetch(1000): user = User.get_by_key_name(member.user_id) ret_val.append({'name' : user.name, 'id' : member.key().id()}) self.write(json.dumps(ret_val))
def get(self): company_id = int(str(self['company_id'])) if not Company.get_by_id(company_id): self.write('no company') return if not isAdminAccess(self): return path = 'startup_edit.html' company_json = self.prepare_company_json(company_id) form_url = blobstore.create_upload_url('/api/startups/update_company') template_values = {'form_url': form_url, 'company':company_json} self.write(self.get_rendered_html(path, template_values), 200)
def get(self): company_id = int(str(self['company_id'])) if not Company.get_by_id(company_id): self.write('no company') return if not isAdminAccess(self): return path = 'startup_edit.html' company_json = self.prepare_company_json(company_id) form_url = blobstore.create_upload_url('/api/startups/update_company') template_values = {'form_url': form_url, 'company': company_json} self.write(self.get_rendered_html(path, template_values), 200)
def open_invoice_as_email(inv: Invoice): """ Opens E-Mail windows to send the invoice """ recipients = [] if inv.payer.email != "": recipients.append(inv.payer.email) accounting_company = Company(config.CONSTANTS["COMPANY_NAME_ACCOUNTING"]) if accounting_company.email != "": recipients.append(accounting_company.email) popup_email(recipients=recipients, subject=f"Fatura {inv.serial}", attachment=inv.file_path)
def get(self): expertise = None company = Company.get_by_id(int(str(self['company_id']))) if not company: self.write('no company') return if self['member_id']: member = CompanyMember.get_by_id(int(str(self['member_id'])), parent=company) expertise = member.get_expertise() else: expertise = company.get_expertise_avg() self.write(json.dumps(get_skills_json(expertise)))
def prepare_company_json(self, id): company = Company.get_by_id(id) company_json = {} company_json['id'] = id company_json['name'] = company.name if company.image: company_json['image'] = '/api/common/download_image/'+company.image company_json['image_key'] = company.image company_json['hello'] = company.hello company_json['profile'] = company.profile company_json['website'] = company.website company_json['tags'] = ', '.join(str(x) for x in company.tags) return company_json
def generate(invoices: []): """ Prints given invoices """ companies = [] for snumber in range(2): # pylint: disable=W0612 companies.append( Company(config.CONSTANTS["COMPANY_NAME_ACCOUNTING"])) for invoice in invoices: companies.append(invoice.payer) CompanyLabel().generate(companies)
def get(self): company_id = str(self['company_id']) if not Company.get_by_id(int(company_id)): self.write('no company') return if not isAdminAccess(self): return path = 'invite_member.html' rd_url = '/member/dashboard_invite?company_id='+company_id template_values = prepare_template_values_for_invite(rd_url) template_values['invite_form_url'] = '/api/members/invite?company_id=' + company_id template_values['done_redirect'] = '/member/list?company_id=' + self['company_id'] self.write(self.get_rendered_html(path, template_values), 200)
def register_participant(): content = request.get_json(force=True) print(content) comp_id = Company.find_id(content.get('company_name'), content.get('company_password'), content.get('event')) User.registerParticipant(content.get('username'), content.get('password'), content.get('email'), content.get('event'), comp_id) Event.add_participant(content.get('event')) return jsonify({"register": True})
def update_company(self): company_id = int(str(self['company_id'])) c = Company.get_by_id(company_id) if c: c.name = self['company_name'] c.website = self['website'] c.profile = self['profile'] c.hello = self['hello'] tags = re.findall(r"[\w']+", str(self['tags'])) c.tags = tags[0:3] if len(tags)>3 else tags image = self.read_image() if image: c.image = image c.put()
def prepare_company_json(self, id): company = Company.get_by_id(id) company_json = {} company_json['id'] = id company_json['name'] = company.name if company.image: company_json[ 'image'] = '/api/common/download_image/' + company.image company_json['image_key'] = company.image company_json['hello'] = company.hello company_json['profile'] = company.profile company_json['website'] = company.website company_json['tags'] = ', '.join(str(x) for x in company.tags) return company_json
def get(self): path = 'startups_search_results.html' project_id = long(self['project_id']) project = Project.get_by_id(project_id) skills = project.skills q = Company.all() sorted_companies = {} for c in q.fetch(50): expertise_dict = convert_string_list_to_dict(c.expertise_avg) score = 0.0 matched_skills = 0.0 fit = 0.0 id = c.key().id() sorted_companies[id] = {} sorted_companies[id]['name'] = c.name sorted_companies[id]['influence'] = c.influence_avg sorted_companies[id]['skills'] = [] if skills: for skill in skills: skill = str(skill) if skill in expertise_dict: skill_dict = { 'name': skill, 'value': float(expertise_dict[skill]) } score += float(expertise_dict[skill]) matched_skills += 1 else: skill_dict = {'name': skill, 'value': 0.0} sorted_companies[id]['skills'].append(skill_dict) score = float(score / len(skills)) fit = float(matched_skills / len(skills)) if matched_skills > 0.0 else 0.0 sorted_companies[id]['combined'] = score sorted_companies[id]['fit'] = fit donuts = (len(skills) if skills else 0) + 3 sorted_companies = sorted(sorted_companies.iteritems(), key=lambda (k, v): v['combined'], reverse=True) donut_size = 80 - (5 * donuts) score_font_size = 40 - (2.25 * donuts) tooltip_font_size = 14 - donuts template_values = { 'startups': sorted_companies, 'skills': skills, 'donut_size': donut_size, 'score_font_size': score_font_size, 'tooltip_font_size': tooltip_font_size } self.write(self.get_rendered_html(path, template_values), 200)
def get(self): company_id = str(self['company_id']) if not Company.get_by_id(int(company_id)): self.write('no company') return if not isAdminAccess(self): return path = 'invite_member.html' rd_url = '/member/dashboard_invite?company_id=' + company_id template_values = prepare_template_values_for_invite(rd_url) template_values[ 'invite_form_url'] = '/api/members/invite?company_id=' + company_id template_values[ 'done_redirect'] = '/member/list?company_id=' + self['company_id'] self.write(self.get_rendered_html(path, template_values), 200)
def get_locations() -> dict: """ Returns all locations defined in JSON files """ output = {} companies = Company.get_companies() for comp in companies["companies"]: try: locs = comp["locations"] except Exception: continue for loc in locs: location_key = comp["name"] + " - " + loc output[location_key] = location_key return output
def get(self): q = Company.all() companies = [] domain = {'influence' : [0, 1], 'expertise' : [0, 1], 'size' : [0, 5]} for c in q.fetch(100): curr_c = {} curr_c['name'] = c.name curr_c['influence'] = c.influence_avg curr_c['expertise'] = get_skills_json(c.get_expertise_avg()) curr_c['id'] = c.key().id() curr_c['size'] = self.get_size_for(c) companies.append(curr_c) ret_val = {'companies' : companies, 'domain' : domain} self.write(json.dumps(ret_val))
def get_company_by_oid(self, company_oid): url = f'{appUrl}/idm/api/companies/card/{company_oid}' headers = {"Accept-Encoding": "gzip, deflate", "Accept-Language": "ru"} params = {"sort": ""} json = None company_got_by_oid = Company() response = self.rest.call_request(request_type="GET", url=url, json=json, headers=headers, params=params) json_response = response.json() self.fill_company_data_from_response(company_object=company_got_by_oid, json_response=json_response) # print(company_got_by_oid) return company_got_by_oid
def get(self): path = 'startup_details.html' company_id = int(str(self['company_id'])) c = Company.get_by_id(company_id) dev_stats = self.get_dev_stats(c) tl_stats = self.get_tl_stats() if not c: self.write('no company') return aggregated_designs = Design.aggregate_data_for(c) session = get_current_session() q = CompanyMember.all().ancestor(c) design_stats = [('Live Apps', aggregated_designs['live_apps']), ('Shots', aggregated_designs['shots']), ('Likes', aggregated_designs['likes']), ('Followers', aggregated_designs['followers'])] picture_rows = [] picture_row = [] picture_urls = aggregated_designs['shot_urls'] for index, picture_url in enumerate(picture_urls, start=1): picture_row.append(picture_url) if index%3 == 0: picture_rows.append(picture_row) picture_row = [] elif index == len(picture_urls): picture_rows.append(picture_row) scores = [('Design', c.influence_avg if c.influence_avg else 0.0), ('Development', (c.influence_avg + 0.23) if c.influence_avg else 0.0), ('Community', (c.influence_avg + 0.37) if c.influence_avg else 0.0)] template_values = {'company_id': company_id, 'city': cities_map[str(company_id)] if str(company_id) in cities_map else cities_map['default'], 'name': c.name, 'image': c.image, 'hello': c.hello if c.hello else '', 'profile': c.profile if c.profile else '', 'influence': c.influence_avg if c.influence_avg else 0.0, 'expertise': c.expertise_avg if c.expertise_avg else [], 'design_stats': design_stats, 'pictures':picture_rows, 'nav_color':'dark-nav', 'dev_stats':dev_stats, 'tl_stats':tl_stats, 'donuts':DonutFactory.get_donuts(128, 0.8, scores, '#333333', '#139fe1', 'transparent')} self.write(self.get_rendered_html(path, template_values), 200)
def get(self): email = self['email'] company_id = str(self['company_id']) invited_member = InvitedMember.for_(email, company_id) if not Company.get_by_id(int(company_id)): self.write('no company') return if not invited_member: self.write('... not invited') return if self.user_exists(email): self.create_company_member(email, company_id) invited_member.delete() redirect_url = '/member/expose_third_party?company_id=' + company_id else: self.authenticate_user(email) self.save_in_session(email, company_id) redirect_url = '/member/signup?network=custom' self.redirect(redirect_url)
def get(self): company_id = str(self['company_id']) if not Company.get_by_id(int(company_id)): self.write('no company') return if not isAdminAccess(self): return path = 'invite_member.html' rd_url = '/member/invite?company_id='+self['company_id'] breadcrumb_idx = 2 template_values = prepare_template_values_for_invite(rd_url) template_values['form_url'] = '/api/members/invite?company_id=' + company_id template_values['breadcrumbs'] = registration_breadcrumbs[startups] template_values['breadcrumb_idx'] = breadcrumb_idx template_values['breadcrumbs_len']=len(registration_breadcrumbs[startups]) template_values['breadcrumb']=registration_breadcrumbs[startups][breadcrumb_idx-1] template_values['progress']=(100/len(registration_breadcrumbs[startups]))*breadcrumb_idx template_values['done_redirect'] = '/member/expose_third_party?company_id=' + self['company_id'] self.write(self.get_rendered_html(path, template_values), 200)
def get(self): path = 'startups_search_results.html' project_id = long(self['project_id']) project = Project.get_by_id(project_id) skills = project.skills q = Company.all() sorted_companies = {} for c in q.fetch(50): expertise_dict = convert_string_list_to_dict(c.expertise_avg) score = 0.0 matched_skills = 0.0 fit = 0.0 id = c.key().id() sorted_companies[id] = {} sorted_companies[id]['name'] = c.name sorted_companies[id]['influence'] = c.influence_avg sorted_companies[id]['skills'] = [] if skills: for skill in skills: skill = str(skill) if skill in expertise_dict: skill_dict = { 'name':skill,'value':float(expertise_dict[skill]) } score += float(expertise_dict[skill]) matched_skills += 1 else: skill_dict = { 'name':skill,'value':0.0 } sorted_companies[id]['skills'].append(skill_dict) score = float(score / len(skills)) fit = float(matched_skills / len(skills)) if matched_skills > 0.0 else 0.0 sorted_companies[id]['combined']=score sorted_companies[id]['fit']=fit donuts = (len(skills) if skills else 0) + 3 sorted_companies = sorted(sorted_companies.iteritems(), key=lambda (k,v): v['combined'], reverse = True) donut_size = 80-(5*donuts) score_font_size = 40-(2.25*donuts) tooltip_font_size = 14-donuts template_values = {'startups' : sorted_companies, 'skills' : skills, 'donut_size' : donut_size, 'score_font_size' : score_font_size, 'tooltip_font_size' : tooltip_font_size} self.write(self.get_rendered_html(path, template_values), 200)
def get(self): session = get_current_session() company_id = str(self['company_id']) c = Company.get_by_id(int(company_id)) if not c: self.write('no company') return user_id = session['me_email'] path = 'expose_social_data.html' user = User.get_by_key_name(str(user_id)) breadcrumb_idx = 3 template_values = {'name':user.name, 'company_id': company_id, 'github_auth_url': '/users/data/github/update?company_id=' + company_id, 'angellist_auth_url': '/users/data/angellist/update?company_id=' + company_id, 'linkedin_auth_url': '/users/data/linkedin/update?company_id=' + company_id, 'dribbble_auth_url': '/users/data/dribbble/update?company_id=' + company_id, 'odesk_auth_url': '/users/data/odesk/update?company_id=' + company_id, 'breadcrumbs' : registration_breadcrumbs[startups], 'breadcrumb_idx':breadcrumb_idx, 'breadcrumbs_len':len(registration_breadcrumbs[startups]), 'breadcrumb':registration_breadcrumbs[startups][breadcrumb_idx-1], 'progress': (100/len(registration_breadcrumbs[startups]))*breadcrumb_idx} self.write(self.get_rendered_html(path, template_values), 200)
def put(self): company_id = int(str(self.request.get('company_id'))) company = Company.get_by_id(company_id) deferred.defer(pull_company_data, company)
def create_company_member(self, email, company_id): company = Company.get_by_id(int(company_id)) CompanyMember(parent=company, is_admin=False, user_id=email).put()
def get_companies(self): q = Company.all() companies = [] for company in q.fetch(100): companies.append({'value' : company.key().id(), 'name' : company.name}) return companies