diff --git a/polls/models.py b/polls/models.py index 6cac1ef..e4f3d41 100644 --- a/polls/models.py +++ b/polls/models.py @@ -212,4 +212,7 @@ class AppVersion(models.Model): id = models.UUIDField('id', primary_key=True, default=uuid.uuid4) version = models.IntegerField('version', default=1) added = models.DateTimeField(auto_now_add=True) - updated = models.DateTimeField(auto_now=True) \ No newline at end of file + updated = models.DateTimeField(auto_now=True) + + class Meta: + ordering = ["-version"] diff --git a/polls/urls.py b/polls/urls.py index df27fe8..1e51507 100644 --- a/polls/urls.py +++ b/polls/urls.py @@ -71,5 +71,6 @@ urlpatterns = [ path('messages/read/', views.read_message, name='polls_message_read'), path('app/intro.html', views.app_intro, name='polls_app_intro'), - path('app/download/', views.download, name='polls_app_download') + path('app/download/', views.download, name='polls_app_download'), + path('app/has/update/', views.has_update, name='polls_app_has_update') ] diff --git a/polls/views/__init__.py b/polls/views/__init__.py index 6879918..5f45fd7 100644 --- a/polls/views/__init__.py +++ b/polls/views/__init__.py @@ -8,4 +8,4 @@ from .group import groups, room, is_level1_or_leve2, group_member, group_manager from .compartment import compartments from .organizations import organizations, organization_level from .message import last_messages, send_text_message, is_read_message, read_message -from .app import download, app_intro +from .download import download, app_intro, has_update diff --git a/polls/views/__pycache__/__init__.cpython-38.pyc b/polls/views/__pycache__/__init__.cpython-38.pyc index 103621d..552b9a2 100644 Binary files a/polls/views/__pycache__/__init__.cpython-38.pyc and b/polls/views/__pycache__/__init__.cpython-38.pyc differ diff --git a/polls/views/__pycache__/app.cpython-38.pyc b/polls/views/__pycache__/app.cpython-38.pyc new file mode 100644 index 0000000..aff7a9e Binary files /dev/null and b/polls/views/__pycache__/app.cpython-38.pyc differ diff --git a/polls/views/__pycache__/download.cpython-38.pyc b/polls/views/__pycache__/download.cpython-38.pyc index 69bf512..039011e 100644 Binary files a/polls/views/__pycache__/download.cpython-38.pyc and b/polls/views/__pycache__/download.cpython-38.pyc differ diff --git a/polls/views/app.py b/polls/views/download.py similarity index 90% rename from polls/views/app.py rename to polls/views/download.py index ee58de1..54077f6 100644 --- a/polls/views/app.py +++ b/polls/views/download.py @@ -10,7 +10,7 @@ def app_intro(request): def download(request): - app = AppVersion.objects.last('version') + app = AppVersion.objects.first() filename = 'app-%s.apk' % (app.version,) file_path = os.path.join(settings.MEDIA_ROOT, filename) if os.path.exists(file_path): @@ -25,5 +25,5 @@ def download(request): def has_update(request): version = request.GET.get('version', '1') - last = AppVersion.objects.last('version') + last = AppVersion.objects.first() return JsonResponse({'status': 'success', 'message': last != version})