本文整理汇总了Python中models.Profile.all方法的典型用法代码示例。如果您正苦于以下问题:Python Profile.all方法的具体用法?Python Profile.all怎么用?Python Profile.all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Profile
的用法示例。
在下文中一共展示了Profile.all方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from models import Profile [as 别名]
# 或者: from models.Profile import all [as 别名]
def post(self):
form = ProfileForm(data=self.request.POST)
if form.is_valid():
user = users.get_current_user()
username = self.request.get('username')
#profile = Profile.all().filter('user !=', user).filter('username =', username).get()
profile = Profile.all().filter('username =', username).get()
if profile and profile.user != user:
errors = { 'username_exists': ['%s is already exists'] }
profile = { 'username': username }
template_vars = { 'errors': errors, 'profile': profile }
self.render_response('profile/profile_edit.html', template_vars)
else:
profile = Profile.all().filter('user =', user).get()
if profile:
profile.username = username
else:
profile = Profile(user = user,
username = username,
)
profile.put()
self.redirect('/profile')
else:
template_vars = { 'form': form }
self.render_response('profile/profile_edit.html', template_vars)
示例2: get
# 需要导入模块: from models import Profile [as 别名]
# 或者: from models.Profile import all [as 别名]
def get(self):
user = users.get_current_user()
if user:
profile = Profile.all().filter('user =', user).get()
template_vars = { 'profile': profile }
self.render_response('profile/profile_detail.html', template_vars)
else:
self.redirect('/')
示例3: get
# 需要导入模块: from models import Profile [as 别名]
# 或者: from models.Profile import all [as 别名]
def get(self):
self.validate()
profiles_query = Profile.all()
profiles_query.order('last_name')
self.values['profiles'] = profiles_query.fetch(100)
# TODO: Figure out paging
self.output('user_list.html')
示例4: post
# 需要导入模块: from models import Profile [as 别名]
# 或者: from models.Profile import all [as 别名]
def post(self, *args):
name = self.request.get('name')
prof = Profile.all().filter('user = ',users.get_current_user()).get()
if not prof:
prof = Profile(name=name)
else:
prof.name = name
avatar = self.request.get('avatar')
avatar = images.resize(avatar,32,32)
prof.avatar = db.Blob(avatar)
prof.put()
self.redirect('/')
示例5: GET
# 需要导入模块: from models import Profile [as 别名]
# 或者: from models.Profile import all [as 别名]
def GET(self, name=None):
if auth.is_admin():
found_name = False
if name:
q = Profile.all().filter('uid =', name).get()
if q:
found_name = True
return self.individual_profile(q)
if not found_name:
results = dict()
for profile in db.GqlQuery("SELECT * FROM Profile"):
results[profile.uid] = profile
for l in db.GqlQuery("SELECT * FROM LastOnline"):
if l.uid in results:
results[l.uid].last_online = l.last_online
return super(self.__class__, self).GET({'students' : results})
else:
return "Access Denied!"
示例6: prompt
# 需要导入模块: from models import Profile [as 别名]
# 或者: from models.Profile import all [as 别名]
def prompt():
sent_count = 0
for profile in Profile.all():
try:
if profile.prompt_now:
mail.send_mail(sender=ADMIN_EMAIL,
to=profile.user.email(),
subject="[workjournal] Daily prompt",
body="""
Hello!
Take a moment to visit this URL and jot down what you did today:
{0}?edit
Thanks, have a good day!
""".format(request.url_root))
sent_count += 1
except Exception, e:
logging.error(str(e))
示例7: get
# 需要导入模块: from models import Profile [as 别名]
# 或者: from models.Profile import all [as 别名]
def get(self):
user = users.get_current_user()
profile = Profile.all().filter('owner = ', user).get()
td = default_template_data()
td["credentials_selected"] = True
td["consumer_key"] = settings.CONSUMER_KEY
td["consumer_secret"] = settings.CONSUMER_SECRET
if os.environ['SERVER_SOFTWARE'].startswith('Development'):
td["authorized"] = True
td["oauth_token"] = "ACCESS_TOKEN"
td["oauth_token_secret"] = "ACCESS_TOKEN_SECRET"
elif profile:
td["authorized"] = True
td["oauth_token"] = profile.token
td["oauth_token_secret"] = profile.secret
else:
td["authorized"] = False
self.render(td, 'admin/credentials.html')
return
示例8: digest
# 需要导入模块: from models import Profile [as 别名]
# 或者: from models.Profile import all [as 别名]
def digest():
sent_count = 0
for profile in Profile.all():
try:
if profile.digest_now:
send_digest = False
body = "Hello! Here's what your team is up to:\n\n"
for p in profile.following:
entry = p.entry_yesterday
if entry:
send_digest = True
body += "## {0}\n\n{1}\n\n".format(
p.username, entry.summary)
if entry.details:
body += "More details: {0}{1}\n\n".format(
request.url_root, p.username)
if send_digest:
mail.send_mail(sender=ADMIN_EMAIL,
to=profile.user.email(),
subject="[workjournal] Daily digest",
body=body)
sent_count += 1
except Exception, e:
logging.error(str(e))
示例9: get
# 需要导入模块: from models import Profile [as 别名]
# 或者: from models.Profile import all [as 别名]
def get(self):
consumer_key = 'anonymous'
consumer_secret = 'anonymous'
td = default_template_data()
td["logged_in"] = False
td["credentials_selected"] = True
td["consumer_key"] = consumer_key
user = users.get_current_user()
if user:
td["logged_in"] = users.is_current_user_admin()
profile = Profile.all().filter('owner = ', user).get()
if profile:
td["user_is_authorized"] = True
td["profile"] = profile
else:
host = self.request.headers.get('host', 'nohost')
callback = 'http://%s/documentation/verify' % host
request_token_url = 'https://%s/_ah/OAuthGetRequestToken?oauth_callback=%s' % (host, callback)
authorize_url = 'https://%s/_ah/OAuthAuthorizeToken' % host
consumer = oauth.Consumer(consumer_key, consumer_secret)
client = oauth.Client(consumer)
# Step 1: Get a request token. This is a temporary token that is used for
# having the user authorize an access token and to sign the request to obtain
# said access token.
td["user_is_authorized"] = False
if "localhost" not in host:
resp, content = client.request(request_token_url, "GET")
if resp['status'] == '200':
request_token = dict(cgi.parse_qsl(content))
authr = AuthRequest.all().filter("owner =", user).get()
if authr:
authr.request_secret = request_token['oauth_token_secret']
else:
authr = AuthRequest(owner=user,
request_secret=request_token['oauth_token_secret'])
authr.put()
td["oauth_url"] = "%s?oauth_token=%s" % (authorize_url, request_token['oauth_token'])
self.render(td, 'credentials.html')
示例10: get
# 需要导入模块: from models import Profile [as 别名]
# 或者: from models.Profile import all [as 别名]
def get(self):
"""Simply returns a Response object with an enigmatic salutation."""
c = Profile.all().count()
return self.render_response('index.html', form=self.form, c=c)
示例11: getProfile
# 需要导入模块: from models import Profile [as 别名]
# 或者: from models.Profile import all [as 别名]
def getProfile(self, user):
return Profile.all().filter('user = ', user).get()
示例12: getCurrentUserName
# 需要导入模块: from models import Profile [as 别名]
# 或者: from models.Profile import all [as 别名]
def getCurrentUserName(self):
user = users.get_current_user()
prof = Profile.all().filter('user = ', user).get()
if prof:
return prof.name
return None
示例13: getUserNameAndID
# 需要导入模块: from models import Profile [as 别名]
# 或者: from models.Profile import all [as 别名]
def getUserNameAndID(self,user):
prof = Profile.all().filter('user = ', user).get()
if prof:
return prof.name, prof.key()
return None, None
示例14: get
# 需要导入模块: from models import Profile [as 别名]
# 或者: from models.Profile import all [as 别名]
def get(self):
prof = Profile.all().filter('user = ',users.get_current_user()).get()
self.templ_vals.update({
'profile':prof
})
self.render_to_response('edit_profile.html',self.templ_vals)