當前位置: 首頁>>代碼示例>>Python>>正文


Python models.Employee類代碼示例

本文整理匯總了Python中models.Employee的典型用法代碼示例。如果您正苦於以下問題:Python Employee類的具體用法?Python Employee怎麽用?Python Employee使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Employee類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: create_invoice

def create_invoice():
    if Security.is_login(SK):
        item = Item()
        employee = Employee()
        return render_template('invoice/create_invoice.html', title='Create Invoice', items=item.get_items(),
                               employees=employee.get_employees())
    return redirect(url_for('login', callback=stack()[0][3]))
開發者ID:dsantosp12,項目名稱:PyTry,代碼行數:7,代碼來源:PyTry.py

示例2: profile_handler

def profile_handler(doc, name, url, path):
    filename = os.path.join(path, name + ".html")
    employee = Employee(name=name, url=url)

    # 隻保存名稱和個人主頁,個人簡曆文件另存當前目錄
    soup = BeautifulSoup(doc, Config.SOUP_PARSER)
    divs = soup.find_all(name="div", attrs={"id":"phy-main"}, limit=1)
    if not divs or len(divs) == 0:
        return employee

    div = divs[0]
    if not os.path.exists(filename):
        with open(filename, 'wb') as fp:
            content = div.prettify()
            fp.write(content)
            fp.close()
    
    #email
    email_div = soup.find_all(name='a',class_="phy-mail")
    if email_div and len(email_div) != 0:
        employee.email = email_div[0].get_text().strip()

    te_div = soup.find_all(name='a',class_="phy-phone")
    if te_div and len(te_div) != 0:
        employee.tel = te_div[0].get_text().strip()
    
    # 使用純文本方式處理
    lines = div.stripped_strings
    # text=div.get_text(strip=True)
    parser = ProfileParser(lines=lines,employee=employee,set_attr_hook=set_attr_hook)
    return parser.parse()
開發者ID:Jumbo-WJB,項目名稱:EduParser,代碼行數:31,代碼來源:MyHandler.py

示例3: profile_handler

def profile_handler(doc, name, url, path):
    filename = os.path.join(path, name + ".html")
    employee = Employee(name=name, url=url)

    # 隻保存名稱和個人主頁,個人簡曆文件另存當前目錄
    soup = BeautifulSoup(doc, Config.SOUP_PARSER)
    divs = soup.find_all(name="div", attrs={"id":"right_2"}, limit=1)
    if not divs or len(divs) == 0:
        return employee

    div = divs[0]
    if not os.path.exists(filename):
        with open(filename, 'wb') as fp:
            content = div.prettify()
            fp.write(content)
            fp.close()
    
    researches = [' ',' ']
    tds = div.find_all(name="td",attrs={"bgcolor":"#FFFFFF","class":"ft12","valign":"top"},limit=4)
    if len(tds) == 4:
        researches[0] = tds[2].get_text().strip()
        researches[1] = tds[3].get_text().strip()
        employee.research = researches[0] + ";" +researches[1]
        print "research:" + employee.research 
    # 使用純文本方式處理
    lines = div.stripped_strings
    # text=div.get_text(strip=True)
    parser = ProfileParser(lines=lines,employee=employee,ignore=set(['research']))
    return parser.parse()
開發者ID:Jumbo-WJB,項目名稱:EduParser,代碼行數:29,代碼來源:MyHandler.py

示例4: profile_handler

def profile_handler(doc, name, url, path):
    filename = os.path.join(path, name + ".html")
    employee = Employee(name=name, url=url)

    # 隻保存名稱和個人主頁,個人簡曆文件另存當前目錄
    soup = BeautifulSoup(doc, Config.SOUP_PARSER)
    divs = soup.find_all(name="div", class_="box_rt01 list", limit=1)
    if not divs or len(divs) == 0:
        div = soup
    else:
        div = divs[0]

    with open(filename, 'wb') as fp:
        content = div.prettify()
        fp.write(content)
        fp.close()

    h3s = div.find_all('h3')
    if h3s and len(h3s) != 0:
        title = h3s[0].get_text()
        title = ''.join(title.split())
        print title
        for t in PROFILE_TITLES:
            if t in title:
                employee.title = title
                print "got => " + title
                break
    else:
        print "not found h3"
    # 使用純文本方式處理
    lines = div.stripped_strings
    # text=div.get_text(strip=True)
    parser = ProfileParser(lines=lines,employee=employee,force_email=True)
    return parser.parse()
開發者ID:Jumbo-WJB,項目名稱:EduParser,代碼行數:34,代碼來源:MyHandler.py

示例5: index

def index(request):
  e = Employee(name="John",
               role="manager",
               email='[email protected]')
  e.hire_date = datetime.datetime.now().date()
  #e.put()
  day1 = datetime.timedelta(days=1)
  trendslist=[]
  gtrendslist=[]
  yesterday = datetime.date.today()-day1
  query = Trend.all().filter('created >= ', yesterday).order('-created')
  results = query.fetch(100)
  for p in results:
    trendslist.append(p.title)
 
  
        
  gv = globvars
  context = {
    'thispage':'Home',
    'trends':trendslist,
    'gtrends':gtrendslist,
      }
  context = dict(context, **gv.context) #combines the 'local' context with the 'global' context
  return render_to_response('index.html', context)
開發者ID:m1ck,項目名稱:hottrends,代碼行數:25,代碼來源:views.py

示例6: post

    def post(self):
        if (self.request.get('username')):
            user = self.request.get('username')
        else:
            user = self.session['username']
        employee_query = Employee.query(Employee.login_name == user)
        employee = employee_query.fetch()[0]

        timesheet_query = Timesheet.query(Timesheet.time_period == self.request.get('time_period'), Timesheet.worked_by == employee.key)
        timesheet = timesheet_query.fetch()

        currentPositions = []
        for sheet in timesheet:
            currentPositions.append(sheet.position)

        for position in employee.positions:
            if position not in currentPositions:
                new_timesheet = Timesheet(worked_by=employee.key, position=position, time_period=self.request.get('time_period'))
                new_timesheet.put()
                timesheet.append(new_timesheet)

        jsonSheet = {'sheets': []}
        for t in timesheet:
            obj = {
                'worked_by': Employee.query(Employee.key == t.worked_by).fetch()[0].login_name,
                'position': Position.query(Position.key == t.position).fetch()[0].title,
                'hours_worked': t.hours_worked,
                'time_period': t.time_period,
                'is_submitted': t.is_submitted,
                'is_approved': t.is_approved
            }
            jsonSheet['sheets'].append(obj)

        self.response.headers['Content-Type'] = 'application/json'
        self.response.write(json.dumps(jsonSheet))
開發者ID:kulczajr,項目名稱:custom-timesheet,代碼行數:35,代碼來源:main.py

示例7: 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

示例8: test_callingGetDevelopmentPlansWithAsManagerEqualToTrueCallsFilterWithOwnerManagerAsArgument

	def test_callingGetDevelopmentPlansWithAsManagerEqualToTrueCallsFilterWithOwnerManagerAsArgument(self):
		employee = Employee()
		employee.pk = 38
		DevelopmentPlan.objects.filter = mock.MagicMock()
		DevelopmentPlan.objects.filter.return_value.order_by = mock.MagicMock()
		employee.getDevelopmentPlans(as_manager=True)
		DevelopmentPlan.objects.filter.assert_called_once_with(owner__manager__pk=38)
開發者ID:crmtoolboxgit,項目名稱:nxtlvl,代碼行數:7,代碼來源:oldtests.py

示例9: 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

示例10: handler

def handler(tag):
    name = tag.get_text()
    name = ''.join(name.split())
    names = name.split('_')
    name = names[0]
    employee = Employee(url=tag['href'], name=name)
    if len(names) >= 2:
        employee.title = names[1]
    return employee
開發者ID:Jumbo-WJB,項目名稱:EduParser,代碼行數:9,代碼來源:MyHandler.py

示例11: profile_handler

def profile_handler(doc,name,url,path):
    # employee可用屬性(url, name, email, tel, title, profile, research, departments,fax,addr):
    symbols = {
        u'Email:'    :'email',
        u'郵箱:'      :'email',
        u'電子郵件:'   :'email',
        u'電子郵箱:'   :'email',
        u'電話:'      :'tel',  
        u'聯係電話:'   :'tel',
        u'Tel:'       :'tel',
        u'辦公電話:'   :'tel',
        u'傳真:'      :'fax',  
        u'URL:'      :'url',
        u'職稱:'      :'title'
    }
    employee = None
    
    # 太亂了,隻保存名稱和個人主頁,個人簡曆文件另存當前目錄
    soup = BeautifulSoup(doc, Config.SOUP_PARSER)
    divs = soup.find_all(id="s2_right_con",limit=1)
    filename = path+name+".html"
    if not divs or len(divs) == 0:
        return Employee(name=name,url=url)
    div =divs[0]
    with open(filename,'wb') as fp:
        content = div.prettify()
        fp.write(content)
        fp.close()
     
    
    employee = Employee()
    # parse name
    name_h4 = div.h4
    if name_h4:
        employee.name = name_h4.string.strip(' \t\n\r')
    else:
        print name_h4
    
    for tag in div.children:
        if not tag.string:
            continue
        text = tag.string.strip(' \t\n\r')
        if len(text) == 0:
            continue
        for symbol,name in symbols.items():
            idx = text.find(symbol)
            if idx != -1:
                idx += len(symbol)
                value = text[idx:]
                if hasattr(employee, name):
                    setattr(employee, name, value)
                    symbols
                    # print (name + ":" + value)
                else:
                    print ("no attr %s in employee" % name)
                break
    return  employee
開發者ID:yixiaoyang,項目名稱:pyScripts,代碼行數:57,代碼來源:MyHandler.py

示例12: test_callingCanAssociateNewPlanReturnsFalseIfTheEmployeeHasAnOpenDevelopmentPlan

	def test_callingCanAssociateNewPlanReturnsFalseIfTheEmployeeHasAnOpenDevelopmentPlan(self):
		employee = Employee()
		employee.pk = 38
		employee.user = User()
		employee.user.pk = 9
		CompetenceFieldCollectionToUserRelation.objects.filter = mock.MagicMock()
		CompetenceFieldCollectionToUserRelation.objects.filter.return_value.exists = mock.MagicMock()
		CompetenceFieldCollectionToUserRelation.objects.filter.return_value.exists.return_value = [CompetenceFieldCollectionToUserRelation(employee.user, finished_at=None),]
		self.assertFalse(employee.canAssociateNewPlan())
		CompetenceFieldCollectionToUserRelation.objects.filter.assert_called_once_with(user__pk=employee.user.pk, finished_at=None)
開發者ID:crmtoolboxgit,項目名稱:nxtlvl,代碼行數:10,代碼來源:oldtests.py

示例13: test_callingGetDevelopmentPlansCallsFilterAndOrderByOnDevelopmentPlanWithGivenUserAsArgument

	def test_callingGetDevelopmentPlansCallsFilterAndOrderByOnDevelopmentPlanWithGivenUserAsArgument(self):
		employee = Employee()
		employee.pk = 38
		employee.user = User()
		employee.user.pk = 9
		DevelopmentPlan.objects.filter = mock.MagicMock()
		DevelopmentPlan.objects.filter.return_value.order_by = mock.MagicMock()
		employee.getDevelopmentPlans()
		DevelopmentPlan.objects.filter.assert_called_once_with(owner__pk=38)
		DevelopmentPlan.objects.filter.return_value.order_by.assert_called_once_with('-created_at')
開發者ID:crmtoolboxgit,項目名稱:nxtlvl,代碼行數:10,代碼來源:oldtests.py

示例14: 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.store = Store(code="10011001", name="test_store", company=self.company)
        self.store.save()

        self.emp_region = Employee(username="emp_region", organization=self.region)
        self.emp_company = Employee(username="emp_company", organization=self.company)
        self.emp_store = Employee(username="emp_store", organization=self.store)
開發者ID:xhacker5000,項目名稱:wandoujia-oem,代碼行數:12,代碼來源:tests.py

示例15: handler

def handler(tag):
    employee = Employee()
    name_divs = tag.find_all("div",class_="teacher-title")
    if name_divs and len(name_divs) != 0:
        employee.name = name_divs[0].get_text()
        employee.name = ''.join(employee.name.split())
    
    # 使用純文本方式處理
    lines = tag.stripped_strings
    # text=div.get_text(strip=True)
    parser = ProfileParser(lines=lines,employee=employee)
    return parser.parse()
開發者ID:yixiaoyang,項目名稱:pyScripts,代碼行數:12,代碼來源:MyHandler.py


注:本文中的models.Employee類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。