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 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 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 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 = 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 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 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 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): 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(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): 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): 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 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 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 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 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)