Пример #1
0
    def test_get_feature_starrers__some_starrers(self):
        """Two users have starred the given feature."""
        app_user_1 = models.AppUser(email='*****@*****.**')
        app_user_1.put()
        app_user_2 = models.AppUser(email='*****@*****.**')
        app_user_2.put()
        feature_1_id = self.feature_1.key().id()
        notifier.FeatureStar.set_star(app_user_1.email, feature_1_id)
        notifier.FeatureStar.set_star(app_user_2.email, feature_1_id)

        actual = notifier.FeatureStar.get_feature_starrers(feature_1_id)
        self.assertItemsEqual([app_user_1.email, app_user_2.email],
                              [au.email for au in actual])
Пример #2
0
    def setUp(self):
        self.user_1 = models.AppUser(email='*****@*****.**')
        self.user_1.put()

        request = webapp2.Request.blank('/some/path')
        response = webapp2.Response()
        self.handler = common.BaseHandler(request, response)
Пример #3
0
def create(request):
    v = request.POST
    if not v["password"] or not v["password_confirmation"] or not v["password"] == v["password_confirmation"]:
        return render(request, 'login/new.html', {'error_message': 'Passwords do not match'})
    if not len(v["password"]) > 5:
        return render(request, 'login/new.html', {'error_message': 'Password too short'})
    salty = hex(getrandbits(64))[2:-1]
    user = models.AppUser(email=v["email"],
        password=permute(v["password"].encode('utf-8'), salty), plan=0, salt=salty, name=v["name"])
    try:
        user.save()
    except IntegrityError:
        return render(request, 'login/new.html', {'error_message': 'Email and Username must be unique'})
    request.session["user"] = user.email
    request.session["isnew"] = user.name + ", you have successfully created your account"
    return redirect(reverse("login:view"))
Пример #4
0
    def post(self, path, user_id=None):
        if user_id:
            self._delete(user_id)
            self.redirect('/admin/users/new')
            return

        email = self.request.get('email')

        # Don't add a duplicate email address.
        user = models.AppUser.all(keys_only=True).filter('email = ',
                                                         email).get()
        if not user:
            user = models.AppUser(email=db.Email(email))
            user.put()

            self.response.set_status(201, message='Created user')
            self.response.headers['Content-Type'] = 'application/json'
            return self.response.write(json.dumps(user.format_for_template()))
        else:
            self.response.set_status(200, message='User already exists')
            self.response.write(json.dumps({'id': user.id()}))
Пример #5
0
def on_new_user(data):
    db.session.add(
        models.AppUser("*****@*****.**", "Tony", "Tiger",
                       models.AuthUserType.GOOGLE, "tonytiger.png"))