Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add previously worked label in user directory #4455

Merged
merged 4 commits into from
May 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app/dashboard/templates/dashboard/users.html
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ <h5 class="text-center card-user_name">
<i class="far fa-star" :class="star <= user.avg_rating.overall.toFixed() ? 'fas' : 'far'" v-for="star in user.avg_rating.overall.toFixed(), 5"></i>
([[ user.avg_rating.total_rating ]] ratings)
</div>
<small class="text-center pb-1" v-if="user.previously_worked">
<i class="far fa-handshake mr-1"></i>Worked with you
</small>
</div>
<div class="card-body d-flex flex-column justify-content-between">
<div v-if="user.keywords" class="text-center">
Expand Down
17 changes: 16 additions & 1 deletion app/dashboard/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 hasattr(request, 'user') and request.user.is_authenticated and hasattr(request.user, 'profile') else None

context = {}
if not settings.DEBUG:
network = 'mainnet'
Expand Down Expand Up @@ -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,
Expand All @@ -822,10 +827,20 @@ 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 = 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()
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
Expand Down