def test_deactivated_user_should_not_be_sponsoring_working_or_watching(self):
        offer = test_data.create_dummy_offer_btc()
        user = offer.sponsor
        solution = test_data.create_dummy_solution(programmer=user)
        issue = test_data.create_dummy_issue()
        watch_services.toggle_watch(user, 'ISSUE', issue.id, Watch.WATCHED)
        
        user = User.objects.get(pk=user.id)
        offer = Offer.objects.get(pk=offer.id)
        solution = Solution.objects.get(pk=solution.id)
        self.assertTrue(user.is_active)
        self.assertEqual(Offer.OPEN, offer.status)
        self.assertEqual(Solution.IN_PROGRESS, solution.status)
        self.assertTrue(watch_services.is_watching_issue(user, issue.id))

        user_services.deactivate_user(user)

        user = User.objects.get(pk=user.id)
        offer = Offer.objects.get(pk=offer.id)
        solution = Solution.objects.get(pk=solution.id)
        self.assertFalse(user.is_active)
        self.assertEqual(Offer.REVOKED, offer.status)
        self.assertEqual(Solution.ABORTED, solution.status)
        self.assertFalse(watch_services.is_watching_issue(user, issue.id))
        self.assertFalse(watch_services.is_watching_project(user, issue.project.id))
        self.assertFalse(watch_services.is_watching_issue(user, offer.issue.id))
        self.assertFalse(watch_services.is_watching_issue(user, solution.issue.id))
    def test_watch_toggle_issue(self):
        issue = test_data.create_dummy_issue()
        user = issue.createdByUser

        self.assertTrue(not watch_services.is_watching_issue(user, issue.id))

        watch_services.watch_issue(user, issue.id, Watch.WATCHED)
        self.assertTrue(watch_services.is_watching_issue(user, issue.id))

        watch_services.toggle_watch(user, 'ISSUE', issue.id, Watch.WATCHED)
        self.assertTrue(not watch_services.is_watching_issue(user, issue.id))
def toggle_watch(request):
    objid = int(request.POST.get('objid'))
    entity = request.POST.get('entity')
    watching = watch_services.toggle_watch(request.user, entity, objid, Watch.WATCHED)
    return HttpResponse('WATCHING' if watching else 'NOT_WATCHING')
Пример #4
0
def toggle_watch(request):
    objid = int(request.POST.get('objid'))
    entity = request.POST.get('entity')
    watching = watch_services.toggle_watch(request.user, entity, objid, Watch.WATCHED)
    return HttpResponse('WATCHING' if watching else 'NOT_WATCHING', content_type="text/plain")