本文整理汇总了Python中models.Account类的典型用法代码示例。如果您正苦于以下问题:Python Account类的具体用法?Python Account怎么用?Python Account使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Account类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: save
def save(self, role=1):
user = Account(**self.data)
user.role=role
user.save()
stuusr=Student(stuid=user.username,grade="20"+user.username[0:2])
stuusr.save()
return user
开发者ID:ihciah,项目名称:xk-database,代码行数:7,代码来源:account.py
示例2: saveProfile
def saveProfile(self, request):
"""Update & return user profile."""
sandy = Account(username='Sandy',
userid=123,
email='[email protected]')
sandy_key = sandy.put()
return self._doProfile(request)
开发者ID:bpoole6,项目名称:Uprojects,代码行数:7,代码来源:conference.py
示例3: get_current_account
def get_current_account():
"""Retrieve the Account entity associated with the current user."""
user = endpoints.get_current_user()
if user is None:
return None
email = user.email().lower()
# Try latest recorded auth_email first
accounts = Account.query(Account.auth_email == email).fetch(1)
if len(accounts) > 0:
return accounts[0]
# Try the user's default email next
accounts = Account.query(Account.email == email).fetch(1)
if len(accounts) > 0:
# Store auth email for next time
accounts[0].auth_email = email
accounts[0].put()
return accounts[0]
# Try via the user's Google ID
user_id = _getUserId()
accounts = Account.query(Account.gplus_id == user_id).fetch(1)
if len(accounts) > 0:
# Store auth email for next time
accounts[0].auth_email = email
accounts[0].put()
return accounts[0]
return None
开发者ID:Scarygami,项目名称:gde-app-backend,代码行数:32,代码来源:utils.py
示例4: basicinfo
def basicinfo(user, self):
if user:
url = users.create_logout_url(self.request.uri)
url_linktext = 'Logout'
nickname = user.nickname()
accounts = Account.query(Account.guser == user).fetch()
if len(accounts) == 0: # if no Account object exists for user
new_account = Account(
guser=user,
modules_completed=[],
projects_completed=[]
)
new_account.put()
else:
url = users.create_login_url(self.request.uri)
url_linktext = 'Login'
nickname = None
template_values = {
'title': config.SITE_NAME,
'url': url,
'url_linktext': url_linktext,
'nickname': nickname
}
return template_values
开发者ID:N0tinuse,项目名称:senior_project,代码行数:26,代码来源:functions.py
示例5: add_user
def add_user():
mobile = request.form.get('mobile')
username = request.form.get('username')
password = request.form.get('password')
u = User({'mobile': mobile, 'username': username,
'password': password})
u.upsert()
i = 0
lnames = []
while True:
login_name = request.form.get('accounts[{}][login_name]'.format(i))
login_password = request.form.get(
'accounts[{}][login_password]'.format(i))
if login_name and login_password:
a = Account({'user_id': u._id,
'login_name': login_name,
'login_password': login_password})
a.upsert()
lnames.append(login_name)
i += 1
else:
break
Account.delete_many({'user_id': u._id,
'login_name': {'$nin': lnames}})
return jsonify(status=200)
开发者ID:sopnic,项目名称:ybk,代码行数:25,代码来源:app.py
示例6: process_tx_initial
def process_tx_initial(tx_obj: Tx):
found_relevant_address = False
for out in tx_obj.txs_out:
address = out.bitcoin_address()
if address in all_addresses:
found_relevant_address = True
break
if not found_relevant_address:
logging.info('Found irrelevant tx %s' % hash_to_hex(tx_obj.hash()))
return
tx_hash = tx_obj.hash()
txid = hash_to_hex(tx_hash).decode()
if tx_hash in known_txs:
return
known_txs.add(tx_hash)
txs[tx_hash] = tx_obj.as_hex()
for out in tx_obj.txs_out:
address = out.bitcoin_address()
if address in all_addresses and address is not None:
unprocessed_txs.add(tx_hash)
uid = addr_to_uid[address]
account = Account(uid)
account.txs.add(tx_hash)
account.unconf_minutes.incr(calc_node_minutes(satoshi_amount=out.coin_value, exchange_rate=exchange_rate.get()))
account.add_msg('Found tx for %.08f, %s' % (out.coin_value / COIN, txid))
nodes_recently_updated.append(account.uid)
开发者ID:rnicoll,项目名称:nodeup-xk-io,代码行数:27,代码来源:wallet.py
示例7: create_for_email
def create_for_email(self, email, commit=False):
if self.is_email_registered(email): raise EmailAlreadyInUse(email)
account = Account(email=email)
account.password = self.hasher.generate()
db.session.add(account)
if commit: db.session.commit()
return account
开发者ID:Bindambc,项目名称:segue,代码行数:7,代码来源:services.py
示例8: register_page
def register_page(request):
if request.method == 'POST':
form = FormularzRejestracji(request.POST)
if form.is_valid():
user = User.objects.create_user(
username=form.cleaned_data['username'],
password=form.cleaned_data['password1'],
)
user.save()
acc = Account()
acc.owner = user.username
acc.balance = 0
acc.save()
if form.cleaned_data['log_on']:
user = authenticate(username=form.cleaned_data['username'],password=form.cleaned_data['password1'])
login(request,user)
return HttpResponseRedirect("/blog/")
else:
template = get_template("registration/register_success.html")
variables = RequestContext(request,{'username':form.cleaned_data['username']})
output = template.render(variables)
return HttpResponse(output)
else:
form = FormularzRejestracji()
template = get_template("registration/register.html")
variables = RequestContext(request,{'form':form})
output = template.render(variables)
return HttpResponse(output)
开发者ID:ShadowDancer,项目名称:django,代码行数:29,代码来源:views.py
示例9: get_or_init_account
def get_or_init_account(user):
account = Account.all().filter('user =', user).get()
if account is None:
account = Account(user=user)
account.put()
return account
开发者ID:bmander,项目名称:amaurot,代码行数:7,代码来源:views.py
示例10: test_model_liability
def test_model_liability(self):
"Test liability model"
contact_type = ContactType(name='test')
contact_type.save()
contact = Contact(name='test', contact_type=contact_type)
contact.save()
currency = Currency(code="GBP",
name="Pounds",
symbol="L",
is_default=True)
currency.save()
account = Account(
name='test', owner=contact, balance_currency=currency)
account.save()
obj = Liability(name='test',
source=contact,
target=contact,
account=account,
value=10,
value_currency=currency)
obj.save()
self.assertEquals('test', obj.name)
self.assertNotEquals(obj.id, None)
obj.delete()
开发者ID:tovmeod,项目名称:anaf,代码行数:28,代码来源:tests.py
示例11: test_get_one_returns_entity
def test_get_one_returns_entity(self):
acc = Account(username=self.username, password=self.password, userid=self.userid)
acc.put()
result = Account.get_one()
self.assertEqual(acc, result)
开发者ID:notapresent,项目名称:rutracker_rss,代码行数:7,代码来源:test_models.py
示例12: process_request
def process_request(self, request):
""" This function sets up the user object
Depending on the value of require_login, it
can return None as 'profile'.
"""
#Get Google user_id
google_user = users.get_current_user()
account = None
is_admin = False
logging.info(request.META['HTTP_USER_AGENT'])
if google_user:
#Check if the user already has a site profile
user_id = google_user.user_id()
is_admin = users.is_current_user_admin()
q = Account.all()
q.filter('google_user =', google_user)
account = q.get()
if not account:
nickname = hashlib.md5(google_user.nickname()).hexdigest()[:10]
account = Account(user_id = user_id, nickname = nickname)
account.put()
box = Box(title='My Box')
box.put()
request.user = account
Account.current_user_account = account
request.user_is_admin = is_admin
开发者ID:noio,项目名称:Cardbox,代码行数:28,代码来源:middleware.py
示例13: callback
def callback(request):
oauth_token = request.GET.get('oauth_token')
oauth_verifier = request.GET.get('oauth_verifier')
oauth = OAuth1(settings.CONSUMER_KEY,
client_secret=settings.CONSUMER_SECRET,
resource_owner_key = request.session['key'],
resource_owner_secret = request.session['secret'],
verifier=oauth_verifier)
r = requests.post(TWITTER_BASE + 'oauth/access_token', auth=oauth)
credentials = parse_qs(r.content)
oauth_token = credentials.get('oauth_token')[0]
oauth_token_secret = credentials.get('oauth_token_secret')[0]
user_id = credentials.get('user_id')[0]
screen_name = credentials.get('screen_name')[0]
account = Account(
oauth_token=oauth_token,
oauth_token_secret=oauth_token_secret,
user_id=user_id,
screen_name=screen_name)
account.save()
d = {
'oauth_token': oauth_token,
'oauth_token_secret': oauth_token_secret,
'user_id': user_id,
'screen_name': screen_name,
}
return render_to_response('callback.html', d)
开发者ID:joshma,项目名称:botsandbans,代码行数:29,代码来源:views.py
示例14: verify_mail
def verify_mail():
"""
"""
account_obj = _get_account_by_email(g._db, request.form.get('email', ''))
if account_obj:
raise MainException.ACCOUNT_DUPLICATE
email = request.form.get('email', '')
password = request.form.get('password', '')
password = generate_password_hash(password)
code = random_ascii_string(40)
account_id = Account.gen_id(g._db)
send_verify_email(email, code, email_cb=url_for('account.register_valid', code='', _external=True))
Account.insert_verify_email(g._db, email, code, EmailUsageType.DEVELOPER_VERIFY, account_id)
Account.create_account(g._db, account_id, email, password, 0, RoleType.DEVELOPER)
if 'user' not in session:
session['user'] = {}
session['user']['id'] = account_id
session['user']['email'] = email
session['user']['email_checked'] = 0
session['user']['role'] = RoleType.DEVELOPER
account = {
"id":account_id,
"email":email,
"email_checked":0,
"role":RoleType.DEVELOPER
}
return send_response(account)
开发者ID:jzxyouok,项目名称:kefu_web,代码行数:34,代码来源:api.py
示例15: cw_register
def cw_register(request):
username = request.POST.get('username', '')
password = request.POST.get('password', '')
email = request.POST.get('email', '')
first_name = request.POST.get('first_name', '')
last_name = request.POST.get('last_name', '')
zip_code = request.POST.get('zip', '')
if User.objects.filter(email=email).exists():
return HttpResponseBadRequest(reason='An account exists for this email address.')
if User.objects.filter(username=username).exists():
return HttpResponseBadRequest(reason='Sorry, this username is taken.')
try:
User.objects.create_user(username, email, password)
user = authenticate(username=username, password=password)
user.is_active = False
user.save()
except Exception as e:
return HttpResponseServerError(reason=str(e))
try:
account = Account(user=user, email=email, first_name=first_name, last_name=last_name, zip_code=zip_code)
account.save()
login(request, user)
return HttpResponse()
except Exception as e:
user.delete()
return HttpResponseServerError(reason=str(e))
开发者ID:CiviWikiorg,项目名称:civiwiki.org,代码行数:29,代码来源:views_auth.py
示例16: test_Account_initialization
def test_Account_initialization(self):
try:
Account().put()
self.assertEqual(1,2)
except BadValueError:
pass
try:
Account(username='Captain Blackbeard').put()
self.assertEqual(1,2)
except BadValueError:
pass
try:
Account(email='[email protected]').put()
self.assertEqual(1,2)
except BadValueError:
pass
# test contructor
Account(username='Captain BlackBeard', email='[email protected]').put()
self.assertEqual(1, len(Account.query().fetch(2)))
# test add new user
request = AccountRequest('First Mate', '[email protected]')
Account.add_new_user(request)
self.assertEqual(2, len(Account.query().fetch(3)))
开发者ID:chris-womack,项目名称:Party-Queue,代码行数:25,代码来源:models_test.py
示例17: configure_droplet
def configure_droplet(id, servers=None):
# presumably id was just popped from droplets_to_configure
if servers is None:
servers = get_servers()
account = Account(droplet_to_uid[id])
logging.info('Configuring %s for %s' % (id, account.uid))
droplet = servers[id]
logging.info('Got server %s' % repr(droplet))
ip = droplet['main_ip']
password = droplet['default_password']
droplet_ips[id] = ip
# ssh
try:
print('root', password, ip)
_, stdout, stderr = ssh(ip, 'root', password, create_install_command(account.name.get(), account.client.get(), account.branch.get(), gen_loc(account.dcid.get())))
except Exception as e:
print(e)
logging.error('could not configure server %s due to %s' % (id, repr(e)))
return
print(stdout.read(), stderr.read())
account.add_msg('Started compilation script on server %s -- can take hours as it also bootstraps the blockchain.' % id)
logging.info('Configuring server %s' % id)
account.compile_ts.set(int(time.time()))
droplets_to_configure.remove(id)
currently_compiling.add(id)
开发者ID:XertroV,项目名称:nodeup-xk-io,代码行数:25,代码来源:monitor_nodes.py
示例18: setAccountInfo
def setAccountInfo(info):
e = Account.get_by_id(info['uid'])
if e:
pass
else:
account = Account(id = info['uid'], uid = info['uid'], name = info['display_name'], country = info['country'], link = info['referral_link'],
quota_normal = info['quota_info']['normal'], quota_shared = info['quota_info']['shared'], quota_quota = info['quota_info']['quota'])
account.put()
开发者ID:var,项目名称:dbxcard,代码行数:8,代码来源:dataaccess.py
示例19: new_user
def new_user(type, custom_options={}):
service = Service.query.filter(Service.type == type).one()
account = Account()
account.fill(service)
db.session.add(account)
db.session.commit()
return custom_action("new_user", service, custom_options, account=account)
开发者ID:nickhs,项目名称:hermes,代码行数:8,代码来源:commands.py
示例20: find_existing
def find_existing(cls, email):
hash = hashlib.md5(email).hexdigest()
found = Account.all().filter("hash =", hash).get()
if not found:
found = Account.all().filter("hashes =", hash).get()
if not found:
found = Email.all().filter("email =", email).get()
return found
开发者ID:Mondego,项目名称:pyreco,代码行数:8,代码来源:allPythonContent.py
注:本文中的models.Account类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论