예제 #1
0
def signup(request, username, password, email, **kwargs):
    """Create a new account

    - Username must have only letters/numbers and be 3-30 chars
    - Password must be 6-128 chars
    - Email is optional
    """
    raise APIException("disabled")
    if request.user.is_authenticated():
        raise APIException(_("you're already logged in"))
    check_username(username=username)
    if len(password) < 6:
        raise APIException(_("password must be at least six characters"))
    if len(password) > 128:
        raise APIException(_("password too long"))
    if email:
        if not email_re.match(email):
            raise APIException(_("invalid email address"))
    user = db.User()
    user.username = username
    user.set_password(password)
    user.email = email
    user.save()
    userinfo = db.UserInfo()
    userinfo.user = user
    userinfo.attendance = 'maybe'
    userinfo.save()
    user.userinfo = userinfo
    user.save()
    res = login(request, username, password)
    res[0]['conversion'] = render_to_string('occupywallst/conversion.html')
    return res
예제 #2
0
 def test_user_info_wo_geodata(self):
     ui = db.UserInfo(user=self.red_user)
     assert str(ui) != ''
     assert ui.position_lat == None
     assert ui.position_lng == None
     assert ui.position_latlng == None
     assert len(ui.as_dict().keys()) > 0
예제 #3
0
    def create_users(self):
        """Create users for functional testing of access control.

        It seems easier to create the users with a code block than as
        json fixtures, because the password is clearer before it is
        encrypted.
        """
        from django.contrib.auth.models import User
        self.red_user = User.objects.create_user('red', '', 'red')
        self.green_user = User.objects.create_user('green', '', 'green')
        self.blue_user = User.objects.create_user('blue', '', 'blue')
        for u in [self.red_user, self.green_user, self.blue_user]:
            ui = db.UserInfo(user=u)
            ui.save()
예제 #4
0
 def save(self):
     username = self.cleaned_data.get('username')
     password = self.cleaned_data.get('password')
     user = db.User()
     user.username = username
     user.set_password(password)
     user.save()
     userinfo = db.UserInfo()
     userinfo.user = user
     userinfo.attendance = 'maybe'
     userinfo.save()
     user.userinfo = userinfo
     user.save()
     self.user = user
     return super(SignupForm, self).save()
예제 #5
0
 def save_model(self, request, user, form, change):
     user.save()
     if db.UserInfo.objects.filter(user=user).count() == 0:
         userinfo = db.UserInfo()
         userinfo.user = user
         userinfo.save()
예제 #6
0
 def test_user_info_w_geodata(self):
     ui = db.UserInfo(user=self.red_user, position=Point((20, 10)))
     assert ui.position_lat == 10
     assert ui.position_lng == 20
     assert ui.position_latlng == (10, 20)