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


Python User.set_password方法代码示例

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


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

示例1: ajax_sale_add

# 需要导入模块: from core.models import User [as 别名]
# 或者: from core.models.User import set_password [as 别名]
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,代码行数:31,代码来源:ajax.py

示例2: facebook_connect

# 需要导入模块: from core.models import User [as 别名]
# 或者: from core.models.User import set_password [as 别名]
def facebook_connect(user_data):
    try:
        # Logging in with Facebook
        user = User.objects.get(facebook_id=user_data['id'])
        user.tz_offset = user_data['timezone']
        user.save()
    except User.DoesNotExist:
        # Creating new account with Facebook
        user = User()
        user.email = user_data['email']
        user.facebook_id = user_data['id']
        user.tz_offset = user_data['timezone']
        user.set_password(random_string())
        user.save()
    return user
开发者ID:elesant,项目名称:HackBase,代码行数:17,代码来源:facebook.py

示例3: test_call_register_channel

# 需要导入模块: from core.models import User [as 别名]
# 或者: from core.models.User import set_password [as 别名]
    def test_call_register_channel(self):
        '''
        Test registration to a channel
        '''

        u = User()
        u.username = "sample_post"
        u.first_name = "sample_post"
        u.email = "[email protected]"
        u.set_password("123")
        u.save()

        ch1 = Channel()

        ch1.owner = u
        ch1.name = "PostSub"
        ch1.image = 'http://www.google.com'
        ch1.description = "A channel description"
        ch1.kind = PUBLIC
        ch1.hidden = False
        ch1.subscriptions = 0

        ch1.save()

        sub1 = Subscriber()
        sub1.sub_type = 'type2'
        sub1.token = 'token2'
        sub1.device_id = 'devid5'
        sub1.save()


        resp = ask_subscribe_channel(ch1, sub1.device_id)

        self.assertEqual(resp, SubscribeResponse.SUBSCRIBED)
        test_user = User.objects.create_superuser('test_user', '[email protected]', 'password')
        self.client.login(username='test_user', password='password')

        data = {
                'channel' : ch1.name,
                'token' : sub1.token,
                'browser' : 'chrome',
                'device_id' : sub1.device_id
        }

        response = self.client.post(reverse('browser-registration'), json.dumps(data), sub1.token)

        self.assertTrue(response.status_code, 200)
开发者ID:Mikelord2,项目名称:pushetta-api-django,代码行数:49,代码来源:test.py

示例4: test_call_delete

# 需要导入模块: from core.models import User [as 别名]
# 或者: from core.models.User import set_password [as 别名]
    def test_call_delete(self):
        '''
        Test deleting of a registration of a device from a channel
        '''

        u = User()
        u.username = "sample_del"
        u.first_name = "sample_del"
        u.email = "[email protected]"
        u.set_password("123")
        u.save()

        ch1 = Channel()

        ch1.owner = u
        ch1.name = "DelSub"
        ch1.image = 'http://www.google.com'
        ch1.description = "A channel description"
        ch1.kind = PUBLIC
        ch1.hidden = False
        ch1.subscriptions = 0

        ch1.save()

        sub1 = Subscriber()
        sub1.sub_type = 'type2'
        sub1.token = 'token2'
        sub1.device_id = 'devid6'
        sub1.save()


        resp = ask_subscribe_channel(ch1, sub1.device_id)

        self.assertEqual(resp, SubscribeResponse.SUBSCRIBED)
        test_user = User.objects.create_superuser('test_user', '[email protected]', 'password')
        self.client.login(username='test_user', password='password')

        response = self.client.delete(reverse('browser-get-registration', kwargs={'device_id': sub1.device_id,
                                                                       'channel_name' : ch1.name}))

        self.assertEqual(response.status_code, 200)

        channels = SubscriberManager().get_device_subscriptions(sub1.device_id)
        sub_channel = next((x for x in channels if x == ch1.name.lower()), None)

        self.assertIsNone(sub_channel)
开发者ID:Mikelord2,项目名称:pushetta-api-django,代码行数:48,代码来源:test.py

示例5: api_user_register

# 需要导入模块: from core.models import User [as 别名]
# 或者: from core.models.User import set_password [as 别名]
def api_user_register(request):
    benchmark_start = time.time()
    response = prepare_response(request)
    status = 200
    form = UserRegisterForm(request.POST)
    errors = get_validation_errors(form)
    if form.is_valid():
        data = form.cleaned_data
        new_user = User(email=data['email'])
        new_user.set_password(data['password'])
        new_user.save()
        response['new_user_id'] = new_user.id
        status = 201
    else:
        response['errors'] = errors
        status = 400
    response['meta']['status'] = status
    benchmark_end = time.time()
    response['meta']['execution_time'] = benchmark_end - benchmark_start
    return build_response(response, status=status)
开发者ID:elesant,项目名称:BirthdayStarter,代码行数:22,代码来源:views.py

示例6: post

# 需要导入模块: from core.models import User [as 别名]
# 或者: from core.models.User import set_password [as 别名]
 def post(self):
     login = self.get_argument("login")
     password = self.get_argument("password")
     password_confirm = self.get_argument("password_confirm")
     if len(password) >= 4 and (password == password_confirm):
         users = yield User.find(login=login)
         if len(users):
             self.write_error(500, "Already exist")
             return
         user = User(login=login)
         user.set_password(new_password=password)
         user.save()
         self.set_secure_cookie("user", login)
         self.get_user_from_cookies = lambda : login
         session = self.project_session
         session['current_user'] = user
         session.save()
         self.redirect("/")
     else:
         self.write_error(500, 'Incorrect password')
开发者ID:0lmer,项目名称:tornado-poker,代码行数:22,代码来源:auth.py

示例7: test_call_get

# 需要导入模块: from core.models import User [as 别名]
# 或者: from core.models.User import set_password [as 别名]
    def test_call_get(self):
        '''
        Test check if a device is registered to a channel
        '''

        u = User()
        u.username = "sample_un"
        u.first_name = "Sample_un"
        u.email = "[email protected]"
        u.set_password("123")
        u.save()

        ch1 = Channel()

        ch1.owner = u
        ch1.name = "GetSub"
        ch1.image = 'http://www.google.com'
        ch1.description = "A channel description"
        ch1.kind = PUBLIC
        ch1.hidden = False
        ch1.subscriptions = 0

        ch1.save()

        sub1 = Subscriber()
        sub1.sub_type = 'type2'
        sub1.token = 'token2'
        sub1.device_id = 'devid4'
        sub1.save()


        resp = ask_subscribe_channel(ch1, 'devid4')

        self.assertEqual(resp, SubscribeResponse.SUBSCRIBED)
        test_user = User.objects.create_superuser('test_user', '[email protected]', 'password')
        self.client.login(username='test_user', password='password')

        response = self.client.get(reverse('browser-get-registration', kwargs={'device_id': 'devid4', 'channel_name' : 'GetSub'}) )
        
        self.assertTrue(response.status_code, 200)
开发者ID:Mikelord2,项目名称:pushetta-api-django,代码行数:42,代码来源:test.py

示例8: ajax_client_add

# 需要导入模块: from core.models import User [as 别名]
# 或者: from core.models.User import set_password [as 别名]
def ajax_client_add(request):
    r_incomingclient = request.POST.get('incomingclient')
    r_manager = request.POST.get('manager')
    r_incomingtask = request.POST.get('incomingtask')
    r_incomingcontact = request.POST.get('incomingcontact')
    r_date = request.POST.get('date')
    r_comment = request.POST.get('comment')
    r_email = request.POST.get('email')
    r_password = request.POST.get('password')
    incomingclient = IncomingClient.objects.get(pk=int(r_incomingclient))
    incomingtask = IncomingTask.objects.get(pk=int(r_incomingtask))
    if r_incomingcontact:
        incomingcontact = IncomingClientContact.objects.get(pk=int(r_incomingcontact))
    else:
        incomingcontact = incomingtask.incomingclientcontact
    manager = Manager.objects.get(pk=int(r_manager))
    try:
        User.objects.get(email=r_email)
    except User.DoesNotExist:
        user = User(email=r_email, password=r_password, type=3)
        user.set_password(r_password)
        user.save()
        client = Client(
            user=user,
            city=incomingclient.city,
            manager=incomingclient.manager,
            legal_name=incomingclient.name,
            actual_name=incomingclient.name,
            legal_address=incomingclient.actual_address
        )
        client.save()
        incomingtask.status = 1
        incomingtask.save()
        return HttpResponseRedirect(reverse('client:change', args=(client.id, )))
    return_url = reverse('incoming:task-list') + '?error=1'
    return HttpResponseRedirect(return_url)
开发者ID:od-5,项目名称:crm,代码行数:38,代码来源:ajax.py

示例9: handle

# 需要导入模块: from core.models import User [as 别名]
# 或者: from core.models.User import set_password [as 别名]

#.........这里部分代码省略.........
              print err
              return
         p6=subprocess.Popen(["git rm --ignore-unmatch -r -f "+photo_file_path],stdin=subprocess.PIPE,stderr=subprocess.PIPE,shell=True)
         (out,err) = p6.communicate()
         if err != '':
              print err
              return
         print 'removing existing document files...'
         
         p5=subprocess.Popen(["rm -r -f "+doc_file_path],stdin=subprocess.PIPE,stderr=subprocess.PIPE,shell=True)
         (out,err) = p5.communicate()
         if err != '':
              print err
              return
         p6=subprocess.Popen(["git rm --ignore-unmatch -r -f "+doc_file_path],stdin=subprocess.PIPE,stderr=subprocess.PIPE,shell=True)
         (out,err) = p6.communicate()
         if err != '':
              print err
              return
         print 'syncing database...'
         p4=subprocess.Popen(["python "+manage_file_path+" syncdb"],stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE,shell=True)
         p4.stdin.write("yes\n")
         p4.stdin.flush()
         p4.stdin.write("[email protected]\n")
         p4.stdin.flush()
         print 'Email: [email protected]'
         (out,err) = p4.communicate()
         if err != '':
              print err
              return
         print 'setting up photologue...'
         print 'creating size \'admin_thumbnail\''
         p4=subprocess.Popen(["python "+manage_file_path+" plcreatesize admin_thumbnail"],stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE,shell=True)
         p4.stdin.write("100\n")#width
         p4.stdin.write("100\n")#height
         p4.stdin.write("yes\n")#crop to fit
         p4.stdin.write("yes\n")#pre cache
         p4.stdin.write("yes\n")#increment count
         print 'creating size \'activity_cover_small\''
         p4=subprocess.Popen(["python "+manage_file_path+" plcreatesize activity_cover_small"],stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE,shell=True)
         p4.stdin.write("100\n")#width
         p4.stdin.write("100\n")#height
         p4.stdin.write("yes\n")#crop to fit
         p4.stdin.write("yes\n")#pre cache
         p4.stdin.write("yes\n")#increment count
         print 'creating size \'activity_cover_medium\''
         p4=subprocess.Popen(["python "+manage_file_path+" plcreatesize activity_cover_medium"],stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE,shell=True)
         p4.stdin.write("180\n")#width
         p4.stdin.write("180\n")#height
         p4.stdin.write("no\n")#crop to fit
         p4.stdin.write("yes\n")#pre cache
         p4.stdin.write("yes\n")#increment count
         print 'creating size \'activity_cover_large\''
         p4=subprocess.Popen(["python "+manage_file_path+" plcreatesize activity_cover_large"],stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE,shell=True)
         p4.stdin.write("320\n")#width
         p4.stdin.write("320\n")#height
         p4.stdin.write("no\n")#crop to fit
         p4.stdin.write("yes\n")#pre cache
         p4.stdin.write("yes\n")#increment count
         print 'creating size \'photo_small\''
         p4=subprocess.Popen(["python "+manage_file_path+" plcreatesize photo_small"],stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE,shell=True)
         p4.stdin.write("100\n")#width
         p4.stdin.write("100\n")#height
         p4.stdin.write("yes\n")#crop to fit
         p4.stdin.write("yes\n")#pre cache
         p4.stdin.write("yes\n")#increment count
         print 'creating size \'photo_medium\''
         p4=subprocess.Popen(["python "+manage_file_path+" plcreatesize photo_medium"],stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE,shell=True)
         p4.stdin.write("300\n")#width
         p4.stdin.write("300\n")#height
         p4.stdin.write("no\n")#crop to fit
         p4.stdin.write("yes\n")#pre cache
         p4.stdin.write("yes\n")#increment count
         print 'creating size \'photo_large\''
         p4=subprocess.Popen(["python "+manage_file_path+" plcreatesize photo_large"],stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE,shell=True)
         p4.stdin.write("600\n")#width
         p4.stdin.write("600\n")#height
         p4.stdin.write("no\n")#crop to fit
         p4.stdin.write("yes\n")#pre cache
         p4.stdin.write("yes\n")#increment count
         print 'setting up markdown...'
         p4=subprocess.Popen(["cp -rf "+markdown_extension_file_path+" "+markdown_extension_path],stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE,shell=True)
         (out,err) = p4.communicate()
         if err != '':
              print err
              return
         print 'setting up development environment...'
         print 'creating first organization (for development only)'
         from core.models import Organization
         org = Organization(username="org1",email="[email protected]")
         org.set_password("123456")
         org.save()
         print 'creating first user (for development only)'
         from core.models import User
         usr = User(first_name="W",last_name="TF",email="[email protected]")
         usr.set_password("123456")
         usr.save()
         print "site successfully deployed!"
     else:
         print self.usage_str
开发者ID:zPatrickz,项目名称:DFC-website,代码行数:104,代码来源:deploy.py


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