def create_hireme_project(session, title, description, currency, budget, jobs, hireme_initial_bid): """ Create a fixed project """ jobs.append(create_job_object(id=417)) # Hire Me job, required project_data = { 'title': title, 'description': description, 'currency': currency, 'budget': budget, 'jobs': jobs, 'hireme': True, 'hireme_initial_bid': hireme_initial_bid } # POST /api/projects/0.1/projects/ response = make_post_request(session, 'projects', json_data=project_data) json_data = response.json() if response.status_code == 200: project_data = json_data['result'] p = Project(project_data) p.url = urljoin(session.url, 'projects/%s' % p.seo_url) return p else: raise ProjectNotCreatedException( message=json_data['message'], error_code=json_data['error_code'], )
def sample_create_hireme_project(): oauth_token = os.environ.get('FLN_OAUTH_TOKEN') url = os.environ.get('FLN_URL') session = Session(oauth_token=oauth_token, url=url) project_data = { 'title': 'My new hireme project', 'description': 'description', 'currency': create_currency_object(id=1), 'budget': create_budget_object(minimum=10), 'jobs': [create_job_object(id=7)], 'hireme_initial_bid': create_bid_object( id=None, # No bid id yet bidder_id=2, # Freelancer we want to hire project_id=None, # This project retracted=None, amount=100, period=7, # Days description='Hello', project_owner_id=1) } try: p = create_hireme_project(session, **project_data) except ProjectNotCreatedException as e: print(('Error message: %s' % e.message)) print(('Error code: %s' % e.error_code)) return None else: return p
def sample_create_local_project(): oauth_token = os.environ.get('FLN_OAUTH_TOKEN') url = os.environ.get('FLN_URL') session = Session(oauth_token=oauth_token, url=url) project_data = { 'title': 'My new local project', 'description': 'description', 'currency': create_currency_object(id=1), 'budget': create_budget_object(minimum=10), 'jobs': [create_job_object(id=649)], # Must be a local job 'location': create_location_object(create_country_object('Australia'), 'Sydney', -33.875461, 151.201678) } try: p = create_local_project(session, **project_data) except ProjectNotCreatedException as e: print(('Error message: %s' % e.message)) print(('Error code: %s' % e.error_code)) return None else: return p
def sample_create_hourly_project(): oauth_token = os.environ.get('FLN_OAUTH_TOKEN') url = os.environ.get('FLN_URL') session = Session(oauth_token=oauth_token, url=url) project_data = { 'title': 'My new hourly project', 'description': 'description', 'currency': create_currency_object(id=1), 'budget': create_budget_object(minimum=10), 'jobs': [create_job_object(id=7)], 'hourly_project_info': create_hourly_project_info_object(40, 'WEEK', 'ONE_TO_FOUR_WEEKS') } try: p = create_hourly_project(session, **project_data) except ProjectNotCreatedException as e: print(('Error message: %s' % e.message)) print(('Error code: %s' % e.error_code)) return None else: return p
def post_project(): if request.method == "GET": return render_template("create_project.html") data = { 'title': "Need someone to buy and bring me a beer ASAP.", 'description': json.loads(request.data)['description'], 'budget': create_budget_object( minimum=10, maximum=25, ), 'currency': create_currency_object(id=3), 'jobs': [create_job_object(id=632)], 'location': create_location_object( country=create_country_object('Australia'), city='Sydney', latitude=-33.8744101, longitude=151.2028132, full_address="Sydney, NSW, Australia", ) } result = None try: # TODO: Make this an app level attribute instead s = Session(oauth_token=h["Freelancer-OAuth-V1"], url=base_url) result = create_local_project(s, **data) except ProjectNotCreatedException as e: print(('Error message: %s' % e.message)) print(('Error code: %s' % e.error_code)) return jsonify(result) else: user_id = User.query.filter_by(name=session['name']).first().id project = Project(result.id, user_id) db.session.add(project) db.session.commit() result = {'result': {'id': result.id, 'seo_url': result.seo_url}} return jsonify(result)
def sample_create_project(): id = os.environ["FLN_DEVELOPER_ID"] token = os.environ["FLN_DEVELOPER_TOKEN"] url = os.environ["FLN_URL"] session = Session(id=id, token=token, url=url) project_data = { "title": "My new project", "description": "description", "currency": create_currency_object(id=1), "budget": create_budget_object(minimum=10), "jobs": [create_job_object(id=7)], } try: p = create_project(session, **project_data) except ProjectNotCreatedException as e: print("Error message: %s" % e.message) print("Error code: %s" % e.error_code) return None else: return p
def sample_create_project(): id = os.environ['FLN_DEVELOPER_ID'] token = os.environ['FLN_DEVELOPER_TOKEN'] url = os.environ['FLN_URL'] session = Session(id=id, token=token, url=url) project_data = { 'title': 'My new project', 'description': 'description', 'currency': create_currency_object(id=1), 'budget': create_budget_object(minimum=10), 'jobs': [create_job_object(id=7)], } try: p = create_project(session, **project_data) except ProjectNotCreatedException as e: print('Error message: %s' % e.message) print('Error code: %s' % e.error_code) return None else: return p