This commit is contained in:
Allen Short 2012-06-22 07:03:22 -05:00
Родитель 12f9b5a161
Коммит c79782887c
5 изменённых файлов: 116 добавлений и 2 удалений

Просмотреть файл

@ -350,8 +350,11 @@ class ActivityLog(amo.models.ModelBase):
arguments.remove(arg)
if isinstance(arg, Version) and not version:
text = _('Version %s') % arg.version
version = self.f(u'<a href="{0}">{1}</a>',
arg.get_url_path(), text)
if settings.MARKETPLACE:
version = self.f(text)
else:
version = self.f(u'<a href="{0}">{1}</a>',
arg.get_url_path(), text)
arguments.remove(arg)
if isinstance(arg, Collection) and not collection:
collection = self.f(u'<a href="{0}">{1}</a>',

Просмотреть файл

@ -0,0 +1,47 @@
{% extends 'mkt/base.html' %}
{% block content %}
<section class="island c">
<section id="activity-info">
<h2>{{ _('App Updates') }}</h2>
<ol class="simple-log">
{% for item in user_items %}
<li class="item">
<p>
<span class="action {{ log_action_class(item.action) }}"></span>
{{ item }}
</p>
<p class="timestamp">
{% trans user=item.user|user_link, ago=item.created|timesince,
iso=item.created|isotime,
pretty=item.created|babel_datetime %}
<time datetime="{{ iso }}" title="{{ pretty }}">{{ ago }}</time>
by {{ user }}
{% endtrans %}
</p>
</li>
{% endfor %}
</ol>
{# Show this if the account belongs to an admin/reviewer #}
<h2>{{ _('Administrative Actions') }}</h2>
<ol class="simple-log">
{% for item in admin_items %}
<li class="item">
<p>
<span class="action {{ log_action_class(item.action) }}"></span>
{{ item }}
</p>
<p class="timestamp">
{% trans user=item.user|user_link, ago=item.created|timesince,
iso=item.created|isotime,
pretty=item.created|babel_datetime %}
<time datetime="{{ iso }}" title="{{ pretty }}">{{ ago }}</time>
by {{ user }}
{% endtrans %}
</p>
</li>
{% endfor %}
</ol>
</section>
</section>
{% endblock %}

Просмотреть файл

@ -17,6 +17,7 @@ from amo.helpers import external_url, numberfmt, urlparams
import amo.tests
from amo.urlresolvers import reverse
from addons.models import AddonCategory, AddonUpsell, AddonUser, Category
from devhub.models import ActivityLog
from market.models import PreApprovalUser
from users.models import UserProfile
@ -612,3 +613,45 @@ class TestReportAbuse(DetailBase):
self.client.post(self.url, {'text': 'spammy'})
assert 'spammy' in mail.outbox[0].body
assert AbuseReport.objects.get(addon=self.webapp)
class TestActivity(amo.tests.TestCase):
fixtures = ['base/users', 'webapps/337141-steamcube']
def setUp(self):
self.app = Webapp.objects.get(pk=337141)
self.reviewer = UserProfile.objects.get(username='admin')
self.user = UserProfile.objects.get(pk=999)
self.url = reverse('acct_lookup.user_activity', args=[self.user.pk])
def test_not_allowed(self):
self.client.logout()
self.assertLoginRequired(self.client.get(self.url))
def test_not_even_mine(self):
self.client.login(username=self.user.email, password='password')
eq_(self.client.get(self.url).status_code, 403)
def test_access(self):
self.client.login(username=self.reviewer.email, password='password')
res = self.client.get(self.url)
eq_(res.status_code, 200)
eq_(len(pq(res.content)('.simple-log div')), 0)
def test_log(self):
self.client.login(username=self.reviewer.email, password='password')
res = self.client.get(self.url)
log_item = ActivityLog.objects.get(action=amo.LOG.ADMIN_VIEWED_LOG.id)
eq_(len(log_item.arguments), 1)
eq_(log_item.arguments[0].id, self.reviewer.id)
eq_(log_item.user, self.user)
def test_display(self):
amo.log(amo.LOG.CREATE_ADDON, self.app, user=self.user)
amo.log(amo.LOG.ADMIN_USER_EDITED, self.user, 'spite', user=self.user)
self.client.login(username=self.reviewer.email, password='password')
res = self.client.get(self.url)
eq_(res.status_code, 200)
doc = pq(res.content)
assert 'created' in doc('li.item').eq(0).text()
assert 'edited' in doc('li.item').eq(1).text()

Просмотреть файл

@ -22,4 +22,6 @@ urlpatterns = patterns('',
# Ratings.
('^reviews/', include(review_patterns)),
url('^activity/', views.app_activity, name='detail.app_activity'),
)

Просмотреть файл

@ -8,7 +8,10 @@ from tower import ugettext as _
from abuse.models import send_abuse_report
from access import acl
from addons.decorators import addon_view_factory
import amo
from amo.decorators import login_required, permission_required
from amo.forms import AbuseForm
from devhub.models import ActivityLog
from reviews.models import Review
from mkt.site import messages
@ -65,3 +68,19 @@ def abuse_recaptcha(request, addon):
else:
return jingo.render(request, 'detail/abuse_recaptcha.html',
{'product': addon, 'abuse_form': form})
@login_required
@permission_required('AccountLookup', 'View')
@addon_view
def app_activity(request, addon):
"""Shows the app activity age for single app."""
user_items = ActivityLog.objects.for_apps([addon]).exclude(
action__in=amo.LOG_HIDE_DEVELOPER)
admin_items = ActivityLog.objects.for_apps([addon]).filter(
action__in=amo.LOG_HIDE_DEVELOPER)
return jingo.render(request, 'detail/app_activity.html',
{'user_items': user_items,
'admin_items': admin_items})