divide admin and users
This commit is contained in:
parent
7e4c104a56
commit
19665c557f
3 changed files with 46 additions and 11 deletions
|
@ -21,6 +21,18 @@ def format_messages(messages):
|
|||
} for msg in messages]
|
||||
return json.dumps(msg_list, default=str)
|
||||
|
||||
def get_admin_online_status():
|
||||
all_admin = Profile.objects.filter(display_rank='admin')
|
||||
last_five_minutes = timezone.now()-timezone.timedelta(minutes=5)
|
||||
ret = []
|
||||
|
||||
for admin in all_admin:
|
||||
is_online = False
|
||||
if (admin.last_access >= last_five_minutes):
|
||||
is_online = True
|
||||
ret.append({'user': admin, 'is_online': is_online})
|
||||
|
||||
return ret
|
||||
|
||||
class ChatView(ListView):
|
||||
model = Message
|
||||
|
@ -47,7 +59,10 @@ class ChatView(ListView):
|
|||
context['title'] = self.title
|
||||
last_five_minutes = timezone.now()-timezone.timedelta(minutes=5)
|
||||
context['online_users'] = Profile.objects \
|
||||
.filter(last_access__gte = last_five_minutes)
|
||||
.filter(display_rank='user',
|
||||
last_access__gte = last_five_minutes)\
|
||||
.order_by('-rating')
|
||||
context['admin_status'] = get_admin_online_status()
|
||||
return context
|
||||
|
||||
def delete_message(request):
|
||||
|
|
|
@ -101,16 +101,20 @@
|
|||
width: 100%;
|
||||
}
|
||||
|
||||
.dot {
|
||||
.green-dot, .red-dot {
|
||||
height: 0.8em;
|
||||
width: 0.8em;
|
||||
background-color: #39ff14;
|
||||
border-radius: 50%;
|
||||
display: inline-block;
|
||||
margin-bottom: -0.2em;
|
||||
border: 1px lightgreen solid;
|
||||
margin-bottom: -0.15em;
|
||||
}
|
||||
.green-dot {
|
||||
background-color: #42f58d;
|
||||
}
|
||||
|
||||
.red-dot {
|
||||
background-color: red;
|
||||
}
|
||||
|
||||
@media (min-width: 800px) {
|
||||
#chat-container {
|
||||
|
|
|
@ -212,8 +212,8 @@
|
|||
</script>
|
||||
|
||||
{% endblock js_media %}
|
||||
<!--
|
||||
{% block media %}
|
||||
|
||||
<!-- {% block media %}
|
||||
<style>
|
||||
</style>
|
||||
{% endblock media %}
|
||||
|
@ -246,11 +246,27 @@
|
|||
<i class="fa fa-wifi"></i>
|
||||
</h3>
|
||||
<ul id="chat-online-content">
|
||||
{% for user in online_users %}
|
||||
<li>
|
||||
<span class="dot"></span>
|
||||
<h4>{{_('Admins')}}: </h4>
|
||||
<hr/>
|
||||
{% for user in admin_status %}
|
||||
<li style="padding-left: 1em">
|
||||
{% if user.is_online %}
|
||||
<span class="green-dot"></span>
|
||||
{% else %}
|
||||
<span class="red-dot"></span>
|
||||
{% endif %}
|
||||
<span style="padding-left:0.25em">
|
||||
{{ link_user(user) }}
|
||||
{{ link_user(user.user) }}
|
||||
</span>
|
||||
</li>
|
||||
{% endfor %}
|
||||
<h4 style="margin-top:1em;">{{_('Users')}}: </h4>
|
||||
<hr/>
|
||||
{% for user in online_users %}
|
||||
<li style="padding-left: 1em">
|
||||
<span class="green-dot"></span>
|
||||
<span style="padding-left:0.25em">
|
||||
{{ link_user(user.user) }}
|
||||
</span>
|
||||
</li>
|
||||
{% endfor %}
|
||||
|
|
Loading…
Reference in a new issue