fix task records status bug
This commit is contained in:
parent
8e1df38953
commit
faa78f8cf0
|
@ -4,7 +4,7 @@ import datetime
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
|
||||||
from dashboard.models import Group
|
from dashboard.models import Group, Group_user
|
||||||
|
|
||||||
VERIFY_CODE_TYPE_CHOICES = (
|
VERIFY_CODE_TYPE_CHOICES = (
|
||||||
(0, 'register'),
|
(0, 'register'),
|
||||||
|
@ -101,7 +101,8 @@ class Task(models.Model):
|
||||||
return TaskRecord.objects.filter(task=self).count()
|
return TaskRecord.objects.filter(task=self).count()
|
||||||
|
|
||||||
def records(self):
|
def records(self):
|
||||||
return TaskRecord.objects.filter(task=self)
|
group_ids = [group.id for group in self.groups.all()]
|
||||||
|
return Group_user.objects.filter(group__in=group_ids)
|
||||||
|
|
||||||
def add_task_message(self, user_id):
|
def add_task_message(self, user_id):
|
||||||
for group in self.groups.all():
|
for group in self.groups.all():
|
||||||
|
|
Binary file not shown.
|
@ -4,7 +4,7 @@ from django.views.decorators.csrf import csrf_exempt
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
from polls.decorators import polls_login_required
|
from polls.decorators import polls_login_required
|
||||||
from polls.models import Message, Notice, Task, TaskAddition
|
from polls.models import Message, Notice, Task, TaskAddition, TaskRecord
|
||||||
from django.core.exceptions import ObjectDoesNotExist
|
from django.core.exceptions import ObjectDoesNotExist
|
||||||
from polls.utils import model_to_dict, queryset_to_list, parse
|
from polls.utils import model_to_dict, queryset_to_list, parse
|
||||||
from dashboard.models import Group, Group_user, Userprofile
|
from dashboard.models import Group, Group_user, Userprofile
|
||||||
|
@ -98,9 +98,9 @@ def get_task(request):
|
||||||
n = []
|
n = []
|
||||||
for r in records:
|
for r in records:
|
||||||
p = dict()
|
p = dict()
|
||||||
p['id'] = r.id
|
p['id'] = r.user_id
|
||||||
p['added'] = task.added.strftime("%Y-%m-%d %H:%M:%S")
|
is_finished = TaskRecord.objects.filter(user_id=r.user_id, task_id=task_id)
|
||||||
p['status'] = r.status
|
p['status'] = '完成' if is_finished else '未完成'
|
||||||
profile = Userprofile.objects.filter(user_id=r.user_id).first()
|
profile = Userprofile.objects.filter(user_id=r.user_id).first()
|
||||||
p['name'] = profile.name
|
p['name'] = profile.name
|
||||||
p['organization'] = profile.organization.name
|
p['organization'] = profile.organization.name
|
||||||
|
|
Loading…
Reference in New Issue