Exemple #1
0
    def setUpClass(cls):
        cls.client = BountyClient()

        deadline = datetime(2019, 1, 1, 1, 1, 1)
        bounty_to_activate = Bounty(
            id=1,
            bounty_id=1,
            fulfillmentAmount=1,
            usd_price=1,
            deadline=deadline,
            paysTokens=True,
            bountyStage=DRAFT_STAGE)
        bounty_to_activate.save()
        cls.bounty_to_activate_id = bounty_to_activate.id

        bounty_to_extend_deadline = Bounty(
            id=2,
            bounty_id=2,
            fulfillmentAmount=1,
            usd_price=1,
            deadline=deadline,
            paysTokens=True,
            bountyStage=ACTIVE_STAGE)
        bounty_to_extend_deadline.save()
        cls.bounty_to_extend_deadline_id = bounty_to_extend_deadline.id
from std_bounties.bounty_client import BountyClient
from notifications.notification_client import NotificationClient
from std_bounties.slack_client import SlackMessageClient
from std_bounties.seo_client import SEOClient
from std_bounties.models import Bounty

bounty_client = BountyClient()
notification_client = NotificationClient()
slack_client = SlackMessageClient()
seo_client = SEOClient()


def bounty_issued(bounty_id, **kwargs):
    bounty = Bounty.objects.filter(bounty_id=bounty_id)
    inputs = kwargs.get('inputs', {})
    is_issue_and_activate = inputs.get('value', None)

    if bounty.exists():
        return

    created_bounty = bounty_client.issue_bounty(bounty_id, **kwargs)
    if not is_issue_and_activate:
        notification_client.bounty_issued(bounty_id, **kwargs)
        slack_client.bounty_issued(created_bounty)
        seo_client.bounty_preview_screenshot(bounty.platform, bounty_id)
        seo_client.publish_new_sitemap(created_bounty.platform)


def bounty_activated(bounty_id, **kwargs):
    bounty = Bounty.objects.get(bounty_id=bounty_id)
    bounty_client.activate_bounty(bounty, **kwargs)
 def setUpClass(cls):
     cls.client = BountyClient()