Пример #1
0
def create_activities(bounty):
    act = helpers.record_bounty_activity('new_bounty', None, bounty)
    set_created(act, bounty.web3_created)
    approval_required = bounty.permission_type == 'approval'
    for interest in bounty.interested.all():
        event_name = 'start_work' if not approval_required else 'worker_applied'
        act = record_bounty_activity(bounty, interest.profile.user, event_name,
                                     interest)
        set_created(act, interest.created)
        if approval_required and not interest.pending:
            act = record_bounty_activity(bounty, interest.profile.user,
                                         'worker_approved', interest)
            set_created(act, interest.acceptance_date)
    done_recorded = False
    for fulfillment in bounty.fulfillments.all():
        act = helpers.record_bounty_activity('work_submitted',
                                             bounty.prev_bounty, bounty,
                                             fulfillment)
        set_created(act, fulfillment.created_on)
        if fulfillment.accepted:
            act = helpers.record_bounty_activity('work_done',
                                                 bounty.prev_bounty, bounty,
                                                 fulfillment)
            set_created(act, fulfillment.accepted_on)
            done_recorded = True
    if bounty.status == 'done' and not done_recorded:
        act = helpers.record_bounty_activity('work_done', bounty.prev_bounty,
                                             bounty)
        set_created(act, bounty.fulfillment_accepted_on)
    if bounty.status == 'cancelled':
        act = helpers.record_bounty_activity('killed_bounty',
                                             bounty.prev_bounty, bounty)
        set_created(act, bounty.canceled_on)
Пример #2
0
    def handle(self, *args, **options):

        bounties = Bounty.objects.current().filter(
            web3_created__lt=timezone.datetime(2019, 3, 5)).filter(
                network='mainnet')
        for bounty in bounties:
            try:
                record_bounty_activity('new_bounty',
                                       None,
                                       bounty,
                                       _fulfillment=None,
                                       override_created=bounty.web3_created)
                #print(bounty.url)
                for ful in bounty.fulfillments.all():
                    record_bounty_activity('work_submitted',
                                           None,
                                           bounty,
                                           _fulfillment=ful,
                                           override_created=ful.created_on)
            except Exception as e:
                print(e)

        for tip in Tip.objects.filter(network='mainnet').filter(
                created_on__lt=timezone.datetime(2019, 3, 5)):
            try:
                record_tip_activity(tip,
                                    tip.username,
                                    'new_tip',
                                    override_created=tip.created_on)
                #print(tip.pk)
            except Exception as e:
                print(e)

        for instance in Profile.objects.filter(hide_profile=False):
            instance.calculate_all()
            instance.save()