Add friend

This commit is contained in:
cuom1999 2020-06-23 20:46:33 -05:00
parent 5298e6aaa5
commit e951c761f5
12 changed files with 158 additions and 14 deletions

View file

@ -1,5 +1,7 @@
{% extends "user/base-users-table.html" %}
{% set friends = request.profile.get_friends() if request.user.is_authenticated else {} %}
{% block after_rank_head %}
{% if has_rating %}
<th>{{ _('Rating') }}</th>
@ -52,9 +54,7 @@
{% endblock %}
{% block row_extra %}
{% if user.participation.is_disqualified %}
class="disqualified"
{% endif %}
class="{{ 'disqualified' if user.participation.is_disqualified }} {{ 'friend' if user.username in friends }} {{'highlight' if user.username == request.user.username}}"
{% endblock %}
{% block before_point %}

View file

@ -286,6 +286,22 @@
$('#show-organizations-checkbox').click(function () {
$('.organization-column').toggle();
});
{% if request.user.is_authenticated %}
$('#show-friends-checkbox').click(function() {
let checked = $('#show-friends-checkbox').is(':checked');
if (checked) {
$('tbody tr').hide();
$('.friend').show();
$('.friend').last().find('td').css({'border-bottom-width':
'1px', 'border-color': '#ccc'});
}
else {
$('tr').show();
$('.friend').last().find('td').removeAttr('style');
}
})
{% endif %}
highlightFirstSolve();
});
@ -301,7 +317,12 @@
{% endif %}
{% endif %}
<input id="show-organizations-checkbox" type="checkbox" style="vertical-align: bottom">
<label for="show-organizations-checkbox" style="vertical-align: bottom">{{ _('Show organizations') }}</label>
<label for="show-organizations-checkbox" style="vertical-align: bottom; margin-right: 1em;">{{ _('Show organizations') }}</label>
{% if request.user.is_authenticated %}
<input id="show-friends-checkbox" type="checkbox" style="vertical-align: bottom;">
<label for="show-friends-checkbox" style="vertical-align: bottom;">{{ _('Show friends only') }}</label>
{% endif %}
</div>
{% include "contest/ranking-table.html" %}
{% endblock %}

View file

@ -16,7 +16,11 @@
{% block title_ruler %}{% endblock %}
{% block title_row %}
{% set tab = 'list' %}
{% if request.GET.get('friend') == 'true'%}
{% set tab = 'friends' %}
{% else %}
{% set tab = 'list' %}
{% endif %}
{% set title = 'Leaderboard' %}
{% include "user/user-list-tabs.html" %}
{% endblock %}

View file

@ -9,6 +9,20 @@
{% block user_content %}
<div class="content-description">
{% if request.user != user.user %}
<form method="post">
{% csrf_token %}
<button class="{{ 'unfollow' if followed else 'follow' }}">
{% if followed %}
<i class="fa fa-remove"></i>
{{ _('Unfollow') }}
{% else %}
<i class="fa fa-user-plus"></i>
{{ _('Follow') }}
{% endif %}
</button>
</form>
{% endif %}
{% with orgs=user.organizations.all() %}
{% if orgs %}
<p style="margin-top: 0"><b>{{ _('From') }}</b>

View file

@ -1,6 +1,7 @@
{% extends "tabs-base.html" %}
{% block tabs %}
{{ make_tab('list', 'fa-users', url('user_list'), _('Leaderboard')) }}
{{ make_tab('list', 'fa-trophy', url('user_list'), _('Leaderboard')) }}
{{ make_tab('friends', 'fa-users', url('user_list') + '?friend=true', _('Friends')) }}
{{ make_tab('organizations', 'fa-university', url('organization_list'), _('Organizations')) }}
{% endblock %}