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 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 django.core.exceptions import ObjectDoesNotExist
|
||||
from polls.utils import model_to_dict, queryset_to_list
|
||||
|
@ -45,7 +45,7 @@ def create_task(request):
|
|||
return JsonResponse({'status': 'error', 'message': '内容不能为空'})
|
||||
groups = request.POST.getlist('groups', [])
|
||||
task = Task.objects.create(created_by=user, content=content)
|
||||
task.add_groups(groups)
|
||||
task.add_groups(groups)
|
||||
url = request.POST.get('url')
|
||||
print(groups, content, url)
|
||||
file = request.FILES.get('file')
|
||||
|
@ -53,12 +53,17 @@ def create_task(request):
|
|||
if url:
|
||||
urlAddtion = TaskAddition.objects.create(
|
||||
task=task, category=0, url=url)
|
||||
|
||||
|
||||
if file:
|
||||
fileAddtion = TaskAddition.objects.create(
|
||||
task=task, category=1, file=file)
|
||||
if picture:
|
||||
pictureAddtion = TaskAddition.objects.create(
|
||||
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"])
|
||||
# gs = queryset_to_list(task.groups.all(), ["id"])
|
||||
# channel_layer = get_channel_layer()
|
||||
|
|
Loading…
Reference in New Issue