def test_links_to_sections_go_to_the_correct_pages_whether_they_be_sections_or_questions(
            self, content_loader, brief):  # noqa
        content_fixture = ContentLoader("tests/fixtures/content")
        content_fixture.load_manifest("dos", "data", "edit_brief")
        content_loader.get_manifest.return_value = content_fixture.get_manifest(
            "dos", "edit_brief")

        document = self.get_requirements_task_list_page(brief)

        section_steps = document.cssselect("ol.dm-task-list")
        section_1_link = section_steps[0].xpath(
            'li//a[contains(text(), "Section 1")]')
        section_2_link = section_steps[0].xpath(
            'li//a[contains(text(), "Section 2")]')
        section_4_link = section_steps[0].xpath(
            'li//a[contains(text(), "Section 4")]')

        # section with multiple questions
        assert (
            section_1_link[0].get("href").strip() ==
            "/buyers/frameworks/digital-outcomes-and-specialists-4/requirements/digital-specialists/1234/section-1"
        )
        # section with single question
        assert (
            section_2_link[0].get("href").strip() ==
            "/buyers/frameworks/digital-outcomes-and-specialists-4"
            "/requirements/digital-specialists/1234/edit/section-2/required2")
        # section with single question and a description
        assert (
            section_4_link[0].get("href").strip() ==
            "/buyers/frameworks/digital-outcomes-and-specialists-4/requirements/digital-specialists/1234/section-4"
        )
def load_manifest(schema_type, framework_slug, lot_slug):
    loader = ContentLoader('./')
    loader.load_manifest(framework_slug,
                         MANIFESTS[schema_type]['question_set'],
                         MANIFESTS[schema_type]['manifest'])

    return loader.get_builder(framework_slug,
                              MANIFESTS[schema_type]['manifest']).filter(
                                  {'lot': lot_slug})
Ejemplo n.º 3
0
    def test_edit_brief_submission_raises_error_if_question_type_not_known(self, content_loader):
        with pytest.raises(UndefinedError):
            content_fixture = ContentLoader('tests/fixtures/content')
            content_fixture.load_manifest('dos', 'data', 'edit_brief_fail')
            content_loader.get_manifest.return_value = content_fixture.get_manifest('dos', 'edit_brief_fail')

            self.client.get(
                "/buyers/frameworks/digital-outcomes-and-specialists-4/requirements/digital-specialists"
                "/1234/edit/section-1/unhandled")
def load_manifest(schema_type, framework_slug, lot_slug):
    loader = ContentLoader('./')
    loader.load_manifest(
        framework_slug,
        MANIFESTS[schema_type]['question_set'],
        MANIFESTS[schema_type]['manifest']
    )

    return loader.get_builder(framework_slug, MANIFESTS[schema_type]['manifest']).filter({'lot': lot_slug})
Ejemplo n.º 5
0
def main():
    args = docopt(__doc__)

    frameworks_repo = Path(args["--frameworks-repo"]).resolve()
    framework_slug = args["<framework_slug>"]

    content_loader = ContentLoader(frameworks_repo)
    content_loader.load_manifest(framework_slug, "services",
                                 "services_search_filters")
    manifest = content_loader.get_manifest(framework_slug,
                                           "services_search_filters")

    # FIXME there isn't a uniform way to get the lots from the framework
    # content repo, hard code for G-Cloud for now
    framework_lots = [
        {
            "name": "Cloud hosting",
            "slug": "cloud-hosting"
        },
        {
            "name": "Cloud software",
            "slug": "cloud-software"
        },
        {
            "name": "Cloud support",
            "slug": "cloud-support"
        },
    ]

    writer = csv.writer(sys.stdout)

    # do the thing

    writer.writerow(["lot", "filter name", "filter value", "filter sub-value"])

    def rows_for_filters(filters: dict):
        for section in filters.values():
            yield ["", str(section["label"]), "", ""]
            for option in section["filters"]:
                yield ["", "", str(option["label"]), ""]
                # category filters can have sub-categories
                # (but not sub-sub-categories)
                if "children" in option:
                    for suboption in option["children"]:
                        yield ["", "", "", suboption["label"]]

    # start with filters that are common to all lots
    common_filters = filters_for_lot("all", manifest, framework_lots)
    writer.writerow(["Any lot", "", ""])
    writer.writerows(rows_for_filters(common_filters))

    for lot in framework_lots:
        writer.writerow([lot.get("name", lot["slug"])])
        writer.writerows(
            rows_for_filters(
                filters_for_lot(lot["slug"], manifest, framework_lots)))
Ejemplo n.º 6
0
    def test_edit_brief_submission_return_link_to_brief_overview_if_single_question(self, content_loader):
        content_fixture = ContentLoader('tests/fixtures/content')
        content_fixture.load_manifest('dos', 'data', 'edit_brief')
        content_loader.get_manifest.return_value = content_fixture.get_manifest('dos', 'edit_brief')

        res = self.client.get(
            "/buyers/frameworks/digital-outcomes-and-specialists-4/requirements/digital-specialists"
            "/1234/edit/section-2/required2")

        assert res.status_code == 200
        document = html.fromstring(res.get_data(as_text=True))
        secondary_action_link = document.xpath('//a[normalize-space(text())="Return to overview"]')[0]
        assert document.xpath('//h1')[0].text_content().strip() == "Required 2"
        assert secondary_action_link.get('href').strip() == "/buyers/frameworks/digital-outcomes-and-specialists-4/requirements/digital-specialists/1234"  # noqa
        self._test_breadcrumbs_on_question_page(response=res, has_summary_page=False, question="Required 2")
Ejemplo n.º 7
0
    def test_edit_brief_submission_multiquestion(self, content_loader):
        content_fixture = ContentLoader('tests/fixtures/content')
        content_fixture.load_manifest('dos', 'data', 'edit_brief')
        content_loader.get_manifest.return_value = content_fixture.get_manifest('dos', 'edit_brief')

        res = self.client.get(
            "/buyers/frameworks/digital-outcomes-and-specialists-4/requirements/digital-specialists/1234/edit/section-5/required3")  # noqa

        assert res.status_code == 200

        document = html.fromstring(res.get_data(as_text=True))
        assert document.xpath('//h1')[0].text_content().strip() == "Required 3"
        assert document.xpath(
            '//label[contains(@for, "required3_1")]')[0].text_content().strip() == "Required 3_1"
        assert document.xpath(
            '//label[contains(@for, "required3_2")]')[0].text_content().strip() == "Required 3_2"
Ejemplo n.º 8
0
    def test_post_update_if_single_question_no_description_redirects_to_overview(self, content_loader):
        content_fixture = ContentLoader('tests/fixtures/content')
        content_fixture.load_manifest('dos', 'data', 'edit_brief')
        content_loader.get_manifest.return_value = content_fixture.get_manifest('dos', 'edit_brief')

        res = self.client.post(
            "/buyers/frameworks/digital-outcomes-and-specialists-4/requirements/"
            "digital-specialists/1234/edit/section-2/required2",
            data={
                "required2": "Answer"
            })

        assert res.status_code == 302
        self.data_api_client.update_brief.assert_called_with(
            '1234',
            {"required2": "Answer"},
            page_questions=['required2'],
            updated_by='*****@*****.**'
        )
        assert res.headers['Location'].endswith(
            'buyers/frameworks/digital-outcomes-and-specialists-4/requirements/digital-specialists/1234'
        ) is True
Ejemplo n.º 9
0
    def setup(self):
        content_loader = ContentLoader('tests/fixtures/content')
        content_loader.load_manifest('dos', "services", "edit_submission")
        self.content_manifest = content_loader.get_manifest(
            'dos', "edit_submission")

        self.record = {
            "supplier": {
                "name": "ACME INC"
            },
            "declaration": {
                "supplierRegisteredName": "ACME Ltd"
            },
            "supplier_id":
            34567,
            "onFramework":
            True,
            "services": [{
                "locations": ["Offsite", "Scotland", "North East England"],
                "accessibleApplicationsOutcomes":
                True
            }]
        }
def main():
    args = docopt(__doc__)

    frameworks_repo = Path(args["--frameworks-repo"]).resolve()
    framework_slug = args["<framework_slug>"]
    stage = args["<stage>"]
    lot = args["<lot>"]

    data_api_client = DataAPIClient(get_api_endpoint_from_stage(stage), get_auth_token('api', stage))

    content_loader = ContentLoader(frameworks_repo)
    content_loader.load_manifest(framework_slug, "services", "services_search_filters")
    manifest = content_loader.get_manifest(framework_slug, "services_search_filters")

    # FIXME there isn't a uniform way to get the lots from the framework
    # content repo, hard code for G-Cloud for now
    framework_lots = [
        {"name": "Cloud hosting", "slug": "cloud-hosting"},
        {"name": "Cloud software", "slug": "cloud-software"},
        {"name": "Cloud support", "slug": "cloud-support"},
    ]

    writer = csv.writer(sys.stdout)

    # do the thing
    writer.writerow(['serviceId', 'topLevelCategories'])
    for service in data_api_client.find_services_iter(framework=framework_slug, status='published', lot=lot):
        service_categories = service['serviceCategories'] if service.get('serviceCategories') else []

        top_level_categories = []

        for f in filters_for_lot(service['lot'], manifest, framework_lots)['categories']['filters']:
            children = [f['label'] for f in f['children']] if f.get('children') else []
            if any(item in service_categories for item in children):
                top_level_categories.append(f['label'])

        writer.writerow([service['id'], '; '.join(top_level_categories)])
def _make_content_loader_factory():
    master_cl = ContentLoader('app/content')
    master_cl.load_manifest('g-cloud-6', 'services', 'edit_service')
    master_cl.load_messages('g-cloud-6', ['urls'])

    master_cl.load_manifest('g-cloud-7', 'services', 'edit_service')
    master_cl.load_manifest('g-cloud-7', 'services', 'edit_submission')
    master_cl.load_manifest('g-cloud-7', 'declaration', 'declaration')
    master_cl.load_messages('g-cloud-7', ['urls'])

    master_cl.load_manifest('digital-outcomes-and-specialists', 'declaration', 'declaration')
    master_cl.load_manifest('digital-outcomes-and-specialists', 'services', 'edit_submission')
    master_cl.load_manifest('digital-outcomes-and-specialists', 'briefs', 'edit_brief')
    master_cl.load_messages('digital-outcomes-and-specialists', ['urls'])

    master_cl.load_manifest('digital-outcomes-and-specialists-2', 'declaration', 'declaration')
    master_cl.load_manifest('digital-outcomes-and-specialists-2', 'services', 'edit_submission')
    master_cl.load_manifest('digital-outcomes-and-specialists-2', 'services', 'edit_service')
    master_cl.load_manifest('digital-outcomes-and-specialists-2', 'briefs', 'edit_brief')
    master_cl.load_messages('digital-outcomes-and-specialists-2', ['urls'])

    master_cl.load_manifest('g-cloud-8', 'services', 'edit_service')
    master_cl.load_manifest('g-cloud-8', 'services', 'edit_submission')
    master_cl.load_manifest('g-cloud-8', 'declaration', 'declaration')
    master_cl.load_messages('g-cloud-8', ['urls'])

    master_cl.load_manifest('g-cloud-9', 'services', 'edit_service')
    master_cl.load_manifest('g-cloud-9', 'services', 'edit_submission')
    master_cl.load_manifest('g-cloud-9', 'declaration', 'declaration')
    master_cl.load_messages('g-cloud-9', ['urls', 'advice'])

    master_cl.load_manifest('g-cloud-10', 'services', 'edit_service')
    master_cl.load_manifest('g-cloud-10', 'services', 'edit_submission')
    master_cl.load_manifest('g-cloud-10', 'declaration', 'declaration')
    master_cl.load_messages('g-cloud-10', ['urls', 'advice'])
    master_cl.load_metadata('g-cloud-10', ['copy_services'])

    master_cl.load_manifest('digital-outcomes-and-specialists-3', 'declaration', 'declaration')
    master_cl.load_manifest('digital-outcomes-and-specialists-3', 'services', 'edit_submission')
    master_cl.load_manifest('digital-outcomes-and-specialists-3', 'services', 'edit_service')
    master_cl.load_manifest('digital-outcomes-and-specialists-3', 'briefs', 'edit_brief')
    master_cl.load_messages('digital-outcomes-and-specialists-3', ['urls'])
    master_cl.load_metadata('digital-outcomes-and-specialists-3', ['copy_services', 'following_framework'])

    master_cl.load_manifest('g-cloud-11', 'services', 'edit_service')
    master_cl.load_manifest('g-cloud-11', 'services', 'edit_submission')
    master_cl.load_manifest('g-cloud-11', 'declaration', 'declaration')
    master_cl.load_messages('g-cloud-11', ['urls', 'advice'])
    master_cl.load_metadata('g-cloud-11', ['copy_services', 'following_framework'])

    master_cl.load_manifest('digital-outcomes-and-specialists-4', 'declaration', 'declaration')
    master_cl.load_manifest('digital-outcomes-and-specialists-4', 'services', 'edit_submission')
    master_cl.load_manifest('digital-outcomes-and-specialists-4', 'services', 'edit_service')
    master_cl.load_manifest('digital-outcomes-and-specialists-4', 'briefs', 'edit_brief')
    master_cl.load_messages('digital-outcomes-and-specialists-4', ['urls'])
    master_cl.load_metadata('digital-outcomes-and-specialists-4', ['copy_services', 'following_framework'])

    master_cl.load_manifest('g-cloud-12', 'services', 'edit_service')
    master_cl.load_manifest('g-cloud-12', 'services', 'edit_submission')
    master_cl.load_manifest('g-cloud-12', 'declaration', 'declaration')
    master_cl.load_messages('g-cloud-12', ['urls', 'advice', 'e-signature'])
    master_cl.load_metadata('g-cloud-12', ['copy_services', 'following_framework'])

    master_cl.load_manifest('digital-outcomes-and-specialists-5', 'declaration', 'declaration')
    master_cl.load_manifest('digital-outcomes-and-specialists-5', 'services', 'edit_submission')
    master_cl.load_manifest('digital-outcomes-and-specialists-5', 'services', 'edit_service')
    master_cl.load_manifest('digital-outcomes-and-specialists-5', 'briefs', 'edit_brief')
    master_cl.load_messages('digital-outcomes-and-specialists-5', ['urls', 'e-signature'])
    master_cl.load_metadata('digital-outcomes-and-specialists-5', ['copy_services', 'following_framework'])

    # seal master_cl in a closure by returning a function which will only ever return an independent copy of it
    return lambda: deepcopy(master_cl)
Ejemplo n.º 12
0
class TestViewBriefSectionSummaryPage(BaseApplicationTest):

    def setup_method(self, method):
        super().setup_method(method)
        self.data_api_client_patch = mock.patch(
            "app.main.views.create_a_brief.edit.data_api_client", autospec=True
        )
        self.data_api_client = self.data_api_client_patch.start()

        self.data_api_client.get_brief.return_value = BriefStub(
            framework_slug="digital-outcomes-and-specialists-4",
        ).single_result_response()
        self.data_api_client.get_framework.return_value = FrameworkStub(
            slug='digital-outcomes-and-specialists-4',
            status='live',
            lots=[
                LotStub(slug='digital-specialists', allows_brief=True).response()
            ]
        ).single_result_response()
        self.login_as_buyer()

        self.content_fixture = ContentLoader('tests/fixtures/content')
        self.content_fixture.load_manifest('dos', 'data', 'edit_brief')

    def teardown_method(self, method):
        self.data_api_client_patch.stop()
        super().teardown_method(method)

    def _setup_brief(self, brief_status="draft", **stub_kwargs):
        brief_json = BriefStub(
            framework_slug="digital-outcomes-and-specialists-4",
            status=brief_status,
            **stub_kwargs
        ).single_result_response()
        brief_questions = brief_json['briefs']
        brief_questions.update({
            'required1': 'test background info',
            'required2': 'work work work',
            'required3_1': 'yep',
            'required3_2': 'yep'
        })
        return brief_json

    @mock.patch('app.main.views.create_a_brief.edit.content_loader', autospec=True)
    def test_get_view_section_summary(self, content_loader):
        content_loader.get_manifest.return_value = self.content_fixture.get_manifest('dos', 'edit_brief')

        res = self.client.get(
            "/buyers/frameworks/digital-outcomes-and-specialists-4/requirements/digital-specialists/1234/section-1"
        )

        assert res.status_code == 200

    @pytest.mark.parametrize('show_dos_preview_links', (True, False, None))
    @mock.patch('app.main.views.create_a_brief.edit.content_loader', autospec=True)
    def test_get_view_section_summary_links(self, content_loader, show_dos_preview_links):
        content_loader.get_manifest.return_value = self.content_fixture.get_manifest('dos', 'edit_brief')
        brief = self._setup_brief(lot_slug='digital-specialists')
        self.data_api_client.get_brief.return_value = brief

        res = self.client.get(
            "/buyers/frameworks/digital-outcomes-and-specialists-4/requirements/digital-specialists/1234/section-1"
        )

        assert res.status_code == 200
        document = html.fromstring(res.get_data(as_text=True))

        overview_links = document.xpath(
            '//a[@href="/buyers/frameworks/digital-outcomes-and-specialists-4/requirements/digital-specialists/1234"]'
        )
        assert [link.text_content().strip() for link in overview_links] == [
            "I need a thing to do a thing",  # breadcrumbs
            "Return to overview"             # bottom nav link
        ]
        assert document.xpath(
            "//a[@href=$u][normalize-space(string())=$t]",
            u="/buyers/frameworks/digital-outcomes-and-specialists-4/requirements/digital-specialists/1234/preview",
            t="Preview your requirements",
        )

    def test_wrong_lot_get_view_section_summary(self):
        res = self.client.get(
            "/buyers/frameworks/digital-outcomes-and-specialists-4/requirements/digital-outcomes/1234/section-1"
        )

        assert res.status_code == 404
Ejemplo n.º 13
0
from flask import Blueprint, current_app, flash
from flask_login import current_user, login_required
from dmcontent.content_loader import ContentLoader

buyers = Blueprint('buyers', __name__)

content_loader = ContentLoader('app/content')
content_loader.load_manifest('digital-outcomes-and-specialists', 'briefs',
                             'edit_brief')
content_loader.load_manifest('digital-outcomes-and-specialists',
                             'brief-responses', 'output_brief_response')
content_loader.load_manifest('digital-outcomes-and-specialists',
                             'clarification_question',
                             'clarification_question')
content_loader.load_manifest('digital-service-professionals', 'briefs',
                             'edit_brief')
content_loader.load_manifest('digital-service-professionals',
                             'brief-responses', 'output_brief_response')
content_loader.load_manifest('digital-service-professionals',
                             'clarification_question',
                             'clarification_question')
content_loader.load_manifest('digital-marketplace', 'briefs', 'edit_brief')
content_loader.load_manifest('digital-marketplace', 'brief-responses',
                             'output_brief_response')
content_loader.load_manifest('digital-marketplace', 'clarification_question',
                             'clarification_question')


@buyers.before_request
@login_required
def require_login():
            ("supplier_name", record["supplier"]["name"]),
            ("supplier_declaration_name",
             record["declaration"].get("supplierRegisteredName", "")),
            ("status", "PASSED" if record["onFramework"] else "FAILED"),
        ]
        return row + make_fields_from_content_questions(questions, record)

    return inner


if __name__ == '__main__':
    arguments = docopt(__doc__)

    STAGE = arguments['<stage>']
    CONTENT_PATH = arguments['<content_path>']
    FRAMEWORK_SLUG = arguments['<framework_slug>']

    client = DataAPIClient(get_api_endpoint_from_stage(STAGE),
                           get_auth_token('api', STAGE))

    content_loader = ContentLoader(CONTENT_PATH)
    content_loader.load_manifest(FRAMEWORK_SLUG, "services", "edit_submission")
    content_manifest = content_loader.get_manifest(FRAMEWORK_SLUG,
                                                   "edit_submission")

    records = find_all_participants(client)

    write_csv_with_make_row(
        records, make_row(content_manifest),
        "output/{}-user-research-participants.csv".format(FRAMEWORK_SLUG))
Ejemplo n.º 15
0
import mock
import unittest
import datetime
from werkzeug.exceptions import NotFound

import app.helpers as helpers
from dmcontent.content_loader import ContentLoader

from dmapiclient import api_stubs

content_loader = ContentLoader('tests/fixtures/content')
content_loader.load_manifest('dos', 'data', 'edit_brief')
questions_builder = content_loader.get_builder('dos', 'edit_brief')


class TestBuyersHelpers(unittest.TestCase):
    def test_get_framework_and_lot(self):
        data_api_client = mock.Mock()
        data_api_client.get_framework.return_value = api_stubs.framework(
            slug='digital-outcomes-and-specialists',
            status='live',
            lots=[
                api_stubs.lot(slug='digital-specialists', allows_brief=True)
            ])

        framework, lot = helpers.buyers_helpers.get_framework_and_lot(
            'digital-outcomes-and-specialists', 'digital-specialists',
            data_api_client)

        assert framework['status'] == "live"
        assert framework['name'] == 'Digital Outcomes and Specialists'
Ejemplo n.º 16
0
from flask import Blueprint
from dmcontent.content_loader import ContentLoader

main = Blueprint('main', __name__)

content_loader = ContentLoader('app/content')
content_loader.load_manifest('g-cloud-6', 'services', 'edit_service')
content_loader.load_messages('g-cloud-6', ['dates'])

content_loader.load_manifest('g-cloud-7', 'services', 'edit_service')
content_loader.load_manifest('g-cloud-7', 'services', 'edit_submission')
content_loader.load_manifest('g-cloud-7', 'declaration', 'declaration')
content_loader.load_messages('g-cloud-7', ['dates'])

content_loader.load_manifest('digital-outcomes-and-specialists', 'declaration',
                             'declaration')
content_loader.load_manifest('digital-outcomes-and-specialists', 'services',
                             'edit_submission')
content_loader.load_manifest('digital-outcomes-and-specialists',
                             'brief-responses', 'edit_brief_response')
content_loader.load_messages('digital-outcomes-and-specialists', ['dates'])

content_loader.load_manifest('g-cloud-8', 'services', 'edit_service')
content_loader.load_manifest('g-cloud-8', 'services', 'edit_submission')
content_loader.load_manifest('g-cloud-8', 'declaration', 'declaration')
content_loader.load_messages('g-cloud-8', ['dates'])


@main.after_request
def add_cache_control(response):
    response.cache_control.no_cache = True
import mock
import unittest
import datetime
from werkzeug.exceptions import NotFound

import app.helpers as helpers
from dmcontent.content_loader import ContentLoader

from dmapiclient import api_stubs

content_loader = ContentLoader('tests/fixtures/content')
content_loader.load_manifest('dos', 'data', 'edit_brief')
questions_builder = content_loader.get_builder('dos', 'edit_brief')


class TestBuyersHelpers(unittest.TestCase):
    def test_get_framework_and_lot(self):
        data_api_client = mock.Mock()
        data_api_client.get_framework.return_value = api_stubs.framework(
            slug='digital-outcomes-and-specialists',
            status='live',
            lots=[
                api_stubs.lot(slug='digital-specialists', allows_brief=True)
            ]
        )

        framework, lot = helpers.buyers_helpers.get_framework_and_lot('digital-outcomes-and-specialists',
                                                                      'digital-specialists',
                                                                      data_api_client)

        assert framework['status'] == "live"
import os
import json
import unittest
from mock import Mock
from dmcontent.content_loader import ContentLoader
from werkzeug.datastructures import MultiDict

from app.presenters.search_presenters import filters_for_lot, set_filter_states

content_loader = ContentLoader('tests/fixtures/content')
content_loader.load_manifest('g6', 'data', 'manifest')
questions_builder = content_loader.get_builder('g6', 'manifest')


def _get_fixture_data():
    test_root = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
    fixture_path = os.path.join(test_root, 'fixtures',
                                'search_results_fixture.json')
    with open(fixture_path) as fixture_file:
        return json.load(fixture_file)


def _get_fixture_multiple_pages_data():
    test_root = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
    fixture_path = os.path.join(test_root, 'fixtures',
                                'search_results_multiple_pages_fixture.json')
    with open(fixture_path) as fixture_file:
        return json.load(fixture_file)


class TestSearchFilters(unittest.TestCase):
Ejemplo n.º 19
0
def _make_content_loader_factory():
    master_cl = ContentLoader('app/content')

    master_cl.load_manifest('digital-outcomes-and-specialists', 'briefs',
                            'edit_brief')
    master_cl.load_manifest('digital-outcomes-and-specialists',
                            'brief-responses', 'legacy_edit_brief_response')
    master_cl.load_manifest('digital-outcomes-and-specialists',
                            'brief-responses', 'edit_brief_response')
    master_cl.load_manifest('digital-outcomes-and-specialists',
                            'brief-responses', 'legacy_display_brief_response')
    master_cl.load_manifest('digital-outcomes-and-specialists',
                            'brief-responses', 'display_brief_response')

    master_cl.load_manifest('digital-outcomes-and-specialists-2', 'briefs',
                            'edit_brief')
    master_cl.load_manifest('digital-outcomes-and-specialists-2',
                            'brief-responses', 'edit_brief_response')
    master_cl.load_manifest('digital-outcomes-and-specialists-2',
                            'brief-responses', 'display_brief_response')

    master_cl.load_manifest('digital-outcomes-and-specialists-3', 'briefs',
                            'edit_brief')
    master_cl.load_manifest('digital-outcomes-and-specialists-3',
                            'brief-responses', 'edit_brief_response')
    master_cl.load_manifest('digital-outcomes-and-specialists-3',
                            'brief-responses', 'display_brief_response')

    master_cl.load_manifest('digital-outcomes-and-specialists-4', 'briefs',
                            'edit_brief')
    master_cl.load_manifest('digital-outcomes-and-specialists-4',
                            'brief-responses', 'edit_brief_response')
    master_cl.load_manifest('digital-outcomes-and-specialists-4',
                            'brief-responses', 'display_brief_response')

    master_cl.load_manifest('digital-outcomes-and-specialists-5', 'briefs',
                            'edit_brief')
    master_cl.load_manifest('digital-outcomes-and-specialists-5',
                            'brief-responses', 'edit_brief_response')
    master_cl.load_manifest('digital-outcomes-and-specialists-5',
                            'brief-responses', 'display_brief_response')

    # seal master_cl in a closure by returning a function which will only ever return an independent copy of it
    return lambda: deepcopy(master_cl)
import os
import json
import unittest
from mock import Mock
from dmcontent.content_loader import ContentLoader
from werkzeug.datastructures import MultiDict

from app.presenters.search_presenters import filters_for_lot, set_filter_states


content_loader = ContentLoader('tests/fixtures/content')
content_loader.load_manifest('g6', 'data', 'manifest')
questions_builder = content_loader.get_builder('g6', 'manifest')


def _get_fixture_data():
    test_root = os.path.abspath(
        os.path.join(os.path.dirname(__file__), "..")
    )
    fixture_path = os.path.join(
        test_root, 'fixtures', 'search_results_fixture.json'
    )
    with open(fixture_path) as fixture_file:
        return json.load(fixture_file)


def _get_fixture_multiple_pages_data():
    test_root = os.path.abspath(
        os.path.join(os.path.dirname(__file__), "..")
    )
    fixture_path = os.path.join(
from flask_login import LoginManager

import dmapiclient
from dmutils import init_app, init_frontend_app, formats
from dmutils.user import User
from dmcontent.content_loader import ContentLoader

from config import configs


bootstrap = Bootstrap()
data_api_client = dmapiclient.DataAPIClient()
login_manager = LoginManager()

content_loader = ContentLoader('app/content')
content_loader.load_manifest('g-cloud-6', 'services', 'edit_service_as_admin')
content_loader.load_manifest('g-cloud-7', 'declaration', 'declaration')
content_loader.load_manifest('digital-outcomes-and-specialists', 'declaration', 'declaration')
content_loader.load_manifest('g-cloud-8', 'declaration', 'declaration')

from app.main.helpers.service import parse_document_upload_time  # noqa


def create_app(config_name):

    application = Flask(__name__,
                        static_folder='static/',
                        static_url_path=configs[config_name].ASSET_PATH)

    init_app(
        application,
import dmapiclient
from dmutils import init_app, init_frontend_app
from dmutils.user import User
from dmcontent.content_loader import ContentLoader

from config import configs
from app.helpers.terms_helpers import TermsManager

from react.render import render_component

cache = Cache()
login_manager = LoginManager()
data_api_client = dmapiclient.DataAPIClient()

content_loader = ContentLoader('app/content')
content_loader.load_manifest('g-cloud-6', 'services', 'search_filters')
content_loader.load_manifest('g-cloud-6', 'services', 'display_service')
content_loader.load_manifest('digital-outcomes-and-specialists', 'briefs', 'display_brief')
content_loader.load_manifest('digital-service-professionals', 'briefs', 'display_brief')
content_loader.load_manifest('digital-marketplace', 'briefs', 'display_brief')


def create_app(config_name):
    asset_path = os.environ.get('ASSET_PATH', configs[config_name].ASSET_PATH)
    application = Flask(__name__, static_url_path=asset_path)

    init_app(
        application,
        configs[config_name],
        data_api_client=data_api_client,
        login_manager=login_manager,
from flask import Blueprint
from dmcontent.content_loader import ContentLoader

main = Blueprint('main', __name__)

content_loader = ContentLoader('app/content')
content_loader.load_manifest('g-cloud-6', 'services', 'edit_service')
content_loader.load_messages('g-cloud-6', ['dates'])

content_loader.load_manifest('g-cloud-7', 'services', 'edit_service')
content_loader.load_manifest('g-cloud-7', 'services', 'edit_submission')
content_loader.load_manifest('g-cloud-7', 'declaration', 'declaration')
content_loader.load_messages('g-cloud-7', ['dates'])

content_loader.load_manifest('digital-outcomes-and-specialists', 'declaration', 'declaration')
content_loader.load_manifest('digital-outcomes-and-specialists', 'services', 'edit_submission')
content_loader.load_manifest('digital-outcomes-and-specialists', 'briefs', 'edit_brief')
content_loader.load_manifest('digital-outcomes-and-specialists', 'brief-responses', 'edit_brief_response')
content_loader.load_manifest('digital-outcomes-and-specialists', 'brief-responses', 'display_brief_response')
content_loader.load_messages('digital-outcomes-and-specialists', ['dates'])

content_loader.load_manifest('digital-service-professionals', 'declaration', 'declaration')
content_loader.load_manifest('digital-service-professionals', 'services', 'edit_submission')
content_loader.load_manifest('digital-service-professionals', 'briefs', 'edit_brief')
content_loader.load_manifest('digital-service-professionals', 'brief-responses', 'edit_brief_response')
content_loader.load_manifest('digital-service-professionals', 'brief-responses', 'display_brief_response')
content_loader.load_messages('digital-service-professionals', ['dates'])

content_loader.load_manifest('digital-marketplace', 'declaration', 'declaration')
content_loader.load_manifest('digital-marketplace', 'services', 'edit_submission')
content_loader.load_manifest('digital-marketplace', 'briefs', 'edit_brief')
from dmutils import init_app, init_frontend_app, formats
from dmutils.user import User
from dmcontent.content_loader import ContentLoader

from config import configs

import redis
from flask_kvsession import KVSessionExtension
from simplekv.memory.redisstore import RedisStore

bootstrap = Bootstrap()
data_api_client = dmapiclient.DataAPIClient()
login_manager = LoginManager()

content_loader = ContentLoader('app/content')
content_loader.load_manifest('g-cloud-6', 'services', 'edit_service_as_admin')
content_loader.load_manifest('g-cloud-7', 'declaration', 'declaration')
content_loader.load_manifest('digital-outcomes-and-specialists', 'declaration',
                             'declaration')
content_loader.load_manifest('g-cloud-8', 'declaration', 'declaration')

from app.main.helpers.service import parse_document_upload_time  # noqa


def create_app(config_name):

    application = Flask(__name__,
                        static_folder='static/',
                        static_url_path=configs[config_name].ASSET_PATH)

    init_app(application,
Ejemplo n.º 25
0
from config import configs
from app.helpers.terms_helpers import TermsManager

from react.render import render_component

import redis
from flask_kvsession import KVSessionExtension
from simplekv.memory.redisstore import RedisStore

cache = Cache()
login_manager = LoginManager()
data_api_client = dmapiclient.DataAPIClient()

content_loader = ContentLoader('app/content')
content_loader.load_manifest('g-cloud-6', 'services', 'search_filters')
content_loader.load_manifest('g-cloud-6', 'services', 'display_service')
content_loader.load_manifest('digital-outcomes-and-specialists', 'briefs',
                             'display_brief')
content_loader.load_manifest('digital-service-professionals', 'briefs',
                             'display_brief')
content_loader.load_manifest('digital-marketplace', 'briefs', 'display_brief')


def create_app(config_name):
    asset_path = os.environ.get('ASSET_PATH', configs[config_name].ASSET_PATH)
    application = Flask(__name__, static_url_path=asset_path)

    init_app(
        application,
        configs[config_name],
Ejemplo n.º 26
0
def _make_content_loader_factory():
    primary_cl = ContentLoader('app/content')
    primary_cl.load_manifest('digital-outcomes-and-specialists', 'briefs',
                             'edit_brief')
    primary_cl.load_manifest('digital-outcomes-and-specialists',
                             'brief-responses', 'output_brief_response')
    primary_cl.load_manifest('digital-outcomes-and-specialists',
                             'brief-responses', 'legacy_output_brief_response')
    primary_cl.load_manifest('digital-outcomes-and-specialists',
                             'clarification_question',
                             'clarification_question')
    primary_cl.load_manifest('digital-outcomes-and-specialists', 'briefs',
                             'award_brief')

    primary_cl.load_manifest('digital-outcomes-and-specialists-2', 'briefs',
                             'edit_brief')
    primary_cl.load_manifest('digital-outcomes-and-specialists-2',
                             'brief-responses', 'output_brief_response')
    primary_cl.load_manifest('digital-outcomes-and-specialists-2',
                             'clarification_question',
                             'clarification_question')
    primary_cl.load_manifest('digital-outcomes-and-specialists-2', 'briefs',
                             'award_brief')

    primary_cl.load_manifest('digital-outcomes-and-specialists-3', 'briefs',
                             'edit_brief')
    primary_cl.load_manifest('digital-outcomes-and-specialists-3',
                             'brief-responses', 'output_brief_response')
    primary_cl.load_manifest('digital-outcomes-and-specialists-3',
                             'clarification_question',
                             'clarification_question')
    primary_cl.load_manifest('digital-outcomes-and-specialists-3', 'briefs',
                             'award_brief')

    primary_cl.load_manifest('digital-outcomes-and-specialists-4', 'briefs',
                             'edit_brief')
    primary_cl.load_manifest('digital-outcomes-and-specialists-4', 'briefs',
                             'display_brief')
    primary_cl.load_manifest('digital-outcomes-and-specialists-4',
                             'brief-responses', 'output_brief_response')
    primary_cl.load_manifest('digital-outcomes-and-specialists-4',
                             'clarification_question',
                             'clarification_question')
    primary_cl.load_manifest('digital-outcomes-and-specialists-4', 'briefs',
                             'award_brief')

    primary_cl.load_manifest('digital-outcomes-and-specialists-5', 'briefs',
                             'edit_brief')
    primary_cl.load_manifest('digital-outcomes-and-specialists-5', 'briefs',
                             'display_brief')
    primary_cl.load_manifest('digital-outcomes-and-specialists-5',
                             'brief-responses', 'output_brief_response')
    primary_cl.load_manifest('digital-outcomes-and-specialists-5',
                             'clarification_question',
                             'clarification_question')
    primary_cl.load_manifest('digital-outcomes-and-specialists-5', 'briefs',
                             'award_brief')

    # seal primary_cl in a closure by returning a function which will only ever return an independent copy of it
    return lambda: deepcopy(primary_cl)
    return inner


def get_specialist_roles(section):
    return [
        question
        for outer_question in section.questions
        for question in outer_question.questions
    ]


if __name__ == '__main__':
    arguments = docopt(__doc__)

    STAGE = arguments['<stage>']
    API_TOKEN = arguments['<api_token>']
    CONTENT_PATH = arguments['<content_path>']

    client = DataAPIClient(get_api_endpoint_from_stage(STAGE), API_TOKEN)

    content_loader = ContentLoader(CONTENT_PATH)
    content_loader.load_manifest(FRAMEWORK_SLUG, "services", "edit_submission")
    content_manifest = content_loader.get_manifest(FRAMEWORK_SLUG, "edit_submission")

    suppliers = find_all_specialists(client)

    write_csv(suppliers,
              make_row(content_manifest),
              "output/dos-specialists.csv")