Exemplo n.º 1
0
def get_webapp_id_for(username):
    """
	获取user对应的webapp id
	"""
    user = User.get(username=username)
    profile = UserProfile.get(user=user)
    return profile.webapp_id
Exemplo n.º 2
0
def create_request(args):
    request = FakeRequest(args.get('full_path', 'unknown'))
    request.GET = args['GET']
    request.COOKIES = args['COOKIES']
    request.method = args['method']
    request.POST = args['POST']
    request.META = dict()

    data = args['data']
    app_id = data['app_id']
    user_id = data['user_id']
    webppuser_id = data['webppuser_id']
    user_profile_id = data['user_profile_id']
    social_account_id = data['social_account_id']
    member_id = data['member_id']
    request.app = None
    request.user = User.get(id=user_id) if user_id != -1 else None
    request.social_account = SocialAccount.get(
        id=social_account_id) if social_account_id != -1 else None
    request.member = Member.get(id=member_id) if member_id != -1 else None
    request.user_profile = UserProfile.get(
        id=user_profile_id) if user_profile_id != -1 else None
    request.webapp_user = WebAppUser.get(
        id=webppuser_id) if webppuser_id != -1 else None
    request.visit_data = args['visit_data']
    if request.user_profile:
        request.webapp_owner_id = request.user_profile.user_id
    else:
        request.webapp_owner_id = -1

    # if request.user:
    # 	request.user.is_from_mobile_phone = data['is_user_from_mobile_phone']
    # 	request.user.is_from_weixin = data['is_user_from_weixin']
    return request
Exemplo n.º 3
0
	def create_user_has_messages(self, message):
		created_list = []
		# User表
		for user in User.select().where(id > 1):
			created_list.append({
				'user': user,
				'message': message,
			})
		message_models.UserHasMessage.insert_many(created_list).execute()
Exemplo n.º 4
0
def get_user_id_for(username):
    return User.get(User.username == username).id
Exemplo n.º 5
0
 def reset(self):
     self.cookies = SimpleCookie()
     if hasattr(self, 'user'):
         self.user = User()
Exemplo n.º 6
0
from __future__ import absolute_import

import os
import sys

sys.path.insert(0,
                os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
sys.path.insert(
    0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../..')))
sys.path.insert(
    0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../../..')))
from db.account.models import User, UserProfile
from db.member.models import Member, SocialAccount, MemberHasSocialAccount, WebAppUser
from core.watchdog.utils import *

user = User.get(username='******')
user_id = user.id
user_profile = UserProfile.get(user=user)
user_profile_id = user_profile.id
social_account = SocialAccount.get(webapp_id=user_profile.webapp_id,
                                   openid='bill_jobs')
member = MemberHasSocialAccount.get(account=social_account).member
webapp_user = WebAppUser.get(webapp_id=user_profile.webapp_id,
                             member_id=member.id)


def test_local_handle():
    # 测试本地情况的handle
    from core.handlers.event_handler_util import handle
    args = {
        'GET': {
Exemplo n.º 7
0
from api.mall.models import *
from db.account.models import User  # 对应 django.auth.models.User


def dump(categories):
    print("============================")
    for category in categories:
        print("id:{}, user:{}, name:{}, pic_url:{}, created_at:{}".format(
            category.id, category.owner.username, category.name.encode('utf8'),
            category.pic_url.encode('utf8'),
            category.created_at.strftime('%Y-%m-%d %H:%M')))


if __name__ == "__main__":
    user = User.select().where(User.username == 'jobs')

    user = User.get(User.id == 1)
    print("user: {}".format(user))

    # 创建记录
    category = ProductCategory.create(owner=user,
                                      name="分类XX",
                                      pic_url="http://someplace/",
                                      product_count=0)
    category2 = ProductCategory(owner=user, name="分类ZZ", pic_url='')
    category2.save()

    #c = ProductCategory.get(ProductCategory.id == 1)
    #print("category: {}".format(c))