本文整理匯總了Python中accounts.models.Account.email方法的典型用法代碼示例。如果您正苦於以下問題:Python Account.email方法的具體用法?Python Account.email怎麽用?Python Account.email使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類accounts.models.Account
的用法示例。
在下文中一共展示了Account.email方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: registerUser
# 需要導入模塊: from accounts.models import Account [as 別名]
# 或者: from accounts.models.Account import email [as 別名]
def registerUser(request):
rtn_dict = {'success': False, "msg": ""}
login_failed = False
if request.method == 'POST':
try:
new_user = User(username=request.POST.get("username"))
new_user.is_active = True
new_user.password = make_password(request.POST.get('password1'))
new_user.email = request.POST.get('email')
new_user.save()
user = authenticate(username=request.POST.get("username"), password=request.POST.get("password1"))
if user is None:
login_failed = True
status = 401
else:
auth_login(request, user)
account = Account(user=user)
account.email = user.email
account.user_name = user.username
account.save()
rtn_dict['success'] = True
rtn_dict['msg'] = 'Successfully registered new user'
rtn_dict['user'] = new_user.id
rtn_dict['account'] = account.id
return HttpResponse(json.dumps(rtn_dict, cls=DjangoJSONEncoder), content_type="application/json", status=status)
'''
r = R.r
#PUSH NOTIFICATIONS
token = request.POST.get('device_token', None)
if token is not None:
try:
# Strip out any special characters that may be in the token
token = re.sub('<|>|\s', '', token)
registerDevice(user, token)
device_token_key = 'account.{0}.device_tokens.hash'.format(account.id)
token_dict = {str(token): True}
r.hmset(device_token_key, token_dict)
except Exception as e:
print 'Error allowing push notifications {0}'.format(e)
user_key = 'account.{0}.hash'.format(account.id)
r.hmset(user_key, model_to_dict(account))
'''
except Exception as e:
print 'Error registering new user: {0}'.format(e)
logger.info('Error registering new user: {0}'.format(e))
rtn_dict['msg'] = 'Error registering new user: {0}'.format(e)
else:
rtn_dict['msg'] = 'Not POST'
return HttpResponse(json.dumps(rtn_dict, cls=DjangoJSONEncoder), content_type="application/json")
示例2: handle
# 需要導入模塊: from accounts.models import Account [as 別名]
# 或者: from accounts.models.Account import email [as 別名]
def handle(self, *args, **options):
"""
Get JSON response from server, parse it and save to the database
"""
#create url with headers and get response from request
req = urllib2.Request(
"%s?username=%s&api_key=%s" %
(settings.NL_SETTINGS['url'], settings.NL_SETTINGS['username'],
settings.NL_SETTINGS['api_key'])
)
req.add_header('Accept','application/json')
req.add_header('Content-Type','application/json')
opener = urllib2.build_opener()
f = opener.open(req)
server_data = simplejson.load(f)
#data from server contents meta information and objects
for object_data in server_data['objects']:
referral = Referral()
referral.name = object_data['tr_referral']['name']
referral.resource_uri = object_data['tr_referral']['resource_uri']
referral.save()
account = Account()
account.birth_date = object_data['birth_date']
account.city = object_data['city']
account.email = object_data['email']
account.first_name = object_data['first_name']
account.gender = object_data['gender']
account.last_name = object_data['last_name']
account.lead = object_data['lead']
account.last_name = object_data['last_name']
account.phone = object_data['phone']
account.resource_uri = object_data['resource_uri']
account.street_number = object_data['street_number']
account.tr_input_method = object_data['tr_input_method']
account.ip_address = object_data['ip_address']
account.tr_language = object_data['tr_language']
account.utm_campaign = object_data['utm_campaign']
account.utm_medium = object_data['utm_medium']
account.utm_medium = object_data['utm_source']
account.utm_medium = object_data['zipcode']
account.tr_referral = referral
account.save_from_server()
for mailing_list_data in object_data['mailing_lists']:
mailing_list = MailingList()
mailing_list.name = mailing_list_data['name']
mailing_list.resource_uri = mailing_list_data['resource_uri']
mailing_list.save()
account.mailing_lists.add(mailing_list)
account.save_from_server()