The users panel was just showing a red Error indicator on 8.0.0 pro in my system which has USE_TZ and TIMEZONE set in seahub_settings.py.
In seahub.log I saw a traceback ending with:
File "/opt/seafile/seafile-pro-server-8.0.0/seahub/seahub/api2/endpoints/admin/users.py", line 98, in get_user
_last_access_time
return datetime_to_isoformat_timestr(sorted(last_access_time_list)[-1])
TypeError: can’t compare offset-naive and offset-aware datetimes
Here is the patch I made to seahub/seahub/api2/endpoints/admin/users.py near line 98. With this patch, the users are displayed correctly. I am not sure if this is the best solution, but it got my client moving.
if not last_access_time_list:
return ''
else:
# 13.0.8.7.0-t8 jimays make all times timezone-aware since last_accessed time has tz with TZ set in conf
# gratitude https://stackoverflow.com/questions/5802108/how-to-check-if-a-datetime-object-is-localized-with-pytz
# gratitude https://stackoverflow.com/questions/11480042/python-3-turn-range-to-a-list
# f=open('/tmp/tz', 'a')
for i in list(range(0, len(last_access_time_list))):
t = last_access_time_list[i]
# f.write("t: %s\n" % str(t))
if t.tzinfo is None or t.tzinfo.utcoffset(t) is None:
# gratitude seahub/thirdpart/constance/admin.py
from django import conf
from django.utils import timezone
from datetime import datetime
if conf.settings.USE_TZ and isinstance(t, datetime) and not timezone.is_aware(t):
last_access_time_list[i] = timezone.make_aware(t)
# f.write("done\n")
# f.close()
return datetime_to_isoformat_timestr(sorted(last_access_time_list)[-1])
Note this issue is similar to what happened during Android client login to the community edition 8.0.3 where I made a similar patch in issue Seafile client doesn't connect to server