diff --git a/chat/templates/chat/chatmanagement.html b/chat/templates/chat/chatmanagement.html index bb14ecc..8678f6e 100644 --- a/chat/templates/chat/chatmanagement.html +++ b/chat/templates/chat/chatmanagement.html @@ -69,7 +69,16 @@
-
+
{{user.first_name}} {{user.last_name}}
@@ -130,6 +139,8 @@ console.log(data); $( ".status-circle" ).each(function( index ) { if(data["onlineusers"].indexOf($(this)[0]["id"].split("_")[2]) !== -1){ + + console.log(data["onlineusers"][index+1]); $("#" + $(this)[0]["id"]).css("background-color", "green"); } else{ diff --git a/chat/views.py b/chat/views.py index 4fa3b54..0739a1f 100644 --- a/chat/views.py +++ b/chat/views.py @@ -52,6 +52,7 @@ def getloggedusersdata(request): 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) return JsonResponse({"onlineusers" : user_online_final}) else: diff --git a/digitaleagentur/__pycache__/settings.cpython-38.pyc b/digitaleagentur/__pycache__/settings.cpython-38.pyc index 8d6cd54..bd1326b 100644 Binary files a/digitaleagentur/__pycache__/settings.cpython-38.pyc and b/digitaleagentur/__pycache__/settings.cpython-38.pyc differ diff --git a/standards/templatetags/__pycache__/counter_tag.cpython-38.pyc b/standards/templatetags/__pycache__/counter_tag.cpython-38.pyc index 89ba131..3415ff3 100644 Binary files a/standards/templatetags/__pycache__/counter_tag.cpython-38.pyc and b/standards/templatetags/__pycache__/counter_tag.cpython-38.pyc differ diff --git a/standards/templatetags/counter_tag.py b/standards/templatetags/counter_tag.py index 1d00d60..8c9665b 100644 --- a/standards/templatetags/counter_tag.py +++ b/standards/templatetags/counter_tag.py @@ -439,4 +439,19 @@ def getsomeyears(start): @register.simple_tag def getsomemonths(): - return ["Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"] \ No newline at end of file + return ["Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"] + +@register.simple_tag +def getonlinestatuscolor(user): + maincolor = "red" + + if(user.profile.onlinestatus == 0): + maincolor = "green" + elif(user.profile.onlinestatus == 1): + maincolor = "red" + elif(user.profile.onlinestatus == 2): + maincolor = "orange" + elif(user.profile.onlinestatus == 3): + maincolor = "grey" + + return maincolor \ No newline at end of file diff --git a/users/models.py b/users/models.py index 57c8d0a..c29c0eb 100644 --- a/users/models.py +++ b/users/models.py @@ -212,6 +212,17 @@ class Profile(models.Model): user_messages_mail = models.BooleanField(default=True) user_messages_push = models.BooleanField(default=True) + # ONLINESTATUS + ''' + + 0 = ONLINE - green + 1 = BESCHAFTIGT - red + 2 = ABWESEND - orange + 3 = OFFLINE - grey + + ''' + onlinestatus = models.IntegerField(default=0) + def __str__(self): return f'{self.user.last_name}' diff --git a/users/signals.py b/users/signals.py index 45f3428..884e920 100644 --- a/users/signals.py +++ b/users/signals.py @@ -54,9 +54,10 @@ def loadingFreeDays(plz): # CHECK SOMETHING WHEN USER LOGGED IN @receiver(signal=user_logged_in, sender=User) def checkForWorkDays(sender, user, request, **kwargs): + user.profile.onlinestatus = 0 + user.save() today = date.today() wd = Workday.objects.filter(user=user, end=None, start__day__lte=today.day) - for d in wd: d.end = datetime.datetime(d.start.year, d.start.month, d.start.day, 23, 59, 00) d.save() diff --git a/users/templates/users/base.html b/users/templates/users/base.html index a28ee00..89ed206 100644 --- a/users/templates/users/base.html +++ b/users/templates/users/base.html @@ -332,11 +332,13 @@
@@ -344,10 +346,29 @@