impala user profile page
This commit is contained in:
Родитель
123188cdb2
Коммит
62b05155f9
|
@ -0,0 +1,77 @@
|
|||
{% extends "impala/base.html" %}
|
||||
|
||||
{% block title %}{{ page_title(_('User Info for {0}')|f(profile.name)) }}{% endblock %}
|
||||
{% block js %}{% include("amo/recaptcha_js.html") %}{% endblock %}
|
||||
{% block bodyclass %}meet gutter{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
{% include "messages.html" %}
|
||||
|
||||
{{ impala_breadcrumbs([(None, profile.name)]) }}
|
||||
<h1 class="fn n">{{ profile.name }}</h1>
|
||||
|
||||
<div class="vcard island c object-lead">
|
||||
<aside class="secondary">
|
||||
<img class="avatar" src="{{ profile.picture_url }}"
|
||||
{% if not profile.picture_type %}alt="{{ _('No Photo') }}"{% endif %}>
|
||||
{% if profile.is_developer %}
|
||||
<div class="user-role">{{ _('Add-ons Developer') }}</div>
|
||||
{% endif %}
|
||||
{% if own_profile %}
|
||||
<a class="button" href="{{ url('users.edit') }}">{{ _('Edit Profile') }}</a>
|
||||
{% endif %}
|
||||
{% if edit_any_user %}
|
||||
{# TODO XXX Once zamboni can delete users, uncomment this line. bug 595035 #}
|
||||
{# <a href="{{ url("admin:users_userprofile_change", profile.id) }}">{{ _('Manage User') }}</a> #}
|
||||
<a class="button" href="{{ remora_url("/admin/users/%s" % profile.id) }}">{{ _('Manage User') }}</a>
|
||||
{% endif %}
|
||||
</aside>
|
||||
<section class="primary">
|
||||
<h2>{{ _('About Me')}}</h2>
|
||||
<div class="vcard">
|
||||
{% with table_class='person-info' %}
|
||||
{% include "users/impala/vcard.html" %}
|
||||
{% endwith %}
|
||||
</div>
|
||||
<div class="prose">
|
||||
{% if profile.bio %}
|
||||
<h3>{{ _('In a little more detail...') }}</h3>
|
||||
<p class="intro">{{ profile.bio|nl2br }}</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
{% if addons.object_list %}
|
||||
<div class="island c listing">
|
||||
<h2>{{ _("Add-ons I've created") }}</h2>
|
||||
{% cache addons.object_list %}
|
||||
{{ impala_addon_listing_items(addons.object_list, src='category',
|
||||
show_date=sorting) }}
|
||||
{% endcache %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% cache reviews %}
|
||||
<div class="island c" id="reviews">
|
||||
<h2>{{ _('My Reviews') }}</h2>
|
||||
<div class="article">
|
||||
{% if reviews %}
|
||||
{% for review in reviews %}
|
||||
{% set addon = review.addon %}
|
||||
{% include "reviews/impala/review.html" %}
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<p class="noreviews">{{ _('No add-on reviews yet.') }}</p>
|
||||
{% endif %}
|
||||
</div>{# /article #}
|
||||
</div>{# /primary #}
|
||||
{% endcache %}
|
||||
|
||||
{% if abuse_form %}
|
||||
<div class="abuse-wrapper c">{{ user_report_abuse(hide=True, profile=profile) }}</div>
|
||||
{% endif %}
|
||||
|
||||
|
||||
{% endblock %}
|
|
@ -20,6 +20,10 @@ detail_patterns = patterns('',
|
|||
url('^abuse', views.report_abuse, name='users.abuse'),
|
||||
)
|
||||
|
||||
impala_detail_patterns = patterns('',
|
||||
url('^$', views.impala_profile, name='i_users.profile'),
|
||||
)
|
||||
|
||||
impala_users_patterns = patterns('',
|
||||
url('^edit$', views.edit_impala, name='users.edit_impala'),
|
||||
url('^edit(?:/(?P<user_id>\d+))?$', views.admin_edit_impala,
|
||||
|
@ -52,6 +56,7 @@ users_patterns = patterns('',
|
|||
|
||||
urlpatterns = patterns('',
|
||||
# URLs for a single user.
|
||||
('^i/user/(?P<user_id>\d+)/', include(impala_detail_patterns)),
|
||||
('^user/(?P<user_id>\d+)/', include(detail_patterns)),
|
||||
('^i/users/', include(impala_users_patterns)),
|
||||
('^users/', include(users_patterns)),
|
||||
|
|
|
@ -459,6 +459,51 @@ def profile(request, user_id):
|
|||
return jingo.render(request, 'users/profile.html', data)
|
||||
|
||||
|
||||
def impala_profile(request, user_id):
|
||||
"""user profile display page"""
|
||||
user = get_object_or_404(UserProfile, id=user_id)
|
||||
|
||||
# get user's own and favorite collections, if they allowed that
|
||||
if user.display_collections:
|
||||
own_coll = (Collection.objects.listed().filter(author=user)
|
||||
.order_by('-created'))[:10]
|
||||
else:
|
||||
own_coll = []
|
||||
if user.display_collections_fav:
|
||||
fav_coll = (Collection.objects.listed()
|
||||
.filter(following__user=user)
|
||||
.order_by('-following__created'))[:10]
|
||||
else:
|
||||
fav_coll = []
|
||||
|
||||
edit_any_user = acl.action_allowed(request, 'Admin', 'EditAnyUser')
|
||||
own_profile = request.user.is_authenticated() and (
|
||||
request.amo_user.id == user.id)
|
||||
|
||||
if user.is_developer:
|
||||
addons = amo.utils.paginate(
|
||||
request,
|
||||
user.addons_listed.order_by('-weekly_downloads'))
|
||||
else:
|
||||
addons = []
|
||||
|
||||
def get_addons(reviews):
|
||||
if not reviews:
|
||||
return
|
||||
qs = Addon.objects.filter(id__in=set(r.addon_id for r in reviews))
|
||||
addons = dict((addon.id, addon) for addon in qs)
|
||||
for review in reviews:
|
||||
review.addon = addons.get(review.addon_id)
|
||||
reviews = user.reviews.transform(get_addons)
|
||||
|
||||
data = {'profile': user, 'own_coll': own_coll, 'reviews': reviews,
|
||||
'fav_coll': fav_coll, 'edit_any_user': edit_any_user,
|
||||
'addons': addons, 'own_profile': own_profile,
|
||||
'abuse_form': AbuseForm(request=request)}
|
||||
|
||||
return jingo.render(request, 'users/impala/profile.html', data)
|
||||
|
||||
|
||||
@anonymous_csrf
|
||||
def register(request):
|
||||
if request.user.is_authenticated():
|
||||
|
|
|
@ -46,7 +46,7 @@ header .feed {
|
|||
}
|
||||
}
|
||||
|
||||
.listing .primary .item {
|
||||
.listing .item {
|
||||
border-top: 1px dotted @border-blue;
|
||||
color: @note-gray;
|
||||
display: table;
|
||||
|
|
|
@ -49,9 +49,10 @@ a {
|
|||
border-bottom: 0;
|
||||
}
|
||||
}
|
||||
&.hero {
|
||||
width: 720px;
|
||||
}
|
||||
}
|
||||
|
||||
header + .island {
|
||||
margin-top: 1em;
|
||||
}
|
||||
|
||||
.primary {
|
||||
|
@ -68,6 +69,9 @@ a {
|
|||
.secondary {
|
||||
float: right;
|
||||
}
|
||||
.island.hero {
|
||||
width: 720px;
|
||||
}
|
||||
}
|
||||
|
||||
.html-rtl.gutter .primary {
|
||||
|
|
|
@ -72,6 +72,12 @@ table.person-info {
|
|||
img.avatar {
|
||||
border: 3px solid #fff;
|
||||
}
|
||||
.user-role {
|
||||
font-weight: bold;
|
||||
color: @dark-gray;
|
||||
margin: 0 4px 1em;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
img.icon {
|
||||
padding: 4px;
|
||||
|
|
|
@ -1,22 +1,20 @@
|
|||
$(function () {
|
||||
if ($('body').hasClass('listing')) {
|
||||
$('.performance-note .popup').each(function(i,p) {
|
||||
var $p = $(this),
|
||||
$a = $p.siblings('a').first();
|
||||
$p.popup($a, {width: 300, pointTo: $a});
|
||||
});
|
||||
$('.item.addon').each(function(i,p){
|
||||
var $this = $(this);
|
||||
if ($this.find('.concealed').length == $this.find('.button').length) {
|
||||
$this.addClass('incompatible');
|
||||
}
|
||||
});
|
||||
$(document.body).bind('newStatic', function() {
|
||||
$('.install-note:visible').closest('.item').addClass('static');
|
||||
}).bind('closeStatic', function() {
|
||||
$('.item.static').removeClass('static');
|
||||
});
|
||||
}
|
||||
$('.performance-note .popup').each(function(i,p) {
|
||||
var $p = $(this),
|
||||
$a = $p.siblings('a').first();
|
||||
$p.popup($a, {width: 300, pointTo: $a});
|
||||
});
|
||||
$('.item.addon').each(function(i,p){
|
||||
var $this = $(this);
|
||||
if ($this.find('.concealed').length == $this.find('.button').length) {
|
||||
$this.addClass('incompatible');
|
||||
}
|
||||
});
|
||||
$(document.body).bind('newStatic', function() {
|
||||
$('.install-note:visible').closest('.item').addClass('static');
|
||||
}).bind('closeStatic', function() {
|
||||
$('.item.static').removeClass('static');
|
||||
});
|
||||
|
||||
if (!$("body").hasClass('addon-details')) return;
|
||||
$(".previews").zCarousel({
|
||||
|
|
Загрузка…
Ссылка в новой задаче