0.12.24 timezone in chat messages
This commit is contained in:
@@ -1,5 +1,19 @@
|
||||
from django.template.loader import render_to_string
|
||||
|
||||
|
||||
def get_user_timezone_Dict(user, request=None):
|
||||
tz = None
|
||||
if request:
|
||||
tz = request.COOKIES.get("user_tz")
|
||||
if not tz and user.is_authenticated:
|
||||
tz = user.user_profile.get_timezone()
|
||||
|
||||
if not tz:
|
||||
from django.conf import settings
|
||||
tz = settings.TIME_ZONE
|
||||
|
||||
return {'user_tz': tz}
|
||||
|
||||
def get_dashboard_page_content_html(request):
|
||||
|
||||
from ChatServiceApp.funcs import get_unanswered_msgs_count_for_user
|
||||
|
||||
@@ -232,6 +232,7 @@ def chats_ajax(request):
|
||||
'receivers': receivers,
|
||||
# 'messages': cur_chat_msgs
|
||||
}
|
||||
Dict.update(get_user_timezone_Dict(request.user, request=request))
|
||||
|
||||
html = render_to_string('blocks/profile/b_chats.html', Dict, request=request)
|
||||
return JsonResponse({'html': html}, status=200)
|
||||
|
||||
@@ -53,6 +53,12 @@ class UserProfile(BaseModel):
|
||||
|
||||
mailing_on = models.BooleanField(default=False, verbose_name=_('Рассылка'))
|
||||
|
||||
def get_timezone(self):
|
||||
tz = None
|
||||
if 'user_timezone' in self.json_data:
|
||||
tz = self.json_data['user_timezone']
|
||||
return tz
|
||||
|
||||
def save_user_alerts_to_session(self, request):
|
||||
for_save_to_session = self.get_node_by_name('for_save_to_session')
|
||||
if for_save_to_session:
|
||||
|
||||
Reference in New Issue
Block a user