Beispiel #1
0
def user(request):
    user = users.get_current_user()
    
    if user:
        usetting = UserSetting.gql('WHERE userid = :1', user.user_id())
        if usetting.count() == 0:
            usetting = UserSetting(userid=user.user_id(), email=db.Email(user.email()), is_contrib=False)
            usetting.put()
        userurl = users.create_logout_url(request.get_full_path())
    else:
        userurl = users.create_login_url(request.get_full_path())
        
    return {
        "user": user,
        "userurl": userurl
    }
    def post(self):
        user = users.get_current_user()
        if not user or not self.request.get('customize'): return

        pacName = self.request.get('pacname', '').lower()
        if pacName != user.nickname().lower():
            self.error(400)
            return

        UserSetting(
            key_name=user.user_id(),
            defaultProxy=self.request.get('proxy'),
            pacName=pacName,
            customRules=self.request.get('addrules').splitlines(),
        ).put()

        if self.request.get('usage') != 'online':
            self.redirect('/%s%s%s?download' %
                          (PAC_URL_PREFIX, PAC_USER_URL_PREFIX, pacName),
                          permanent=False)
Beispiel #3
0
    def setUp(self):
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_datastore_v3_stub()
        self.testbed.init_memcache_stub()

        self.user_a = User()
        self.user_a.put()

        self.user_b = User()
        self.user_b.name = 'Foo Bar'
        self.user_b.clientID = 'C123'
        self.user_b.put()

        self.setting = UserSettingKey()
        self.setting.name = 'SEND_EMAIL'
        self.setting.description = 'Acceptance to receiv E-mail'
        self.setting.values = ['0', '1']
        self.setting.put()

        self.user_setting = UserSetting()
        self.user_setting.setting_key = self.setting.key
        self.user_setting.user = self.user_b.key
        self.user_setting.value = '0'
        self.user_setting.put()

        self.email_a = UserEmail()
        self.email_a.email = '*****@*****.**'
        self.email_a.is_activated = False
        self.email_a.is_default = False
        self.email_a.user = self.user_b.key
        self.email_a.put()

        self.email_b = UserEmail()
        self.email_b.email = '*****@*****.**'
        self.email_b.is_activated = True
        self.email_b.is_default = True
        self.email_b.user = self.user_b.key
        self.email_b.put()