Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
7360d61a8e
|
@ -45,7 +45,8 @@ class Notice(models.Model):
|
|||
type = models.IntegerField(
|
||||
'category', choices=NOTICE_TYPE_CHOICES, default=0)
|
||||
content = models.CharField('内容', max_length=256, null=False)
|
||||
group_id = models.CharField('group_id', max_length=256, null=True, blank=True)
|
||||
group_id = models.CharField(
|
||||
'group_id', max_length=256, null=True, blank=True)
|
||||
app = models.CharField('app', max_length=256, null=True, blank=True)
|
||||
model = models.CharField('model', max_length=256, null=True, blank=True)
|
||||
field = models.CharField('field', max_length=256, null=True, blank=True)
|
||||
|
@ -112,7 +113,6 @@ class Task(models.Model):
|
|||
Message.objects.create(
|
||||
type=1, send_from_id=user_id, send_to_id=group.id, task=self, page_title=title, page_description=description, page_image=image, url=url)
|
||||
|
||||
|
||||
class Meta:
|
||||
ordering = ["-added"]
|
||||
|
||||
|
@ -206,3 +206,10 @@ class GroupRecord(models.Model):
|
|||
leave_at = models.DateTimeField(auto_now=True)
|
||||
added = models.DateTimeField(auto_now_add=True)
|
||||
updated = models.DateTimeField(auto_now=True)
|
||||
|
||||
|
||||
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)
|
|
@ -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 .download import download, app_intro
|
||||
from .app import download, app_intro
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
import os
|
||||
from django.conf import settings
|
||||
from django.http import Http404, HttpResponse, JsonResponse
|
||||
from django.shortcuts import render
|
||||
from polls.models import AppVersion
|
||||
|
||||
|
||||
def app_intro(request):
|
||||
return render(request, 'polls/app.html')
|
||||
|
||||
|
||||
def download(request):
|
||||
app = AppVersion.objects.last('version')
|
||||
filename = 'app-%s.apk' % (app.version,)
|
||||
file_path = os.path.join(settings.MEDIA_ROOT, filename)
|
||||
if os.path.exists(file_path):
|
||||
with open(file_path, 'rb') as fh:
|
||||
response = HttpResponse(
|
||||
fh.read(), content_type="application/vnd.android.package-archive")
|
||||
response['Content-Disposition'] = 'inline; filename=' + \
|
||||
os.path.basename(file_path)
|
||||
return response
|
||||
raise Http404
|
||||
|
||||
|
||||
def has_update(request):
|
||||
version = request.GET.get('version', '1')
|
||||
last = AppVersion.objects.last('version')
|
||||
return JsonResponse({'status': 'success', 'message': last != version})
|
|
@ -1,17 +0,0 @@
|
|||
import os
|
||||
from django.conf import settings
|
||||
from django.http import HttpResponse, Http404
|
||||
from django.shortcuts import render
|
||||
|
||||
def app_intro(request):
|
||||
return render(request, 'polls/app.html')
|
||||
|
||||
|
||||
def download(request):
|
||||
file_path = os.path.join(settings.MEDIA_ROOT, 'pom.apk')
|
||||
if os.path.exists(file_path):
|
||||
with open(file_path, 'rb') as fh:
|
||||
response = HttpResponse(fh.read(), content_type="application/vnd.android.package-archive")
|
||||
response['Content-Disposition'] = 'inline; filename=' + os.path.basename(file_path)
|
||||
return response
|
||||
raise Http404
|
Loading…
Reference in New Issue