Ejemplo n.º 1
0
    def publish(self):
        self.is_published = True
        self.save()

        challenge = self.get_challenge()

        # Create activity
        msg = '<a href="%s">%s</a>: %s | <a href="%s">Read more</a>' % (
            challenge.get_absolute_url(), challenge.title, self.title,
            self.get_absolute_url())
        status = Status(author=self.created_by,
                        project=challenge.project,
                        status=msg)
        status.save()

        # Send thanks email
        user = self.created_by
        share_url = reverse('submission_edit_share', kwargs={
            'slug': challenge.slug,
            'submission_id': self.pk
        })
        submission_url = reverse('submission_show', kwargs={
            'slug': challenge.slug,
            'submission_id': self.pk
        })
        subj = _('Thanks for entering in the Knight-Mozilla Innovation Challenge!')
        body = render_to_string('challenges/emails/submission_thanks.txt', {
            'share_url': share_url,
            'submission_url': submission_url,
        })

        SendUserEmail.apply_async((user, subj, body))
Ejemplo n.º 2
0
    def publish(self):
        self.is_published = True
        self.save()

        challenge = self.get_challenge()

        # Create activity
        msg = '<a href="%s">%s</a>: %s | <a href="%s">Read more</a>' % (
            challenge.get_absolute_url(), challenge.title, self.title,
            self.get_absolute_url())
        status = Status(author=self.created_by,
                        project=challenge.project,
                        status=msg)
        status.save()

        # Send thanks email
        user = self.created_by
        share_url = reverse('submission_edit_share',
                            kwargs={
                                'slug': challenge.slug,
                                'submission_id': self.pk
                            })
        submission_url = reverse('submission_show',
                                 kwargs={
                                     'slug': challenge.slug,
                                     'submission_id': self.pk
                                 })
        subj = _(
            'Thanks for entering in the Knight-Mozilla Innovation Challenge!')
        body = render_to_string('challenges/emails/submission_thanks.txt', {
            'share_url': share_url,
            'submission_url': submission_url,
        })

        SendUserEmail.apply_async((user, subj, body))
Ejemplo n.º 3
0
def submission_activity_handler(sender, **kwargs):
    submission = kwargs.get('instance', None)
    if not isinstance(submission, Submission):
        return
    challenge = submission.get_challenge()
    if not challenge:
        return

    msg = '<a href="%s">%s</a>: %s | <a href="%s">Read more</a>' % (
        challenge.get_absolute_url(), challenge.title, submission.title,
        submission.get_absolute_url())
    status = Status(author=submission.created_by,
                    project=challenge.project,
                    status=msg)
    status.save()
Ejemplo n.º 4
0
def submission_activity_handler(sender, **kwargs):
    submission = kwargs.get('instance', None)
    if not isinstance(submission, Submission):
        return
    challenge = submission.get_challenge()
    if not challenge:
        return

    msg = '<a href="%s">%s</a>: %s | <a href="%s">Read more</a>' % (
        challenge.get_absolute_url(), challenge.title, submission.title,
        submission.get_absolute_url())
    status = Status(author=submission.created_by,
                    project=challenge.project,
                    status=msg)
    status.save()
Ejemplo n.º 5
0
    def test_reply_to_status(self):
        """ Test a reply sent to a status update on a course page """
        status = Status(status="status update")
        status.author = self.user
        status.project = self.project
        status.save()

        callback_url = "/en/comments/create/activity/activity/{0}/project/projects/{1}/callback/".format(
            status.activity.get().id, self.project.id
        )

        data = {u"api-key": settings.INTERNAL_API_KEY, u"from": u"*****@*****.**", u"text": u"Maybe this time\n"}

        comment_count = PageComment.objects.filter(sent_by_email=True).count()
        response = self.client.post(callback_url, data)
        self.assertEqual(response.status_code, 200)
        comments = PageComment.objects.filter(sent_by_email=True)
        self.assertEqual(comment_count + 1, comments.count())
Ejemplo n.º 6
0
    def test_reply_to_status(self):
        """ Test a reply sent to a status update on a course page """
        status = Status(status="status update")
        status.author = self.user
        status.project = self.project
        status.save()

        callback_url = "/en/comments/create/activity/activity/{0}/project/projects/{1}/callback/".format(
            status.activity.get().id, self.project.id)

        data = {
            u'api-key': settings.INTERNAL_API_KEY,
            u'from': self.test_username,
            u'text': u'Maybe this time\n',
        }

        comment_count = PageComment.objects.filter(sent_by_email=True).count()
        response = self.client.post(callback_url, data)
        self.assertEqual(response.status_code, 200)
        comments = PageComment.objects.filter(sent_by_email=True)
        self.assertEqual(comment_count + 1, comments.count())