Repository: nextcloud/appstore

Issue:
Nightlies on the app detail page
The app detail page lists the latest stable release but not the latest unstable release for a Nextcloud version. In addition if only nightlies exist there will be no link to the releases page at all.

There should be another column to the right of the current stable version which is colored in the same color like the nightly on the releases page if a nightly is available. That way you can always access the releases page, even when only nightlies exist for that Nextcloud version



Discussion:

Resolving patch:
diff --git a/nextcloudappstore/core/models.py b/nextcloudappstore/core/models.py
--- a/nextcloudappstore/core/models.py
+++ b/nextcloudappstore/core/models.py
@@ -94,6 +94,11 @@ def releases_by_platform_v(self):
         """Looks up all compatible non-nightly releases for each platform
         version.
 
+        Example of returned dict:
+
+        {'9.1': [<AppRelease object>, <AppRelease object>],
+        '9.0': [<AppRelease object>]}
+
         :return dict with all compatible non-nightly releases for each platform
                 version.
         """
@@ -105,6 +110,11 @@ def releases_by_platform_v(self):
     def nightly_releases_by_platform_v(self):
         """Looks up all compatible nightly releases for each platform version.
 
+        Example of returned dict:
+
+        {'9.1': [<AppRelease object>, <AppRelease object>],
+        '9.0': [<AppRelease object>]}
+
         :return dict with all compatible nightly releases for each platform
                 version.
         """
@@ -114,16 +124,34 @@ def nightly_releases_by_platform_v(self):
             settings.PLATFORM_VERSIONS))
 
     def latest_releases_by_platform_v(self):
-        """Looks up the latest release for each platform version.
-        Ignores nightly releases.
-        :return dict with the latest release for each platform version.
+        """Looks up the latest stable and nightly release for each platform
+        version.
+
+        Example of returned dict:
+
+        {'9.1': {
+            'stable': <AppRelease object>,
+            'nightly': <AppRelease object>
+        },
+        '9.0': {
+            'stable': <AppRelease object>
+        }}
+
+        :return dict with the latest stable and nightly release for each
+                platform version.
         """
 
-        all_latest = {}
-        for p_version in settings.PLATFORM_VERSIONS:
-            compatible = self.compatible_releases(p_version)
-            all_latest[p_version] = self._latest(compatible)
-        return all_latest
+        def dict_item(ver):
+            return (
+                ver,
+                {
+                    'stable': self._latest(self.compatible_releases(ver)),
+                    'nightly':
+                        self._latest(self.compatible_nightly_releases(ver))
+                }
+            )
+
+        return dict(map(dict_item, settings.PLATFORM_VERSIONS))
 
     def compatible_releases(self, platform_version, inclusive=True):
         """Returns all non-nightly releases of this app that are compatible


Test patch:
diff --git a/nextcloudappstore/core/tests/test_compatibility.py b/nextcloudappstore/core/tests/test_compatibility.py
--- a/nextcloudappstore/core/tests/test_compatibility.py
+++ b/nextcloudappstore/core/tests/test_compatibility.py
@@ -69,26 +69,32 @@ def test_compatible_releases(self):
         self.assertEqual(len(app2rel), 1)
         self.assertEqual(len(app2rel2), 1)
 
+    def test_compatible_nightly_releases(self):
+        app1 = self.app1.compatible_nightly_releases('10.0')
+        app2 = self.app2.compatible_nightly_releases('10.0')
+        self.assertEqual(app1[0].version, '6.0.0-nightly')
+        self.assertEqual(len(app1), 1)
+        self.assertEqual(app2, [])
+
     def test_compatible_releases_by_platform_v(self):
         with self.settings(PLATFORM_VERSIONS=self.platform_versions):
             app1 = self.app1.latest_releases_by_platform_v()
             app2 = self.app2.latest_releases_by_platform_v()
-            self.assertEqual(app1['9.0'].version, '2.0.0')
-            self.assertEqual(app1['9.1'].version, '3.0.0')
-            self.assertEqual(app1['9.2'].version, '4.0.0')
-            self.assertEqual(app1['10.0'].version, '5.0.0')
-            self.assertEqual(app2['9.0'].version, '1.0.0')
-            self.assertEqual(app2['9.1'].version, '2.0.0')
-            self.assertEqual(app2['9.2'].version, '4.0.0')
-            self.assertEqual(app2['10.0'], None)
+            self.assertEqual(app1['9.0']['stable'].version, '2.0.0')
+            self.assertEqual(app1['9.0']['nightly'], None)
+            self.assertEqual(app1['9.1']['stable'].version, '3.0.0')
+            self.assertEqual(app1['9.1']['nightly'], None)
+            self.assertEqual(app1['9.2']['stable'].version, '4.0.0')
+            self.assertEqual(app1['9.2']['nightly'], None)
+            self.assertEqual(app1['10.0']['stable'].version, '5.0.0')
+            self.assertEqual(app1['10.0']['nightly'].version, '6.0.0-nightly')
+            self.assertEqual(app2['9.0']['stable'].version, '1.0.0')
+            self.assertEqual(app2['9.1']['stable'].version, '2.0.0')
+            self.assertEqual(app2['9.2']['stable'].version, '4.0.0')
+            self.assertEqual(app2['10.0']['stable'], None)
 
-    def test_correct_comparison_and_ignore_nightly(self):
+    def test_correct_comparison(self):
         with self.settings(PLATFORM_VERSIONS=self.platform_versions):
             app1 = self.app1.latest_releases_by_platform_v()
-            self.assertEqual(app1['10.0'].version, '5.0.0')
-
-    def test_nightlies(self):
-        with self.settings(PLATFORM_VERSIONS=self.platform_versions):
-            app1 = self.app1.compatible_nightly_releases('10.0')
-            self.assertEqual(app1[0].version, '6.0.0-nightly')
-            self.assertEqual(len(app1), 1)
+            self.assertEqual(app1['10.0']['stable'].version, '5.0.0')
+            self.assertEqual(app1['10.0']['nightly'].version, '6.0.0-nightly')