Esempio n. 1
0
    def bounty_fulfilled(self, bounty, fulfillment, **kwargs):
        string_data_fulfiller = notification_templates[
            'FulfillmentSubmitted'].format(bounty_title=bounty.title)
        string_data_issuer = notification_templates[
            'FulfillmentSubmittedIssuer'].format(bounty_title=bounty.title)

        # to fulfiller
        create_bounty_notification(
            bounty=bounty,
            uid=str(kwargs.get('uid')) +
            str(notifications['FulfillmentSubmitted']),
            notification_name=notifications['FulfillmentSubmitted'],
            user=fulfillment.user,
            issuer=bounty.user,
            from_user=bounty.user,
            string_data=string_data_fulfiller,
            notification_created=fulfillment.created,
            subject='New Submission')

        # to bounty issuer
        create_bounty_notification(
            bounty=bounty,
            uid=str(kwargs.get('uid')) +
            str(notifications['FulfillmentSubmittedIssuer']),
            notification_name=notifications['FulfillmentSubmittedIssuer'],
            user=bounty.user,
            from_user=fulfillment.user,
            issuer=bounty.user,
            string_data=string_data_issuer,
            subject='You Received a New Submission',
            fulfillment_description=fulfillment.description,
            notification_created=fulfillment.created,
            is_activity=False)
Esempio n. 2
0
 def fulfillment_updated(self, bounty, **kwargs):
     fulfillment_id = kwargs.get('fulfillment_id')
     fulfillment = Fulfillment.objects.get(bounty=bounty.pk,
                                           fulfillment_id=fulfillment_id)
     string_data_issuer = notification_templates[
         'FulfillmentUpdatedIssuer'].format(bounty_title=bounty.title)
     string_data_fulfiller = notification_templates[
         'FulfillmentUpdated'].format(bounty_title=bounty.title)
     create_bounty_notification(
         bounty=bounty,
         uid=str(kwargs.get('uid')) +
         str(notifications['FulfillmentUpdatedIssuer']),
         notification_name=notifications['FulfillmentUpdatedIssuer'],
         user=bounty.user,
         issuer=bounty.user,
         from_user=fulfillment.user,
         string_data=string_data_issuer,
         subject='Submission was Updated',
         notification_created=kwargs.get('event_date'),
         fulfillment_description=fulfillment.description,
         is_activity=False)
     create_bounty_notification(
         bounty=bounty,
         uid=str(kwargs.get('uid')) +
         str(notifications['FulfillmentUpdated']),
         notification_name=notifications['FulfillmentUpdated'],
         user=fulfillment.user,
         issuer=bounty.user,
         from_user=bounty.user,
         string_data=string_data_fulfiller,
         notification_created=kwargs.get('event_date'),
         fulfillment_description=fulfillment.description,
         subject='Submission Updated')
Esempio n. 3
0
 def fulfillment_updated(self, bounty_id, fulfillment_id, event_date, uid,
                         **kwargs):
     bounty = Bounty.objects.get(id=bounty_id)
     fulfillment = Fulfillment.objects.get(bounty_id=bounty,
                                           fulfillment_id=fulfillment_id)
     string_data_issuer = notification_templates[
         'FulfillmentUpdatedIssuer'].format(bounty_title=bounty.title)
     string_data_fulfiller = notification_templates[
         'FulfillmentUpdated'].format(bounty_title=bounty.title)
     create_bounty_notification(
         bounty=bounty,
         uid=str(uid) + str(notifications['FulfillmentUpdatedIssuer']),
         notification_name=notifications['FulfillmentUpdatedIssuer'],
         user=bounty.user,
         from_user=fulfillment.user,
         string_data=string_data_issuer,
         subject='Submission was Updated',
         notification_created=event_date,
         is_activity=False)
     create_bounty_notification(
         bounty=bounty,
         uid=str(uid) + str(notifications['FulfillmentUpdated']),
         notification_name=notifications['FulfillmentUpdated'],
         user=fulfillment.user,
         from_user=bounty.user,
         string_data=string_data_fulfiller,
         notification_created=event_date,
         subject='Submission Updated')
Esempio n. 4
0
 def issuer_transferred(self, bounty_id, transaction_from, inputs,
                        event_date, uid, **kwargs):
     bounty = Bounty.objects.get(id=bounty_id)
     original_user = User.objects.get(
         public_address=transaction_from.lower())
     string_data_transferrer = notification_templates[
         'IssuerTransferred'].format(bounty_title=bounty.title)
     string_data_recipient = notification_templates[
         'TransferredRecipient'].format(bounty_title=bounty.title)
     create_bounty_notification(
         bounty=bounty,
         uid=str(uid) + str(notifications['IssuerTransferred']),
         notification_name=notifications['IssuerTransferred'],
         user=original_user,
         issuer=bounty.user,
         from_user=bounty.user,
         string_data=string_data_transferrer,
         notification_created=event_date,
         subject='Bounty Transferred')
     create_bounty_notification(
         bounty=bounty,
         uid=str(uid) + str(notifications['TransferRecipient']),
         notification_name=notifications['TransferRecipient'],
         user=bounty.user,
         issuer=bounty.user,
         from_user=original_user,
         string_data=string_data_recipient,
         subject='A Bounty was Transferred to You',
         notification_created=event_date,
         is_activity=False)
Esempio n. 5
0
    def comment_received(self, bounty_id, event_date, uid, **kwargs):
        bounty = Bounty.objects.get(pk=bounty_id)
        comment = Comment.objects.get(id=uid)
        string_data = notification_templates['BountyCommentReceived'].format(
            bounty_title=bounty.title)

        commenters = list(map(lambda c: c.user, bounty.comments.all()))
        fulfillers = list(map(lambda f: f.user, bounty.fulfillments.all()))

        users = list(
            filter(lambda u: u != bounty.user and u != comment.user,
                   commenters + fulfillers))

        if bounty.user != comment.user:
            users.append(bounty.user)

        for user in set(users):
            create_bounty_notification(
                bounty=bounty,
                uid='{}-{}'.format(uid, user.id),
                notification_name=notifications['BountyCommentReceived'],
                user=user,
                from_user=comment.user,
                string_data=string_data,
                subject='You Received a Comment',
                notification_created=event_date,
                comment=comment,
                is_activity=False)
Esempio n. 6
0
 def bounty_issued(self, bounty, uid, event_date, **kwargs):
     string_data = notification_templates['BountyIssued'].format(
         bounty_title=bounty.title)
     create_bounty_notification(
         bounty=bounty,
         uid=uid,
         notification_name=notifications['BountyIssued'],
         user=bounty.user,
         from_user=None,
         string_data=string_data,
         notification_created=event_date,
         subject='New bounty issued')
Esempio n. 7
0
    def bounty_changed(self, bounty, **kwargs):
        string_data = notification_templates['BountyChanged'].format(
            bounty_title=bounty.title)

        create_bounty_notification(
            bounty=bounty,
            uid=kwargs.get('uid'),
            notification_name=notifications['BountyChanged'],
            user=bounty.user,
            from_user=None,
            string_data=string_data,
            notification_created=kwargs.get('event_date'),
            subject='Bounty Updated')
Esempio n. 8
0
 def bounty_completed(self, bounty, fulfillment_id):
     string_data = notification_templates['BountyCompleted'].format(
         bounty_title=bounty.title)
     create_bounty_notification(
         bounty=bounty,
         uid='{}-{}-completed'.format(bounty.id, fulfillment_id),
         notification_name=notifications['BountyCompleted'],
         user=bounty.user,
         from_user=None,
         notification_created=datetime.utcnow(),
         string_data=string_data,
         subject='Your Bounty Completed',
         is_activity=False)
Esempio n. 9
0
 def bounty_activated(self, bounty_id, event_date, uid, **kwargs):
     bounty = Bounty.objects.get(id=bounty_id)
     string_data = notification_templates['BountyActivated'].format(
         bounty_title=bounty.title)
     create_bounty_notification(
         bounty=bounty,
         uid=uid,
         notification_name=notifications['BountyActivated'],
         user=bounty.user,
         from_user=None,
         string_data=string_data,
         notification_created=event_date,
         subject='Bounty Activated')
Esempio n. 10
0
    def application_created(self, bounty, application):
        string_data = notification_templates['ApplicationCreated'].format(
            bounty_title=bounty.title)

        create_bounty_notification(
            bounty=bounty,
            uid='{}-{}-application-created'.format(bounty.id, application.id),
            notification_name=notifications['ApplicationCreated'],
            user=application.applicant,
            from_user=None,
            notification_created=datetime.utcnow(),
            string_data=string_data,
            subject='You Submitted an Application',
            is_activity=True)
Esempio n. 11
0
 def payout_increased(self, bounty_id, event_date, uid, **kwargs):
     bounty = Bounty.objects.get(id=bounty_id)
     string_data = notification_templates['PayoutIncreased'].format(
         bounty_title=bounty.title)
     create_bounty_notification(
         bounty=bounty,
         uid=uid,
         notification_name=notifications['PayoutIncreased'],
         user=bounty.user,
         issuer=bounty.user,
         from_user=bounty.user,
         string_data=string_data,
         notification_created=event_date,
         subject='Payout Increased')
Esempio n. 12
0
    def application_received(self, bounty, application):
        string_data = notification_templates['ApplicationReceived'].format(
            bounty_title=bounty.title)

        create_bounty_notification(
            bounty=bounty,
            uid='{}-{}-application-received'.format(bounty.id, application.id),
            notification_name=notifications['ApplicationReceived'],
            user=bounty.user,
            from_user=application.applicant,
            notification_created=datetime.utcnow(),
            string_data=string_data,
            subject='You Received a New Application',
            application_message=application.message,
            is_activity=False)
Esempio n. 13
0
 def comment_issued(self, bounty_id, event_date, uid, **kwargs):
     bounty = Bounty.objects.get(id=bounty_id)
     comment = Comment.objects.get(id=uid)
     string_data = notification_templates['BountyComment'].format(
         bounty_title=bounty.title)
     create_bounty_notification(
         bounty=bounty,
         uid='BountyComment' + str(uid),
         notification_name=notifications['BountyComment'],
         user=comment.user,
         from_user=None,
         string_data=string_data,
         subject='You Commented on a Bounty',
         notification_created=event_date,
         is_activity=True)
Esempio n. 14
0
    def deadline_changed(self, bounty, **kwargs):
        string_data = notification_templates['DeadlineExtended'].format(
            bounty_title=bounty.title)

        create_bounty_notification(
            bounty=bounty,
            uid=kwargs.get('uid'),
            notification_name=notifications['DeadlineExtended'],
            user=bounty.user,
            issuer=bounty.user,
            from_user=bounty.user,
            string_data=string_data,
            notification_created=kwargs.get('event_date'),
            subject='Deadline Extended',
        )
 def rating_issued(self, bounty_id, review, uid, reviewer, reviewee,
                   **kwargs):
     bounty = Bounty.objects.get(id=bounty_id)
     string_data = notification_templates['RatingIssued'].format(
         bounty_title=bounty.title)
     create_bounty_notification(
         bounty=bounty,
         uid='{}-{}'.format(uid, reviewer.id),
         notification_name=notifications['RatingIssued'],
         user=reviewer,
         from_user=reviewee,
         string_data=string_data,
         notification_created=review.created,
         subject='You Wrote a Review',
         review=review)
Esempio n. 16
0
    def application_accepted_applicant(self, bounty, application):
        string_data = notification_templates[
            'ApplicationAcceptedApplicant'].format(bounty_title=bounty.title)

        create_bounty_notification(
            bounty=bounty,
            uid='{}-{}-application-accepted-applicant'.format(
                bounty.id, application.id),
            notification_name=notifications['ApplicationAcceptedApplicant'],
            user=application.applicant,
            from_user=bounty.user,
            notification_created=datetime.utcnow(),
            string_data=string_data,
            subject='Your Application Was Accepted',
            application_message=application.message,
            is_activity=False)
 def rating_received(self, bounty_id, review, uid, reviewer, reviewee,
                     **kwargs):
     bounty = Bounty.objects.get(id=bounty_id)
     string_data = notification_templates['RatingReceived'].format(
         bounty_title=bounty.title)
     create_bounty_notification(
         bounty=bounty,
         uid='{}-{}'.format(uid, reviewee.id),
         notification_name=notifications['RatingReceived'],
         user=reviewee,
         from_user=reviewer,
         string_data=string_data,
         notification_created=review.created,
         review=review,
         subject='You Received a Review',
         is_activity=False)
Esempio n. 18
0
    def application_rejected_issuer(self, bounty, application):
        string_data = notification_templates[
            'ApplicationRejectedIssuer'].format(bounty_title=bounty.title)

        create_bounty_notification(
            bounty=bounty,
            uid='{}-{}-application-rejected-issuer'.format(
                bounty.id, application.id),
            notification_name=notifications['ApplicationRejectedIssuer'],
            user=bounty.user,
            from_user=None,
            notification_created=datetime.utcnow(),
            string_data=string_data,
            subject='You Rejected an Application',
            application_message=application.message,
            is_activity=True)
Esempio n. 19
0
    def fulfillment_comment_issued(self, bounty_id, fulfillment_id, event_date,
                                   uid, **kwargs):
        bounty = Bounty.objects.get(pk=bounty_id)
        comment = Comment.objects.get(id=uid)

        string_data = notification_templates[
            'FulfillmentCommentIssued'].format(bounty_title=bounty.title)

        create_bounty_notification(
            bounty=bounty,
            uid='FulfillmentComment' + str(uid),
            notification_name=notifications['FulfillmentCommentIssued'],
            user=comment.user,
            issuer=bounty.user,
            from_user=comment.user,
            string_data=string_data,
            subject='You Commented on a Submission',
            notification_created=event_date,
            is_activity=True)
Esempio n. 20
0
    def fulfillment_accepted(self, bounty, fulfillment, **kwargs):
        string_data_issuer = notification_templates[
            'FulfillmentAccepted'].format(bounty_title=bounty.title)
        string_data_fulfiller = notification_templates[
            'FulfillmentAcceptedFulfiller'].format(bounty_title=bounty.title)
        string_data_issuer_email = email_templates[
            'FulfillmentAccepted'].format(bounty_title=bounty.title)
        string_data_fulfiller_email = email_templates[
            'FulfillmentAcceptedFulfiller'].format(bounty_title=bounty.title)

        create_bounty_notification(
            bounty=bounty,
            uid=str(kwargs.get('uid')) +
            str(notifications['FulfillmentAccepted']),
            notification_name=notifications['FulfillmentAccepted'],
            user=bounty.user,
            issuer=bounty.user,
            from_user=fulfillment.user,
            string_data=string_data_issuer,
            subject='Submission Accepted',
            fulfillment_id=fulfillment.fulfillment_id,
            string_data_email=string_data_issuer_email,
            notification_created=kwargs.get('event_date'),
            email_button_string='Rate Fulfiller')

        create_bounty_notification(
            bounty=bounty,
            uid=str(kwargs.get('uid')) +
            str(notifications['FulfillmentAcceptedFulfiller']),
            notification_name=notifications['FulfillmentAcceptedFulfiller'],
            user=fulfillment.user,
            issuer=bounty.user,
            from_user=bounty.user,
            string_data=string_data_fulfiller,
            subject='Your Submission was Accepted',
            fulfillment_description=fulfillment.description,
            fulfillment_id=fulfillment.fulfillment_id,
            is_activity=False,
            string_data_email=string_data_fulfiller_email,
            notification_created=kwargs.get('event_date'),
            email_button_string='Rate Issuer')
Esempio n. 21
0
    def comment_received(self, bounty_id, event_date, uid, **kwargs):
        bounty = Bounty.objects.get(pk=bounty_id)
        comment = Comment.objects.get(id=uid)
        fulfiller_string_data = notification_templates[
            'BountyCommentReceived'].format(bounty_title=bounty.title)
        commenter_string_data = notification_templates[
            'BountyCommentReceivedCommenter'].format(bounty_title=bounty.title)
        issuer_string_data = notification_templates[
            'BountyCommentReceivedIssuer'].format(bounty_title=bounty.title)

        commenters = list(map(lambda c: c.user, bounty.comments.all()))
        fulfillers = list(map(lambda f: f.user, bounty.fulfillments.all()))

        fulfillers_final = list(
            filter(lambda u: u != bounty.user and u != comment.user,
                   fulfillers))

        commenters_final = list(
            filter(lambda u: u != bounty.user and u != comment.user,
                   commenters))

        for user in set(fulfillers_final):
            create_bounty_notification(
                bounty=bounty,
                uid='{}-{}'.format(uid, user.id),
                notification_name=notifications['BountyCommentReceived'],
                user=user,
                issuer=bounty.user,
                from_user=comment.user,
                string_data=fulfiller_string_data,
                subject='Someone Commented on a Bounty',
                notification_created=event_date,
                comment=comment,
                is_activity=False)
        for user in set(commenters_final):
            create_bounty_notification(bounty=bounty,
                                       uid='{}-{}'.format(uid, user.id),
                                       notification_name=notifications[
                                           'BountyCommentReceivedCommenter'],
                                       user=user,
                                       issuer=bounty.user,
                                       from_user=comment.user,
                                       string_data=commenter_string_data,
                                       subject='Someone Commented on a Bounty',
                                       notification_created=event_date,
                                       comment=comment,
                                       is_activity=False)
        if comment.user != bounty.user:
            create_bounty_notification(
                bounty=bounty,
                uid='{}-{}'.format(uid, bounty.user.id),
                notification_name=notifications['BountyCommentReceivedIssuer'],
                user=bounty.user,
                issuer=bounty.user,
                from_user=comment.user,
                string_data=issuer_string_data,
                subject='Someone Commented on Your Bounty',
                notification_created=event_date,
                comment=comment,
                is_activity=False)
Esempio n. 22
0
    def contribution_added(self, contribution, **kwargs):
        bounty = contribution.bounty
        from_user = contribution.contributor
        uid = kwargs.get('uid')

        amount = '{} {}'.format(contribution.bounty.token_symbol,
                                contribution.calculated_amount)

        added_string_data = notification_templates['ContributionAdded'].format(
            bounty_title=bounty.title, amount=amount)

        received_string_data = notification_templates[
            'ContributionReceived'].format(bounty_title=bounty.title,
                                           amount=amount)

        if bounty.user == from_user:
            # activity to bounty issuer
            create_bounty_notification(
                bounty=bounty,
                uid='{}-{}-activity'.format(uid, bounty.user.public_address),
                notification_name=notifications['ContributionAdded'],
                user=bounty.user,
                from_user=bounty.user,
                issuer=bounty.user,
                string_data=added_string_data,
                notification_created=contribution.created,
                subject='Contribution Added',
                is_activity=True,
                amount=kwargs.get('amount'))
        else:
            # notification to bounty issuer
            create_bounty_notification(
                bounty=bounty,
                uid='{}-{}-notification'.format(uid,
                                                bounty.user.public_address),
                notification_name=notifications['ContributionReceived'],
                user=bounty.user,
                issuer=bounty.user,
                from_user=from_user,
                string_data=received_string_data,
                notification_created=contribution.created,
                subject='Contribution Received',
                is_activity=False,
                amount=kwargs.get('amount'))

            # activity to user contributing to the bounty
            create_bounty_notification(
                bounty=bounty,
                uid='{}-{}-activity'.format(uid, from_user.public_address),
                notification_name=notifications['ContributionAdded'],
                user=from_user,
                issuer=bounty.user,
                from_user=from_user,
                string_data=added_string_data,
                notification_created=contribution.created,
                subject='Contribution Added',
                is_activity=True,
                amount=kwargs.get('amount'))
Esempio n. 23
0
    def bounty_changed(self, bounty, **kwargs):
        string_data_fulfiller = notification_templates['BountyChanged'].format(
            bounty_title=bounty.title)
        string_data_applicant = notification_templates[
            'BountyChangedApplicant'].format(bounty_title=bounty.title)
        string_data_issuer = notification_templates[
            'BountyChangedIssuer'].format(bounty_title=bounty.title)

        fulfillers = list(map(lambda f: f.user, bounty.fulfillments.all()))
        applicants = list(
            map(lambda a: a.applicant,
                FulfillerApplication.objects.filter(bounty_id=bounty.id)))

        users = [user for user in applicants if user not in fulfillers]

        for user in set(users):
            create_bounty_notification(
                bounty=bounty,
                uid='{}-{}-notification'.format(kwargs.get('uid'),
                                                user.public_address),
                notification_name=notifications['BountyChangedApplicant'],
                user=user,
                issuer=bounty.user,
                from_user=bounty.user,
                string_data=string_data_applicant,
                notification_created=kwargs.get('event_date'),
                subject='Bounty Updated',
                is_activity=False)
        for user in set(fulfillers):
            create_bounty_notification(
                bounty=bounty,
                uid='{}-{}-notification'.format(kwargs.get('uid'),
                                                user.public_address),
                notification_name=notifications['BountyChanged'],
                user=user,
                issuer=bounty.user,
                from_user=bounty.user,
                string_data=string_data_fulfiller,
                notification_created=kwargs.get('event_date'),
                subject='Bounty Updated',
                is_activity=False)
        create_bounty_notification(
            bounty=bounty,
            uid='{}-{}-notification'.format(kwargs.get('uid'),
                                            bounty.user.public_address),
            notification_name=notifications['BountyChangedIssuer'],
            user=bounty.user,
            issuer=bounty.user,
            from_user=bounty.user,
            string_data=string_data_issuer,
            notification_created=kwargs.get('event_date'),
            subject='Bounty Updated',
            is_activity=True)
Esempio n. 24
0
    def contribution_added(self, bounty_id, event_date, inputs,
                           transaction_from, uid, **kwargs):
        bounty = Bounty.objects.get(id=bounty_id)

        try:
            from_user = transaction_from and User.objects.get(
                public_address=transaction_from.lower())
        except User.DoesNotExist:
            logger.error('No user for address: {}'.format(
                transaction_from.lower()))
            return

        amount = '{} {}'.format(
            bounty.tokenSymbol,
            token_decimals(
                calculate_token_value(int(Decimal(inputs['value'])),
                                      bounty.tokenDecimals)))

        added_string_data = notification_templates['ContributionAdded'].format(
            bounty_title=bounty.title, amount=amount)
        received_string_data = notification_templates[
            'ContributionReceived'].format(bounty_title=bounty.title,
                                           amount=amount)

        if bounty.user == from_user:
            # activity to bounty issuer
            create_bounty_notification(
                bounty=bounty,
                uid='{}-{}-activity'.format(uid, bounty.user.public_address),
                notification_name=notifications['ContributionAdded'],
                user=bounty.user,
                from_user=None,
                string_data=added_string_data,
                notification_created=event_date,
                inputs=inputs,
                subject='Contribution Added',
                is_activity=True)
        else:
            # notification to bounty issuer
            create_bounty_notification(
                bounty=bounty,
                uid='{}-{}-notification'.format(uid,
                                                bounty.user.public_address),
                notification_name=notifications['ContributionReceived'],
                user=bounty.user,
                from_user=from_user,
                string_data=received_string_data,
                notification_created=event_date,
                inputs=inputs,
                subject='Contribution Received',
                is_activity=False)
            # activity to user contributing to the bounty
            create_bounty_notification(
                bounty=bounty,
                uid='{}-{}-activity'.format(uid, from_user.public_address),
                notification_name=notifications['ContributionAdded'],
                user=from_user,
                from_user=None,
                string_data=added_string_data,
                notification_created=event_date,
                inputs=inputs,
                subject='Contribution Added',
                is_activity=True)