def get(self, request, pk, format=None): followrelation = self.get_object(pk) if not (is_in_the_same_segment(request.user, followrelation.follower_user) and is_in_the_same_segment(request.user, followrelation.following_user)): followrelation = None serialized_followrelation = FollowRelationSerializer(followrelation) return Response(serialized_followrelation.data)
def get(self, request, format=None): followrelations = FollowRelation.objects.all() allowed_relations = [] for folloewr_relation in followrelations: if is_in_the_same_segment( request.user, folloewr_relation. follower_user) and is_in_the_same_segment( request.user, folloewr_relation.following_user): allowed_relations.append(folloewr_relation) serialized_followrelations = FollowRelationSerializer( allowed_relations, many=True) return Response(serialized_followrelations.data)
def get(self, request, pk, format = None): userupdate = self.get_object(pk) if not is_in_the_same_segment(request.user, userupdate.recipient): userupdate = None serialized_userupdate = UserUpdateSerializer(userupdate) return Response(serialized_userupdate.data)
def get(self, request, pk, format = None): serialized_user = None user = self.get_object(pk) if is_in_the_same_segment( request.user, user): serialized_user = UserSerializer(user) return Response(serialized_user.data)
def get(self, request, pk, format = None): userprofile = self.get_object(pk) if not is_in_the_same_segment( request.user, userprofile.user): userprofile = None serialized_userprofile = UserProfileSerializer(userprofile) return Response(serialized_userprofile.data)
def get(self, request, pk, format=None): userupdate = self.get_object(pk) if not is_in_the_same_segment(request.user, userupdate.recipient): userupdate = None serialized_userupdate = UserUpdateSerializer(userupdate) return Response(serialized_userupdate.data)
def get(self, request, pk, format=None): userprofile = self.get_object(pk) if not is_in_the_same_segment(request.user, userprofile.user): userprofile = None serialized_userprofile = UserProfileSerializer(userprofile) return Response(serialized_userprofile.data)
def get(self, request, pk, format=None): serialized_user = None user = self.get_object(pk) if is_in_the_same_segment(request.user, user): serialized_user = UserSerializer(user) return Response(serialized_user.data)
def get(self, request,format = None): userupdates = UserUpdate.objects.order_by("-created_at") allowed_userupdates = [] for user_update in userupdates: if is_in_the_same_segment( request.user, user_update.recipient): allowed_userupdates.append(user_update) serialized_userupdates =UserUpdateSerializer(allowed_userupdates, many = True) return Response(serialized_userupdates.data)
def get(self, request,format = None): userprofiles = UserProfile.objects.all() allowed_userprofiles = [] for userprofile in userprofiles: if is_in_the_same_segment( request.user, userprofile.user): allowed_userprofiles.append(userprofile) serialized_userprofiles =UserProfileSerializer(allowed_userprofiles, many = True) return Response(serialized_userprofiles.data)
def get(self, request,format = None): followrelations = FollowRelation.objects.all() allowed_relations = [] for folloewr_relation in followrelations: if is_in_the_same_segment( request.user, folloewr_relation.follower_user) and is_in_the_same_segment( request.user, folloewr_relation.following_user): allowed_relations.append(folloewr_relation) serialized_followrelations =FollowRelationSerializer(allowed_relations, many = True) return Response(serialized_followrelations.data)
def get(self, request, format=None): userprofiles = UserProfile.objects.all() allowed_userprofiles = [] for userprofile in userprofiles: if is_in_the_same_segment(request.user, userprofile.user): allowed_userprofiles.append(userprofile) serialized_userprofiles = UserProfileSerializer(allowed_userprofiles, many=True) return Response(serialized_userprofiles.data)
def get(self, request, format=None): userupdates = UserUpdate.objects.order_by("-created_at") allowed_userupdates = [] for user_update in userupdates: if is_in_the_same_segment(request.user, user_update.recipient): allowed_userupdates.append(user_update) serialized_userupdates = UserUpdateSerializer(allowed_userupdates, many=True) return Response(serialized_userupdates.data)
def start_follow_user(request, username): try: following_user = User.objects.get(username=username) except User.DoesNotExist: return render(request, 'coplay/message.html', { 'message' : 'לא נמצא', 'rtl': 'dir="rtl"'}) if not is_in_the_same_segment(request.user, following_user): return render(request, 'coplay/message.html', { 'message' : 'משתמש ממודר', 'rtl': 'dir="rtl"'}) start_users_following( request.user, following_user) return HttpResponseRedirect(reverse('coplay:user_coplay_report', kwargs={'username': following_user}))
def start_follow_user(request, username): try: following_user = User.objects.get(username=username) except User.DoesNotExist: return render(request, 'coplay/message.html', { 'message': 'לא נמצא', 'rtl': 'dir="rtl"' }) if not is_in_the_same_segment(request.user, following_user): return render(request, 'coplay/message.html', { 'message': 'משתמש ממודר', 'rtl': 'dir="rtl"' }) start_users_following(request.user, following_user) return HttpResponseRedirect( reverse('coplay:user_coplay_report', kwargs={'username': following_user}))
def get(self, request, pk, format = None): followrelation = self.get_object(pk) if not (is_in_the_same_segment( request.user, followrelation.follower_user) and is_in_the_same_segment( request.user, followrelation.following_user)): followrelation = None serialized_followrelation = FollowRelationSerializer(followrelation) return Response(serialized_followrelation.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() })