本文整理汇总了Python中weasyl.profile.select_relation函数的典型用法代码示例。如果您正苦于以下问题:Python select_relation函数的具体用法?Python select_relation怎么用?Python select_relation使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了select_relation函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_insert_ignores
def test_insert_ignores(self):
user1 = db_utils.create_user()
user2 = db_utils.create_user()
# user1 ignores user2
db_utils.create_ignoreuser(user1, user2)
# attempts to follow in either direction throw a WeasylError
self.assertRaises(WeasylError, followuser.insert, user1, user2)
self.assertRaises(WeasylError, followuser.insert, user2, user1)
self.assertFalse(profile.select_relation(user1, user2)["follow"])
self.assertFalse(profile.select_relation(user2, user1)["follower"])
开发者ID:Syfaro,项目名称:weasyl,代码行数:11,代码来源:test_followuser.py
示例2: test_mutual_follow
def test_mutual_follow(self):
user1 = db_utils.create_user()
user2 = db_utils.create_user()
# user1 watches user2
followuser.insert(user1, user2)
# user2 watches user1
followuser.insert(user2, user1)
self.assertTrue(profile.select_relation(user1, user2)["follow"])
self.assertTrue(profile.select_relation(user2, user1)["follower"])
self.assertTrue(profile.select_relation(user2, user1)["follow"])
self.assertTrue(profile.select_relation(user1, user2)["follower"])
开发者ID:Syfaro,项目名称:weasyl,代码行数:12,代码来源:test_followuser.py
示例3: test_insert_s_only
def test_insert_s_only(self, followuser_insert, followuser_remove, get_config):
user1 = db_utils.create_user()
user2 = db_utils.create_user()
get_config.side_effect = lambda userid: "s"
# user1 watches user2
followuser.insert(user1, user2)
self.assertTrue(profile.select_relation(user1, user2)["follow"])
self.assertTrue(profile.select_relation(user2, user1)["follower"])
self.assertEqual(1, d.sessionmaker().query(orm.Follow).count())
followuser_remove.assert_called_once_with(user1, user2)
followuser_insert.assert_called_once_with(user1, user2)
self.assertEqual("s", d.sessionmaker().query(orm.Follow).first().settings)
开发者ID:Syfaro,项目名称:weasyl,代码行数:13,代码来源:test_followuser.py
示例4: GET
def GET(self, name=None):
form = web.input(userid="")
otherid = profile.resolve(self.user_id, define.get_int(form.userid), name)
if not otherid:
raise WeasylError("userRecordMissing")
userprofile = profile.select_profile(otherid, images=True, viewer=self.user_id)
has_fullname = userprofile['full_name'] is not None and userprofile['full_name'].strip() != ''
page_title = u"%s's staff notes" % (userprofile['full_name'] if has_fullname else userprofile['username'],)
page = define.common_page_start(self.user_id, title=page_title)
userinfo = profile.select_userinfo(otherid, config=userprofile['config'])
reportstats = profile.select_report_stats(otherid)
userinfo['reportstats'] = reportstats
userinfo['reporttotal'] = sum(reportstats.values())
page.append(define.render(template.user_shouts, [
# Profile information
userprofile,
# User information
userinfo,
# Relationship
profile.select_relation(self.user_id, otherid),
# Myself
profile.select_myself(self.user_id),
# Comments
shout.select(self.user_id, ownerid=otherid, staffnotes=True),
# Feature
"staffnotes",
]))
return define.common_page_end(self.user_id, page, now=time.time())
开发者ID:0x15,项目名称:weasyl,代码行数:32,代码来源:profile.py
示例5: followed_
def followed_(request):
cachename = "user/followed.html"
form = request.web_input(userid="", name="", backid=None, nextid=None)
form.name = request.matchdict.get('name', form.name)
form.userid = define.get_int(form.userid)
otherid = profile.resolve(request.userid, form.userid, form.name)
if not otherid:
raise WeasylError("userRecordMissing")
elif not request.userid and "h" in define.get_config(otherid):
return Response(define.errorpage(request.userid, errorcode.no_guest_access))
userprofile = profile.select_profile(otherid, images=True, viewer=request.userid)
return Response(define.webpage(request.userid, cachename, [
# Profile information
userprofile,
# User information
profile.select_userinfo(otherid, config=userprofile['config']),
# Relationship
profile.select_relation(request.userid, otherid),
# Followed
followuser.select_followed(request.userid, otherid, limit=44,
backid=define.get_int(form.backid), nextid=define.get_int(form.nextid)),
]))
开发者ID:Syfaro,项目名称:weasyl,代码行数:27,代码来源:profile.py
示例6: staffnotes_
def staffnotes_(request):
form = request.web_input(userid="")
otherid = profile.resolve(request.userid, define.get_int(form.userid), request.matchdict.get('name', None))
if not otherid:
raise WeasylError("userRecordMissing")
userprofile = profile.select_profile(otherid, images=True, viewer=request.userid)
has_fullname = userprofile['full_name'] is not None and userprofile['full_name'].strip() != ''
page_title = u"%s's staff notes" % (userprofile['full_name'] if has_fullname else userprofile['username'],)
page = define.common_page_start(request.userid, title=page_title)
userinfo = profile.select_userinfo(otherid, config=userprofile['config'])
reportstats = profile.select_report_stats(otherid)
userinfo['reportstats'] = reportstats
userinfo['reporttotal'] = sum(reportstats.values())
page.append(define.render('user/shouts.html', [
# Profile information
userprofile,
# User information
userinfo,
# Relationship
profile.select_relation(request.userid, otherid),
# Myself
profile.select_myself(request.userid),
# Comments
shout.select(request.userid, ownerid=otherid, staffnotes=True),
# Feature
"staffnotes",
]))
return Response(define.common_page_end(request.userid, page))
开发者ID:Syfaro,项目名称:weasyl,代码行数:32,代码来源:profile.py
示例7: shouts_
def shouts_(request):
form = request.web_input(userid="", name="", backid=None, nextid=None)
form.name = request.matchdict.get('name', form.name)
form.userid = define.get_int(form.userid)
otherid = profile.resolve(request.userid, form.userid, form.name)
if not otherid:
raise WeasylError("userRecordMissing")
elif not request.userid and "h" in define.get_config(otherid):
return Response(define.errorpage(request.userid, errorcode.no_guest_access))
userprofile = profile.select_profile(otherid, images=True, viewer=request.userid)
has_fullname = userprofile['full_name'] is not None and userprofile['full_name'].strip() != ''
page_title = u"%s's shouts" % (userprofile['full_name'] if has_fullname else userprofile['username'],)
page = define.common_page_start(request.userid, title=page_title)
page.append(define.render('user/shouts.html', [
# Profile information
userprofile,
# User information
profile.select_userinfo(otherid, config=userprofile['config']),
# Relationship
profile.select_relation(request.userid, otherid),
# Myself
profile.select_myself(request.userid),
# Comments
shout.select(request.userid, ownerid=otherid),
# Feature
"shouts",
]))
return Response(define.common_page_end(request.userid, page))
开发者ID:Syfaro,项目名称:weasyl,代码行数:33,代码来源:profile.py
示例8: test_update
def test_update(self):
user1 = db_utils.create_user()
user2 = db_utils.create_user()
# user1 watches user2
followuser.insert(user1, user2)
# user1 updates watch settings
followuser.update(user1, user2, followuser.WatchSettings.from_code("cf"))
self.assertEqual("cf", d.sessionmaker().query(orm.Follow).first().settings)
# again
followuser.update(user1, user2, followuser.WatchSettings.from_code("st"))
self.assertTrue(profile.select_relation(user1, user2)["follow"])
self.assertTrue(profile.select_relation(user2, user1)["follower"])
self.assertEqual("st", d.sessionmaker().query(orm.Follow).first().settings)
开发者ID:Syfaro,项目名称:weasyl,代码行数:16,代码来源:test_followuser.py
示例9: test_remove
def test_remove(self, followuser_remove):
user1 = db_utils.create_user()
user2 = db_utils.create_user()
# user1 watches user2
followuser.insert(user1, user2)
self.assertEqual(1, d.sessionmaker().query(orm.Follow).count())
followuser_remove.reset_mock()
# user1 changed their mind
followuser.remove(user1, user2)
self.assertFalse(profile.select_relation(user1, user2)["follow"])
self.assertFalse(profile.select_relation(user2, user1)["follower"])
self.assertEqual(0, d.sessionmaker().query(orm.Follow).count())
followuser_remove.assert_called_once_with(user1, user2)
开发者ID:Syfaro,项目名称:weasyl,代码行数:16,代码来源:test_followuser.py
示例10: test_insert
def test_insert(self, followuser_insert, followuser_remove, get_config):
user1 = db_utils.create_user()
user2 = db_utils.create_user()
get_config.side_effect = lambda userid: "scftj"
self.assertFalse(profile.select_relation(user1, user2)["follow"])
# user1 watches user2
followuser.insert(user1, user2)
self.assertEqual(1, d.sessionmaker().query(orm.Follow).count())
# profile.select_relation should return u1 follows u2, u2 is follower of u1, u1 is not
# follower of u2
self.assertTrue(profile.select_relation(user1, user2)["follow"])
self.assertTrue(profile.select_relation(user2, user1)["follower"])
self.assertFalse(profile.select_relation(user1, user2)["follower"])
followuser_remove.assert_called_once_with(user1, user2)
followuser_insert.assert_called_once_with(user1, user2)
self.assertEqual("cfjst", d.sessionmaker().query(orm.Follow).first().settings)
开发者ID:Syfaro,项目名称:weasyl,代码行数:17,代码来源:test_followuser.py
示例11: collections_
def collections_(request):
form = request.web_input(userid="", name="", backid=None, nextid=None,
folderid=None)
form.name = request.matchdict.get('name', form.name)
form.userid = define.get_int(form.userid)
config = define.get_config(request.userid)
rating = define.get_rating(request.userid)
otherid = profile.resolve(request.userid, form.userid, form.name)
if not otherid:
raise WeasylError("userRecordMissing")
elif not request.userid and "h" in define.get_config(otherid):
return Response(define.errorpage(request.userid, errorcode.no_guest_access))
userprofile = profile.select_profile(otherid, images=True, viewer=request.userid)
has_fullname = userprofile['full_name'] is not None and userprofile['full_name'].strip() != ''
page_title = u"%s's collections" % (userprofile['full_name'] if has_fullname else userprofile['username'],)
page = define.common_page_start(request.userid, title=page_title)
url_format = "/collections?userid={userid}&%s".format(userid=userprofile['userid'])
result = pagination.PaginatedResult(
collection.select_list, collection.select_count, 'submitid', url_format, request.userid, rating, 66,
otherid=otherid, backid=define.get_int(form.backid), nextid=define.get_int(form.nextid), config=config)
page.append(define.render('user/collections.html', [
# Profile information
userprofile,
# User information
profile.select_userinfo(otherid, config=userprofile['config']),
# Relationship
profile.select_relation(request.userid, otherid),
# Collections
result,
]))
return Response(define.common_page_end(request.userid, page))
开发者ID:Syfaro,项目名称:weasyl,代码行数:37,代码来源:profile.py
示例12: profile_
def profile_(request):
form = request.web_input(userid="", name="")
form.name = request.matchdict.get('name', form.name)
form.userid = define.get_int(form.userid)
config = define.get_config(request.userid)
rating = define.get_rating(request.userid)
otherid = profile.resolve(request.userid, form.userid, form.name)
if not otherid:
raise WeasylError("userRecordMissing")
userprofile = profile.select_profile(otherid, images=True, viewer=request.userid)
extras = {
"canonical_url": "/~" + define.get_sysname(form.name)
}
if not request.userid:
# Only generate the Twitter/OGP meta headers if not authenticated (the UA viewing is likely automated).
twit_card = profile.twitter_card(otherid)
if define.user_is_twitterbot():
extras['twitter_card'] = twit_card
# The "og:" prefix is specified in page_start.html, and og:image is required by the OGP spec, so something must be in there.
extras['ogp'] = {
'title': twit_card['title'],
'site_name': "Weasyl",
'type': "website",
'url': twit_card['url'],
'description': twit_card['description'],
'image': twit_card['image:src'] if 'image:src' in twit_card else define.cdnify_url('/static/images/logo-mark-light.svg'),
}
if not request.userid and "h" in userprofile['config']:
return Response(define.errorpage(
request.userid,
"You cannot view this page because the owner does not allow guests to view their profile.",
**extras))
has_fullname = userprofile['full_name'] is not None and userprofile['full_name'].strip() != ''
extras['title'] = u"%s's profile" % (userprofile['full_name'] if has_fullname else userprofile['username'],)
page = define.common_page_start(request.userid, **extras)
define.common_view_content(request.userid, otherid, "profile")
if 'O' in userprofile['config']:
submissions = collection.select_list(
request.userid, rating, 11, otherid=otherid, options=["cover"], config=config)
more_submissions = 'collections'
featured = None
elif 'A' in userprofile['config']:
submissions = character.select_list(
request.userid, rating, 11, otherid=otherid, options=["cover"], config=config)
more_submissions = 'characters'
featured = None
else:
submissions = submission.select_list(
request.userid, rating, 11, otherid=otherid, options=["cover"], config=config,
profile_page_filter=True)
more_submissions = 'submissions'
featured = submission.select_featured(request.userid, otherid, rating)
if userprofile['show_favorites_bar']:
favorites = favorite.select_submit(request.userid, rating, 11, otherid=otherid, config=config)
else:
favorites = None
statistics, show_statistics = profile.select_statistics(otherid)
page.append(define.render('user/profile.html', [
# Profile information
userprofile,
# User information
profile.select_userinfo(otherid, config=userprofile['config']),
macro.SOCIAL_SITES,
# Relationship
profile.select_relation(request.userid, otherid),
# Myself
profile.select_myself(request.userid),
# Recent submissions
submissions, more_submissions,
favorites,
featured,
# Folders preview
folder.select_preview(request.userid, otherid, rating, 3),
# Latest journal
journal.select_latest(request.userid, rating, otherid=otherid, config=config),
# Recent shouts
shout.select(request.userid, ownerid=otherid, limit=8),
# Statistics information
statistics,
show_statistics,
# Commission information
commishinfo.select_list(otherid),
# Friends
lambda: frienduser.has_friends(otherid),
]))
return Response(define.common_page_end(request.userid, page))
开发者ID:Weasyl,项目名称:weasyl,代码行数:99,代码来源:profile.py
示例13: favorites_
def favorites_(request):
def _FEATURE(target):
if target == "submit":
return 10
elif target == "char":
return 20
elif target == "journal":
return 30
else:
return 0
form = request.web_input(userid="", name="", feature="", backid=None, nextid=None)
form.name = request.matchdict.get('name', form.name)
form.userid = define.get_int(form.userid)
config = define.get_config(request.userid)
rating = define.get_rating(request.userid)
otherid = profile.resolve(request.userid, form.userid, form.name)
# TODO(hyena): Why aren't more of these WeasylErrors?
if not otherid:
raise WeasylError("userRecordMissing")
elif not request.userid and "h" in define.get_config(otherid):
return Response(define.errorpage(request.userid, errorcode.no_guest_access))
elif request.userid != otherid and 'v' in define.get_config(otherid):
return Response(define.errorpage(
request.userid,
"You cannot view this page because the owner does not allow anyone to see their favorites."))
userprofile = profile.select_profile(otherid, images=True, viewer=request.userid)
has_fullname = userprofile['full_name'] is not None and userprofile['full_name'].strip() != ''
page_title = u"%s's favorites" % (userprofile['full_name'] if has_fullname else userprofile['username'],)
page = define.common_page_start(request.userid, title=page_title)
if form.feature:
nextid = define.get_int(form.nextid)
backid = define.get_int(form.backid)
url_format = (
"/favorites?userid={userid}&feature={feature}&%s".format(userid=userprofile['userid'], feature=form.feature))
id_field = form.feature + "id"
count_function = None
if form.feature == "submit":
select_function = favorite.select_submit
count_function = favorite.select_submit_count
elif form.feature == "char":
select_function = favorite.select_char
elif form.feature == "journal":
select_function = favorite.select_journal
else:
raise httpexceptions.HTTPNotFound()
faves = pagination.PaginatedResult(
select_function, count_function,
id_field, url_format, request.userid, rating, 60,
otherid=otherid, backid=backid, nextid=nextid, config=config)
else:
faves = {
"submit": favorite.select_submit(request.userid, rating, 22, otherid=otherid, config=config),
"char": favorite.select_char(request.userid, rating, 22, otherid=otherid, config=config),
"journal": favorite.select_journal(request.userid, rating, 22, otherid=otherid, config=config),
}
page.append(define.render('user/favorites.html', [
# Profile information
userprofile,
# User information
profile.select_userinfo(otherid, config=userprofile['config']),
# Relationship
profile.select_relation(request.userid, otherid),
# Feature
form.feature,
# Favorites
faves,
]))
return Response(define.common_page_end(request.userid, page))
开发者ID:Syfaro,项目名称:weasyl,代码行数:77,代码来源:profile.py
示例14: GET
def GET(self, login):
userid = self.user_id
otherid = profile.resolve_by_login(login)
user = profile.select_profile(otherid)
rating = d.get_rating(userid)
u_config = d.get_config(userid)
o_config = user.pop('config')
o_settings = user.pop('settings')
if not otherid and "h" in o_config:
return json.dumps({
"error": {
"code": 200,
"text": "Profile hidden from unlogged users."
}})
user.pop('userid', None)
user.pop('commish_slots', None)
user['created_at'] = d.iso8601(user.pop('unixtime'))
user['media'] = api.tidy_all_media(user.pop('user_media'))
user['login_name'] = d.get_sysname(user['username'])
user['profile_text'] = markdown(user['profile_text'])
folders = folder.select_list(otherid, "api/all")
if folders:
old_folders = folders
folders = list()
for fldr in (i for i in old_folders if 'parentid' not in i):
newfolder = {
"folder_id": fldr['folderid'],
"title": fldr['title']
}
if fldr['haschildren']:
subfolders = list()
for sub in (i for i in old_folders if 'parentid' in i and i['parentid'] == fldr['folderid']):
subfolders.append({
"folder_id": sub['folderid'],
"title": sub['title']
})
newfolder['subfolders'] = subfolders
folders.append(newfolder)
user['folders'] = folders
commissions = {
"details": None,
"price_classes": None,
"commissions": self.convert_commission_setting(o_settings[0]),
"trades": self.convert_commission_setting(o_settings[1]),
"requests": self.convert_commission_setting(o_settings[2])
}
commission_list = commishinfo.select_list(otherid)
if commission_list:
commissions['details'] = commission_list['content']
if len(commission_list['class']) > 0:
classes = list()
for cclass in commission_list['class']:
commission_class = {
"title": cclass['title']
}
if len(commission_list['price']) > 0:
prices = list()
for cprice in (i for i in commission_list['price'] if i['classid'] == cclass['classid']):
if 'a' in cprice['settings']:
ptype = 'additional'
else:
ptype = 'base'
price = {
"title": cprice['title'],
"price_min": self.convert_commission_price(cprice['amount_min'], cprice['settings']),
"price_max": self.convert_commission_price(cprice['amount_min'], cprice['settings']),
'price_type': ptype
}
prices.append(price)
commission_class['prices'] = prices
classes.append(commission_class)
commissions['price_classes'] = classes
user['commission_info'] = commissions
user['relationship'] = profile.select_relation(userid, otherid) if userid else None
if 'O' in o_config:
submissions = collection.select_list(
userid, rating, 11, otherid=otherid, options=["cover"], config=u_config)
more_submissions = 'collections'
featured = None
elif 'A' in o_config:
submissions = character.select_list(
userid, rating, 11, otherid=otherid, options=["cover"], config=u_config)
#.........这里部分代码省略.........
开发者ID:0x15,项目名称:weasyl,代码行数:101,代码来源:api.py
注:本文中的weasyl.profile.select_relation函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论