예제 #1
0
def bounty_fulfilled(bounty_id, **kwargs):
    fulfillment_id = kwargs.get('fulfillment_id')
    bounty = Bounty.objects.get(bounty_id=bounty_id)
    bounty_client.fulfill_bounty(bounty, **kwargs)
    notification_client.fulfillment_submitted(bounty_id, fulfillment_id)
    slack_client.bounty_fulfilled(bounty, fulfillment_id)

    if bounty.platform == 'colorado':
        email_url = bounty_url_for(bounty_id, platform='colorado')
    else:
        email_url = bounty_url_for(bounty_id)

    if bounty.platform != 'gitcoin':
        send_email(
            bounty.issuer_email, 'Bounty Contribution Received',
            'Hey there! You received a contribution for your bounty: {}. {}'.
            format(bounty.title, email_url))
예제 #2
0
def bounty_activated(bounty_id, **kwargs):
    bounty = Bounty.objects.get(bounty_id=bounty_id)
    msg = "{title} {bounty_id} {tokenSymbol} {usd_price} {link}"
    add_link = partial(merge, source2={'link': bounty_url_for(bounty_id)})

    apply_and_notify(bounty,
                     event='Bounty Activated',
                     action=bounty_client.activate_bounty,
                     inputs=kwargs,
                     fields=['title', 'bounty_id', 'tokenSymbol', 'usd_price'],
                     msg=msg,
                     slack_client=sc,
                     before_formatter=[add_link]
                     )
예제 #3
0
def issuer_transfered(bounty_id, **kwargs):
    bounty = Bounty.objects.get(bounty_id=bounty_id)
    msg = "{title}, {bounty_id} {link}"
    add_link = partial(merge, source2={'link': bounty_url_for(bounty_id)})

    apply_and_notify(bounty,
                     event='Issuer Transferred',
                     action=bounty_client.transfer_issuer,
                     inputs=kwargs,
                     fields=['title', 'bounty_id'],
                     msg=msg,
                     slack_client=sc,
                     before_formatter=[add_link]
                     )
def get_base_bounty_values(bounty):
    base_fields = narrower(
        bounty, ['title', 'bounty_id', 'tokenSymbol', 'tokenDecimals'])
    base_fields['total_value'] = calculate_token_quantity(
        bounty.fulfillmentAmount, bounty.tokenDecimals)
    base_fields['usd_price'] = Decimal(bounty.usd_price).quantize(
        Decimal(10)**-2)
    base_fields['deadline'] = bounty.deadline.strftime('%m/%d/%Y')
    base_fields[
        'token_price'] = 'Unkown Price' if not bounty.token else Decimal(
            bounty.token.price_usd).quantize(Decimal(10)**-2)
    base_fields[
        'token_lock_price'] = 'Unkown Price' if not bounty.tokenLockPrice else Decimal(
            bounty.tokenLockPrice).quantize(Decimal(10)**-2)
    base_fields['link'] = bounty_url_for(bounty.bounty_id, bounty.platform)
    return base_fields
예제 #5
0
def payout_increased(bounty_id, **kwargs):
    bounty = Bounty.objects.get(bounty_id=bounty_id)
    msg = "{title}, {bounty_id} {link}"
    add_link = partial(merge, source2={'link': bounty_url_for(bounty_id)})

    apply_and_notify(bounty,
                     event='Payout Increased',
                     action=bounty_client.increase_payout,
                     inputs=kwargs,
                     fields=['title',
                             'bounty_id',
                             ],
                     msg=msg,
                     slack_client=sc,
                     before_formatter=[add_link]
                     )
예제 #6
0
def deadline_extended(bounty_id, **kwargs):
    bounty = Bounty.objects.get(bounty_id=bounty_id)
    previous_deadline = narrower(bounty, [('deadline', 'previous_deadline')])
    msg = "{title}, {bounty_id}, {previous_deadline}, {deadline} {link}"
    mix_previous_deadline = wrapped_partial(merge, source2=previous_deadline)
    add_link = partial(merge, source2={'link': bounty_url_for(bounty_id)})

    apply_and_notify(bounty,
                     event='Deadline Extended',
                     action=bounty_client.extend_deadline,
                     inputs=kwargs,
                     fields=['title', 'bounty_id', 'deadline'],
                     msg=msg,
                     slack_client=sc,
                     before_formatter=[mix_previous_deadline, add_link]
                     )
예제 #7
0
def fullfillment_updated(bounty_id, **kwargs):
    bounty = Bounty.objects.get(bounty_id=bounty_id)
    msg = "{title}, {bounty_id}, {fulfillment_id} {link}"
    add_link = partial(merge, source2={'link': bounty_url_for(bounty_id)})

    apply_and_notify(bounty,
                     event='Fulfillment Updated',
                     action=bounty_client.update_fulfillment,
                     inputs=kwargs,
                     fields=[('bounty__title', 'title'),
                             ('bounty__bounty_id', 'bounty_id'),
                             'fulfillment_id'
                             ],
                     msg=msg,
                     slack_client=sc,
                     before_formatter=[add_link]
                     )
예제 #8
0
def bounty_issued(bounty_id, **kwargs):
    msg = "{title}, {bounty_id}, {tokenSymbol} @ {tokenDecimals}, {fulfillmentAmount}, " \
          "{usd_price}, {deadline} {link}"
    bounty = Bounty.objects.filter(bounty_id=bounty_id)
    add_link = partial(merge, source2={'link': bounty_url_for(bounty_id)})

    if not bounty.exists():
        apply_and_notify(bounty_id,
                         event='Bounty Issued',
                         action=bounty_client.issue_bounty,
                         inputs=kwargs,
                         fields=['title', 'bounty_id', 'tokenSymbol', 'tokenDecimals',
                                 'fulfillmentAmount', 'usd_price', 'deadline'],
                         msg=msg,
                         slack_client=sc,
                         before_formatter=[add_link]
                         )
예제 #9
0
def bounty_fulfilled(bounty_id, **kwargs):
    bounty = Bounty.objects.get(bounty_id=bounty_id)
    msg = "{title}, {bounty_id}, {fulfillment_id},  {tokenSymbol} @ {tokenDecimals}," \
          " {fulfillmentAmount}, {usd_price}, {deadline} {link}"
    add_link = partial(merge, source2={'link': bounty_url_for(bounty_id)})

    apply_and_notify(bounty,
                     event='Bounty Fulfilled',
                     action=bounty_client.fulfill_bounty,
                     inputs=kwargs,
                     fields=[('bounty__title', 'title'),
                             ('bounty__bounty_id', 'bounty_id'),
                             'fulfillment_id',
                             ('bounty__tokenSymbol', 'tokenSymbol'),
                             ('bounty__tokenDecimals', 'tokenDecimals'),
                             ('bounty__fulfillmentAmount', 'fulfillmentAmount'),
                             ('bounty__usd_price', 'usd_price'),
                             ('bounty__deadline', 'deadline')],
                     msg=msg,
                     slack_client=sc,
                     before_formatter=[add_link]
                     )
예제 #10
0
def contribution_added(bounty_id, **kwargs):
    bounty = Bounty.objects.get(bounty_id=bounty_id)
    msg = "{title}, {bounty_id}, {tokenDecimals}, {balance}, {usd_price}, {tokenDecimals}," \
          "{old_balance} {link}"
    add_link = partial(merge, source2={'link': bounty_url_for(bounty_id)})

    apply_and_notify(bounty,
                     event='Contribution Added',
                     action=bounty_client.add_contribution,
                     inputs=kwargs,
                     fields=['title',
                             'bounty_id',
                             'tokenDecimals',
                             'balance',
                             'usd_price',
                             'tokenDecimals',
                             'old_balance'
                             ],
                     msg=msg,
                     slack_client=sc,
                     before_formatter=[add_link]
                     )
예제 #11
0
    def test_consensys_platform(self):
        expected = 'https://consensys.bounties.network/bounty/v1/1/'

        result = bounty_url_for(self.bounty_id, self.consensys_platform)
        self.assertEqual(result, expected)
예제 #12
0
    def test_default_platform(self):
        expected = 'http://127.0.0.1/bounty/v1/1/'

        result = bounty_url_for(self.bounty_id)
        self.assertEqual(result, expected)