def test_watch_toggle_offer(self):
        offer = test_data.create_dummy_offer()
        user = offer.issue.createdByUser

        self.assertTrue(not watch_services.is_watching_offer(user, offer.id))

        watch_services.watch_offer(user, offer.id, OfferWatch.WATCHED)
        self.assertTrue(watch_services.is_watching_offer(user, offer.id))

        watch_services.unwatch_offer(user, offer.id)
        self.assertTrue(not watch_services.is_watching_offer(user, offer.id))
    def test_watch_toggle_offer(self):
        offer = test_data.create_dummy_offer_usd()
        user = offer.issue.createdByUser

        self.assertTrue(not watch_services.is_watching_offer(user, offer.id))

        watch_services.watch_offer(user, offer.id, OfferWatch.WATCHED)
        self.assertTrue(watch_services.is_watching_offer(user, offer.id))

        watch_services.unwatch_offer(user, offer.id)
        self.assertTrue(not watch_services.is_watching_offer(user, offer.id))
    def test_watch_unwatch_offer(self):
        offer = test_data.create_dummy_offer_usd()
        self.assertTrue(not watch_services.is_watching_offer(self.user, offer.id))

        response = self.client.get(_reverse('watchOffer', offer_id=offer.id))
        self.assertEqual(response.status_code, 200)
        self.assertEqual(response.content, 'WATCHING')
        self.assertTrue(watch_services.is_watching_offer(self.user, offer.id))

        response = self.client.get(_reverse('unwatchOffer', offer_id=offer.id))
        self.assertEqual(response.status_code, 200)
        self.assertEqual(response.content, 'NOT_WATCHING')
        self.assertTrue(not watch_services.is_watching_offer(self.user, offer.id))
    def test_watch_unwatch_offer(self):
        offer = test_data.create_dummy_offer_usd()
        self.assertTrue(not watch_services.is_watching_offer(self.user, offer.id))

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

        response = self.client.get('/core/unwatch/offer/%s'%offer.id)
        self.assertEqual(response.status_code, 200)
        self.assertEqual(response.content, 'NOT_WATCHING')
        self.assertTrue(not watch_services.is_watching_offer(self.user, offer.id))
    def test_watch_unwatch_offer(self):
        offer = test_data.create_dummy_offer_usd()
        self.assertTrue(
            not watch_services.is_watching_offer(self.user, offer.id))

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

        response = self.client.get('/core/unwatch/offer/%s' % offer.id)
        self.assertEqual(response.status_code, 200)
        self.assertEqual(response.content, 'NOT_WATCHING')
        self.assertTrue(
            not watch_services.is_watching_offer(self.user, offer.id))
예제 #6
0
def viewOffer(request, offer_id):
    offer = Offer.objects.get(pk=offer_id)
    payment = None
    myoffer = None
    mysolution = None
    show_alert = None

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

    alert = request.GET.get('alert')
    if(alert == 'SPONSOR' and offer.issue.project):
        show_alert = 'core/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_offer(request.user, offer.id)

    return render_to_response(template_folder(request) + 'offer.html',
        {'offer':offer,
        'is_watching':is_watching,
        'issue':offer.issue,
        'show_alert':show_alert,
        'myoffer':myoffer,
        'mysolution':mysolution,
        'alert_reputation_revoking': alert_reputation_revoking,
        'invoke_parent_callback' : invoke_parent_callback},
        context_instance = RequestContext(request))
def viewOffer(request, offer_id):
    offer = Offer.objects.get(pk=offer_id)
    payment = None
    myoffer = None
    mysolution = None
    show_alert = None

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

    alert = dictOrEmpty(request.GET, 'alert')
    if(alert == 'SPONSOR' and offer.issue.project):
        show_alert = 'core/popup_just_sponsored.html'
    invoke_parent_callback = (dictOrEmpty(request.GET, 'c') == 's')

    is_watching = request.user.is_authenticated() and watch_services.is_watching_offer(request.user, offer.id)

    return render_to_response('core/offer.html',
        {'offer':offer,
        'is_watching':is_watching,
        'issue':offer.issue,
        'show_alert':show_alert,
        'myoffer':myoffer,
        'mysolution':mysolution,
        'invoke_parent_callback' : invoke_parent_callback},
        context_instance = RequestContext(request))
def viewOffer(request, offer_id):
    offer = Offer.objects.get(pk=offer_id)
    payment = None
    myoffer = None
    mysolution = None
    show_alert = None

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

    alert = request.GET.get("alert")
    if alert == "SPONSOR" and offer.issue.project:
        show_alert = "core/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_offer(request.user, offer.id)

    return render_to_response(
        template_folder(request) + "offer.html",
        {
            "offer": offer,
            "is_watching": is_watching,
            "issue": offer.issue,
            "show_alert": show_alert,
            "myoffer": myoffer,
            "mysolution": mysolution,
            "alert_reputation_revoking": alert_reputation_revoking,
            "invoke_parent_callback": invoke_parent_callback,
        },
        context_instance=RequestContext(request),
    )
def viewOffer(request, offer_id):
    offer = Offer.objects.get(pk=offer_id)
    payment = None
    myoffer = None
    mysolution = None
    show_alert = None

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

    alert = dictOrEmpty(request.GET, 'alert')
    if (alert == 'SPONSOR' and offer.issue.project):
        show_alert = 'core/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 = (dictOrEmpty(request.GET, 'c') == 's')

    is_watching = request.user.is_authenticated(
    ) and watch_services.is_watching_offer(request.user, offer.id)

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