Unclaim work from the Bounty. Can only be called by someone who has started work :request method: POST post_id (int): ID of the Bounty. Returns: dict: The success key with a boolean value and accompanying error.
(request, bounty_id)
| 306 | @csrf_exempt |
| 307 | @require_POST |
| 308 | def remove_interest(request, bounty_id): |
| 309 | """Unclaim work from the Bounty. |
| 310 | |
| 311 | Can only be called by someone who has started work |
| 312 | |
| 313 | :request method: POST |
| 314 | |
| 315 | post_id (int): ID of the Bounty. |
| 316 | |
| 317 | Returns: |
| 318 | dict: The success key with a boolean value and accompanying error. |
| 319 | |
| 320 | """ |
| 321 | profile_id = request.user.profile.pk if request.user.is_authenticated and getattr(request.user, 'profile', None) else None |
| 322 | |
| 323 | access_token = request.GET.get('token') |
| 324 | if access_token: |
| 325 | helper_handle_access_token(request, access_token) |
| 326 | github_user_data = get_github_user_data(access_token) |
| 327 | profile = Profile.objects.filter(handle=github_user_data['login']).first() |
| 328 | profile_id = profile.pk |
| 329 | |
| 330 | if not profile_id: |
| 331 | return JsonResponse( |
| 332 | {'error': _('You must be authenticated via github to use this feature!')}, |
| 333 | status=401) |
| 334 | |
| 335 | try: |
| 336 | bounty = Bounty.objects.get(pk=bounty_id) |
| 337 | except Bounty.DoesNotExist: |
| 338 | return JsonResponse({'errors': ['Bounty doesn\'t exist!']}, |
| 339 | status=401) |
| 340 | |
| 341 | try: |
| 342 | interest = Interest.objects.get(profile_id=profile_id, bounty=bounty) |
| 343 | record_user_action(request.user, 'stop_work', interest) |
| 344 | record_bounty_activity(bounty, request.user, 'stop_work') |
| 345 | bounty.interested.remove(interest) |
| 346 | interest.delete() |
| 347 | maybe_market_to_slack(bounty, 'stop_work') |
| 348 | maybe_market_to_user_slack(bounty, 'stop_work') |
| 349 | maybe_market_to_user_discord(bounty, 'stop_work') |
| 350 | maybe_market_to_twitter(bounty, 'stop_work') |
| 351 | except Interest.DoesNotExist: |
| 352 | return JsonResponse({ |
| 353 | 'errors': [_('You haven\'t expressed interest on this bounty.')], |
| 354 | 'success': False}, |
| 355 | status=401) |
| 356 | except Interest.MultipleObjectsReturned: |
| 357 | interest_ids = bounty.interested \ |
| 358 | .filter( |
| 359 | profile_id=profile_id, |
| 360 | bounty=bounty |
| 361 | ).values_list('id', flat=True) \ |
| 362 | .order_by('-created') |
| 363 | |
| 364 | bounty.interested.remove(*interest_ids) |
| 365 | Interest.objects.filter(pk__in=list(interest_ids)).delete() |
nothing calls this directly
no test coverage detected