diff --git a/spkrepo/templates/frontend/package.html b/spkrepo/templates/frontend/package.html index fc943a1..37b4140 100644 --- a/spkrepo/templates/frontend/package.html +++ b/spkrepo/templates/frontend/package.html @@ -8,9 +8,7 @@

{{ package.versions[-1].displaynames['enu'].displayname }} - v{{ package.versions[-1].version_string }} - {% if package.versions[-1].report_url %}beta{% endif %} - + v{{ package.versions[-1].version_string }}

{{ package.versions[-1].descriptions['enu'].description }}

@@ -20,31 +18,36 @@

{{ package.versions[-1].displaynames['enu'].displaynam

{% for version in package.versions|reverse %}
-
Version {{ version.version_string | safe }}
+
Version {{ version.version_string | safe }}{% if version.report_url %} beta{% endif %}
{{ version.changelog | safe }}
Date
-
{{ version.insert_date }}
+
{{ version.insert_date.replace(microsecond=0) }}
Architectures
- {% for (version, builds) in version.builds_per_dsm.items() %} + {% for (version, builds) in version.builds_per_dsm.items() %} {% if version == '1' %} - SRM {{ version }}.x: + SRM {{ version }}.x: {% else %} - DSM {{ version }}.x: + DSM {{ version }}.x: {% endif %} {% for build in builds %} - {% for arch in build.architectures %} - {{ build.firmware.version }} {{ arch.code }} - {% endfor %} + {% if build.active %} + {% for arch in build.architectures %} + {{ build.firmware.version }} {{ arch.code }} + {% endfor %} + {% else %} + {% for arch in build.architectures %} + {{ build.firmware.version }} {{ arch.code }} + {% endfor %} + {% endif %} {% endfor %}
- {% endfor %} + {% endfor %}
{% endfor %}
- {% endblock %} diff --git a/spkrepo/templates/frontend/packages.html b/spkrepo/templates/frontend/packages.html index fcac622..7996db1 100644 --- a/spkrepo/templates/frontend/packages.html +++ b/spkrepo/templates/frontend/packages.html @@ -12,9 +12,7 @@

{{ version.displaynames['enu'].displayname }} - v{{ version.version_string }} - {% if version.report_url %}beta{% endif %} - + v{{ version.version_string }}

{{ version.descriptions['enu'].description }}

diff --git a/spkrepo/templates/layout.html b/spkrepo/templates/layout.html index 80c2eca..5ba0130 100644 --- a/spkrepo/templates/layout.html +++ b/spkrepo/templates/layout.html @@ -90,9 +90,9 @@ diff --git a/spkrepo/templates/security/login_user.html b/spkrepo/templates/security/login_user.html index 0ce1fb9..ab61e62 100644 --- a/spkrepo/templates/security/login_user.html +++ b/spkrepo/templates/security/login_user.html @@ -3,5 +3,4 @@ {% block content %}

Login

{{ wtf.quick_form(login_user_form, field_order=['email'], button_map={'submit': 'primary'}) }} -

I forgot my password

{% endblock %} diff --git a/spkrepo/tests/test_frontend.py b/spkrepo/tests/test_frontend.py index 4e467ea..632161c 100644 --- a/spkrepo/tests/test_frontend.py +++ b/spkrepo/tests/test_frontend.py @@ -12,68 +12,101 @@ class IndexTestCase(BaseTestCase): def test_get_anonymous(self): response = self.client.get(url_for("frontend.index")) self.assert200(response) - self.assertIn("Login", response.data.decode()) - self.assertIn("Register", response.data.decode()) + response_data = response.data.decode() + self.assertIn("Login", response_data) + self.assertIn("Register", response_data) def test_get_logged_user(self): with self.logged_user(): response = self.client.get(url_for("frontend.index")) self.assert200(response) - self.assertIn("Logout", response.data.decode()) - self.assertIn("Profile", response.data.decode()) + response_data = response.data.decode() + self.assertIn("Logout", response_data) + self.assertIn("Profile", response_data) class PackagesTestCase(BaseTestCase): - def test_get_active_stable(self): - build = BuildFactory(version__report_url=None, active=True) + # Assert beta is not shown on Packages page + def test_get_active_not_stable(self): + build = BuildFactory(active=True) db.session.commit() response = self.client.get(url_for("frontend.packages")) self.assert200(response) + response_data = response.data.decode() self.assertIn( build.version.displaynames["enu"].displayname, - response.data.decode(), + response_data, ) - self.assertNotIn("beta", response.data.decode()) + self.assertNotIn("beta", response_data) - def test_get_active_not_stable(self): - build = BuildFactory(active=True) + # Assert package with only inactive version(s) is shown on Packages page + def test_get_not_active_not_stable(self): + build = BuildFactory(active=False) db.session.commit() response = self.client.get(url_for("frontend.packages")) self.assert200(response) + response_data = response.data.decode() self.assertIn( build.version.displaynames["enu"].displayname, - response.data.decode(), + response_data, ) - self.assertIn("beta", response.data.decode()) + self.assertNotIn("beta", response_data) - def test_get_not_active_not_stable(self): - build = BuildFactory(active=False) + +class PackageTestCase(BaseTestCase): + def test_get_active_stable(self): + build = BuildFactory( + version__package__author=UserFactory(), + version__report_url=None, + active=True, + ) db.session.commit() - response = self.client.get(url_for("frontend.packages")) + response = self.client.get( + url_for("frontend.package", name=build.version.package.name) + ) self.assert200(response) - self.assertNotIn( + response_data = response.data.decode() + for a in build.architectures: + self.assertIn(a.code, response_data) + self.assertIn( build.version.displaynames["enu"].displayname, - response.data.decode(), + response_data, ) - self.assertNotIn("beta", response.data.decode()) + self.assertIn( + build.version.descriptions["enu"].description, + response_data, + ) + self.assertNotIn("beta", response_data) + self.assertIn("label label-success", response_data) def test_get_not_active_stable(self): - build = BuildFactory(active=False) + build = BuildFactory( + version__package__author=UserFactory(), + version__report_url=None, + active=False, + ) db.session.commit() - response = self.client.get(url_for("frontend.packages")) + response = self.client.get( + url_for("frontend.package", name=build.version.package.name) + ) self.assert200(response) - self.assertNotIn( + response_data = response.data.decode() + for a in build.architectures: + self.assertIn(a.code, response_data) + self.assertIn( build.version.displaynames["enu"].displayname, - response.data.decode(), + response_data, ) - self.assertNotIn("beta", response.data.decode()) - + self.assertIn( + build.version.descriptions["enu"].description, + response_data, + ) + self.assertNotIn("beta", response_data) + self.assertIn("label label-default", response_data) -class PackageTestCase(BaseTestCase): - def test_get(self): + def test_get_active_not_stable(self): build = BuildFactory( version__package__author=UserFactory(), - version__report_url=None, active=True, ) db.session.commit() @@ -81,16 +114,44 @@ def test_get(self): url_for("frontend.package", name=build.version.package.name) ) self.assert200(response) + response_data = response.data.decode() + for a in build.architectures: + self.assertIn(a.code, response_data) + self.assertIn( + build.version.displaynames["enu"].displayname, + response_data, + ) + self.assertIn( + build.version.descriptions["enu"].description, + response_data, + ) + self.assertIn("beta", response_data) + self.assertIn("label label-success", response_data) + + def test_get_not_active_not_stable(self): + build = BuildFactory( + version__package__author=UserFactory(), + active=False, + ) + db.session.commit() + response = self.client.get( + url_for("frontend.package", name=build.version.package.name) + ) + self.assert200(response) + response_data = response.data.decode() for a in build.architectures: - self.assertIn(a.code, response.data.decode()) + self.assertIn(a.code, response_data) self.assertIn( build.version.displaynames["enu"].displayname, - response.data.decode(), + response_data, ) self.assertIn( build.version.descriptions["enu"].description, - response.data.decode(), + response_data, ) + self.assertIn("beta", response_data) + self.assertIn("label label-default", response_data) + self.assertIn("Inactive: Manual installation only.", response_data) def test_get_no_package(self): response = self.client.get(url_for("frontend.package", name="no-package")) diff --git a/spkrepo/views/frontend.py b/spkrepo/views/frontend.py index 18a24d4..f6627f2 100644 --- a/spkrepo/views/frontend.py +++ b/spkrepo/views/frontend.py @@ -64,12 +64,12 @@ def profile(): @frontend.route("/packages") def packages(): + # show only packages with at least one version, but ignore whether builds are active latest_version = ( db.session.query( Version.package_id, db.func.max(Version.version).label("latest_version") ) .join(Build) - .filter(Build.active) .group_by(Version.package_id) .subquery() ) @@ -96,9 +96,8 @@ def packages(): @frontend.route("/package/") def package(name): - # TODO: show only packages with at least a version and an active build package = Package.query.filter_by(name=name).first() - if package is None: + if package is None or not package.versions: abort(404) return render_template("frontend/package.html", package=package)