add message

This commit is contained in:
baoliang 2020-10-27 21:02:08 +08:00
parent 8583b5c5a7
commit 137149fd3d
7 changed files with 9 additions and 5 deletions

View File

@ -213,3 +213,6 @@ class AppVersion(models.Model):
version = models.IntegerField('version', default=1)
added = models.DateTimeField(auto_now_add=True)
updated = models.DateTimeField(auto_now=True)
class Meta:
ordering = ["-version"]

View File

@ -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')
]

View File

@ -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

Binary file not shown.

View File

@ -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})