Skip to content

Commit

Permalink
background image for users
Browse files Browse the repository at this point in the history
  • Loading branch information
twd2 committed Jul 23, 2017
1 parent 5dfed2d commit 91ae290
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 5 deletions.
4 changes: 4 additions & 0 deletions vj4/locale/zh_CN.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -636,3 +636,7 @@ Lucky: 手气不错
Pick a problem randomly based on current filter: 根据当前过滤条件随机选择一道题
No problem.: 没有题目。
Initialize: 初始化
Background Image: 背景图片
'{} is a moderator of this domain.': '{}是这个域的管理者之一。'
He:
She:
2 changes: 2 additions & 0 deletions vj4/model/adaptor/setting.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
desc='If left blank, the built-in template of the corresponding language will be used.')]

ACCOUNT_SETTINGS = [
Setting('setting_info', 'background_img', int, range=constant.setting.BACKGROUND_RANGE,
ui='select', name='Background Image'),
Setting('setting_info', 'gravatar', str,
name='Gravatar Email', desc='We use Gravatar to present your avatar icon.'),
Setting('setting_info', 'qq', str,
Expand Down
25 changes: 25 additions & 0 deletions vj4/ui/constant/setting.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,28 @@ export const FUNCTION_RANGE = {
1: 'Enabled',
};
attachObjectMeta(FUNCTION_RANGE, 'intKey', true);

export const BACKGROUND_RANGE = {
1: '1',
2: '2',
3: '3',
4: '4',
5: '5',
6: '6',
7: '7',
8: '8',
9: '9',
10: '10',
11: '11',
12: '12',
13: '13',
14: '14',
15: '15',
16: '16',
17: '17',
18: '18',
19: '19',
20: '20',
21: '21',
};
attachObjectMeta(BACKGROUND_RANGE, 'intKey', true);
10 changes: 6 additions & 4 deletions vj4/ui/templates/discussion_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
</form></li>
{% endif %}
<li>
<a href="#"><span class="icon icon-warning"></span> {{ _('Report') }}</a>
<a href="{{ reverse_url('about') }}#contact"><span class="icon icon-warning"></span> {{ _('Report') }}</a>
</li>
</ul>
</div>
Expand Down Expand Up @@ -70,16 +70,17 @@ <h1 class="section__title">{{ _('{0} comments').format(drcount) }}</h1>
</div>
</div>
<div class="medium-3 columns">
{% with udoc = udict[ddoc['owner_uid']] %}
<div class="section side">
<div class="profile__bg user-profile-bg--12"></div>
<div class="profile__bg user-profile-bg--{{ vj4.model.adaptor.setting.UserSetting(udoc).get_setting('background_img') }}"></div>

This comment has been minimized.

Copy link
@breezewish

breezewish Jul 24, 2017

Member

What will happen if user does not have this setting key in database?

This comment has been minimized.

Copy link
@twd2

twd2 Jul 24, 2017

Author Member

Default value 1 would be used.

This comment has been minimized.

Copy link
@breezewish

breezewish Jul 24, 2017

Member

Where is the default value?

This comment has been minimized.

<div class="section__body">
<div class="media sidebar-user-profile">
<div class="media__left">
<img src="{{ udict[ddoc['owner_uid']]['gravatar']|gravatar_url }}" width="80" height="80" class="medium user-profile-avatar">
<img src="{{ udoc['gravatar']|gravatar_url }}" width="80" height="80" class="medium user-profile-avatar">
</div>
<div class="media__body">
<p>
{{ user.render_inline(udict[ddoc['owner_uid']], dudict[ddoc['owner_uid']], avatar=false, modbadge=false) }}
{{ user.render_inline(udoc, dudict[ddoc['owner_uid']], avatar=false, modbadge=false) }}
</p>
</div>
</div>
Expand All @@ -106,6 +107,7 @@ <h1 class="section__title">{{ _('{0} comments').format(drcount) }}</h1>
</div>
</div>
</div>
{% endwith %}
</div>
{% if vnode['doc_type'] == vj4.model.document.TYPE_PROBLEM %}
{% with pdoc=vnode, owner_udoc=udict[vnode['owner_uid']] %}
Expand Down
5 changes: 4 additions & 1 deletion vj4/ui/templates/user_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<div class="row">
<div class="medium-9 columns">
<div class="section">
<div class="profile-header user-profile-bg--{{ bg }}">
<div class="profile-header user-profile-bg--{{ vj4.model.adaptor.setting.UserSetting(udoc).get_setting('background_img') }}">
<div class="profile-header__content clearfix">
<div class="media">
<div class="media__left">
Expand All @@ -22,6 +22,9 @@ <h1>{{ udoc['uname'] }} <small>({{ _('UID') }}: {{ udoc['_id'] }}) {% if handler
{% endif %}
</p>
<p>{{ _('Solved {0} problems, RP: {1} (No. {2})').format(dudoc['num_accept']|default(0), dudoc['rp']|default(0.0)|round(2), dudoc['rank']|default('?')) }}</p>
{% if handler.dudoc_has_perm(udoc, dudoc, vj4.model.builtin.PERM_MOD_BADGE) %}
<p>{{ _('{} is a moderator of this domain.').format(_('She' if handler.get_udoc_setting(udoc, 'gender') == 1 else 'He')) }}</p>
{% endif %}
</div>
</div>
</div>
Expand Down

0 comments on commit 91ae290

Please sign in to comment.