def update_property(request, taskid): result = True try: TaskService.update_property(request, taskid) except Exception as ex: result = Task.task_update_progress_fail SimpleLogger.error(ex) return HttpResponse(result)
def delete(request, taskid): result = True try: TaskService.delete_task(request, taskid) except Exception as ex: result = Task.task_delete_fail SimpleLogger.exception(ex) return HttpResponse(result)
def create(request): result = True try: TaskService.create_task(request) except Exception as ex: result = Task.task_save_fail SimpleLogger.exception(ex) return HttpResponse(result)
def perform_destroy(self, instance): form_data = self.request.POST.get('models', None) if form_data != None: json_decoder = JSONDecoder() validate_data = json_decoder.decode(form_data) task_dependency_id = int(validate_data.get('id', 0)) else: task_dependency_id = int(self.kwargs['id']) TaskService.delete_task_dependency(int(task_dependency_id))
def task_delayed_finished_today(project_id, version_id, request): if str(project_id) == "0": project_all_tasks = TaskService.all_my_tasks( request, request.user.id) else: project_all_tasks = TaskService.project_all_tasks(0, project_id) project_all_tasks = project_all_tasks.filter(Status=2).filter( Parent__isnull=True) if str(version_id) != "0": project_all_tasks = project_all_tasks.filter( Version=int(version_id)) return project_all_tasks.filter(DeadLine__lt=F('FinishedDate')).count()
def update(self, request, *args, **kwargs): partial = kwargs.pop('partial', False) form_data = request.POST.get('models', None) if form_data == None: validate_data = request.POST or request.data else: json_decoder = JSONDecoder() validate_data = json_decoder.decode(form_data) task = self.get_object() print(validate_data) TaskService.edit_task(task, validate_data, request.user) serializer = project_serializer.ProjectTaskSerializer(instance=task) return response.Response(serializer.data)
def task_delayed_today(project_id, version_id, request): if str(project_id) == "0": project_all_tasks = TaskService.all_my_tasks( request, request.user.id) else: project_all_tasks = TaskService.project_all_tasks(0, project_id) project_all_tasks = project_all_tasks.exclude(Status=2).filter( Parent__isnull=True) if str(version_id) != "0": project_all_tasks = project_all_tasks.filter( Version=int(version_id)) return project_all_tasks.filter( DeadLine__lt=DateTimeHelper.get_now_date()).count()
def task_count_bystatus(project_id, version_id, request): if str(project_id) == "0": project_all_tasks = TaskService.all_my_tasks( request, request.user.id) else: project_all_tasks = TaskService.project_all_tasks(0, project_id) if str(version_id) != "0": project_all_tasks = project_all_tasks.filter( Version=int(version_id)) project_all_tasks = project_all_tasks.filter(Parent__isnull=True) result = project_all_tasks.values('Status').annotate( TotalCount=Count('id')).order_by('Status') return result
def task_finished_today(project_id, version_id, request): if str(project_id) == "0": project_all_tasks = TaskService.all_my_tasks( request, request.user.id) else: project_all_tasks = TaskService.project_all_tasks(0, project_id) if str(version_id) != "0": project_all_tasks = project_all_tasks.filter( Version=int(version_id)) project_all_tasks = project_all_tasks.filter(Parent__isnull=True) return project_all_tasks.filter( FinishedDate=DateTimeHelper.get_now_date()).count()
def get_queryset(self): project_id = int(self.kwargs['project_id']) version_id = int(self.kwargs['version_id']) if str(project_id) != '0': if str(version_id) != '0': qs = models.Task.objects.get_tasks(project_id).filter( Version=int(version_id)).order_by('Priority', 'id') else: qs = models.Task.objects.get_tasks(project_id).order_by( 'Priority', 'id') else: qs = TaskService.all_my_tasks(self.request, 'ALL', self.request.user.id) owners = self.request.GET.get("Owner__in", None) if owners is not None: if ',' in owners: owner_tasks = models.ProjectTaskOwner.objects.all().filter( Owner__in=eval(owners)) else: owner_tasks = models.ProjectTaskOwner.objects.all().filter( Owner=int(owners)) owner_task_ids = [task.Task for task in owner_tasks] qs = qs.filter(id__in=owner_task_ids) return project_filter.ProjectTaskFilterSet(data=self.request.GET, queryset=qs).filter()
def get_task_tag_menu(self, task, taskrole): tags = list() for tag in TaskService.all_tags(): tmp_tag = VM_Tag(tag, task.Tags) tags.append(tmp_tag) context_fileds = {'tags': tags, 'tagrole': taskrole} return self.get_webpart(context_fileds, ProjectTaskPath.tag_menu_template_path)
def update(self, request, *args, **kwargs): partial = kwargs.pop('partial', False) form_data = request.POST.get('models', None) if form_data == None: validate_data = request.POST or request.data else: json_decoder = JSONDecoder() validate_data = json_decoder.decode(form_data) task = self.get_object() TaskService.edit_task(task, validate_data, request.user) serializer = self.get_serializer(task, data=validate_data, partial=partial) serializer.is_valid(raise_exception=True) self.perform_update(serializer) if getattr(task, '_prefetched_objects_cache', None): task._prefetched_objects_cache = {} return response.Response(serializer.data)
def post(self, request, *args, **kwargs): form_data = request.POST.get('models', None) if form_data == None: validate_data = request.data else: json_decoder = JSONDecoder() validate_data = json_decoder.decode(form_data) task = TaskService.create_task(validate_data, request.user) serializer = project_serializer.ProjectTaskSerializer(instance=task) headers = self.get_success_headers(serializer.data) return response.Response(serializer.data, status=status.HTTP_201_CREATED, headers=headers)
def get_queryset(self): project_id = int(self.kwargs['project_id']) version_id = int(self.kwargs['version_id']) if str(project_id) != '0': if str(version_id) != '0': qs = models.Task.objects.get_tasks(project_id).filter( Version=int(version_id)).order_by('-Priority', '-id') else: qs = models.Task.objects.get_tasks(project_id).order_by( '-Priority', '-id') else: qs = TaskService.all_my_tasks(self.request, 'ALL', self.request.user.id) return project_filter.ProjectTaskFilterSet(data=self.request.GET, queryset=qs).filter()
def post(self, request, *args, **kwargs): form_data = request.POST.get('models', None) if form_data == None: validate_data = request.data else: json_decoder = JSONDecoder() validate_data = json_decoder.decode(form_data) task_dependency = TaskService.create_task_dependency(validate_data) serializer = project_serializer.ProjectTaskDependencySerializer( instance=task_dependency, data=validate_data) serializer.is_valid(raise_exception=True) headers = self.get_success_headers(serializer.data) return response.Response(serializer.data, status=status.HTTP_201_CREATED, headers=headers)
def get_task_sub_navbar(self, request, task_list, sub_nav_action): task_list = TaskService.all_my_tasks(request, sub_nav_action, 0) owner_id_list = list() vm_members = list() for task in task_list: temp_list = eval(task.Owner) for owner in temp_list: if owner != "" and owner not in owner_id_list: owner_id_list.append(owner) for owner_id in owner_id_list: member = UserService.get_user(int(owner_id)) tmp_member = VM_ProjectMember(0, member, 0, None) vm_members.append(tmp_member) return self.get_left_nav_bar(request, self.sub_side_bar_model, HomeTaskPath.sub_nav_template_path, sub_nav_action=sub_nav_action, tasks=task_list, members=vm_members)
def post(self, request, *args, **kwargs): form_data = request.POST.get('models', None) if form_data == None: validate_data = request.data else: json_decoder = JSONDecoder() validate_data = json_decoder.decode(form_data) task_id = validate_data.get('Task') task = models.Task.objects.get(int(task_id)) owner = validate_data.get('Owner') unit = validate_data.get('Unit') task_owner = TaskService.create_task_owner(task, owner, unit) serializer = project_serializer.ProjectTaskOwnerSerializer( instance=task_owner, data=validate_data) serializer.is_valid(raise_exception=True) headers = self.get_success_headers(serializer.data) return response.Response(serializer.data, status=status.HTTP_201_CREATED, headers=headers)
def get_full_page(self, request, start_index, sub_nav_action): owner = 0 if sub_nav_action.upper() == "CREATEBYME" or sub_nav_action.upper( ) == "ASGINME": owner = request.user.id task_list = TaskService.all_my_tasks(request, sub_nav_action, owner) page_index = [start_index, start_index + 8] sub_leftnav = self.get_task_sub_navbar(request, task_list, sub_nav_action) left_nav_bar = self.get_task_left_bar(request, sub_nav_action) task_page_worker = ProjectTaskPageWorker(request) task_list_webpart = task_page_worker.get_task_list_webpart( task_list, page_index, True, False, True) page_fileds = { 'left_nav_bar': left_nav_bar, 'sub_leftnav': sub_leftnav, 'task_list': task_list_webpart } return self.get_page(page_fileds, HomeTaskPath.task_index_path, request)
def update(self, request, *args, **kwargs): partial = kwargs.pop('partial', False) form_data = request.POST.get('models', None) if form_data == None: validate_data = request.POST or request.data else: json_decoder = JSONDecoder() validate_data = json_decoder.decode(form_data) task_owner_id = validate_data.get('id') unit = validate_data.get('Unit') task_owner = TaskService.edit_task_owner(task_owner_id, unit) serializer = self.get_serializer(instance=task_owner, data=validate_data, partial=partial) serializer.is_valid(raise_exception=True) self.perform_update(serializer) if getattr(task_owner, '_prefetched_objects_cache', None): task_owner._prefetched_objects_cache = {} # return response.Response({'1':1}) return response.Response(serializer.data)
def get_project_task_full_page(self, request, projectid, start_index, sub_nav_action): owner = 0 if sub_nav_action.upper() == "CREATEBYME" or sub_nav_action.upper( ) == "ASGINME": owner = request.user.id task_list = TaskService.project_all_tasks(owner, projectid, sub_nav_action) page_index = [start_index, start_index + 10] sub_leftnav = self.get_task_sub_navbar(request, projectid, task_list, sub_nav_action) task_list_webpart = self.get_task_list_webpart(task_list, page_index) left_nav_bar = self.get_task_left_bar(request, projectid, sub_nav_action) pagefileds = { 'left_nav_bar': left_nav_bar, 'sub_leftnav': sub_leftnav, 'task_list': task_list_webpart } return self.get_full_page_with_header(request, pagefileds, projectid, "task/project_task_index.html")
def task_count(self): all_my_tasks = TaskService.all_my_tasks(self.request, 'ALL', self.request.user.id) all_my_tasks = all_my_tasks.filter(Status__in=(0, 1)).filter(Parent=None) return len(all_my_tasks)
def get_more_tasks(self, request, projectid, filters, owner, start_index): task_list = TaskService.project_tasks_byowner( request, projectid, owner, filters)[start_index:start_index + 8] return self.get_task_listcontrol(task_list, True, False, True)
def get_task_summary(self, request): task_list = TaskService.all_tasks(request, "all")[0:5] page_worker = ProjectTaskPageWorker(request) dashboard_task_list = page_worker.get_task_listcontrol( task_list, True, False, False) return dashboard_task_list
def perform_destroy(self, instance): TaskService.delete_task(self.request, instance.id)
def get_dashboard_tasks(self, request, projectid): task_list = TaskService.project_all_tasks(request, projectid, "all")[0:5] page_worker = ProjectTaskPageWorker(request) return page_worker.get_task_listcontrol(task_list, False, False, False)
def update(self, instance, validated_data, user): instance = TaskService.edit_task(instance, validated_data, user) return instance
def create(self, validated_data, user): task = TaskService.create_task(validated_data, user) return task
def get_more_tasks(self, request, filters, owner, start_index): task_list = TaskService.project_tasks_byowner( request, 0, owner, filters)[start_index:start_index + 8] task_page_worker = ProjectTaskPageWorker(request) return task_page_worker.get_task_listcontrol(task_list, True, False, True)
def get_owner_tasks(self, request, project_id, filters, owner): task_list = TaskService.project_tasks_byowner(request, project_id, owner, filters)[0:8] task_page_worker = ProjectTaskPageWorker(request) return task_page_worker.get_task_listcontrol(task_list, True, False, True)