當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。