当前位置: 首页>>代码示例>>Python>>正文


Python models.User类代码示例

本文整理汇总了Python中core.models.User的典型用法代码示例。如果您正苦于以下问题:Python User类的具体用法?Python User怎么用?Python User使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了User类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: ajax_sale_add

def ajax_sale_add(request):
    r_client = request.POST.get('client')
    r_task = request.POST.get('task')
    r_email = request.POST.get('email')
    r_password = request.POST.get('password')
    client = Client.objects.get(pk=int(r_client))
    task = Task.objects.get(pk=int(r_task))
    try:
        User.objects.get(email=r_email)
    except User.DoesNotExist:
        user = User(email=r_email, password=r_password, type=User.UserType.client)
        user.set_password(r_password)
        user.save()
        sale = Sale(
            user=user,
            city=client.city,
            manager=client.manager,
            moderator=client.moderator,
            legal_name=client.name,
            actual_name=client.name,
            legal_address=client.actual_address,
            password=r_password
        )
        sale.save()
        task.status = 1
        task.save()
        return HttpResponseRedirect(reverse('sale:update', args=(sale.id, )))
    return_url = reverse('client:task-list') + '?error=1'
    return HttpResponseRedirect(return_url)
开发者ID:od-5,项目名称:distrubutor,代码行数:29,代码来源:ajax.py

示例2: test_create_player_from_user

 def test_create_player_from_user(self):
     user = User(login='test_login')
     user.name = 'test_name'
     player = PlayerOrig.from_user(user=user)
     self.assertEqual(player.name, user.name)
     self.assertEqual(player.user, user)
     self.assertEqual(player.id, user.id)
开发者ID:0lmer,项目名称:tornado-poker,代码行数:7,代码来源:test_game.py

示例3: actualizar_registro

 def actualizar_registro(cls, documento, nombres, apellidos,
                         usuario, clave, role, rutas):
     existe_documento = cls.existe_documento(documento)
     if existe_documento and usuario:
         u = User.query(User.documento == documento).get()
         u.nombres = nombres
         u.apellidos = apellidos
         if clave:
             u.clave_hash = User.make_pw_hash(usuario, clave)
         elif u.usuario != usuario and not cls.existe_usuario(usuario) and clave:
             u.clave_hash = User.make_pw_hash(usuario, clave)
             u.usuario = usuario
         u.role = role
         u.put()
         rutasEliminar = cls.query_all_rutas(u.key)
         if rutasEliminar:
             for r in rutasEliminar:
                 if r.usuario.get().usuario == u.usuario:
                     r.key.delete()
         if rutas:
             for rut in rutas:
                 ruta_key = ndb.Key(urlsafe=rut)
                 rta = ruta_key.get()
                 nueva_ruta = UserRuta(ruta=rta.key, usuario=u.key)
                 nueva_ruta.put()
         return ["alert-success", "La actualización ha sido exitoso"]
     else:
         return ["alert-danger", "No se pudo completar la actualización"]
开发者ID:mavalarbe,项目名称:inversiones-va,代码行数:28,代码来源:admin_helper.py

示例4: test_helper_no_profile

 def test_helper_no_profile(self):
     u = User()
     u.first_name = "John"
     u.last_name = "Smith"
     u.save()
     self.assertEquals(False, helpers.user_has_profile(u))
     p = Person()
     p.user = u
     p.save()
     self.assertEquals(True, helpers.user_has_profile(u))
开发者ID:cmc333333,项目名称:collab,代码行数:10,代码来源:test_models.py

示例5: test_eq

 def test_eq(self):
     user = User(login='test_login')
     user._id = 1
     user2 = User(login='test_login2')
     player = PlayerOrig.from_user(user=user)
     player2 = PlayerOrig.from_user(user=user)
     self.assertEqual(player, player2)
     player3 = PlayerOrig.from_user(user=user2)
     self.assertNotEqual(player, player3)
     self.assertNotEqual(player3, player3)
     self.assertNotEqual(player3, None)
开发者ID:0lmer,项目名称:tornado-poker,代码行数:11,代码来源:test_game.py

示例6: add_user

def add_user(auth, fields):
    user = authenticate(username=auth.get('username'),
                        password=auth.get('password'))
    auth['tenant'] = user.site.login_base

    sites = _get_sites(fields.get('site')) 
    if sites: fields['site'] = sites[0]     
    user = User(**fields)
    user.os_manager = OpenStackManager(auth=auth, caller = user)
    user.save()
    return user
开发者ID:Dchouras,项目名称:planetLab,代码行数:11,代码来源:users.py

示例7: test_ne

    def test_ne(self):
        user = User(login='test_login')
        user._id = 1
        player = PlayerOrig.from_user(user=user)

        user2 = User(login='test_login')
        user2._id = 2
        player2 = PlayerOrig.from_user(user=user2)

        user3 = User(login='test_login2')
        player3 = PlayerOrig.from_user(user=user2)

        self.assertNotEqual(player, player2)
        self.assertNotEqual(player, player3)
开发者ID:0lmer,项目名称:tornado-poker,代码行数:14,代码来源:test_game.py

示例8: UserRegHandler

def UserRegHandler(request):
    NewAccount = Account()
    NewAccount.username = request.POST['username'].encode('utf-8')
    NewAccount.password = request.POST['password'].encode('utf-8')
    NewAccount.urtype = request.POST['urtype'].encode('utf-8')
    NewAccount.created = datetime.now()
    NewUser = User()
    NewUser.name = request.POST['name'].encode('utf-8')
    NewUser.mobile = request.POST['mobile'].encode('utf-8')
#    NewUser.address = request.POST['address'].encode('utf-8')
    NewUser.save()
    NewAccount.urid = NewUser.id
    NewAccount.save()
    return HttpResponse(NewAccount.id) 
开发者ID:shane-Git,项目名称:EzMeal,代码行数:14,代码来源:views.py

示例9: create

    def create(self):
        xos_args = self.get_xos_args()

        if not xos_args.get("site",None):
             raise Exception("Site name must be specified when creating user")
        if ("firstname" not in xos_args) or ("lastname" not in xos_args):
             raise Exception("firstname and lastname must be specified when creating user")

        user = User(**xos_args)
        user.save()

        self.postprocess(user)

        self.info("Created User '%s'" % (str(user), ))
开发者ID:vpramo,项目名称:xos-1,代码行数:14,代码来源:user.py

示例10: create

    def create(self):
        nodetemplate = self.nodetemplate

        xos_args = self.get_xos_args()

        if not xos_args.get("site",None):
             raise Exception("Site name must be specified when creating user")

        user = User(**xos_args)
        user.save()

        self.postprocess(user)

        self.info("Created User '%s'" % (str(user), ))
开发者ID:digideskio,项目名称:xos,代码行数:14,代码来源:user.py

示例11: system_users

def system_users():
    user = auth.is_logged_in(request)
    permission = auth.is_sys_admin(user)

    return listing(request, None, User.select(),
                   'system_users', 'system_manage_users',
                   user=user)
开发者ID:syegulalp,项目名称:mercury,代码行数:7,代码来源:user.py

示例12: select_by_user

 def select_by_user(user):
     if user.is_admin:
         qs = ControllerUser.objects.all()
     else:
         users = User.select_by_user(user)
         qs = ControllerUser.objects.filter(user__in=users)
     return qs
开发者ID:Chunhai,项目名称:xos-1,代码行数:7,代码来源:controlleruser.py

示例13: existe_documento

 def existe_documento(cls, documento):
     if documento:
         if User.query(User.documento == documento).fetch():
             return True
         else:
             return False
     else:
         return False
开发者ID:mavalarbe,项目名称:inversiones-va,代码行数:8,代码来源:admin_helper.py

示例14: blog_user

def blog_user(user_id, blog_id):
    # Obtains user edit in blog context.
    user = auth.is_logged_in(request)
    blog = Blog.load(blog_id)
    permission = auth.is_blog_admin(user, blog)
    user_to_edit = User.find(user_id)

    return edit_user(user_to_edit, editing_user=user, context=blog_context, blog=blog)
开发者ID:syegulalp,项目名称:mercury,代码行数:8,代码来源:user.py

示例15: site_user

def site_user(user_id, site_id):
    # Obtains user edit in site context.
    user = auth.is_logged_in(request)
    site = Site.load(site_id)
    permission = auth.is_site_admin(user, site)
    user_to_edit = User.find(user_id)

    return edit_user(user_to_edit, editing_user=user, context=site_context, site=site)
开发者ID:syegulalp,项目名称:mercury,代码行数:8,代码来源:user.py


注:本文中的core.models.User类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。