Repository: kartoza/prj.app

Issue:
Release order should be evaluated mathematically
<img width="1240" alt="image" src="https://user-images.githubusercontent.com/178003/67666296-6ef2df80-f963-11e9-85e3-f3a8b0c03098.png">

<img width="384" alt="image" src="https://user-images.githubusercontent.com/178003/67666401-9d70ba80-f963-11e9-9abd-f84c94d1a9a6.png">


The logic should be to take the first word, turn it into a floating point number and sort according to that so in the examples above, QGIS 3.10 sorts to the top of the list and 3.4 LTR goes before 3.6


Discussion:

Resolving patch:
diff --git a/django_project/changes/admin.py b/django_project/changes/admin.py
--- a/django_project/changes/admin.py
+++ b/django_project/changes/admin.py
@@ -36,7 +36,9 @@ def queryset(self, request):
 
 
 class VersionAdmin(reversion.VersionAdmin):
-    """Verion admin model."""
+    """Version admin model."""
+
+    list_display = ('__unicode__', 'project',)
 
     def queryset(self, request):
         """Ensure we use the correct manager.
diff --git a/django_project/changes/models/version.py b/django_project/changes/models/version.py
--- a/django_project/changes/models/version.py
+++ b/django_project/changes/models/version.py
@@ -1,4 +1,5 @@
 # coding=utf-8
+import re
 from django.core.urlresolvers import reverse
 # from django.utils.text import slugify
 from common.utilities import version_slugify
@@ -76,9 +77,21 @@ def save(self, *args, **kwargs):
             filtered_words = [t for t in words if t.lower() not in STOP_WORDS]
             new_list = ' '.join(filtered_words)
             self.slug = version_slugify(new_list)[:50]
-        self.padded_version = self.pad_name(self.name)
+        self.padded_version = self.pad_name(str(self.get_numerical_name()))
         super(Version, self).save(*args, **kwargs)
 
+    def get_numerical_name(self):
+        name = self.name
+        non_decimal = re.compile(r'[^\d.]+')
+        numeric_name = non_decimal.sub('', name)
+        number = numeric_name.split('.')
+
+        # Fix the numbering of the version name to have format: 0.0.0.
+        while len(number) < 3:
+            numeric_name += '.0'
+            number = numeric_name.split('.')
+        return numeric_name
+
     def pad_name(self, version):
         """Create a 0 padded version of the version name.
 
diff --git a/django_project/changes/views/version.py b/django_project/changes/views/version.py
--- a/django_project/changes/views/version.py
+++ b/django_project/changes/views/version.py
@@ -120,6 +120,12 @@ def get_queryset(self):
         """
         versions_qs = Version.objects.all()
 
+        # fix padded version if there is padded name with alphabet.
+        for version in versions_qs:
+            is_alphabet = re.search('[a-zA-Z,.]', str(version.padded_version))
+            if is_alphabet is not None:
+                version.save()
+
         project_slug = self.kwargs.get('project_slug', None)
         if project_slug:
             try:
@@ -133,8 +139,6 @@ def get_queryset(self):
             return versions_qs
         else:
             raise Http404('Sorry! We could not find your version!')
-        # In case no project filter applied
-        return versions_qs
 
 
 class VersionDetailView(VersionMixin, DetailView):


Test patch: