This commit is contained in:
xieshen 2021-03-28 15:44:18 +08:00
commit d7879d93fd
3 changed files with 5 additions and 2 deletions

View File

@ -171,6 +171,7 @@ class Userprofile(models.Model):
status = models.IntegerField('用户状态', null=True, blank=True, default=0) status = models.IntegerField('用户状态', null=True, blank=True, default=0)
admin_status = models.IntegerField('管理状态', default=3) admin_status = models.IntegerField('管理状态', default=3)
message_status = models.BooleanField('是否发送消息', default=True) message_status = models.BooleanField('是否发送消息', default=True)
platform = models.CharField('手机操作系统', null=True, blank=True, max_length=32)
# 20201017新增字段职位 # 20201017新增字段职位
zhiwei = models.CharField('职位', max_length=256, null=True, blank=True) zhiwei = models.CharField('职位', max_length=256, null=True, blank=True)
created = models.DateTimeField('创建时间', auto_now_add=True) created = models.DateTimeField('创建时间', auto_now_add=True)

View File

@ -12,7 +12,6 @@ import os
from pathlib import Path from pathlib import Path
from polls.models import Notice, VerifyCode from polls.models import Notice, VerifyCode
from polls.utils import generate_code, sent_sms_code from polls.utils import generate_code, sent_sms_code
from dashboard.models import Organization, Userprofile from dashboard.models import Organization, Userprofile
@ -38,6 +37,7 @@ def polls_login(request):
if request.method == 'POST': if request.method == 'POST':
phone = request.POST.get('phone') phone = request.POST.get('phone')
password = request.POST.get('password') password = request.POST.get('password')
platform = request.POST.get('platform', 'android')
UserModel = get_user_model() UserModel = get_user_model()
user = UserModel.objects.filter(username=phone).first() user = UserModel.objects.filter(username=phone).first()
if not user: if not user:
@ -63,6 +63,8 @@ def polls_login(request):
result['thumbnail'] = request.build_absolute_uri( result['thumbnail'] = request.build_absolute_uri(
profile.image.url) if profile.image else None profile.image.url) if profile.image else None
result['organization'] = profile.organization.name result['organization'] = profile.organization.name
profile.platform = platform
profile.save()
return JsonResponse({'status': 'success', 'message': result}) return JsonResponse({'status': 'success', 'message': result})
else: else:
return JsonResponse({'status': 'error', 'message': '用户名或密码错误'}) return JsonResponse({'status': 'error', 'message': '用户名或密码错误'})
@ -234,7 +236,7 @@ def upload_profile(request):
ext = source.name.split('.')[-1] ext = source.name.split('.')[-1]
if ext not in ['jpg', 'png', 'jpeg', 'gif']: if ext not in ['jpg', 'png', 'jpeg', 'gif']:
return JsonResponse({'status': 'error', 'message': '上传的文件不是图片'}) return JsonResponse({'status': 'error', 'message': '上传的文件不是图片'})
filename = "%s.%s" % (uuid.uuid4(), ext) filename = "%s.%s" % (uuid.uuid4(), ext)
foldpath = os.path.join(settings.MEDIA_ROOT, 'profile') foldpath = os.path.join(settings.MEDIA_ROOT, 'profile')
Path(foldpath).mkdir(parents=True, exist_ok=True) Path(foldpath).mkdir(parents=True, exist_ok=True)