annotate accounts/__init__.py @ 645:99f7917702ca

Fix 081a88b3bfc8, javascript resize of forum images. Commit 081a88b3bfc8 broke those pages that loaded forums.js but did not load the imagesLoaded jQuery extension. Now we have arranged it so that only the forums topic view loads imagesLoaded and put the resizing javascript inline.
author Brian Neal <bgneal@gmail.com>
date Mon, 11 Mar 2013 15:30:25 -0500
parents ee87ea74d46b
children 988782c6ce6c
rev   line source
bgneal@347 1 import datetime
bgneal@347 2 import logging
bgneal@347 3
bgneal@347 4 from django.contrib.auth.models import User
bgneal@347 5
bgneal@347 6
bgneal@347 7 def create_new_user(pending_user, ip=None, admin_activation=False):
bgneal@347 8 """
bgneal@347 9 This function contains the code to create a new user from a
bgneal@347 10 pending user. The pending user is deleted and the new user
bgneal@347 11 is saved. A log message is produced. If admin_activation is false,
bgneal@347 12 then ip should be the user's IP they confirmed from, if available.
bgneal@347 13
bgneal@347 14 """
bgneal@347 15 new_user = User()
bgneal@347 16
bgneal@347 17 new_user.username = pending_user.username
bgneal@347 18 new_user.first_name = ''
bgneal@347 19 new_user.last_name = ''
bgneal@347 20 new_user.email = pending_user.email
bgneal@347 21 new_user.password = pending_user.password # already been hashed
bgneal@347 22 new_user.is_staff = False
bgneal@347 23 new_user.is_active = True
bgneal@347 24 new_user.is_superuser = False
bgneal@347 25 new_user.last_login = datetime.datetime.now()
bgneal@347 26 new_user.date_joined = new_user.last_login
bgneal@347 27
bgneal@347 28 new_user.save()
bgneal@347 29 pending_user.delete()
bgneal@347 30
bgneal@347 31 if admin_activation:
bgneal@347 32 msg = 'Accounts registration confirmed by ADMIN for %s' % new_user.username
bgneal@347 33 else:
bgneal@347 34 msg = 'Accounts registration confirmed by USER for %s from %s' % (
bgneal@347 35 new_user.username, ip)
bgneal@347 36
bgneal@347 37 logging.info(msg)