Пример #1
0
    def setUp(self):
        app = flask.Flask("test-app")
        app.url_map.strict_slashes = False
        app.template_folder = f"{this_dir}/fixtures/templates"
        app.testing = True

        self.discourse_api = DiscourseAPI(
            base_url="https://discourse.ubuntu.com/",
            session=requests.Session(),
        )
        self.engage_pages = EngagePages(
            parser=EngageParser(
                api=self.discourse_api,
                index_topic_id=17229,
                url_prefix="/engage",
            ),
            document_template="/engage.html",
            url_prefix="/engage",
            blueprint_name="engage-pages",
        ).init_app(app)

        self.client = app.test_client()
        return super().setUp()
Пример #2
0
# Login
app.add_url_rule("/login", methods=["GET", "POST"], view_func=login_handler)
app.add_url_rule("/logout", view_func=logout)

# Engage pages and takeovers from Discourse
# This section needs to provide takeover data for /

engage_path = "/engage"
engage_pages = EngagePages(
    parser=EngageParser(
        api=DiscourseAPI(
            base_url="https://discourse.ubuntu.com/",
            session=session,
        ),
        index_topic_id=17229,
        url_prefix=engage_path,
    ),
    document_template="/engage/base.html",
    url_prefix=engage_path,
    blueprint_name="engage-pages",
)

app.add_url_rule(engage_path, view_func=build_engage_index(engage_pages))


def get_takeovers():
    takeovers = {}

    engage_pages.parser.parse()
    takeovers["sorted"] = sorted(
Пример #3
0
# This section needs to provide takeover data for /
session = talisker.requests.get_session()

discourse_api = DiscourseAPI(
    base_url="https://discourse.ubuntu.com/",
    session=session,
    api_key=os.getenv("DISCOURSE_API_KEY"),
    api_username=os.getenv("DISCOURSE_API_USERNAME"),
)

engage_path = "/engage"
engage_pages = EngagePages(
    parser=EngageParser(
        api=discourse_api,
        index_topic_id=19117,
        url_prefix=engage_path,
    ),
    document_template="/engage/base_engage.html",
    url_prefix=engage_path,
    blueprint_name="engage-pages",
)

app.add_url_rule(engage_path, view_func=build_engage_index(engage_pages))


def get_takeovers():
    takeovers = {}

    engage_pages.parser.parse()
    takeovers["sorted"] = sorted(
        engage_pages.parser.takeovers,
        key=lambda takeover: takeover["publish_date"],
Пример #4
0
# Login
app.add_url_rule("/login", methods=["GET", "POST"], view_func=login_handler)
app.add_url_rule("/logout", view_func=logout)

# Engage pages and takeovers from Discourse
# This section needs to provide takeover data for /

takeovers_path = "/takeovers"
discourse_takeovers = EngagePages(
    parser=EngageParser(
        api=DiscourseAPI(
            base_url="https://discourse.ubuntu.com/",
            session=session,
        ),
        index_topic_id=17229,
        url_prefix=takeovers_path,
    ),
    # Takeovers doesn't need a base template
    # But it is a required arg
    document_template="/base.html",
    url_prefix=takeovers_path,
    blueprint_name="takeovers",
)

engage_path = "/engage"
engage_pages = EngagePages(
    parser=EngageParser(
        api=DiscourseAPI(
            base_url="https://discourse.ubuntu.com/",
            session=session,
        ),