add feature
This commit is contained in:
parent
7df55f6757
commit
3a5fb97c43
Binary file not shown.
|
@ -6,7 +6,7 @@ from channels.layers import get_channel_layer
|
||||||
from asgiref.sync import async_to_sync
|
from asgiref.sync import async_to_sync
|
||||||
|
|
||||||
from polls.decorators import polls_login_required
|
from polls.decorators import polls_login_required
|
||||||
from polls.models import Task, TaskAddition
|
from polls.models import NormalMessage, Task, TaskAddition
|
||||||
from polls.tasks import process_task
|
from polls.tasks import process_task
|
||||||
from django.core.exceptions import ObjectDoesNotExist
|
from django.core.exceptions import ObjectDoesNotExist
|
||||||
from polls.utils import model_to_dict, queryset_to_list
|
from polls.utils import model_to_dict, queryset_to_list
|
||||||
|
@ -45,7 +45,7 @@ def create_task(request):
|
||||||
return JsonResponse({'status': 'error', 'message': '内容不能为空'})
|
return JsonResponse({'status': 'error', 'message': '内容不能为空'})
|
||||||
groups = request.POST.getlist('groups', [])
|
groups = request.POST.getlist('groups', [])
|
||||||
task = Task.objects.create(created_by=user, content=content)
|
task = Task.objects.create(created_by=user, content=content)
|
||||||
task.add_groups(groups)
|
task.add_groups(groups)
|
||||||
url = request.POST.get('url')
|
url = request.POST.get('url')
|
||||||
print(groups, content, url)
|
print(groups, content, url)
|
||||||
file = request.FILES.get('file')
|
file = request.FILES.get('file')
|
||||||
|
@ -53,12 +53,17 @@ def create_task(request):
|
||||||
if url:
|
if url:
|
||||||
urlAddtion = TaskAddition.objects.create(
|
urlAddtion = TaskAddition.objects.create(
|
||||||
task=task, category=0, url=url)
|
task=task, category=0, url=url)
|
||||||
|
|
||||||
|
|
||||||
if file:
|
if file:
|
||||||
fileAddtion = TaskAddition.objects.create(
|
fileAddtion = TaskAddition.objects.create(
|
||||||
task=task, category=1, file=file)
|
task=task, category=1, file=file)
|
||||||
if picture:
|
if picture:
|
||||||
pictureAddtion = TaskAddition.objects.create(
|
pictureAddtion = TaskAddition.objects.create(
|
||||||
task=task, category=2, image=picture)
|
task=task, category=2, image=picture)
|
||||||
|
|
||||||
|
for group in groups:
|
||||||
|
normalMessage = NormalMessage.objects.create(send_from__id=user.id, send_to__id=group, task=task, content=content)
|
||||||
# t = model_to_dict(task, ["id", "content"])
|
# t = model_to_dict(task, ["id", "content"])
|
||||||
# gs = queryset_to_list(task.groups.all(), ["id"])
|
# gs = queryset_to_list(task.groups.all(), ["id"])
|
||||||
# channel_layer = get_channel_layer()
|
# channel_layer = get_channel_layer()
|
||||||
|
|
Loading…
Reference in New Issue