• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python models.Company类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中models.Company的典型用法代码示例。如果您正苦于以下问题:Python Company类的具体用法?Python Company怎么用?Python Company使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Company类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: _create_new_company

def _create_new_company(company_name):
    """
    Adds a new record for the given company name to our database.

    The plan is to use the crunchbase/glassdoor API to query for the given
    company name.
    If the calls return info on the company, happily add it
    to our database. If not, we'll assume the given company name is
    faulty, and return an appropriate message to the user.
    """
    crunchbase = CrunchbaseAPI()
    response = crunchbase.get_company_info(company_name)
    if response['exists']:
        # Create the company using the name returned by crunchbase
        # TODO: We should add our own checks.. so a search for '*' doesn't give
        # back 'Google'
        # Or maybe we shouldn't let crunchbase spellcheck?
        company_name = response['name'].lower()

        try:
            # If company already exists, redirect to it
            company = Company.objects.get(name=company_name)
            redirect('/companies/{}'.format(new_company.id))
        except Company.DoesNotExist:
            new_company = Company(name=company_name)
            new_company.save()

            logger.info('New company created: {}'.format(company_name))
            return redirect('/companies/{}'.format(new_company.id))
    else:
        return redirect('/')
开发者ID:njdup,项目名称:shesays,代码行数:31,代码来源:views.py


示例2: test_f_expression_update_attribute

    def test_f_expression_update_attribute(self):
        # F expressions can be used to update attributes on single objects
        test_gmbh = Company.objects.get(name='Test GmbH')
        self.assertEqual(test_gmbh.num_employees, 32)
        test_gmbh.num_employees = F('num_employees') + 4
        test_gmbh.save()
        test_gmbh = Company.objects.get(pk=test_gmbh.pk)
        self.assertEqual(test_gmbh.num_employees, 36)
        
        # F expressions cannot be used to update attributes which are
        # foreign keys, or attributes which involve joins.
        test_gmbh.point_of_contact = None
        test_gmbh.save()
        self.assertEqual(test_gmbh.point_of_contact, None)
        self.assertRaises(ValueError,
                          setattr,
                          test_gmbh, 'point_of_contact', F('ceo'))

        test_gmbh.point_of_contact = test_gmbh.ceo
        test_gmbh.save()
        test_gmbh.name = F('ceo__last_name')
        self.assertRaises(FieldError,
                          test_gmbh.save)
        
        # F expressions cannot be used to update attributes on objects
        # which do not yet exist in the database
        acme = Company(name='The Acme Widget Co.', num_employees=12, 
                       num_chairs=5, ceo=test_gmbh.ceo)
        acme.num_employees = F('num_employees') + 16
        self.assertRaises(TypeError,
                          acme.save)
开发者ID:Leveofan,项目名称:django-old,代码行数:31,代码来源:tests.py


示例3: test_callingGetEmployeesReturnsListOfDicts

	def test_callingGetEmployeesReturnsListOfDicts(self):
		Employee.objects.filter = mock.MagicMock()
		company = Company()
		company.pk = 98
		employee_one = Employee()
		employee_one.pk = 12
		employee_one.user = User()
		employee_one.user.first_name = 'Fornavn'
		employee_one.user.last_name = 'Efternavn'
		employee_one.company = company
		employee_two = Employee()
		employee_two.pk = 13
		employee_two.user = User()
		employee_two.user.first_name = 'Fornavn'
		employee_two.user.last_name = 'Efternavn'
		employee_two.company = company
		Employee.objects.filter.return_value = [employee_one, employee_two]
		employee_one.getMyEmployees = mock.MagicMock()
		employee_one.getMyEmployees.return_value = []
		employee_list = employee_one.getEmployees()
		self.assertEquals(2, len(employee_list))
		self.assertTrue(isinstance(employee_list[0], dict))
		self.assertTrue(isinstance(employee_list[0]['manager'], Employee))
		self.assertEquals(employee_list[0]['manager'].pk, 12)
		self.assertTrue(isinstance(employee_list[0]['employees'], list))
		self.assertEquals(employee_list[0]['manager'].user.first_name, 'Fornavn')
		self.assertEquals(employee_list[0]['manager'].user.last_name, 'Efternavn')
开发者ID:crmtoolboxgit,项目名称:nxtlvl,代码行数:27,代码来源:oldtests.py


示例4: Simulation

class Simulation(object):

    def __init__(self, aggregator, strategy, reserved_resources, sleep_time=0):


        self.aggregator = aggregator

        self.strategy = strategy
# 2 year warm up, and 10 year run
        self.stats = Stats(24, 120)
        self.company = Company(20, reserved_resources, self.strategy, self.stats)
        self.sleep_time = sleep_time
        self.reserved_resources = reserved_resources

        print(sim_to_key(self))

    def run(self):

        for t in range(self.stats.runs):

            self.stats.start_month()

            projects = [generate_project() for _ in range(sample.project_count())]
            self.company.decide_projects(projects)

            used_resources = self.company.workflow.work()

            self.stats.end_month(used_resources, self.company.workflow.average_workload())

            if self.sleep_time > 0:
                sleep(self.sleep_time)

            #print(self.stats.monthly_report())

        self.aggregator.add_result(self)
开发者ID:acrespo,项目名称:Simulaciones,代码行数:35,代码来源:sim.py


示例5: update_company

    def update_company(self, company):
        self.logger.debug("update_company")

        self.logger.info("saving company to database")
        self.logger.debug("company: %s", company)
        Company.update(
                code=company.code, name=company.name, nif=company.nif,
                address=company.address, city=company.city,
                state=company.state, zip_code=company.zip_code,
                phone=company.phone, contact_person=company.contact_person,
                alternative_phone=company.alternative_phone,
                fax=company.fax, email=company.email, iban=company.iban,
                bank_name=company.bank_name, payment_type=company.payment_type,
                expiration_days=company.expiration_days,
                first_payment_day=company.first_payment_day,
                second_payment_day=company.second_payment_day,
                third_payment_day=company.third_payment_day
                ).execute()

        self.logger.info("updating company to model")
        tree_iter = self.get_iter_from_selected_row(company.code)
        self.companies_model.set(
                tree_iter,
                [self.CODE_COLUMN, self.NAME_COLUMN, self.NIF_COLUMN],
                [company.code, company.name, company.nif]
                )
开发者ID:rmunoz,项目名称:sigg,代码行数:26,代码来源:companies_manager_window.py


示例6: create

    def create(self, request, **kwargs):
        serializer = CompanySerializer(data=request.data)
        if serializer.is_valid():
            user = save_user(request.data, UserPermissions.IS_COMPANY)
            city = City(**request.data["city"])
            company = Company(
                name=request.data["name"],
                type=UserType.COMPANY,
                address=request.data["address"],
                identityDoc=request.data["identityDoc"],
                phone=request.data["phone"],
                city=city,
                user=user,
            )

            company.save()
            return Response(
                {
                    "status": "SUCCESS",
                    "msg_status": "Estabecimiento creado satisfactoriamente. Puede ingresar con su nueva contrasena.",
                }
            )
        else:
            messages = []
            make_error(serializer.errors.values(), messages)
            return Response({"status": "FAILURE", "msg_status": messages})
开发者ID:emosquera,项目名称:ticketIntelligence,代码行数:26,代码来源:viewsets.py


示例7: admin_add_company

def admin_add_company():
    data = json.loads(request.data)
    linkedin_id = data.get('linkedin_id')
    name = data.get('name')
    crunchbase_url = data.get('crunchbase_url')
    if not linkedin_id or linkedin_id == "":
        linkedin_id = gen_fake_linkedin_id()
    company = Company(linkedin_id, name)
    company.crunchbase_url = crunchbase_url
    db.session.add(company)
    db.session.commit()
    print ' adding new company for rescraping: ' + name.encode('utf8') + ' --> ' + linkedin_id
    print '              new company id = ' + str(company.id)
    if crunchbase_url and crunchbase_url != "":
        mode = FROM_URL_RESCRAPE_MODE
    else:
        mode = DEFAULT_RESCRAPE_MODE
    rescrape_companies_from_list([company], mode=mode)
    # TODO FUCK FUCK FUCK FUCK HEROKU for not allowing > 1 thread
    # WHAT IN THE FUCKING FUCK.....
    #times_left = 100
    #while not company.is_feed_ready and times_left >= 0:
    #    times_left -= 1 # this is to make sure this doesn't become an infinite for-loop
    #    time.sleep(5)
    #    db.session.commit() # Retarded way to start a new transaction because FUCK sqlalchemy...
    #    print '       ... waiting for scraper callback --> is_feed_ready ' + str(company.is_feed_ready)
    resp = json.dumps({'status': 'ok', 'company_id': company.id})
    return resp 
开发者ID:thejessma,项目名称:startuplinx,代码行数:28,代码来源:endpoints.py


示例8: test_callingGetEmployeesCallsFilterOnEmployeeWithCompanyPkAsArgumentAndIsMangerEqualToTrue

	def test_callingGetEmployeesCallsFilterOnEmployeeWithCompanyPkAsArgumentAndIsMangerEqualToTrue(self):
		employee = Employee()
		company = Company()
		company.pk = 8
		employee.company = company
		with mock.patch.object(Employee, 'objects') as query_mock:
			employee.getEmployees()
			query_mock.filter.assert_called_with(company__pk=company.pk, is_manager=True)
开发者ID:crmtoolboxgit,项目名称:nxtlvl,代码行数:8,代码来源:oldtests.py


示例9: create

 def create(self, validated_data):
     company = Company(
         name=validated_data['name'],
         alias=validated_data['name'].lower(),
         active=validated_data['active']
     )
     company.save()
     return company
开发者ID:JohnProg,项目名称:agenda_services,代码行数:8,代码来源:serializers.py


示例10: createDB

def createDB():
	print "Creating the initial db"
	Company.create_table()
	NewsSource.create_table()
	News.create_table()
	Price.create_table()
	OpinionAPI.create_table()
	OpinionAPIResponse.create_table()
开发者ID:Aaronmyster,项目名称:newtsocks,代码行数:8,代码来源:createDatabase.py


示例11: delete_company

    def delete_company(self, company):
        self.logger.debug("delete_company")

        self.logger.info("deleting company from database")
        Company.delete().where(Company.code == company.code).execute()

        self.logger.info("removing company from model")
        tree_iter = self.get_iter_from_selected_row(company.code)
        self.companies_model.remove(tree_iter)
开发者ID:rmunoz,项目名称:sigg,代码行数:9,代码来源:companies_manager_window.py


示例12: company_insert

 def company_insert(self, request):
     
     if request.from_datastore:
         my_company = request
     else:
         my_company = Company(parent=main.PARENT_KEY, name=request.name, bio=request.bio, logo=request.logo,
                              jobs=request.jobs, majors=request.majors, table=request.table, website=request.website)
         
     my_company.put()
     return my_company
开发者ID:11samype,项目名称:rose_career_fair,代码行数:10,代码来源:career_fair_api.py


示例13: setUp

    def setUp(self):
        self.region = Region(name="test_region")
        self.region.save()

        self.company = Company(code="1001", name="test_company", region=self.region)
        self.company.save()
        self.company2 = Company(code="1002", name="test_company_2", region=self.region)
        self.company2.save()

        self.store = Store(code="10011001", name="test_store", company=self.company)
        self.store.save()
开发者ID:xhacker5000,项目名称:wandoujia-oem,代码行数:11,代码来源:tests.py


示例14: post

 def post(self):
    if(Company.exists(request.form['name'])):
       return jsonify(message='Company exists')
    else:
       company = Company()
       company.name = request.form['name']
       company.tin = request.form['tin']
       company.address = request.form['address']
       db.session.add(company)
       db.session.commit()
       return jsonify(company.serialize)
开发者ID:sephtiger,项目名称:txmo-backend,代码行数:11,代码来源:application.py


示例15: input_companies

def input_companies():
  ''' Creates the company models for each S&P 500 company'''
  
  yahoo_data = yahooDataRetriever.get_dict_500_companies(name_file)
  
  for i in yahoo_data.keys():
    if len(Company.objects.filter(ticker = i)) > 0:
      continue
    c = Company()
    c.name = yahoo_data.get(i)
    c.ticker = i
    c.save()
    print "## Saved Company Object for: " + i
开发者ID:zinglax,项目名称:cmsc424Site,代码行数:13,代码来源:dataloader.py


示例16: post

    def post(self):
            newCompany = Company()
            newCompany.name = self.request.get("name")
            newCompany.cgpa = self.request.get("cgpa")
            newCompany.desc = self.request.get("desc")
            newCompany.sal = self.request.get("sal")
            newCompany.date = self.request.get("date")
            newCompany.lastDate = self.request.get("lastDate"); 
            newCompany.put()
	    self.redirect("/admin")       
开发者ID:byteofprash,项目名称:yunogimmejob,代码行数:10,代码来源:AdminPage.py


示例17: process_company_file

def process_company_file(data_file):
    workbook = xlrd.open_workbook(settings.MEDIA_ROOT+'/'+data_file.uploaded_file.name)
    worksheets = workbook.sheet_names()
    data_file.number_of_sheets = len(worksheets)
    data_file.save()
    for worksheet_name in worksheets:
        worksheet = workbook.sheet_by_name(worksheet_name)
        num_rows = worksheet.nrows - 1
        curr_row = 0            
        while curr_row < num_rows:
            curr_row += 1                
            company_name = worksheet.cell_value(curr_row, 0)
            industry = worksheet.cell_value(curr_row, 1)
            isin = worksheet.cell_value(curr_row, 2)
            bse_code = worksheet.cell_value(curr_row, 3)
            industry, created = Industry.objects.get_or_create(industry_name=industry)
            industry.created_by = data_file.uploaded_by
            industry.save()
            try:
                company = Company.objects.get(isin_code=isin)
            except:
                try:
                    company = Company.objects.get(company_name=company_name)    
                except:
                    company = Company()
            company.isin_code = isin
            if bse_code:
                company.BSE_code = int(bse_code)
            company.industry = industry
            company.company_name = company_name
            company.created_by = data_file.uploaded_by
            company.save()
    data_file.processing_completed = True
    data_file.save()
开发者ID:technomicssolutions,项目名称:progno_stock_rating,代码行数:34,代码来源:utils.py


示例18: save_instance_form

 def save_instance_form(self, form, user):
     company = Company()
     company.nit = form.cleaned_data['nit']
     company.name = form.cleaned_data['name']
     company.location = form.cleaned_data['location']
     company.website = form.cleaned_data['website']
     company.email = form.cleaned_data['email']
     company.phone = form.cleaned_data['phone']
     company.save()
     user.company = company
     user.save()
开发者ID:agar3s,项目名称:recluta,代码行数:11,代码来源:models_factory.py


示例19: create_company

def create_company():
    search_form = SearchForm()
    form = CreateCompanyForm()
    if request.method == "POST":
        comp_obj = Company()
        comp_obj.name = form.company_name.data
        db.session.add(comp_obj)
        db.session.commit()
        flash("Create company success")
        return render_template("create_company.html", search_form=search_form, form=form)
    else:
        if current_user.role != 3:
            flash("You have no permission")
            return redirect(url_for("main"))
        return render_template("create_company.html", search_form=search_form, form=form)
开发者ID:nnduc1994,项目名称:Aurio,代码行数:15,代码来源:views.py


示例20: on_row_activated

    def on_row_activated(self, treeview, path, column):
        self.logger.debug("on_row_activated")

        tree_iter = self.companies_model.get_iter(path)
        code = self.companies_model.get_value(tree_iter, self.CODE_COLUMN)
        company = Company.select().where(Company.code == code).get()

        column_id = column.get_sort_column_id()
        if column_id == self.REMOVE_COLUMN:
            dialog = Gtk.MessageDialog(
                    self.window, 0, Gtk.MessageType.QUESTION,
                    Gtk.ButtonsType.YES_NO,
                    "Are you sure to remove the company?"
                    )

            if dialog.run() == Gtk.ResponseType.YES:
                self.delete_company(company)

            dialog.destroy()
        elif column_id == self.DELIVERY_NOTES_COLUMN:
            DeliveryNotesManagerWindow(company=company, parent=self.window)
        elif column_id == self.INVOICE_COLUMN:
            InvoicesWindow(company=company, parent=self.window)
        else:
            self.populate_form(company)
开发者ID:rmunoz,项目名称:sigg,代码行数:25,代码来源:companies_manager_window.py



注:本文中的models.Company类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python models.Conference类代码示例发布时间:2022-05-27
下一篇:
Python models.Comment类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap