diff --git a/examples/miniapps/ghnav-flask/githubnavigator/application.py b/examples/miniapps/ghnav-flask/githubnavigator/application.py index bcac7289..297c5812 100644 --- a/examples/miniapps/ghnav-flask/githubnavigator/application.py +++ b/examples/miniapps/ghnav-flask/githubnavigator/application.py @@ -12,6 +12,9 @@ def create_app(): app = container.app() app.container = container + bootstrap = container.bootstrap() + bootstrap.init_app(app) + app.add_url_rule('/', view_func=container.index_view.as_view()) return app diff --git a/examples/miniapps/ghnav-flask/githubnavigator/containers.py b/examples/miniapps/ghnav-flask/githubnavigator/containers.py index 40f4d435..872640f1 100644 --- a/examples/miniapps/ghnav-flask/githubnavigator/containers.py +++ b/examples/miniapps/ghnav-flask/githubnavigator/containers.py @@ -3,6 +3,7 @@ from dependency_injector import containers, providers from dependency_injector.ext import flask from flask import Flask +from flask_bootstrap import Bootstrap from github import Github from . import views, services @@ -13,6 +14,8 @@ class ApplicationContainer(containers.DeclarativeContainer): app = flask.Application(Flask, __name__) + bootstrap = flask.Extension(Bootstrap) + config = providers.Configuration() github_client = providers.Factory( diff --git a/examples/miniapps/ghnav-flask/githubnavigator/services.py b/examples/miniapps/ghnav-flask/githubnavigator/services.py index 413e9b04..9df52007 100644 --- a/examples/miniapps/ghnav-flask/githubnavigator/services.py +++ b/examples/miniapps/ghnav-flask/githubnavigator/services.py @@ -29,7 +29,6 @@ class SearchService: 'url': repository.owner.html_url, 'avatar_url': repository.owner.avatar_url, }, - 'created_at': repository.created_at, 'latest_commit': self._format_commit(commits[0]) if commits else {}, } diff --git a/examples/miniapps/ghnav-flask/githubnavigator/templates/base.html b/examples/miniapps/ghnav-flask/githubnavigator/templates/base.html new file mode 100644 index 00000000..2797916a --- /dev/null +++ b/examples/miniapps/ghnav-flask/githubnavigator/templates/base.html @@ -0,0 +1,26 @@ + + + + {% block head %} + + + + + {% block styles %} + + {{ bootstrap.load_css() }} + {% endblock %} + + {% block title %}{% endblock %} + {% endblock %} + + + + {% block content %}{% endblock %} + + {% block scripts %} + + {{ bootstrap.load_js() }} + {% endblock %} + + diff --git a/examples/miniapps/ghnav-flask/githubnavigator/templates/index.html b/examples/miniapps/ghnav-flask/githubnavigator/templates/index.html index ecb7d266..9f75018e 100644 --- a/examples/miniapps/ghnav-flask/githubnavigator/templates/index.html +++ b/examples/miniapps/ghnav-flask/githubnavigator/templates/index.html @@ -1,40 +1,55 @@ - - - - Github Navigator - - -

Github Navigator

-
+{% extends "base.html" %} + +{% block title %}Github Navigator{% endblock %} + +{% block content %} +
+

Github Navigator

+ + +
+ +
+ +
+
+ + + {% if repositories|length == 0 %} + No search results + {% endif %} +

- Search term: - Limit: - + Results found: {{ repositories|length }}

- -

Search results

-{% if repositories|length == 0 %} -No search results -{% endif %} -{% for repository in repositories %} {{n}} -

- Search result # {{ loop.index }} from {{ repositories|length }} -

-

- Repository: {{ repository.name }} -

-

- Repository owner: - avatar - {{ repository.owner.login }} -

-

- Created at: {{ repository.created_at }} -

-

- LastCommit: {{ repository.latest_commit.sha }} {{ repository.latest_commit['message'] }} {{ repository.latest_commit.author_name }} -

-
-{% endfor %} - - + + + + + + + + + + + + + {% for repository in repositories %} {{n}} + + + + + + + {% endfor %} + + +
#RepositoryRepository ownerLast commit
{{ loop.index }}{{ repository.name }}avatar + {{ repository.owner.login }} + {{ repository.latest_commit.sha }} {{ repository.latest_commit['message'] }} {{ repository.latest_commit.author_name }}
+
+ +{% endblock %} diff --git a/examples/miniapps/ghnav-flask/githubnavigator/tests.py b/examples/miniapps/ghnav-flask/githubnavigator/tests.py index 0d6267ed..fa36678c 100644 --- a/examples/miniapps/ghnav-flask/githubnavigator/tests.py +++ b/examples/miniapps/ghnav-flask/githubnavigator/tests.py @@ -25,7 +25,6 @@ def test_index(client, app): html_url='owner1-url', avatar_url='owner1-avatar-url', ), - created_at='repo1-created-at', get_commits=mock.Mock(return_value=[mock.Mock()]), ), mock.Mock( @@ -36,7 +35,6 @@ def test_index(client, app): html_url='owner2-url', avatar_url='owner2-avatar-url', ), - created_at='repo2-created-at', get_commits=mock.Mock(return_value=[mock.Mock()]), ), ] @@ -51,14 +49,12 @@ def test_index(client, app): assert b'owner1-login' in response.data assert b'owner1-url' in response.data assert b'owner1-avatar-url' in response.data - assert b'repo1-created-at' in response.data assert b'repo2-url' in response.data assert b'repo2-name' in response.data assert b'owner2-login' in response.data assert b'owner2-url' in response.data assert b'owner2-avatar-url' in response.data - assert b'repo2-created-at' in response.data def test_index_no_results(client, app):