def get(self, request, pk, format = None): task = self.get_object(pk) status = task_get_status( task) if status == Task.MISSED or ( False == can_user_acess_discussion(task.get_discussion(), request.user)): task = None serialized_task = TaskSerializer(task) return Response(serialized_task.data)
def get(self, request, pk, format=None): task = self.get_object(pk) status = task_get_status(task) if status == Task.MISSED or (False == can_user_acess_discussion( task.get_discussion(), request.user)): task = None serialized_task = TaskSerializer(task) return Response(serialized_task.data)
def get(self, request,format = None): not_missed_tasks = [] tasks = Task.objects.all() for task in tasks: status = task_get_status( task) if status != Task.MISSED and can_user_acess_discussion(task.parent, request.user): not_missed_tasks.append(task) serialized_tasks =TaskSerializer(get_accessed_list( not_missed_tasks, request.user), many = True) return Response(serialized_tasks.data)
def get(self, request, pk, format=None): discussion = self.get_object(pk) not_missed_tasks = [] if can_user_acess_discussion(discussion, request.user): for task in discussion.task_set.all(): if task_get_status(task) != Task.MISSED: not_missed_tasks.append(task) else: discussion = None serialized_discussion = DiscussionWholeSerializer(discussion) return Response(serialized_discussion.data)
def get(self, request, pk, format = None): discussion = self.get_object(pk) not_missed_tasks = [] if can_user_acess_discussion( discussion, request.user): for task in discussion.task_set.all(): if task_get_status(task) != Task.MISSED: not_missed_tasks.append(task) else: discussion = None serialized_discussion = DiscussionWholeSerializer(discussion) return Response(serialized_discussion.data)
def get(self, request, format=None): not_missed_tasks = [] tasks = Task.objects.all() for task in tasks: status = task_get_status(task) if status != Task.MISSED and can_user_acess_discussion( task.parent, request.user): not_missed_tasks.append(task) serialized_tasks = TaskSerializer(get_accessed_list( not_missed_tasks, request.user), many=True) return Response(serialized_tasks.data)
def user_coplay_report(request, username=None): if username: try: user = User.objects.get(username=username) except User.DoesNotExist: return HttpResponse('User not found') else: user = request.user if not is_in_the_same_segment(user, request.user): return render(request, 'coplay/message.html', { 'message': 'משתמש ממודר', 'rtl': 'dir="rtl"' }) if user == request.user: page_name = u'הפעילות שלי ' else: page_name = u'הפעילות של ' + get_user_fullname_or_username(user) open_tasks_list_by_urgancy_list, closed_tasks_list_by_relevancy_list, aborted_tasks_list_by_relevancy_list, missed_tasks_list_by_relevancy_list = get_tasks_lists( ) active_discussions_by_urgancy_list, locked_discussions_by_relevancy_list = get_discussions_lists( ) user_s_open_tasks_list = [] other_users_open_tasks_list = [] failed_tasks_list = [] user_closed_tasks_list = [] for task in open_tasks_list_by_urgancy_list: if can_user_acess_discussion(task.parent, request.user): if task.responsible == user: user_s_open_tasks_list.append(task) else: discussion = task.parent if user in discussion.get_followers_list(): other_users_open_tasks_list.append(task) tasks_by_recent_closed_at_date = Task.objects.all().exclude( status=Task.MISSED).order_by("-closed_at") for task in tasks_by_recent_closed_at_date: discussion = task.parent if user in discussion.get_followers_list( ) and can_user_acess_discussion(discussion, request.user): status = task_get_status(task) if status == Task.ABORTED: failed_tasks_list.append(task) number_of_closed_tasks_for_others = 0 for task in closed_tasks_list_by_relevancy_list: if task.responsible == user: user_closed_tasks_list.append(task) if task.parent.owner != user: number_of_closed_tasks_for_others += 1 user_discussions_active = [] user_discussions_locked = [] for discussion in active_discussions_by_urgancy_list: if user in discussion.get_followers_list( ) and can_user_acess_discussion(discussion, request.user): user_discussions_active.append(discussion) for discussion in locked_discussions_by_relevancy_list: if user in discussion.get_followers_list( ) and can_user_acess_discussion(discussion, request.user): user_discussions_locked.append(discussion) number_of_closed_tasks = len(user_closed_tasks_list) number_of_views = 0 views_list = Viewer.objects.filter(user=user) for view in views_list: if view.discussion.owner != user: number_of_views += view.get_views_counter() number_of_feedbacks = user.feedback_set.all().count() number_of_votes = user.vote_set.all().count() number_of_task_closing = Task.objects.filter(closed_by=user).count() number_of_aborted_tasks = Task.objects.filter(status=Task.ABORTED, responsible=user).count() followers_list = get_followers_list(user) following_list = get_following_list(user) if request.user.is_authenticated(): is_following = is_user_is_following(request.user, user) else: is_following = False user_updates_query_set = user.recipient.all().order_by("-created_at") return render( request, 'coplay/coplay_report.html', { 'number_of_closed_tasks': number_of_closed_tasks, 'number_of_closed_tasks_for_others': number_of_closed_tasks_for_others, 'number_of_aborted_tasks': number_of_aborted_tasks, 'number_of_task_closing': number_of_task_closing, 'number_of_views': number_of_views, 'number_of_feedbacks': number_of_feedbacks, 'number_of_votes': number_of_votes, 'user_updates_that_viewer_can_access_list': user_updates_query_set, 'tasks_open_by_increased_time_left': user_s_open_tasks_list, 'tasks_others_open_by_increased_time_left': other_users_open_tasks_list, 'discussions_active_by_increase_time_left': user_discussions_active, 'discussions_locked_by_increase_locked_at': user_discussions_locked, 'tasks_closed_by_reverse_time': user_closed_tasks_list, 'tasks_failed_by_reverse_update_time': failed_tasks_list, 'applicabale_user': user, 'followers_list': followers_list, 'following_list': following_list, 'is_following': is_following, 'page_name': page_name, 'description': user.userprofile.description, 'location_desc': user.userprofile.location_desc, 'followed_discussions_tags': user.userprofile.followed_discussions_tags.all() })
def user_coplay_report(request, username=None): if username: try: user = User.objects.get(username=username) except User.DoesNotExist: return HttpResponse('User not found') else: user = request.user if not is_in_the_same_segment( user, request.user): return render(request, 'coplay/message.html', { 'message' : 'משתמש ממודר', 'rtl': 'dir="rtl"'}) if user == request.user: page_name = u'הפעילות שלי ' else: page_name = u'הפעילות של ' + get_user_fullname_or_username(user) open_tasks_list_by_urgancy_list, closed_tasks_list_by_relevancy_list, aborted_tasks_list_by_relevancy_list , missed_tasks_list_by_relevancy_list = get_tasks_lists() active_discussions_by_urgancy_list, locked_discussions_by_relevancy_list = get_discussions_lists() user_s_open_tasks_list = [] other_users_open_tasks_list = [] failed_tasks_list = [] user_closed_tasks_list = [] for task in open_tasks_list_by_urgancy_list: if can_user_acess_discussion(task.parent, request.user): if task.responsible == user: user_s_open_tasks_list.append(task) else: discussion = task.parent if user in discussion.get_followers_list(): other_users_open_tasks_list.append(task) tasks_by_recent_closed_at_date = Task.objects.all().exclude(status = Task.MISSED).order_by("-closed_at") for task in tasks_by_recent_closed_at_date: discussion = task.parent if user in discussion.get_followers_list() and can_user_acess_discussion(discussion, request.user): status = task_get_status(task) if status == Task.ABORTED: failed_tasks_list.append(task) number_of_closed_tasks_for_others = 0 for task in closed_tasks_list_by_relevancy_list: if task.responsible == user: user_closed_tasks_list.append(task) if task.parent.owner != user: number_of_closed_tasks_for_others +=1 user_discussions_active = [] user_discussions_locked = [] for discussion in active_discussions_by_urgancy_list: if user in discussion.get_followers_list() and can_user_acess_discussion( discussion, request.user): user_discussions_active.append(discussion) for discussion in locked_discussions_by_relevancy_list: if user in discussion.get_followers_list() and can_user_acess_discussion( discussion, request.user): user_discussions_locked.append(discussion) number_of_closed_tasks = len(user_closed_tasks_list) number_of_views = 0 views_list = Viewer.objects.filter( user = user) for view in views_list: if view.discussion.owner != user: number_of_views += view.get_views_counter() number_of_feedbacks = user.feedback_set.all().count() number_of_votes = user.vote_set.all().count() number_of_task_closing = Task.objects.filter( closed_by = user ).count() number_of_aborted_tasks = Task.objects.filter( status=Task.ABORTED, responsible = user ).count() followers_list = get_followers_list(user) following_list = get_following_list(user) if request.user.is_authenticated(): is_following = is_user_is_following(request.user, user) else: is_following = False user_updates_query_set = user.recipient.all().order_by("-created_at") return render(request, 'coplay/coplay_report.html', { 'number_of_closed_tasks' : number_of_closed_tasks, 'number_of_closed_tasks_for_others': number_of_closed_tasks_for_others, 'number_of_aborted_tasks' : number_of_aborted_tasks, 'number_of_task_closing' : number_of_task_closing, 'number_of_views' : number_of_views , 'number_of_feedbacks' : number_of_feedbacks , 'number_of_votes' : number_of_votes , 'user_updates_that_viewer_can_access_list': user_updates_query_set, 'tasks_open_by_increased_time_left': user_s_open_tasks_list, 'tasks_others_open_by_increased_time_left': other_users_open_tasks_list, 'discussions_active_by_increase_time_left': user_discussions_active, 'discussions_locked_by_increase_locked_at': user_discussions_locked, 'tasks_closed_by_reverse_time': user_closed_tasks_list, 'tasks_failed_by_reverse_update_time': failed_tasks_list, 'applicabale_user': user, 'followers_list' :followers_list, 'following_list' :following_list, 'is_following' :is_following, 'page_name': page_name, 'description': user.userprofile.description, 'location_desc': user.userprofile.location_desc, 'followed_discussions_tags': user.userprofile.followed_discussions_tags.all() } )