本文整理汇总了Python中forum.models.User.last_seen方法的典型用法代码示例。如果您正苦于以下问题:Python User.last_seen方法的具体用法?Python User.last_seen怎么用?Python User.last_seen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类forum.models.User
的用法示例。
在下文中一共展示了User.last_seen方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: import_users
# 需要导入模块: from forum.models import User [as 别名]
# 或者: from forum.models.User import last_seen [as 别名]
def import_users(self, users):
pkey_map = {}
doc = dom.parse(users)
rows = doc.getElementsByTagName('row')
unknown_count = 0
added_names = []
for row in rows:
values = self.row_to_dic(row)
username = values.get('displayname',
values.get('realname',
values.get('email', None)))
if username is None:
unknown_count += 1
username = 'Unknown User %d' % unknown_count
if username in added_names:
cnt = 1
new_username = "%s %d" % (username, cnt)
while new_username in added_names:
cnt += 1
new_username = "%s %d" % (username, cnt)
username = new_username
added_names.append(username)
user = User(username=username, email=values.get('email', ''))
user.reputation = values['reputation']
user.last_seen = self.from_sx_time(values['lastaccessdate'])
user.real_name = values.get('realname', '')
user.about = values.get('aboutme', '')
user.website = values.get('websiteurl', '')
user.date_of_birth = self.from_sx_time(values.get('birthday', None))
user.location = values.get('location', '')
user.is_active = True
user.email_isvalid = True
if int(values['usertypeid']) == 5:
user.is_superuser = True
if int(values['usertypeid']) == 5:
user.is_staff = True
user.save()
pkey_map[values['id']] = user
return users
示例2: update_forum_user
# 需要导入模块: from forum.models import User [as 别名]
# 或者: from forum.models.User import last_seen [as 别名]
def update_forum_user(request):
""" Create or Update Forum User model """
try:
# Customise User Model
# username = request.user.username.split('@')[0]
user = User.objects.get(user_ptr_id=request.user.id)
user.user_ptr = request.user
user.save()
except ObjectDoesNotExist:
obj = User()
obj.user_ptr = request.user
obj.email_isvalid = True
obj.last_seen = request.user.last_login
obj.username = request.user.username if '@' not in request.user.username else request.user.username.split('@')[0]
obj.real_name = "%s %s" % (request.user.first_name, request.user.last_name)
# obj.is_active = request.user.is_active
obj.email = request.user.email
obj.profile_image_url = request.session['profile_image'] if 'profile_image' in request.session else ''
obj.save()