示例#1
0
def search():
    """Render search page."""
    try:
        districts = repo.get_districts()
        facility_types = repo.get_facility_types()
        return render_flod_template(
            'search.html',
            districts=json.dumps(districts),
            facility_types=json.dumps(facility_types)
        )
    except requests.exceptions.ConnectionError:
        app.logger.exception('Request failed')
        return "", 500
示例#2
0
def organisation(organisation_id):
    try:

        organisation = repo.get_organisation(
            organisation_id, getattr(current_user, 'user_id', None))

        recruiting_districts = repo.get_districts()
        districts = repo.get_districts_without_whole_trd()

        try:
            organisation["area"] = next(
                district["name"] for district in districts if district["id"] == organisation.get("area"))
        except StopIteration:
            organisation["area"] = None

        try:
            organisation["recruitment_area"] = next(
                district["name"] for district in recruiting_districts if district["id"] == organisation.get("recruitment_area"))
        except StopIteration:
            organisation["recruitment_area"] = None

        brreg_activity_codes = repo.get_brreg_activity_codes()

        organisation["brreg_activity_code"] = [code for code in brreg_activity_codes if
                                               code["code"] in organisation.get("brreg_activity_code", [])]

        activity_types = [type["flod_activity_types"] for type in organisation.get("brreg_activity_code")]
        activity_types = [y for x in activity_types for y in x]

        organisation["flod_activity_type"] = [type for type in activity_types if
                                              type["id"] in organisation.get("flod_activity_type", [])]

        for key, value in organisation.items():
            if value == "" or value is None:
                del organisation[key]

        return render_org_template(
            'org_info.html',
            organisation_id,
            requires_owner=False,
            organisation=organisation
        )
    except requests.exceptions.ConnectionError:
        app.logger.exception('Request failed')
        return "", 500
    except requests.exceptions.HTTPError as e:
        abort(e.response.status_code)
示例#3
0
def register_org():
    if not (current_user.is_idporten_user() or current_user.is_aktorregister_admin()):
        abort(401)

    """Render home page."""
    try:
        recruiting_districts = repo.get_districts()
        districts = repo.get_districts_without_whole_trd()

        brreg_activity_codes = repo.get_brreg_activity_codes()

        return render_flod_template(
            'register_org.html',
            districts=json.dumps(districts),
            recruiting_districts=json.dumps(recruiting_districts),
            brreg_activity_codes=json.dumps(brreg_activity_codes)
        )
    except requests.exceptions.ConnectionError:
        app.logger.exception('Request failed')
        return "", 500
示例#4
0
def edit_organisation(organisation_id):
    try:
        recruiting_districts = repo.get_districts()
        districts = repo.get_districts_without_whole_trd()
        brreg_activity_codes = repo.get_brreg_activity_codes()

        organisation = repo.get_organisation(
            organisation_id, getattr(current_user, 'user_id', None))

        return render_org_template(
            'edit_org.html',
            organisation_id,
            organisation=json.dumps(organisation),
            districts=json.dumps(districts),
            recruiting_districts=json.dumps(recruiting_districts),
            brreg_activity_codes=json.dumps(brreg_activity_codes)
        )
    except requests.exceptions.ConnectionError:
        app.logger.exception('Request failed')
        return "", 500
    except requests.exceptions.HTTPError as e:
        abort(e.response.status_code)