def test_pages_as_newuser(self): api.user_create(api.ROOT, nick = 'mmmm', password = '******', first_name = 'm', last_name ='m') for page in ('/user/root', '/user/mmmm/overview', '/user/mmmm/contacts', '/user/mmmm/followers', '/user/mmmm', '/channel/popular', '/channel/popular/presence/13345'): r = self.login_and_get('mmmm', page, password='******') self.assertEqual(r.status_code, 200, page + ' failed:' + str(r.status_code))
def promote_user(self, from_jid, nick): ji_ref = api.actor_lookup_im(api.ROOT, from_jid.base()) if jid_ref: # TODO(tyler): Should we tell the user who they are? raise exception.ValidationError( "You already have an account and are signed in.") if not NICK_RE.match(nick): raise exception.ValidationError( "Invalid screen name, can only use letters or numbers, 3 to 16 " "characters") # Create the user. (user_create will check to see if the account has # already been created.) password = util.generate_uuid()[:8] # TODO(termie): Must have a first/last name. :( actor = api.user_create(api.ROOT, nick=nick, password=password, given_name=nick, family_name=nick) # link this im account to the user's account (equivalent of SIGN IN) self.sign_in(from_jid, nick, password) # Inform the user of their new password welcome = '\n'.join([HELP_WELCOME_NICK % nick, HELP_PASSWORD % password, HELP_POST, HELP_CHANNEL_POST, HELP_COMMENT, HELP_FOLLOW, HELP_STOP, HELP_MORE, HELP_FOOTER]) self.send_message([from_jid], welcome)
def join_join(request): if request.user: raise exception.AlreadyLoggedInException() redirect_to = request.REQUEST.get("redirect_to", "/") # get the submitted vars nick = request.REQUEST.get("nick", "") first_name = request.REQUEST.get("first_name", "") last_name = request.REQUEST.get("last_name", "") email = request.REQUEST.get("email", "") password = request.REQUEST.get("password", "") confirm = request.REQUEST.get("confirm", "") hide = request.REQUEST.get("hide", "") if request.POST: try: # TODO validate params = util.query_dict_to_keywords(request.POST) if hide: params["privacy"] = 2 validate.email(email) if not mail.is_allowed_to_send_email_to(email): raise exception.ValidationError("Cannot send email to that address") # TODO start transaction if api.actor_lookup_email(api.ROOT, email): raise exception.ValidationError("That email address is already associated with a member.") actor_ref = api.user_create(api.ROOT, **params) actor_ref.access_level = "delete" api.post(actor_ref, nick=actor_ref.nick, message="Joined %s!" % (settings.SITE_NAME), icon="jaiku-new-user") # send off email confirmation api.activation_request_email(actor_ref, actor_ref.nick, email) # TODO end transaction welcome_url = util.qsa("/welcome", {"redirect_to": redirect_to}) # NOTE: does not provide a flash message response = http.HttpResponseRedirect(welcome_url) user.set_user_cookie(response, actor_ref) return response except: exception.handle_exception(request) # for legal section legal_component = component.include("legal", "dummy_legal") legal_html = legal_component.embed_join() # for sidebar sidebar_green_top = True area = "join" c = template.RequestContext(request, locals()) t = loader.get_template("join.html") return http.HttpResponse(t.render(c))