def link(self, category):
     """Link for the feed as a whole"""
     if self.category:
         base = url('browse.search-tools.rss', self.category.slug)
     else:
         base = url('browse.search-tools.rss')
     return absolutify(base + '?sort=' + self.sort)
Esempio n. 2
0
 def send_notification_email(self):
     if self.reply_to:
         # It's a reply.
         reply_url = jinja_helpers.url(
             'addons.ratings.detail', self.addon.slug,
             self.reply_to.pk, add_prefix=False)
         data = {
             'name': self.addon.name,
             'reply_title': self.title,
             'reply': self.body,
             'reply_url': jinja_helpers.absolutify(reply_url)
         }
         recipients = [self.reply_to.user.email]
         subject = u'Mozilla Add-on Developer Reply: %s' % self.addon.name
         template = 'ratings/emails/reply_review.ltxt'
         perm_setting = 'reply'
     else:
         # It's a new rating.
         reply_url = jinja_helpers.url(
             'addons.ratings.reply', self.addon.slug, self.pk,
             add_prefix=False)
         data = {
             'name': self.addon.name,
             'rating': self,
             'reply_url': jinja_helpers.absolutify(reply_url)
         }
         recipients = [author.email for author in self.addon.authors.all()]
         subject = u'Mozilla Add-on User Review: %s' % self.addon.name
         template = 'ratings/emails/add_review.ltxt'
         perm_setting = 'new_review'
     send_mail_jinja(
         subject, template, data,
         recipient_list=recipients, perm_setting=perm_setting)
Esempio n. 3
0
 def link(self, category):
     """Link for the feed as a whole"""
     if self.category:
         base = url('browse.search-tools.rss', self.category.slug)
     else:
         base = url('browse.search-tools.rss')
     return absolutify(base + '?sort=' + self.sort)
Esempio n. 4
0
 def send_notification_email(self):
     if self.reply_to:
         # It's a reply.
         reply_url = jinja_helpers.url(
             'addons.ratings.detail', self.addon.slug,
             self.reply_to.pk, add_prefix=False)
         data = {
             'name': self.addon.name,
             'reply': self.body,
             'rating_url': jinja_helpers.absolutify(reply_url)
         }
         recipients = [self.reply_to.user.email]
         subject = u'Mozilla Add-on Developer Reply: %s' % self.addon.name
         template = 'ratings/emails/reply_review.ltxt'
         perm_setting = 'reply'
     else:
         # It's a new rating.
         rating_url = jinja_helpers.url(
             'addons.ratings.detail', self.addon.slug, self.pk,
             add_prefix=False)
         data = {
             'name': self.addon.name,
             'rating': self,
             'rating_url': jinja_helpers.absolutify(rating_url)
         }
         recipients = [author.email for author in self.addon.authors.all()]
         subject = u'Mozilla Add-on User Rating: %s' % self.addon.name
         template = 'ratings/emails/new_rating.txt'
         perm_setting = 'new_review'
     send_mail_jinja(
         subject, template, data,
         recipient_list=recipients, perm_setting=perm_setting)
Esempio n. 5
0
    def test_creation_triggers_email_and_logging(self):
        addon = Addon.objects.get(pk=4)
        addon_author = addon.authors.first()
        review_user = user_factory()
        rating = Rating.objects.create(
            user=review_user,
            addon=addon,
            body='RĂŞviiiiiiew',
            user_responsible=review_user,
        )

        activity_log = ActivityLog.objects.latest('pk')
        assert activity_log.user == review_user
        assert activity_log.arguments == [addon, rating]
        assert activity_log.action == amo.LOG.ADD_RATING.id

        assert len(mail.outbox) == 1
        email = mail.outbox[0]
        rating_url = jinja_helpers.absolutify(
            jinja_helpers.url('addons.ratings.detail',
                              addon.slug,
                              rating.pk,
                              add_prefix=False))
        assert email.subject == 'Mozilla Add-on User Rating: my addon name'
        assert 'A user has rated your add-on,' in email.body
        assert 'my addon name' in email.body
        assert rating_url in email.body
        assert email.to == [addon_author.email]
        assert email.from_email == 'Mozilla Add-ons <*****@*****.**>'
Esempio n. 6
0
    def test_creation_triggers_email_and_logging(self):
        addon = Addon.objects.get(pk=4)
        addon_author = addon.authors.first()
        review_user = user_factory()
        rating = Rating.objects.create(
            user=review_user, addon=addon,
            body=u'RĂŞviiiiiiew', user_responsible=review_user)

        activity_log = ActivityLog.objects.latest('pk')
        assert activity_log.user == review_user
        assert activity_log.arguments == [addon, rating]
        assert activity_log.action == amo.LOG.ADD_RATING.id

        assert len(mail.outbox) == 1
        email = mail.outbox[0]
        rating_url = jinja_helpers.absolutify(
            jinja_helpers.url(
                'addons.ratings.detail', addon.slug, rating.pk,
                add_prefix=False))
        assert email.subject == 'Mozilla Add-on User Rating: my addon name'
        assert 'A user has rated your add-on,' in email.body
        assert 'my addon name' in email.body
        assert rating_url in email.body
        assert email.to == [addon_author.email]
        assert email.from_email == 'Mozilla Add-ons <*****@*****.**>'
Esempio n. 7
0
    def test_reply_triggers_email_but_no_logging(self):
        rating = Rating.objects.get(id=1)
        user = user_factory()
        Rating.objects.create(
            reply_to=rating,
            user=user,
            addon=rating.addon,
            body='RĂŞply',
            user_responsible=user,
        )

        assert not ActivityLog.objects.exists()
        assert len(mail.outbox) == 1
        email = mail.outbox[0]
        reply_url = jinja_helpers.absolutify(
            jinja_helpers.url('addons.ratings.detail',
                              rating.addon.slug,
                              rating.pk,
                              add_prefix=False))
        assert email.subject == 'Mozilla Add-on Developer Reply: my addon name'
        assert 'A developer has replied to your review' in email.body
        assert 'add-on my addon name' in email.body
        assert reply_url in email.body
        assert email.to == ['*****@*****.**']
        assert email.from_email == 'Mozilla Add-ons <*****@*****.**>'
Esempio n. 8
0
def add(request, addon):
    if addon.has_author(request.user):
        raise PermissionDenied
    form = forms.RatingForm(request.POST or None)
    if (request.method == 'POST' and form.is_valid() and
            not request.POST.get('detailed')):
        details = _review_details(request, addon, form)
        rating = Rating.objects.create(**details)
        if 'flag' in form.cleaned_data and form.cleaned_data['flag']:
            rf = RatingFlag(rating=rating,
                            user_id=request.user.id,
                            flag=RatingFlag.OTHER,
                            note='URLs')
            rf.save()
        return redirect(jinja_helpers.url('addons.ratings.list', addon.slug))
    return render(request, 'ratings/add.html', {'addon': addon, 'form': form})
Esempio n. 9
0
def add(request, addon):
    if addon.has_author(request.user):
        raise PermissionDenied
    form = forms.RatingForm(request.POST or None)
    if (request.method == 'POST' and form.is_valid() and
            not request.POST.get('detailed')):
        details = _review_details(request, addon, form)
        rating = Rating.objects.create(**details)
        if 'flag' in form.cleaned_data and form.cleaned_data['flag']:
            rf = RatingFlag(rating=rating,
                            user_id=request.user.id,
                            flag=RatingFlag.OTHER,
                            note='URLs')
            rf.save()
        return redirect(jinja_helpers.url('addons.ratings.list', addon.slug))
    return render(request, 'ratings/add.html', {'addon': addon, 'form': form})
Esempio n. 10
0
def reply(request, addon, review_id):
    is_admin = acl.action_allowed(request, amo.permissions.ADDONS_EDIT)
    is_author = acl.check_addon_ownership(request, addon, dev=True)
    if not (is_admin or is_author):
        raise PermissionDenied

    review = get_object_or_404(Review.objects, pk=review_id, addon=addon)
    form = forms.ReviewReplyForm(request.POST or None)
    if request.method == 'POST' and form.is_valid():
        kwargs = {
            'reply_to': review,
            'addon': addon,
            'defaults': _review_details(request, addon, form)
        }
        reply, created = Review.unfiltered.update_or_create(**kwargs)
        return redirect(
            jinja_helpers.url('addons.reviews.detail', addon.slug, review_id))
    ctx = {'review': review, 'form': form, 'addon': addon}
    return render(request, 'reviews/reply.html', ctx)
Esempio n. 11
0
    def test_reply_triggers_email_but_no_logging(self):
        rating = Rating.objects.get(id=1)
        user = user_factory()
        Rating.objects.create(
            reply_to=rating, user=user, addon=rating.addon,
            body=u'RĂŞply', user_responsible=user)

        assert not ActivityLog.objects.exists()
        assert len(mail.outbox) == 1
        email = mail.outbox[0]
        reply_url = jinja_helpers.absolutify(
            jinja_helpers.url(
                'addons.ratings.detail', rating.addon.slug, rating.pk,
                add_prefix=False))
        assert email.subject == 'Mozilla Add-on Developer Reply: my addon name'
        assert 'A developer has replied to your review' in email.body
        assert 'add-on my addon name' in email.body
        assert reply_url in email.body
        assert email.to == ['*****@*****.**']
        assert email.from_email == 'Mozilla Add-ons <*****@*****.**>'
Esempio n. 12
0
def reply(request, addon, review_id):
    is_admin = acl.action_allowed(request, amo.permissions.ADDONS_EDIT)
    is_author = acl.check_addon_ownership(request, addon, dev=True)
    if not (is_admin or is_author):
        raise DjangoPermissionDenied

    rating = get_object_or_404(Rating.objects, pk=review_id, addon=addon)
    form = forms.RatingReplyForm(request.POST or None)
    if request.method == 'POST' and form.is_valid():
        kwargs = {
            'reply_to': rating,
            'addon': addon,
            'defaults': _review_details(request, addon, form)
        }
        reply, created = Rating.unfiltered.update_or_create(**kwargs)
        return redirect(jinja_helpers.url(
            'addons.ratings.detail', addon.slug, review_id))
    ctx = {
        'review': rating,
        'form': form,
        'addon': addon
    }
    return render(request, 'ratings/reply.html', ctx)
Esempio n. 13
0
 def item_link(self, rating):
     """Link for a particular rating (<item><link>)"""
     return jinja_helpers.absolutify(
         jinja_helpers.url('addons.ratings.detail', self.addon.slug,
                           rating.id))
Esempio n. 14
0
 def link(self, addon):
     """Link for the feed"""
     return jinja_helpers.absolutify(jinja_helpers.url('home'))
Esempio n. 15
0
 def link(self):
     return absolutify(url('apps.appversions'))
Esempio n. 16
0
 def link(self, category):
     """Link for the feed as a whole"""
     return absolutify(url('home'))
Esempio n. 17
0
 def item_link(self, review):
     """Link for a particular review (<item><link>)"""
     return jinja_helpers.absolutify(
         jinja_helpers.url('addons.reviews.detail', self.addon.slug,
                           review.id))
Esempio n. 18
0
 def link(self, category):
     """Link for the feed as a whole"""
     return absolutify(url('home'))
Esempio n. 19
0
 def link(self):
     """Link for the feed as a whole"""
     return absolutify(url('devhub.feed_all'))
Esempio n. 20
0
 def item_guid(self, review):
     """Guid for a particuar review  (<item><guid>)"""
     guid_url = jinja_helpers.absolutify(
         jinja_helpers.url('addons.reviews.list', self.addon.slug))
     return guid_url + urllib.quote(str(review.id))
Esempio n. 21
0
 def item_guid(self, rating):
     """Guid for a particuar rating  (<item><guid>)"""
     guid_url = jinja_helpers.absolutify(
         jinja_helpers.url('addons.ratings.list', self.addon.slug))
     return guid_url + urllib.quote(str(rating.id))
Esempio n. 22
0
 def item_link(self, rating):
     """Link for a particular rating (<item><link>)"""
     return jinja_helpers.absolutify(jinja_helpers.url(
         'addons.ratings.detail', self.addon.slug, rating.id))
Esempio n. 23
0
 def test_appversions_feed(self):
     assert self.client.get(url('apps.appversions.rss')).status_code == 200
Esempio n. 24
0
 def link(self, addon):
     """Link for the feed"""
     return absolutify(url('home'))
Esempio n. 25
0
 def get_url_path(self):
     return jinja_helpers.url(
         'addons.ratings.detail', self.addon.slug, self.id)
Esempio n. 26
0
 def link(self):
     return absolutify(url('apps.appversions'))
Esempio n. 27
0
 def item_guid(self, rating):
     """Guid for a particuar rating  (<item><guid>)"""
     guid_url = jinja_helpers.absolutify(
         jinja_helpers.url('addons.ratings.list', self.addon.slug))
     return guid_url + quote(str(rating.id))
Esempio n. 28
0
 def get_url_path(self):
     return jinja_helpers.url('addons.ratings.detail', self.addon.slug,
                              self.id)
Esempio n. 29
0
 def test_appversions_feed(self):
     assert self.client.get(url('apps.appversions.rss')).status_code == 200
Esempio n. 30
0
 def link(self, addon):
     """Link for the feed"""
     return jinja_helpers.absolutify(jinja_helpers.url('home'))
Esempio n. 31
0
 def link(self, addon):
     """Link for the feed"""
     return absolutify(url('home'))
Esempio n. 32
0
 def link(self):
     """Link for the feed as a whole"""
     return absolutify(url('devhub.feed_all'))
Esempio n. 33
0
 def item_link(self, review):
     """Link for a particular review (<item><link>)"""
     return jinja_helpers.absolutify(jinja_helpers.url(
         'addons.reviews.detail', self.addon.slug, review.id))