Skip to content

Commit 929cba6

Browse files
committed
support version 2.0 of django-avatar app and improve the "manage avatars" page
1 parent 7815540 commit 929cba6

18 files changed

Lines changed: 402 additions & 283 deletions

askbot/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#values - the package qualifier to use for pip
1414
REQUIREMENTS = {
1515
'akismet': 'akismet',
16+
'avatar': 'django-avatar>=2.0',
1617
'bs4': 'beautifulsoup4',
1718
'coffin': 'Coffin>=0.3,<=0.3.8',
1819
'compressor': 'django-compressor==1.2',

askbot/doc/source/changelog.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Changes in Askbot
33

44
Development version (only in the repository)
55
--------------------------------------------
6+
* Improved support of uploadable avatars
67
* Added authentication via MediaWiki
78
* Added option to specify `ASKBOT_QUESTION_TITLE_RENDERER` function
89
* Added option to specify `ASKBOT_HTML_MODERATOR` function

askbot/doc/source/optional-modules.rst

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,9 @@ Uploaded avatars
187187
================
188188

189189
To enable uploadable avatars (in addition to :ref:`gravatars <gravatar>`),
190-
please install development version of
191-
application ``django-avatar``, with the following command::
192-
193-
pip install -e git+git://github.com/ericflo/django-avatar.git#egg=django-avatar
190+
please install application ``django-avatar``, with the following command::
191+
192+
pip install django-avatar
194193

195194
Then add ``avatar`` to the list of ``INSTALLED_APPS`` in your ``settings.py`` file
196195
and run (to install database table used by the avatar app):

askbot/media/style/style.css

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,9 @@ body.user-messages {
231231
margin: 0 auto;
232232
padding: 0;
233233
}
234+
.sr-only {
235+
display: none;
236+
}
234237
/* ----- Notify message bar , check blocks/system_messages.html ----- */
235238
.notify {
236239
position: fixed;
@@ -2940,6 +2943,45 @@ ul.js-related-tags li {
29402943
.user-profile-page.inbox-forum .message:last-child, .user-profile-page.inbox-flags .message:last-child {
29412944
border: none;
29422945
}
2946+
.user-profile-page ul.avatars {
2947+
list-style: none;
2948+
margin-left: 0;
2949+
}
2950+
.user-profile-page ul.avatars li {
2951+
display: inline-block;
2952+
max-width: 128px;
2953+
position: relative;
2954+
vertical-align: top;
2955+
}
2956+
.user-profile-page ul.avatars img {
2957+
height: 128px;
2958+
width: 128px;
2959+
}
2960+
.user-profile-page ul.avatars .avatar-delete {
2961+
margin-right: 5px;
2962+
position: absolute;
2963+
right: 0;
2964+
top: 0;
2965+
}
2966+
.user-profile-page ul.avatars form {
2967+
text-align: center;
2968+
}
2969+
.user-profile-page ul.avatars label[for="id_avatar"] {
2970+
display: none;
2971+
}
2972+
.avatar-label {
2973+
background: black;
2974+
color: white !important;
2975+
cursor: help;
2976+
padding: 5px;
2977+
position: absolute;
2978+
}
2979+
.avatar-primary-label {
2980+
height: 28px;
2981+
line-height: 28px !important;
2982+
margin: 3px 0 0 0;
2983+
text-align: center;
2984+
}
29432985
.user-profile-page.inbox-forum .new {
29442986
background: #FFF8C6;
29452987
}

askbot/media/style/style.less

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,10 @@ body.user-messages {
239239
padding: 0;
240240
}
241241

242+
.sr-only {
243+
display: none;
244+
}
245+
242246

243247
/* ----- Notify message bar , check blocks/system_messages.html ----- */
244248

@@ -3146,6 +3150,46 @@ ul.js-related-tags li {
31463150
}
31473151
}
31483152

3153+
.user-profile-page ul.avatars {
3154+
list-style: none;
3155+
margin-left: 0;
3156+
li {
3157+
display: inline-block;
3158+
max-width: 128px;
3159+
position: relative;
3160+
vertical-align: top;
3161+
}
3162+
img {
3163+
height: 128px;
3164+
width: 128px;
3165+
}
3166+
.avatar-delete {
3167+
margin-right: 5px;
3168+
position: absolute;
3169+
right: 0;
3170+
top: 0;
3171+
}
3172+
form {
3173+
text-align: center;
3174+
}
3175+
label[for="id_avatar"] {
3176+
display: none;
3177+
}
3178+
}
3179+
.avatar-label {
3180+
background: black;
3181+
color: white !important;
3182+
cursor: help;
3183+
padding: 5px;
3184+
position: absolute;
3185+
}
3186+
.avatar-primary-label {
3187+
height: 28px;
3188+
line-height: 28px !important;
3189+
margin: 3px 0 0 0;
3190+
text-align: center;
3191+
}
3192+
31493193
.user-profile-page.inbox-forum {
31503194
.new {
31513195
background: #FFF8C6;

askbot/models/__init__.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -289,15 +289,11 @@ def user_get_avatar_url(self, size=48):
289289
"""
290290
if 'avatar' in django_settings.INSTALLED_APPS:
291291
if self.avatar_type == 'n':
292-
import avatar
293-
if askbot_settings.ENABLE_GRAVATAR: #avatar.settings.AVATAR_GRAVATAR_BACKUP:
294-
return self.get_gravatar_url(size)
295-
else:
296-
return self.get_default_avatar_url(size)
292+
return self.get_default_avatar_url(size)
297293
elif self.avatar_type == 'a':
298-
kwargs = {'user_id': self.id, 'size': size}
294+
kwargs = {'user': self.username, 'size': size}
299295
try:
300-
return reverse('avatar_render_primary', kwargs = kwargs)
296+
return reverse('avatar_render_primary', kwargs=kwargs)
301297
except NoReverseMatch:
302298
message = 'Please, make sure that avatar urls are in the urls.py '\
303299
'or update your django-avatar app, '\

askbot/startup_procedures.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -600,12 +600,7 @@ def test_avatar():
600600
"""if "avatar" is in the installed apps,
601601
checks that the module is actually installed"""
602602
if 'avatar' in django_settings.INSTALLED_APPS:
603-
try_import('Image', 'PIL', short_message = True)
604-
try_import(
605-
'avatar',
606-
'-e git+git://github.com/ericflo/django-avatar.git#egg=avatar',
607-
short_message = True
608-
)
603+
try_import('avatar', 'django-avatar', short_message=True)
609604

610605
def test_haystack():
611606
if 'haystack' in django_settings.INSTALLED_APPS:

askbot/templates/avatar/add.html

Lines changed: 0 additions & 20 deletions
This file was deleted.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<img src="{{ avatar.url }}" height="128" width="128"
2+
{% if avatar.is_primary %}
3+
alt="{% trans username=view_user.username|escape %}{{ username }}'s primary avatar{% endtrans %}"
4+
{% else %}
5+
alt="{% trans username=view_user.username|escape %}{{ username }}'s avatar{% endtrans %}"
6+
{% endif %}
7+
/>

askbot/templates/avatar/change.html

Lines changed: 0 additions & 29 deletions
This file was deleted.

0 commit comments

Comments
 (0)