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