コード例 #1
0
    def test_competition_json(self):
        company = CompanyModel('GOL')
        expected = {
            'id': company.id,
            'name': company.name,
        }

        self.assertEqual(
            company.json(), expected,
            "The JSON export of the company is incorrect. Received {}, expected {}."
            .format(company.json(), expected))
コード例 #2
0
ファイル: newcompany.py プロジェクト: walidpfe/stage_pfe
 def post(self):
     user = users.get_current_user()
     url = users.create_login_url(self.request.uri)
     url_linktext = 'Login'
     title= 'Ajouter une entreprise'
     searchkey =  self.request.get('name')
     companies_query = CompanyModel.all().order('-companydateadded')
     companies = companies_query.fetch(30)
     result = list()
     for company in companies:
         
         if company.companyname.lower().find(searchkey.lower())>=0:
             result.append(company.companyname)
         
                 
     if user:
         url = users.create_logout_url(self.request.uri)
         url_linktext = 'Logout'
     values = {
         'searchkey' : searchkey,
         'result' : result,
     'title': title,
         'user': user,
         'url': url,
         'url_linktext': url_linktext,
       }
               
     self.response.out.write(template.render('templates/searchcompany.html', values))
コード例 #3
0
ファイル: editcompany.py プロジェクト: walidpfe/stage_pfe
    def get(self):
        user = users.get_current_user()
        url = users.create_login_url(self.request.uri)
        url_linktext = 'Login'
                    
        if user:
            url = users.create_logout_url(self.request.uri)
            url_linktext = 'Logout'
            raw_id = self.request.get('id')
            ido = int(raw_id)
            lentrepriseo = CompanyModel.get_by_id(ido)
            
        else:
            self.redirect(users.create_login_url(self.request.uri))
# GQL is similar to SQL
      
        
        
        values = {
            'company': lentrepriseo,
        
            'user': user,
            'url': url,
            'url_linktext': url_linktext,
        }
        self.response.out.write(template.render('templates/editcompany.html', values))
コード例 #4
0
ファイル: addtoselection.py プロジェクト: walidpfe/stage_pfe
    def post(self):
        user = users.get_current_user()
        if user:
         

         tagname = self.request.get('tags')
         raw_id = self.request.get('id')
         id = int(raw_id)
         lespace = EspaceModel.get_by_id(id)
         
         tag = TagModel(name =tagname , espace = lespace)
         tag.put();
         idlist = self.request.get_all('id[]')
         for idcompany in idlist:
             idc = int(idcompany)
             company = CompanyModel.get_by_id(idc)
             
             selection = SelectionModel(espace = lespace, company = company, tag = tag,
                                        selectedby =users.get_current_user()).put()

         
         values = {
             
            
	    'idlist': idlist,
	    
          }
コード例 #5
0
    def test_create_competition(self):
        company = CompanyModel('GOL')

        self.assertEqual(
            company.name, 'GOL',
            "The name of the company after creation does not equal the constructor argument."
        )
コード例 #6
0
ファイル: company.py プロジェクト: DanialIdham/FlaskCode
 def delete(self):
     data = self.parser.parse_args()
     companyName = data['companyName']
     company = CompanyModel.find_by_name(companyName)
     if company:
         company.delete_from_db()
         return {'message': 'Company deleted.'}
     return {'message': 'Company not found.'}, 404
コード例 #7
0
ファイル: company.py プロジェクト: DanialIdham/FlaskCode
 def get(self):
     user_id = get_jwt_identity()
     companyList = [company.json() for company in CompanyModel.find_all()]
     if user_id:
         return {'companyList': companyList}, 200
     return {
         'companyList': [company['name'] for company in companyList],
         'message': 'More data available if you log in.'
     }, 200
コード例 #8
0
ファイル: company_test.py プロジェクト: leobene/RadarMiles
    def test_delete_company(self):
        with self.app() as c:
            with self.app_context():
                CompanyModel('Azul').save_to_db()
                r = c.delete('/company/Azul')

                self.assertEqual(r.status_code, 200)
                self.assertDictEqual(d1={'message': 'Company deleted'},
                                     d2=json.loads(r.data.decode('utf-8')))
コード例 #9
0
    def get(self, us_employer_id):
        company = CompanyModel.find_by_us_employer_id(us_employer_id)

        if not company:
            return {
                "message": "No such company registered with this employer ID!"
            }, 404  # returns a tuple: (body, status code), (body:dictionary, status code: integer - default 200)
        else:
            return format_company_to_json(company)
コード例 #10
0
async def update_an_account(id_or_taxcode,
                            account: CompanyModel,
                            account_type: str = 'enterprise'):
    if account_type == 'enterprise':
        obj_company.fn_create_or_update_a_company(id_or_taxcode,
                                                  **account.dict())
        return JSONResponse(content={'message': "Updated successfully."})
    else:
        # TODO: update a personal account
        pass
コード例 #11
0
    def delete(self, us_employer_id):
        company = CompanyModel.find_by_us_employer_id(us_employer_id)

        if not company:
            return {
                "message": "No such company associated with this employer ID!"
            }, 404

        company.delete_from_db()
        return {"message": "company deleted!"}
コード例 #12
0
ファイル: newcompany.py プロジェクト: walidpfe/stage_pfe
 def post(self):
     user = users.get_current_user()
     if user:
      company  = CompanyModel(
             companyaddedby  = users.get_current_user(),
             companyname = self.request.get('companyname'),
             companywebsite = self.request.get('companywebsite'),
             companyaddress = self.request.get('companyaddress'),
             companywilaya = self.request.get('companywilaya'),
             companydescription = self.request.get('companydescription'))
      company.put();
      emails = self.request.get_all('companymail')
      for email in emails:
         CompanyEmailsModel(email = email , company = company).put()
      tels = self.request.get_all('companytel')
      for tel in tels:
          CompanyTelModel(companytel = tel, company = company).put()     
      
      self.redirect('/')
コード例 #13
0
ファイル: addtasksabout.py プロジェクト: walidpfe/stage_pfe
 def get(self):
     user = users.get_current_user()
     url = users.create_login_url(self.request.uri)
     url_linktext = 'Login'
     title= 'Ajouter une entreprise'        
     raw_id = self.request.get('id')
     id = int(raw_id)
     company = CompanyModel.get_by_id(id)
     tasks = TasksAboutModel.all().filter('organisme', CompanyModel.get_by_id(id)).filter('profile', UserProfileModel.getCurrent())
     values = {
         'idcompany' : id,
         'tasks' : tasks,      
         'company': company,
         'title': title,
         'user': user,
         'url': url,
         'url_linktext': url_linktext,
       }
               
     self.response.out.write(template.render('templates/loadtasksabout.html', values))  
コード例 #14
0
ファイル: company_test.py プロジェクト: leobene/RadarMiles
    def test_create_company(self):
        with self.app() as c:
            with self.app_context():
                r = c.post('/company/Azul')

                self.assertEqual(r.status_code, 201)
                self.assertIsNotNone(CompanyModel.find_by_name('Azul'))
                self.assertDictEqual(d1={
                    'id': 1,
                    'name': 'Azul'
                },
                                     d2=json.loads(r.data.decode('utf-8')))
コード例 #15
0
ファイル: company_test.py プロジェクト: leobene/RadarMiles
    def test_company_found(self):
        with self.app() as c:
            with self.app_context():
                CompanyModel('Azul').save_to_db()
                r = c.get('/company/Azul')

                self.assertEqual(r.status_code, 200)
                self.assertDictEqual(d1={'company': {
                    'id': 1,
                    'name': 'Azul'
                }},
                                     d2=json.loads(r.data.decode('utf-8')))
コード例 #16
0
ファイル: entreprises.py プロジェクト: walidpfe/stage_pfe
    def get(self):
        user = users.get_current_user()
        url = users.create_login_url(self.request.uri)
        url_linktext = 'Login'
                    
        if self.hasValidUser():
         if self.isNewUser():
            self.redirect("/login")
         else:
       
            url = users.create_logout_url(self.request.uri)
            url_linktext = 'Logout'
            listdesespaces = EspaceEmailsModel.getMyEspaces()
            companies_query = CompanyModel.all().order('-companydateadded')
            companies = companies_query.fetch(10)
            selection_query = SelectionModel.all()
            selections = selection_query.fetch(10)
       
	
            selectionsview = list()
		
            for company in companies:
                selectionview = SelectionView()
                selectionview.company = company
                selectionview.tags = list()
                companyid = company.key().id_or_name()
	   
            
           
                for espaceid in listdesespaces:
                    newtag = SelectionModel.getAllTagsForCompanyInThisEspace(espaceid,companyid)
                    match = [elt for elt in selectionview.tags if elt == newtag]
                    if not match :

                        selectionview.tags.append(newtag)
            
                selectionsview.append(selectionview)
    
            
            
        
            values = {
                'taggggs' :selectionview.tags,
                'selections' : selectionsview,
                'companies': companies,
	   
           
                'user': user,
                'url': url,
                'url_linktext': url_linktext,
            }
            self.response.out.write(template.render('templates/companies.html', values))
コード例 #17
0
ファイル: ficheentreprise.py プロジェクト: walidpfe/stage_pfe
 def get(self):
     user = users.get_current_user()
     url = users.create_login_url(self.request.uri)
     url_linktext = 'Login'
     title = 'Ajouter une entreprise'        
     raw_id = self.request.get('id')
     id = int(raw_id)
     lentreprise = CompanyModel.get_by_id(id)
     emails = CompanyEmailsModel.getAllEmailsByCompanyID(id)
     tels = CompanyTelModel.getAllTelsByCompanyID(id)
     notes = NoteCompanyModel.all().order('creedate').filter('company', CompanyModel.get_by_id(id))
     values = { 
         'emails' : emails,
         'tels' : tels,
         'company': lentreprise,
         'idcompany' : id,
         'notes' : notes,
         'user': user,
         'url': url,
         'url_linktext': url_linktext,
        }
     self.response.out.write(template.render('templates/loadnotecompany.html', values))
コード例 #18
0
async def create_a_new_account(account: CompanyModel,
                               account_type: str = 'enterprise'):
    if account_type == 'enterprise':
        try:
            # TODO: check constraint tax_code is unique and isn't deleted yet
            obj_company.fn_create_or_update_a_company(**account.dict())
            return JSONResponse(content={'message': "Created successfully."},
                                status_code=201)
        except ConstraintError:
            return JSONResponse(content={'message': "Already exists."})
    else:
        # TODO: create a personal account
        pass
コード例 #19
0
ファイル: company.py プロジェクト: DanialIdham/FlaskCode
    def put(self):
        data = self.parser.parse_args()
        companyName = data['companyName']
        company = CompanyModel.find_by_name(companyName)

        # if company:
        #     company.price = data['price']
        # else:
        #     company = CompanyModel(companyName, **data)

        company.save_to_db()

        return company.json()
コード例 #20
0
ファイル: ficheentreprise.py プロジェクト: walidpfe/stage_pfe
 def post(self):
     user = users.get_current_user()
     url = users.create_login_url(self.request.uri)
     url_linktext = 'Login'
     title= 'Ajouter une entreprise'
     if user:
      raw_id = self.request.get('noteespace')
      id = int(raw_id)
      lacompany = CompanyModel.get_by_id(id)
      note  = NoteCompanyModel(
             profile  = UserProfileModel.getCurrent(),
             texnote = self.request.get('notebody'),
             company = lacompany)
      note.put();
コード例 #21
0
ファイル: ficheentreprise.py プロジェクト: walidpfe/stage_pfe
    def get(self):
        user = users.get_current_user()
        url = users.create_login_url(self.request.uri)
        url_linktext = 'Login'
                    
        if user:
            url = users.create_logout_url(self.request.uri)
            url_linktext = 'Logout'
            raw_id = self.request.get('id')
            id = int(raw_id)
            lentreprise = CompanyModel.get_by_id(id)
            emails = CompanyEmailsModel.getAllEmailsByCompanyID(id)
            notes = NoteCompanyModel.all().order('creedate').filter('company', CompanyModel.get_by_id(id))
            tels = CompanyTelModel.getAllTelsByCompanyID(id)
            persons = PersonModel.all().filter('organisme =', lentreprise)
            sujets = SujetModel.all().filter('organismeref =', lentreprise)
            tasks = TasksAboutModel.all().filter('organisme', lentreprise).filter('profile', UserProfileModel.getCurrent())
        else:
            self.redirect(users.create_login_url(self.request.uri))
		

       
        values = {
            'emails' : emails,
            'idcompany' : id,
            'sujets' : sujets,
            'tasks' : tasks,
            'tels' : tels,
            'persons' : persons,
            'company': lentreprise,
            'notes' : notes,
            'user': user,
            'url': url,
            'url_linktext': url_linktext,
        }
        self.response.out.write(template.render('templates/fiche_entreprise.html', values))
コード例 #22
0
ファイル: company_test.py プロジェクト: leobene/RadarMiles
    def test_crud(self):
        with self.app_context():
            competition = CompanyModel('AVIANCA')

            self.assertIsNone(
                CompanyModel.find_by_name('AVIANCA').first(),
                "Found an competition with name 'AVIANCA' before save_to_db")

            competition.save_to_db()

            self.assertIsNotNone(
                CompanyModel.find_by_name('AVIANCA').first(),
                "Did not find a competition with name 'AVIANCA' after save_to_db"
            )

            competition.delete_from_db()

            self.assertIsNone(
                CompanyModel.find_by_name('AVIANCA').first(),
                "Found an competition with name 'AVIANCA' after delete_from_db"
            )
コード例 #23
0
    def post(self, name):
        if CompanyModel.find_by_name(name):
            return {'message': "A store with name '{}' already exists.".format(name)}, 400

        company = CompanyModel(name)
        try:
            company.save_to_db()
        except:
            return {"message": "An error occurred creating the store."}, 500

        return company.json(), 201
コード例 #24
0
ファイル: addtasksabout.py プロジェクト: walidpfe/stage_pfe
 def post(self):
     user = users.get_current_user()
     url = users.create_login_url(self.request.uri)
     url_linktext = 'Login'
     title= 'Ajouter une entreprise'
     if user:
      raw_id = self.request.get('id')
      id = int(raw_id)
      company = CompanyModel.get_by_id(id)
      
      tache = TasksAboutModel(
             profile  = UserProfileModel.getCurrent() ,
             titretache = self.request.get('task[body]'),
             tachepourdate = self.request.get('task[date]'),
             etattache = True,
             organisme = company)
      tache.put();
コード例 #25
0
 def post(self):
     user = users.get_current_user()
     if user:
       raw_id = self.request.get('id')
       id = int(raw_id)
       lentreprise = CompanyModel.get_by_id(id)
       lentreprise.companyaddedby  = users.get_current_user()
       lentreprise.companyname = self.request.get('companyname')
       lentreprise.companytel = self.request.get('companytel')
       lentreprise.companymail = self.request.get('companymail')
       lentreprise.companywebsite = self.request.get('companywebsite')
       lentreprise.companyaddress = self.request.get('companyaddress')
       lentreprise.companywilaya = self.request.get('companyawilaya')
       lentreprise.companydescription = self.request.get('companydescription')
         
       lentreprise.put();
       self.redirect('/company?id='+raw_id)
コード例 #26
0
 def post(self, name):
     company = CompanyModel.find_by_name(name)
     if company:
         data = Purchase.parser.parse_args()
         purchase_date = datetime.strptime(data['purchase_date'],
                                           "%Y-%m-%d")
         purchase = PurchaseModel(data['price'], data['quantity'],
                                  company.id, purchase_date)
         try:
             purchase.save()
         except:
             return {
                 "message": "An error occurred inserting the purchase."
             }, 500
     else:
         return {"message": "Company not found."}, 204
     return purchase.json(), 201
コード例 #27
0
ファイル: sujetproposer.py プロジェクト: walidpfe/stage_pfe
 def post(self):
     user = users.get_current_user()
     if user:
      sujet  = SujetModel(
             sujetaddedby  = users.get_current_user(),
             titresujet = self.request.get('sujettitre'),
             description = self.request.get('Resume'),
             organismeref = CompanyModel.getCompanyByName(self.request.get('organisme').strip()))
      sujet.put();
      mots = self.request.get_all('motcle')
      for mot in mots:
          MotcleSujetModel(motcle = mot , sujet = sujet).put()
   
      encadreurs = self.request.get_all('autreencadreure')
      for encadreur in encadreurs:
          EncadreurSujetModel(autreencadreur = encadreur , sujet = sujet).put()
 
      self.redirect('/deals')
コード例 #28
0
    def post(self, company_name):
        company = CompanyModel.find_by_name(company_name)

        if company:
            data = Income.parser.parse_args()

            date = datetime.strptime(data['receive_date'], "%Y-%m-%d")
            income = IncomeModel(data['value'], data['income_type'],
                                 company.id, date)
            try:
                income.save()
            except:
                return {
                    "message": "An error occurred inserting the income."
                }, 500
        else:
            return {"message": "Company not found"}, 204
        return income.json()
コード例 #29
0
ファイル: newperson.py プロジェクト: walidpfe/stage_pfe
 def get(self):
    user = users.get_current_user()
    url = users.create_login_url(self.request.uri)
    url_linktext = 'Login'
    title= 'Ajouter une entreprise'
    if user:
     raw_id = self.request.get('id')
     id = int(raw_id)
     company = CompanyModel.get_by_id(id)
     values = {
        'company': company,
        'title': title,
        'user': user,
        'url': url,
        'url_linktext': url_linktext,
      }
              
    self.response.out.write(template.render('templates/addnewpersonat.html', values))  
コード例 #30
0
ファイル: company.py プロジェクト: Mox93/crm_api
    def mutate(root, info, company_data, user_id):
        name_check = CompanyModel.find_by_name(company_data.name)
        if name_check:
            raise Exception("Company already exist!")

        user = User.find_by_id(user_id)
        if user.company:
            raise Exception("User already belongs to a company!")

        owner_role = EmbeddedRole(name="owner", group=0, priority_level=0)

        company = CompanyModel(**company_data)
        company.roles.append(owner_role)
        company.save()

        user.role.append(owner_role)
        user.company = company
        user.save()

        return NewCompany(ok=True, company=company)
コード例 #31
0
ファイル: loadselection.py プロジェクト: walidpfe/stage_pfe
    def get(self):
        user = users.get_current_user()
        url = users.create_login_url(self.request.uri)
        url_linktext = 'Login'
                    
        if user:
            url = users.create_logout_url(self.request.uri)
            url_linktext = 'Logout'
        else:
            self.redirect(users.create_login_url(self.request.uri))
# GQL is similar to SQL
        companies_query = CompanyModel.all().order('-companydateadded')
        companies = companies_query.fetch(10)
        selection_query = SelectionModel.all()
        selections = selection_query.fetch(10)
        id = self.request.get('id')
        espaceid = int(id)
	espace = EspaceModel.get_by_id(espaceid)
        selectionsview = list()
        for company in companies:
            selectionview = SelectionView()
	    selectionview.company = company
            companyid = company.key().id_or_name()
            
            selectionview.tags = SelectionModel.getAllTagsForCompanyInThisEspace(espaceid,companyid)
            selectionsview.append(selectionview)
            
            
        
        values = {
            'selections' : selectionsview,
            'companies': companies,
	    'id':id,
            
            'user': user,
            'url': url,
            'url_linktext': url_linktext,
        }
        self.response.out.write(template.render('templates/loadajax.html', values))           
コード例 #32
0
ファイル: newperson.py プロジェクト: walidpfe/stage_pfe
 def post(self):
     user = users.get_current_user()
     if user:
      person  = PersonModel(
             personaddedby  = users.get_current_user(),
             personname = self.request.get('companyname'),
             personpname = self.request.get('prenom'),
             organisme = CompanyModel.getCompanyByName(self.request.get('organisme').strip()),
             fonction =  self.request.get('fonction'),
             personwebsite = self.request.get('companywebsite'),
             personaddress = self.request.get('companyaddress'),
             personwilaya = self.request.get('companywilaya'),
             persondescription = self.request.get('companydescription'))
      person.put();
      emails = self.request.get_all('companymail')
      for email in emails:
         PersonEmailsModel(email = email , person = person).put()
      tels = self.request.get_all('companytel')
      for tel in tels:
          PersonTelModel(persontel = tel, person = person).put()     
      
      self.redirect('/')
コード例 #33
0
ファイル: addtoselection.py プロジェクト: walidpfe/stage_pfe
    def post(self):
        user = users.get_current_user()
        if user:
         

         tagname = self.request.get('tags')
         listdesespaces = EspaceEmailsModel.getMyEspaces()
         
         tag = TagModel(name =tagname).put();
         
         for idespace in listdesespaces:
             lespace = EspaceModel.get_by_id(idespace)
                
            
             idlist = self.request.get_all('id[]')
             for idcompany in idlist:
                 idc = int(idcompany)
                 company = CompanyModel.get_by_id(idc)
             
                 
             
                 selection = SelectionModel(espace = lespace, company = company, tag = tag,
                                        selectedby =users.get_current_user()).put()
コード例 #34
0
    def get(self, segment_id: int) -> tuple:
        """
        Accesses ResumeModel, GraduationModel, CertificationModel, SkillModel, CompanyModel, 
        ProductModel, PresentationModel and returns all information by segment_id.
        """
        resume = ResumeModel.get_current_by_segment(segment_id)
        graduations = GraduationModel.get_all_by_segment(segment_id, True)
        certifications = CertificationModel.get_all_by_segment(segment_id)
        skills = SkillModel.get_all_by_segment(segment_id)
        companies = CompanyModel.get_all_by_segment(segment_id, True)
        products = ProductModel.get_all_by_segment(segment_id)
        presentations = PresentationModel.get_all_by_segment(segment_id, True)

        return {
            'curriculum': {
                'resume': check_json(resume),
                'graduations': list_map(graduations),
                'certifications': list_map_curriculum(certifications),
                'skills': list_map_curriculum(skills),
                'companies': list_map_curriculum(companies),
                'products': list_map_curriculum(products),
                'presentations': list_map_curriculum(presentations)
            }
        }, 200
コード例 #35
0
    def put(self, us_employer_id):

        company = CompanyModel.find_by_us_employer_id(us_employer_id)

        if not company:
            return {
                "message": "No such company registered with this employer ID !"
            }, 404

        data = Company.parser.parse_args()
        company.company_name = data['company_name']
        company.business_area = data['business_area']
        company.number_of_employees = data['number_of_employees']
        company.phone = data['phone']
        company.address = data['address']

        try:
            company.save_to_db()
        except:
            return {
                "message": "An error occurred while updating the company info!"
            }, 500

        return format_company_to_json(company)
コード例 #36
0
ファイル: company.py プロジェクト: DanialIdham/FlaskCode
    def post(self):
        data = self.parser.parse_args()
        companyName = data['companyName']
        if CompanyModel.find_by_name(companyName):
            return {
                'message':
                "An item with name '{}' already exists.".format(companyName)
            }, 400

        company = CompanyModel(companyName, **data)

        try:
            company.save_to_db()
        except:
            return {
                "message": "An error occurred while inserting the item."
            }, 500

        return company.json(), 201
コード例 #37
0
    def post(self, us_employer_id):

        if CompanyModel.find_by_us_employer_id(us_employer_id):
            return {
                "message":
                "A company already exists with the same employer ID, use a different one!"
            }, 400

        data = Company.parser.parse_args()
        is_valid, error_message = CompanyModel.check_if_data_has_valid_format(
            us_employer_id, **data)

        if is_valid:
            new_company = CompanyModel(us_employer_id, **data)
            try:
                format_company_to_json(new_company)
                new_company.save_to_db()
                return format_company_to_json(new_company), 201
            except:
                return {
                    "message": "An error occurred while creating the user!"
                }, 500
        else:
            return {"message": error_message}, 400
コード例 #38
0
 def get(self, name):
     company = CompanyModel.find_by_name(name)
     if company:
         return company.json()
     return {'message': 'Company not found'}, 404
コード例 #39
0
 def get(self,name):
     company = CompanyModel.find_by_name(name)
     if company:
         return company.json()
     return {'message':'company does not exist'},400
コード例 #40
0
 def get(self):
     return {
         'companies':
         [format_company_to_json(x) for x in CompanyModel.find_all()]
     }  # map() function returns a list of the results after applying the given function to each item of a given iterable (list, tuple etc.)
コード例 #41
0
 def get(self, id):
     company = CompanyModel.get_company(id)
     return company
コード例 #42
0
 def get(self):
     all_companies = CompanyModel.all()
     return all_companies
コード例 #43
0
 def post(self):
     data = Company.parser.parse_args()
     company_model = CompanyModel(data['name'])
     result = company_model.insert()
     return result
コード例 #44
0
    def delete(self, name):
        company = CompanyModel.find_by_name(name)
        if company:
            company.delete_from_db()

        return {'message': 'Store deleted'}