add message
This commit is contained in:
parent
8424e12a9a
commit
4175686f12
|
@ -73,7 +73,7 @@ urlpatterns = [
|
||||||
path('app/intro.html', views.app_intro, name='polls_app_intro'),
|
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'),
|
path('app/has/update/', views.has_update, name='polls_app_has_update'),
|
||||||
path('app/profile/image/upload/', views.upload_image, name='polls_profile_upload'),
|
path('app/profile/image/upload/', views.upload_profile, name='polls_profile_upload'),
|
||||||
]
|
]
|
||||||
|
|
||||||
tasks.process_notify_task(repeat=5)
|
tasks.process_notify_task(repeat=5)
|
|
@ -11,7 +11,6 @@ from aliyunsdkcore.client import AcsClient
|
||||||
import uuid
|
import uuid
|
||||||
from aliyunsdkcore.profile import region_provider
|
from aliyunsdkcore.profile import region_provider
|
||||||
|
|
||||||
|
|
||||||
def sent_sms_code(phone, code):
|
def sent_sms_code(phone, code):
|
||||||
clnt = YunpianClient('304eb08353f7ebf00596737acfc31f53')
|
clnt = YunpianClient('304eb08353f7ebf00596737acfc31f53')
|
||||||
param = {YC.MOBILE: phone,
|
param = {YC.MOBILE: phone,
|
||||||
|
@ -131,7 +130,6 @@ def queryset_to_list(q, fields):
|
||||||
l.append(r)
|
l.append(r)
|
||||||
return l
|
return l
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
# r = sent_sms_code('13993199566', 4321)
|
# r = sent_sms_code('13993199566', 4321)
|
||||||
# print(r.code(), type(r.code()))
|
# print(r.code(), type(r.code()))
|
||||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -6,9 +6,11 @@ from django.views.decorators.csrf import csrf_exempt
|
||||||
from django_token.models import Token
|
from django_token.models import Token
|
||||||
import datetime
|
import datetime
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
import tempfile
|
|
||||||
import shutil
|
import shutil
|
||||||
import uuid
|
import uuid
|
||||||
|
import os
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
from polls.models import Notice, VerifyCode
|
from polls.models import Notice, VerifyCode
|
||||||
|
@ -225,14 +227,19 @@ def reset_password(request):
|
||||||
@csrf_exempt
|
@csrf_exempt
|
||||||
@polls_login_required
|
@polls_login_required
|
||||||
def upload_profile(request):
|
def upload_profile(request):
|
||||||
|
u = request.user
|
||||||
source = request.FILES['photo']
|
source = request.FILES['photo']
|
||||||
ext = source.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)
|
||||||
# fd, filepath = tempfile.mkstemp(
|
foldpath = os.path.join(settings.MEDIA_ROOT, 'profile')
|
||||||
# prefix=source.name, dir=settings.MEDIA_ROOT)
|
Path(foldpath).mkdir(parents=True, exist_ok=True)
|
||||||
# with open(filepath, 'wb') as dest:
|
filepath = os.path.join(foldpath, filename)
|
||||||
# shutil.copyfileobj(source, dest)
|
with open(filepath, 'wb') as dest:
|
||||||
return JsonResponse({'status': 'success', 'message': filename})
|
shutil.copyfileobj(source, dest)
|
||||||
|
profile = Userprofile.objects.filter(user=u).first()
|
||||||
|
profile.image = '/profile/%s' % filename
|
||||||
|
profile.save()
|
||||||
|
return JsonResponse({'status': 'success', 'message': request.build_absolute_uri('/media/profile/%s' % filename)})
|
||||||
|
|
Loading…
Reference in New Issue