From 8d8946a66be98d4d6a8e0f11717ceb966a42ce9e Mon Sep 17 00:00:00 2001 From: Holger Trampe Date: Tue, 19 May 2020 23:28:52 +0200 Subject: [PATCH] csrf --- chat/templates/chat/chatmanagement.html | 24 +++-- chat/views.py | 21 +++- .../__pycache__/settings.cpython-38.pyc | Bin 4750 -> 4750 bytes users/signals.py | 4 + users/templates/users/base.html | 99 +++++++++--------- 5 files changed, 81 insertions(+), 67 deletions(-) diff --git a/chat/templates/chat/chatmanagement.html b/chat/templates/chat/chatmanagement.html index 8678f6e..0bed342 100644 --- a/chat/templates/chat/chatmanagement.html +++ b/chat/templates/chat/chatmanagement.html @@ -78,6 +78,7 @@ orange {% elif user.profile.onlinestatus == 3 %} grey + {% endif %} {% else %} grey {% endif %};"> @@ -126,7 +127,7 @@ }); }); - function updatePresenceLive(e) { + function updatePresenceLive() { $.ajax( { type: "GET", @@ -137,23 +138,24 @@ success: function( data ) { console.log(data); - $( ".status-circle" ).each(function( index ) { - if(data["onlineusers"].indexOf($(this)[0]["id"].split("_")[2]) !== -1){ - - console.log(data["onlineusers"][index+1]); + counter = 0; + $( ".status-circle" ).each(function( index ) { + if(data["user_online_final"].indexOf($(this)[0]["id"].split("_")[2]) !== -1){ $("#" + $(this)[0]["id"]).css("background-color", "green"); } + else if(data["user_besch_final"].indexOf($(this)[0]["id"].split("_")[2]) !== -1){ + $("#" + $(this)[0]["id"]).css("background-color", "red"); + } + else if(data["user_abw_final"].indexOf($(this)[0]["id"].split("_")[2]) !== -1){ + $("#" + $(this)[0]["id"]).css("background-color", "orange"); + } else{ $("#" + $(this)[0]["id"]).css("background-color", "grey"); - } - - - }); - + } + }); } }); }; - diff --git a/chat/views.py b/chat/views.py index 0739a1f..2e004d8 100644 --- a/chat/views.py +++ b/chat/views.py @@ -43,18 +43,29 @@ def getloggedusers(request): @login_required def getloggedusersdata(request): + + user_online_final = [] + user_besch_final = [] + user_abw_final = [] + user_off_final = [] + if request.method == "GET": users_online = Room.objects.get(channel_name="agency_" + str(request.user.profile.agency.pk)).get_users() users_agency = User.objects.filter(profile__agency=request.user.profile.agency).exclude(pk=request.user.pk) - - user_online_final = [] + for u in users_agency: if(u in users_online): - user_online_final.append("" + str(u.pk)) - user_online_final.append("" + str(u.pk) + "_" + u.profile.onlinestatus) + if(u.profile.onlinestatus == 0): + user_online_final.append("" + str(u.pk)) + elif(u.profile.onlinestatus == 1): + user_besch_final.append("" + str(u.pk)) + elif(u.profile.onlinestatus == 2): + user_abw_final.append("" + str(u.pk)) + elif(u.profile.onlinestatus == 3): + user_off_final.append("" + str(u.pk)) - return JsonResponse({"onlineusers" : user_online_final}) + return JsonResponse({"user_online_final" : user_online_final, "user_besch_final" : user_besch_final, "user_abw_final" : user_abw_final, "user_off_final" : user_off_final}) else: return JsonResponse({}) diff --git a/digitaleagentur/__pycache__/settings.cpython-38.pyc b/digitaleagentur/__pycache__/settings.cpython-38.pyc index bd1326b5449c70a4fedbe08821bb9ff32d671f7f..100675d7d0da802347ec07014ff371bda73a6dc9 100644 GIT binary patch delta 19 YcmeBE?Nj9n<>lpK0D^x1ja)5404T)-82|tP delta 19 YcmeBE?Nj9n<>lpK0D@^A8@XD904U4^82|tP diff --git a/users/signals.py b/users/signals.py index 884e920..0a3b710 100644 --- a/users/signals.py +++ b/users/signals.py @@ -135,6 +135,10 @@ def create_profile(sender, instance, created, **kwargs): @receiver(post_save, sender=User) def save_profile(sender, instance, **kwargs): instance.profile.save() + user_to_touch = list(Presence.objects.filter(user=instance.pk))[0] + user_to_touch + Presence.objects.touch(user_to_touch) + # SIGNALS FOR GROUPS diff --git a/users/templates/users/base.html b/users/templates/users/base.html index 89ed206..2f57efb 100644 --- a/users/templates/users/base.html +++ b/users/templates/users/base.html @@ -674,6 +674,50 @@ $(document).on('click', function (e) {