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


Python User.email方法代码示例

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


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

示例1: facebook_connect

# 需要导入模块: from core.models import User [as 别名]
# 或者: from core.models.User import email [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

示例2: test_call_register_channel

# 需要导入模块: from core.models import User [as 别名]
# 或者: from core.models.User import email [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

示例3: test_call_delete

# 需要导入模块: from core.models import User [as 别名]
# 或者: from core.models.User import email [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

示例4: test_call_get

# 需要导入模块: from core.models import User [as 别名]
# 或者: from core.models.User import email [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


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