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, IssueWatch.WATCHED)
        self.assertTrue(watch_services.is_watching_issue(user, issue.id))

        watch_services.unwatch_issue(user, issue.id)
        self.assertTrue(not watch_services.is_watching_issue(user, 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 test_watch_unwatch_issue(self):
        issue = test_data.create_dummy_issue()
        self.assertTrue(not watch_services.is_watching_issue(self.user, issue.id))

        response = self.client.get(_reverse('watchIssue', issue_id=issue.id))
        self.assertEqual(response.status_code, 200)
        self.assertEqual(response.content, 'WATCHING')
        self.assertTrue(watch_services.is_watching_issue(self.user, issue.id))

        response = self.client.get(_reverse('unwatchIssue', issue_id=issue.id))
        self.assertEqual(response.status_code, 200)
        self.assertEqual(response.content, 'NOT_WATCHING')
        self.assertTrue(not watch_services.is_watching_issue(self.user, issue.id))
    def test_watch_unwatch_issue(self):
        issue = test_data.create_dummy_issue()
        self.assertTrue(not watch_services.is_watching_issue(self.user, issue.id))

        response = self.client.get('/core/watch/issue/%s'%issue.id)
        self.assertEqual(response.status_code, 200)
        self.assertEqual(response.content, 'WATCHING')
        self.assertTrue(watch_services.is_watching_issue(self.user, issue.id))

        response = self.client.get('/core/unwatch/issue/%s'%issue.id)
        self.assertEqual(response.status_code, 200)
        self.assertEqual(response.content, 'NOT_WATCHING')
        self.assertTrue(not watch_services.is_watching_issue(self.user, issue.id))
    def test_watch_unwatch_issue(self):
        issue = test_data.create_dummy_issue()
        self.assertTrue(not watch_services.is_watching_issue(self.user, issue.id))

        response = self.client.post('/core/json/toggle_watch', {'entity': 'ISSUE', 'objid': issue.id})
        self.assertEqual(response.status_code, 200)
        self.assertEqual(response.content, 'WATCHING')
        self.assertTrue(watch_services.is_watching_issue(self.user, issue.id))

        response = self.client.post('/core/json/toggle_watch', {'entity': 'ISSUE', 'objid': issue.id})
        self.assertEqual(response.status_code, 200)
        self.assertEqual(response.content, 'NOT_WATCHING')
        self.assertTrue(not watch_services.is_watching_issue(self.user, issue.id))
    def test_watch_unwatch_issue(self):
        issue = test_data.create_dummy_issue()
        self.assertTrue(
            not watch_services.is_watching_issue(self.user, issue.id))

        response = self.client.get('/core/watch/issue/%s' % issue.id)
        self.assertEqual(response.status_code, 200)
        self.assertEqual(response.content, 'WATCHING')
        self.assertTrue(watch_services.is_watching_issue(self.user, issue.id))

        response = self.client.get('/core/unwatch/issue/%s' % issue.id)
        self.assertEqual(response.status_code, 200)
        self.assertEqual(response.content, 'NOT_WATCHING')
        self.assertTrue(
            not watch_services.is_watching_issue(self.user, issue.id))
def viewIssue(request, issue_id):
    issue = Issue.objects.get(pk=issue_id)
    myoffer = None
    mysolution = None
    show_alert = None

    if(request.user.is_authenticated()):
        myoffer = get_or_none(Offer, issue=issue,sponsor=request.user)
        mysolution = get_or_none(Solution, issue=issue,programmer=request.user)

    show_sponsor_popup = (dictOrEmpty(request.GET, 'show_sponsor') == 'true')
    alert = dictOrEmpty(request.GET, 'alert')
    if(alert == 'KICKSTART'):
        show_alert = 'core/popup_just_kickstarted.html'
    invoke_parent_callback = (dictOrEmpty(request.GET, 'c') == 's')

    is_watching = request.user.is_authenticated() and watch_services.is_watching_issue(request.user, issue.id)

    return render_to_response('core/issue.html',
        {'issue':issue,
        'is_watching':is_watching,
        'myoffer':myoffer,
        'mysolution':mysolution,
        'invoke_parent_callback' : invoke_parent_callback,
        'show_sponsor_popup' : show_sponsor_popup,
        'show_alert' : show_alert},

        context_instance = RequestContext(request))
def viewIssue(request, issue_id):
    issue = Issue.objects.get(pk=issue_id)
    myoffer = None
    mysolution = None
    show_alert = None

    if(request.user.is_authenticated()):
        myoffer = get_or_none(Offer, issue=issue, sponsor=request.user, status__in=[Offer.OPEN, Offer.REVOKED])
        mysolution = get_or_none(Solution, issue=issue,programmer=request.user)

    show_sponsor_popup = (request.GET.get('show_sponsor') == 'true')
    alert = request.GET.get('alert')
    if(alert == 'KICKSTART'):
        show_alert = 'core/popup/popup_just_kickstarted.html'
    alert_reputation_revoking = mysolution and mysolution.status == Solution.IN_PROGRESS and mysolution.get_received_payments().count() > 0

    invoke_parent_callback = (request.GET.get('c') == 's')

    is_watching = request.user.is_authenticated() and watch_services.is_watching_issue(request.user, issue.id)

    return render_to_response('core/issue.html',
        {'issue':issue,
        'is_watching':is_watching,
        'myoffer':myoffer,
        'mysolution':mysolution,
        'invoke_parent_callback' : invoke_parent_callback,
        'show_sponsor_popup' : show_sponsor_popup,
        'show_alert' : show_alert,
        'alert_reputation_revoking': alert_reputation_revoking},

        context_instance = RequestContext(request))
Ejemplo n.º 10
0
def viewIssue(request, issue_id):
    try:
        issue = Issue.objects.get(pk=issue_id)
        if timezone.now() - issue.updatedDate > timedelta(hours=1):
            issue.update_redundant_fields()
    except:
        return HttpResponse(status=404, content='Issue not found')
    if issue.get_view_link() != request.path:
        return redirect(issue.get_view_link(),
                        permanent=True)  # only allow one URL per issue
    myoffer = None
    mysolution = None
    show_alert = None

    if (request.user.is_authenticated()):
        myoffer = get_or_none(Offer,
                              issue=issue,
                              sponsor=request.user,
                              status__in=[Offer.OPEN, Offer.REVOKED])
        mysolution = get_or_none(Solution,
                                 issue=issue,
                                 programmer=request.user)

    show_sponsor_popup = (request.GET.get('show_sponsor') == 'true')
    alert = request.GET.get('alert')
    if alert == 'KICKSTART':
        show_alert = 'core2/popup/popup_just_kickstarted.html'
    if alert == 'SPONSOR':
        show_alert = 'core2/popup/popup_just_sponsored.html'
    alert_reputation_revoking = mysolution and mysolution.status == Solution.IN_PROGRESS and mysolution.get_received_payments(
    ).count() > 0

    is_watching = request.user.is_authenticated(
    ) and watch_services.is_watching_issue(request.user, issue.id)
    crumbs = [
        HOME_CRUMB, {
            'link': issue.trackerURL,
            'name': 'issue: ' + issue.title,
            'blank': True,
        }
    ]

    context = {
        'issue': issue,
        'is_watching': is_watching,
        'myoffer': myoffer,
        'mysolution': mysolution,
        'show_sponsor_popup': show_sponsor_popup,
        'show_alert': show_alert,
        'alert_reputation_revoking': alert_reputation_revoking,
        'crumbs': crumbs,
        'actionbar': _actionbar(issue, myoffer, mysolution, request.user)
    }

    return render_to_response('core2/issue.html',
                              context,
                              context_instance=RequestContext(request))
Ejemplo n.º 11
0
def viewIssue(request, issue_id):
    issue = Issue.objects.get(pk=issue_id)
    myoffer = None
    mysolution = None
    show_alert = None

    if (request.user.is_authenticated()):
        myoffer = get_or_none(Offer,
                              issue=issue,
                              sponsor=request.user,
                              status__in=[Offer.OPEN, Offer.REVOKED])
        mysolution = get_or_none(Solution,
                                 issue=issue,
                                 programmer=request.user)

    show_sponsor_popup = (request.GET.get('show_sponsor') == 'true')
    alert = request.GET.get('alert')
    if alert == 'KICKSTART':
        show_alert = template_folder(
            request) + 'popup/popup_just_kickstarted.html'
    if alert == 'SPONSOR':
        show_alert = template_folder(
            request) + 'popup/popup_just_sponsored.html'
    alert_reputation_revoking = mysolution and mysolution.status == Solution.IN_PROGRESS and mysolution.get_received_payments(
    ).count() > 0

    invoke_parent_callback = (request.GET.get('c') == 's')

    is_watching = request.user.is_authenticated(
    ) and watch_services.is_watching_issue(request.user, issue.id)
    crumbs = [
        HOME_CRUMB, {
            'link': issue.trackerURL,
            'name': 'issue: ' + issue.title,
            'blank': True,
        }
    ]

    context = {
        'issue': issue,
        'is_watching': is_watching,
        'myoffer': myoffer,
        'mysolution': mysolution,
        'invoke_parent_callback': invoke_parent_callback,
        'show_sponsor_popup': show_sponsor_popup,
        'show_alert': show_alert,
        'alert_reputation_revoking': alert_reputation_revoking,
        'crumbs': crumbs,
        'actionbar': _actionbar(issue, myoffer, mysolution, request.user)
    }

    return render_to_response(template_folder(request) + 'issue.html',
                              context,
                              context_instance=RequestContext(request))
    def test_watch_unwatch_issue(self):
        issue = test_data.create_dummy_issue()
        self.assertTrue(
            not watch_services.is_watching_issue(self.user, issue.id))

        response = self.client.post('/core/json/toggle_watch', {
            'entity': 'ISSUE',
            'objid': issue.id
        })
        self.assertEqual(response.status_code, 200)
        self.assertEqual(response.content, 'WATCHING')
        self.assertTrue(watch_services.is_watching_issue(self.user, issue.id))

        response = self.client.post('/core/json/toggle_watch', {
            'entity': 'ISSUE',
            'objid': issue.id
        })
        self.assertEqual(response.status_code, 200)
        self.assertEqual(response.content, 'NOT_WATCHING')
        self.assertTrue(
            not watch_services.is_watching_issue(self.user, issue.id))
def viewIssue(request, issue_id):
    try:
        issue = Issue.objects.get(pk=issue_id)
        if timezone.now() - issue.updatedDate > timedelta(hours=1):
            issue.update_redundant_fields()
    except:
        return HttpResponse(status=404, content='Issue not found')
    if issue.get_view_link() != request.path:
        return redirect(issue.get_view_link(), permanent=True)  # only allow one URL per issue
    myoffer = None
    mysolution = None
    show_alert = None

    if(request.user.is_authenticated()):
        myoffer = get_or_none(Offer, issue=issue, sponsor=request.user, status__in=[Offer.OPEN, Offer.REVOKED])
        mysolution = get_or_none(Solution, issue=issue,programmer=request.user)

    show_sponsor_popup = (request.GET.get('show_sponsor') == 'true')
    alert = request.GET.get('alert')
    if alert == 'KICKSTART':
        show_alert = 'core2/popup/popup_just_kickstarted.html'
    if alert == 'SPONSOR':
        show_alert = 'core2/popup/popup_just_sponsored.html'
    alert_reputation_revoking = mysolution and mysolution.status == Solution.IN_PROGRESS and mysolution.get_received_payments().count() > 0

    is_watching = request.user.is_authenticated() and watch_services.is_watching_issue(request.user, issue.id)
    crumbs = [HOME_CRUMB, {
        'link': issue.trackerURL,
        'name': 'issue: ' + issue.title,
        'blank': True,
    }]

    context = {
        'issue': issue,
        'is_watching': is_watching,
        'myoffer': myoffer,
        'mysolution': mysolution,
        'show_sponsor_popup': show_sponsor_popup,
        'show_alert': show_alert,
        'alert_reputation_revoking': alert_reputation_revoking,
        'crumbs': crumbs,
        'actionbar': _actionbar(issue, myoffer, mysolution, request.user)}

    return render(request, 'core2/issue.html', context)
def viewIssue(request, issue_id):
    issue = Issue.objects.get(pk=issue_id)
    myoffer = None
    mysolution = None
    show_alert = None

    if request.user.is_authenticated():
        myoffer = get_or_none(Offer, issue=issue, sponsor=request.user, status__in=[Offer.OPEN, Offer.REVOKED])
        mysolution = get_or_none(Solution, issue=issue, programmer=request.user)

    show_sponsor_popup = request.GET.get("show_sponsor") == "true"
    alert = request.GET.get("alert")
    if alert == "KICKSTART":
        show_alert = template_folder(request) + "popup/popup_just_kickstarted.html"
    if alert == "SPONSOR":
        show_alert = template_folder(request) + "popup/popup_just_sponsored.html"
    alert_reputation_revoking = (
        mysolution and mysolution.status == Solution.IN_PROGRESS and mysolution.get_received_payments().count() > 0
    )

    invoke_parent_callback = request.GET.get("c") == "s"

    is_watching = request.user.is_authenticated() and watch_services.is_watching_issue(request.user, issue.id)
    crumbs = [HOME_CRUMB, {"link": issue.trackerURL, "name": "issue: " + issue.title, "blank": True}]

    context = {
        "issue": issue,
        "is_watching": is_watching,
        "myoffer": myoffer,
        "mysolution": mysolution,
        "invoke_parent_callback": invoke_parent_callback,
        "show_sponsor_popup": show_sponsor_popup,
        "show_alert": show_alert,
        "alert_reputation_revoking": alert_reputation_revoking,
        "crumbs": crumbs,
        "actionbar": _actionbar(issue, myoffer, mysolution, request.user),
    }

    return render_to_response(
        template_folder(request) + "issue.html", context, context_instance=RequestContext(request)
    )
def viewIssue(request, issue_id):
    issue = Issue.objects.get(pk=issue_id)
    myoffer = None
    mysolution = None
    show_alert = None

    if(request.user.is_authenticated()):
        myoffer = get_or_none(Offer, issue=issue, sponsor=request.user, status__in=[Offer.OPEN, Offer.REVOKED])
        mysolution = get_or_none(Solution, issue=issue,programmer=request.user)

    show_sponsor_popup = (request.GET.get('show_sponsor') == 'true')
    alert = request.GET.get('alert')
    if alert == 'KICKSTART':
        show_alert = template_folder(request) + 'popup/popup_just_kickstarted.html'
    if alert == 'SPONSOR':
        show_alert = template_folder(request) + 'popup/popup_just_sponsored.html'
    alert_reputation_revoking = mysolution and mysolution.status == Solution.IN_PROGRESS and mysolution.get_received_payments().count() > 0

    invoke_parent_callback = (request.GET.get('c') == 's')

    is_watching = request.user.is_authenticated() and watch_services.is_watching_issue(request.user, issue.id)
    crumbs = [HOME_CRUMB, {
        'link': issue.trackerURL,
        'name': 'issue: ' + issue.title,
        'blank': True,
    }]

    context = {
        'issue': issue,
        'is_watching': is_watching,
        'myoffer': myoffer,
        'mysolution': mysolution,
        'invoke_parent_callback': invoke_parent_callback,
        'show_sponsor_popup': show_sponsor_popup,
        'show_alert': show_alert,
        'alert_reputation_revoking': alert_reputation_revoking,
        'crumbs': crumbs,
        'actionbar': _actionbar(issue, myoffer, mysolution, request.user)}

    return render_to_response(template_folder(request) + 'issue.html', context, context_instance=RequestContext(request))
Ejemplo n.º 16
0
def viewIssue(request, issue_id):
    issue = Issue.objects.get(pk=issue_id)
    myoffer = None
    mysolution = None
    show_alert = None

    if (request.user.is_authenticated()):
        myoffer = get_or_none(Offer,
                              issue=issue,
                              sponsor=request.user,
                              status__in=[Offer.OPEN, Offer.REVOKED])
        mysolution = get_or_none(Solution,
                                 issue=issue,
                                 programmer=request.user)

    show_sponsor_popup = (request.GET.get('show_sponsor') == 'true')
    alert = request.GET.get('alert')
    if (alert == 'KICKSTART'):
        show_alert = 'core/popup/popup_just_kickstarted.html'
    alert_reputation_revoking = mysolution and mysolution.status == Solution.IN_PROGRESS and mysolution.get_received_payments(
    ).count() > 0

    invoke_parent_callback = (request.GET.get('c') == 's')

    is_watching = request.user.is_authenticated(
    ) and watch_services.is_watching_issue(request.user, issue.id)

    return render_to_response(
        'core/issue.html', {
            'issue': issue,
            'is_watching': is_watching,
            'myoffer': myoffer,
            'mysolution': mysolution,
            'invoke_parent_callback': invoke_parent_callback,
            'show_sponsor_popup': show_sponsor_popup,
            'show_alert': show_alert,
            'alert_reputation_revoking': alert_reputation_revoking
        },
        context_instance=RequestContext(request))
def viewIssue(request, issue_id):
    issue = Issue.objects.get(pk=issue_id)
    myoffer = None
    mysolution = None
    show_alert = None

    if request.user.is_authenticated():
        myoffer = get_or_none(Offer, issue=issue, sponsor=request.user)
        mysolution = get_or_none(Solution, issue=issue, programmer=request.user)

    show_sponsor_popup = dictOrEmpty(request.GET, "show_sponsor") == "true"
    alert = dictOrEmpty(request.GET, "alert")
    if alert == "KICKSTART":
        show_alert = "core/popup_just_kickstarted.html"
    alert_reputation_revoking = (
        mysolution and mysolution.status == Solution.IN_PROGRESS and mysolution.get_received_payments().count() > 0
    )

    invoke_parent_callback = dictOrEmpty(request.GET, "c") == "s"

    is_watching = request.user.is_authenticated() and watch_services.is_watching_issue(request.user, issue.id)

    return render_to_response(
        "core/issue.html",
        {
            "issue": issue,
            "is_watching": is_watching,
            "myoffer": myoffer,
            "mysolution": mysolution,
            "invoke_parent_callback": invoke_parent_callback,
            "show_sponsor_popup": show_sponsor_popup,
            "show_alert": show_alert,
            "alert_reputation_revoking": alert_reputation_revoking,
        },
        context_instance=RequestContext(request),
    )