From 204bb779059f7da6a926453ac1d3a5b87331a216 Mon Sep 17 00:00:00 2001 From: Saptak Sengupta Date: Tue, 21 May 2019 15:32:30 +0530 Subject: [PATCH 1/3] Adds check for past worker --- app/dashboard/views.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/dashboard/views.py b/app/dashboard/views.py index e5a824bcc5e..6f111337d9d 100644 --- a/app/dashboard/views.py +++ b/app/dashboard/views.py @@ -764,6 +764,12 @@ def users_fetch(request): rating = int(request.GET.get('rating', '0')) organisation = request.GET.get('organisation', '') + user_id = request.GET.get('user', None) + if user_id: + profile = Profile.objects.get(id=int(user_id)) + else: + profile = request.user.profile if request.user.is_authenticated and hasattr(request.user, 'profile') else None + context = {} if not settings.DEBUG: network = 'mainnet' @@ -803,7 +809,6 @@ def users_fetch(request): ) if organisation: - print(organisation) user_list = user_list.filter( fulfilled__bounty__network=network, fulfilled__bounty__accepted=True, @@ -822,6 +827,10 @@ def users_fetch(request): profile_json['avatar_url'] = user_avatar.avatar_url count_work_completed = Activity.objects.filter(profile=user, activity_type='work_done').count() count_work_in_progress = Activity.objects.filter(profile=user, activity_type='start_work').count() + previously_worked_with = BountyFulfillment.objects.filter( + bounty__bounty_owner_github_username=profile.handle + ).count() + print(previously_worked_with) profile_json['position_contributor'] = user.get_contributor_leaderboard_index() profile_json['position_funder'] = user.get_funder_leaderboard_index() profile_json['work_done'] = count_work_completed From eb75a24495558b46805ed86eacb93e59325f6f4e Mon Sep 17 00:00:00 2001 From: Saptak Sengupta Date: Wed, 22 May 2019 16:15:30 +0530 Subject: [PATCH 2/3] Adds frontend for previously worked with --- app/dashboard/templates/dashboard/users.html | 3 +++ app/dashboard/views.py | 8 ++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/dashboard/templates/dashboard/users.html b/app/dashboard/templates/dashboard/users.html index a34c16f77b4..b447cdc3f20 100644 --- a/app/dashboard/templates/dashboard/users.html +++ b/app/dashboard/templates/dashboard/users.html @@ -142,6 +142,9 @@
([[ user.avg_rating.total_rating ]] ratings) + + Worked with you +
diff --git a/app/dashboard/views.py b/app/dashboard/views.py index 6f111337d9d..73edd08a01d 100644 --- a/app/dashboard/views.py +++ b/app/dashboard/views.py @@ -828,13 +828,17 @@ def users_fetch(request): count_work_completed = Activity.objects.filter(profile=user, activity_type='work_done').count() count_work_in_progress = Activity.objects.filter(profile=user, activity_type='start_work').count() previously_worked_with = BountyFulfillment.objects.filter( - bounty__bounty_owner_github_username=profile.handle + bounty__bounty_owner_github_username__iexact=profile.handle, + fulfiller_github_username__iexact=user.handle, + bounty__network=network, + bounty__accepted=True ).count() - print(previously_worked_with) + profile_json['position_contributor'] = user.get_contributor_leaderboard_index() profile_json['position_funder'] = user.get_funder_leaderboard_index() profile_json['work_done'] = count_work_completed profile_json['work_inprogress'] = count_work_in_progress + profile_json['previously_worked'] = previously_worked_with > 0 profile_json['job_status'] = user.job_status_verbose if user.job_search_status else None profile_json['verification'] = user.get_my_verified_check From 1363c172f7961b3fca5533b011ce565f6e09a642 Mon Sep 17 00:00:00 2001 From: Saptak Sengupta Date: Wed, 22 May 2019 19:09:37 +0530 Subject: [PATCH 3/3] Checks for user attribute in the wsgi request --- app/dashboard/views.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/app/dashboard/views.py b/app/dashboard/views.py index 73edd08a01d..12e755432d5 100644 --- a/app/dashboard/views.py +++ b/app/dashboard/views.py @@ -768,7 +768,7 @@ def users_fetch(request): if user_id: profile = Profile.objects.get(id=int(user_id)) else: - profile = request.user.profile if request.user.is_authenticated and hasattr(request.user, 'profile') else None + profile = request.user.profile if hasattr(request, 'user') and request.user.is_authenticated and hasattr(request.user, 'profile') else None context = {} if not settings.DEBUG: @@ -827,12 +827,14 @@ def users_fetch(request): profile_json['avatar_url'] = user_avatar.avatar_url count_work_completed = Activity.objects.filter(profile=user, activity_type='work_done').count() count_work_in_progress = Activity.objects.filter(profile=user, activity_type='start_work').count() - previously_worked_with = BountyFulfillment.objects.filter( - bounty__bounty_owner_github_username__iexact=profile.handle, - fulfiller_github_username__iexact=user.handle, - bounty__network=network, - bounty__accepted=True - ).count() + previously_worked_with = 0 + if profile: + previously_worked_with = BountyFulfillment.objects.filter( + bounty__bounty_owner_github_username__iexact=profile.handle, + fulfiller_github_username__iexact=user.handle, + bounty__network=network, + bounty__accepted=True + ).count() profile_json['position_contributor'] = user.get_contributor_leaderboard_index() profile_json['position_funder'] = user.get_funder_leaderboard_index()