def openid_createuser(request): person = openidgae.get_current_person(request, http.HttpResponse()) email = person.get_email() res = util_externals.reponse_if_exists(email) if res is not None: return res nick = util_externals.get_nick_from_email(email) params = { 'nick': nick, 'password': util.generate_password(), 'first_name': person.get_field_value('firstname', 'none'), 'last_name': person.get_field_value('lastname', 'none'), 'fromopenid': True, 'email':email, } actor_ref = util_externals.user_create('google', params, util.display_nick(email), email) # NOTE: does not provide a flash message response = util.RedirectFlash('/', 'Welcome to %s' % util.get_metadata('SITE_NAME')) user.set_user_cookie(response, actor_ref) return response
def twitter_user_create(request): twitter_user, token = util_externals.twitter_user() if not twitter_user: c = template.RequestContext(request, locals()) t = loader.get_template('poboxopenid/templates/twitter_login.html') return http.HttpResponse(t.render(c)) res = util_externals.reponse_if_exists(twitter_user.id, 'twitter') if res is not None: return res nick = util_externals.get_nick_from_email(twitter_user.screen_name) params = { 'nick': nick, 'password': util.generate_password(), 'first_name': twitter_user.name, 'last_name': '', 'fromopenid': True, 'email':None, } actor_ref = util_externals.user_create('twitter', params, twitter_user.screen_name, str(twitter_user.id), 'http://twitter.com/%s'%twitter_user.screen_name) logging.info("Storing twitter_access_token after create a user") actor_ref.extra['twitter_access_token'] = token actor_ref.put() response = util.RedirectFlash('/', 'Welcome to P.O.BoxPress') user.set_user_cookie(response, actor_ref) return response #@decorator_from_middleware(FacebookMiddleware) #@facebook.require_login('/facebook/signin', False) #def facebook_processuser(request): # c = template.RequestContext(request, locals()) # t = loader.get_template('poboxopenid/templates/facebook_login.html') # return http.HttpResponse(t.render(c)) #@decorator_from_middleware(FacebookMiddleware) #@facebook.require_login('/facebook/signin', False) #def facebook_canvas(request): # values = request.facebook.users.getInfo([request.facebook.uid], ['first_name', 'is_app_user', 'has_added_app'])[0] # # name, is_app_user, has_added_app = values['first_name'], values['is_app_user'], values['has_added_app'] # # if has_added_app == '0': # return request.facebook.redirect(request.facebook.get_add_url()) # # c = template.RequestContext(request, locals()) # t = loader.get_template('poboxopenid/templates/canvas.fbml') # return http.HttpResponse(t.render(c))
def login_login(request): redirect_to = request.REQUEST.get('redirect_to', '/') redirect_to = clean.redirect_to(redirect_to) if request.POST: try: login = request.POST.get('log', None) password = request.POST.get('pwd', None) rememberme = request.POST.get('rememberme', None) # TODO validate current_user = user.lookup_user_by_login(login, password) if current_user: if redirect_to == '/': redirect_to = current_user.url('/overview') # Attempt to do some cleanup on the user if necessary api.user_cleanup(api.ROOT, current_user.nick) # if we aren't hosted or aren't ssl just set the cookie and go home if (not settings.HOSTED_DOMAIN_ENABLED or not settings.SSL_LOGIN_ENABLED): response = http.HttpResponseRedirect(redirect_to) response = user.set_user_cookie(response, current_user, rememberme) return response # otherwise, we're going to have to redirect to set the cookie on # the proper domain sso_token = util.generate_uuid() cache.set('sso/%s' % sso_token, (current_user.nick, rememberme), timeout=10) sso_url = 'http://%s/login/noreally' % (settings.DOMAIN) sso_url = util.qsa(sso_url, { 'redirect_to': redirect_to, 'sso_token': sso_token }) return http.HttpResponseRedirect(sso_url) else: raise exception.ValidationError("Invalid username or password") except: exception.handle_exception(request) if request.user: if redirect_to == '/': redirect_to = request.user.url('/overview') return http.HttpResponseRedirect(redirect_to) c = template.RequestContext(request, locals()) t = loader.get_template('login/templates/login.html') return http.HttpResponse(t.render(c))
def login_noreally(request): if 'sso_token' in request.GET: sso_token = request.GET['sso_token'] redirect_to = request.GET['redirect_to'] redirect_to = clean.redirect_to(redirect_to) nick, rememberme = cache.get('sso/%s' % sso_token) cache.delete('sso/%s' % sso_token) actor_ref = api.actor_get(api.ROOT, nick) response = http.HttpResponseRedirect(redirect_to) response = user.set_user_cookie(response, actor_ref, rememberme) return response return http.HttpResponseRedirect('/login')
def login_login(request): redirect_to = request.REQUEST.get('redirect_to', '/') redirect_to = clean.redirect_to(redirect_to) if request.POST: try: login = request.POST.get('log', None) password = request.POST.get('pwd', None) rememberme = request.POST.get('rememberme', None) # TODO validate current_user = user.lookup_user_by_login(login, password) if current_user: if redirect_to == '/': redirect_to = current_user.url('/overview') # Attempt to do some cleanup on the user if necessary api.user_cleanup(api.ROOT, current_user.nick) # if we aren't hosted or aren't ssl just set the cookie and go home if (not settings.HOSTED_DOMAIN_ENABLED or not settings.SSL_LOGIN_ENABLED): response = http.HttpResponseRedirect(redirect_to) response = user.set_user_cookie(response, current_user, rememberme) return response # otherwise, we're going to have to redirect to set the cookie on # the proper domain sso_token = util.generate_uuid() cache.set('sso/%s' % sso_token, (current_user.nick, rememberme), timeout=10) sso_url = 'http://%s/login/noreally' % (settings.DOMAIN) sso_url = util.qsa( sso_url, {'redirect_to': redirect_to, 'sso_token': sso_token}) return http.HttpResponseRedirect(sso_url) else: raise exception.ValidationError("Invalid username or password") except: exception.handle_exception(request) view =user.get_user_from_cookie_or_legacy_auth(request) area="login" if view: if redirect_to == '/': redirect_to = request.user.url('/overview') return http.HttpResponseRedirect(redirect_to) c = template.RequestContext(request, locals()) t = loader.get_template('login/templates/login.html') return http.HttpResponse(t.render(c))
def reponse_if_exists(id, service=None): if service is None: view = api.actor_lookup_email(api.ROOT, id) else: eprofile = api.get_external_profile(service, id) if eprofile is not None: nick = clean.nick(eprofile.nick) view = api.actor_lookup_nick(api.ROOT, nick) else: return None if view: response = http.HttpResponseRedirect(view.url("/overview")) response = user.set_user_cookie(response, view) return response return None
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', '') homepage = request.REQUEST.get('homepage', '') 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/templates/join.html') return http.HttpResponse(t.render(c))
def join_join(request): if request.user: raise exception.AlreadyLoggedInException() redirect_to = request.REQUEST.get('redirect_to', '/') account_types = api.get_config_values(api.ROOT, 'account_type') # 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', ''); country_tag = request.REQUEST.get('country_tag', '') if request.POST: try: # TODO validate params = util.query_dict_to_keywords(request.POST) if hide: params['privacy'] = 2 # XXX: Check if the data come from a openid account # @author: [email protected] fromopenid = request.POST.get('fromopenid', False) and True if fromopenid: try: person = openidgae.get_current_person(request, http.HttpResponse()) except: raise exception.ServiceError email = person.get_email() if email == params['email']: params['password'] = util.generate_password() else: raise exception.ServiceError # ENDXXX 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!' % (util.get_metadata('SITE_NAME'))) if fromopenid: api.email_associate(api.ROOT, actor_ref.nick, email) else: # send off email confirmation api.activation_request_email(actor_ref, actor_ref.nick, email) logging.info('setting firsttime_%s from register page' % actor_ref.nick) memcache.client.set('firsttime_%s' % nick, True) # TODO end transaction welcome_url = util.qsa('/', {'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/templates/join.html') return http.HttpResponse(t.render(c))
def actor_settings(request, nick, page='index'): """ just a static page that links to the rest""" nick = clean.nick(nick) view = api.actor_lookup_nick(api.ROOT, nick) if not api.actor_owns_actor(request.user, view): raise exception.ApiOwnerRequired( 'Operation not allowed: %s does not own %s' % (request.user and request.user.nick or '(nobody)', view.nick)) handled = common_views.handle_view_action( request, { 'activation_activate_mobile': view.url('/settings/mobile'), 'activation_request_email': view.url('/settings/email'), 'activation_request_mobile': view.url('/settings/mobile'), 'settings_change_notify': view.url('/settings/notifications'), 'settings_change_privacy': request.path, 'settings_update_account': view.url('/settings/profile'), 'actor_remove': '/logout', #'oauth_remove_consumer': request.path, #'oauth_remove_access_token': request.path } ) if handled: return handled # TODO(tyler/termie): This conflicts with the global settings import. # Also, this seems fishy. Do none of the settings.* items work in templates? import settings # TODO(tyler): Merge this into handle_view_action, if possible if 'password' in request.POST: try: validate.nonce(request, 'change_password') password = request.POST.get('password', '') confirm = request.POST.get('confirm', '') validate.password_and_confirm(password, confirm, field = 'password') api.settings_change_password(request.user, view.nick, password) response = util.RedirectFlash(view.url() + '/settings/password', 'Password updated') request.user.password = util.hash_password(request.user.nick, password) # TODO(mikie): change when cookie-auth is changed user.set_user_cookie(response, request.user) return response except: exception.handle_exception(request) if page == 'feeds': try: if not settings.FEEDS_ENABLED: raise exception.DisabledFeatureError('Feeds are currently disabled') except: exception.handle_exception(request) if page == 'photo': redirect_to = view.url() + '/settings/photo' handled = common_views.common_photo_upload(request, redirect_to) if handled: return handled area = 'settings' full_page = page.capitalize() if page == 'mobile': full_page = 'Mobile Number' mobile = api.mobile_get_actor(request.user, view.nick) sms_notify = view.extra.get('sms_notify', False) elif page == 'im': full_page = 'IM Address' im_address = api.im_get_actor(request.user, view.nick) im_notify = view.extra.get('im_notify', False) elif page == 'index': email = api.email_get_actor(request.user, view.nick) email_notify = view.extra.get('email_notify', False) im_address = api.im_get_actor(request.user, view.nick) im_notify = view.extra.get('im_notify', False) elif page == 'feeds': full_page = 'Web Feeds' elif page == 'email': full_page = 'Email Address' email_notify = view.extra.get('email_notify', False) # check if we already have an email email = api.email_get_actor(request.user, view.nick) # otherwise look for an unconfirmed one if not email: unconfirmeds = api.activation_get_actor_email(api.ROOT, view.nick) if unconfirmeds: unconfirmed_email = unconfirmeds[0].content elif page == 'design': handled = common_views.common_design_update(request, view.nick) if handled: return handled full_page = 'Look and Feel' elif page == 'notifications': email = api.email_get_actor(request.user, view.nick) email_notify = view.extra.get('email_notify', False) im_address = api.im_get_actor(request.user, view.nick) im_notify = view.extra.get('im_notify', False) mobile = api.mobile_get_actor(request.user, request.user.nick) sms_notify = view.extra.get('sms_notify', False) sms_confirm = sms_notify and not view.extra.get('sms_confirmed', False) # TODO(termie): remove this once we can actually receive sms sms_confirm = False elif page == 'profile': # check if we already have an email email = api.email_get_actor(request.user, view.nick) # otherwise look for an unconfirmed one if not email: unconfirmeds = api.activation_get_actor_email(api.ROOT, view.nick) if unconfirmeds: unconfirmed_email = unconfirmeds[0].content elif page == 'photo': avatars = display.DEFAULT_AVATARS small_photos = api.image_get_all_keys(request.user, view.nick, size='f') # TODO(tyler): Fix this avatar nonsense! own_photos = [{ 'path' : small_photo.key().name(), 'name' : small_photo.key().name()[len('image/'):-len('_f.jpg')], } for small_photo in small_photos ] elif page == 'privacy': PRIVACY_PUBLIC = api.PRIVACY_PUBLIC PRIVACY_CONTACTS = api.PRIVACY_CONTACTS elif page == 'jsbadge': full_page = 'Javascript Badges' elif page == 'badge': badges = [{'id': 'badge-stream', 'width': '200', 'height': '300', 'src': '/themes/%s/badge.swf' % settings.DEFAULT_THEME, 'title': 'Stream', }, {'id': 'badge-map', 'width': '200', 'height': '255', 'src': '/themes/%s/badge-map.swf' % settings.DEFAULT_THEME, 'title': 'Map', }, {'id': 'badge-simple', 'width': '200', 'height': '200', 'src': '/themes/%s/badge-simple.swf' % settings.DEFAULT_THEME, 'title': 'Simple', }, ] elif page in ['password', 'delete']: # Catch for remaining pages before we generate a 404. pass else: return common_views.common_404(request) # rendering c = template.RequestContext(request, locals()) t = loader.get_template('actor/templates/settings_%s.html' % page) return http.HttpResponse(t.render(c))
def actor_settings(request, nick, page='index'): """ just a static page that links to the rest""" nick = clean.nick(nick) view = api.actor_lookup_nick(api.ROOT, nick) if not api.actor_owns_actor(request.user, view): raise exception.ApiOwnerRequired( 'Operation not allowed: %s does not own %s' % (request.user and request.user.nick or '(nobody)', view.nick)) handled = common_views.handle_view_action( request, { 'activation_activate_mobile': view.url('/settings/mobile'), 'activation_request_email': view.url('/settings/email'), 'activation_request_mobile': view.url('/settings/mobile'), 'settings_change_notify': view.url('/settings/notifications'), 'settings_change_privacy': request.path, 'settings_update_account': view.url('/settings/profile'), 'actor_remove': '/logout', #'oauth_remove_consumer': request.path, #'oauth_remove_access_token': request.path }) if handled: return handled # TODO(tyler/termie): This conflicts with the global settings import. # Also, this seems fishy. Do none of the settings.* items work in templates? import settings # TODO(tyler): Merge this into handle_view_action, if possible if 'password' in request.POST: try: validate.nonce(request, 'change_password') password = request.POST.get('password', '') confirm = request.POST.get('confirm', '') validate.password_and_confirm(password, confirm, field='password') api.settings_change_password(request.user, view.nick, password) response = util.RedirectFlash(view.url() + '/settings/password', 'Password updated') request.user.password = util.hash_password(request.user.nick, password) # TODO(mikie): change when cookie-auth is changed user.set_user_cookie(response, request.user) return response except: exception.handle_exception(request) if page == 'feeds': try: if not settings.FEEDS_ENABLED: raise exception.DisabledFeatureError( 'Feeds are currently disabled') except: exception.handle_exception(request) if page == 'photo': redirect_to = view.url() + '/settings/photo' handled = common_views.common_photo_upload(request, redirect_to) if handled: return handled area = 'settings' full_page = page.capitalize() if page == 'mobile': full_page = 'Mobile Number' mobile = api.mobile_get_actor(request.user, view.nick) sms_notify = view.extra.get('sms_notify', False) elif page == 'im': full_page = 'IM Address' im_address = api.im_get_actor(request.user, view.nick) im_notify = view.extra.get('im_notify', False) elif page == 'index': email = api.email_get_actor(request.user, view.nick) email_notify = view.extra.get('email_notify', False) im_address = api.im_get_actor(request.user, view.nick) im_notify = view.extra.get('im_notify', False) elif page == 'feeds': full_page = 'Web Feeds' elif page == 'email': full_page = 'Email Address' email_notify = view.extra.get('email_notify', False) # check if we already have an email email = api.email_get_actor(request.user, view.nick) # otherwise look for an unconfirmed one if not email: unconfirmeds = api.activation_get_actor_email(api.ROOT, view.nick) if unconfirmeds: unconfirmed_email = unconfirmeds[0].content elif page == 'design': handled = common_views.common_design_update(request, view.nick) if handled: return handled full_page = 'Look and Feel' elif page == 'notifications': email = api.email_get_actor(request.user, view.nick) email_notify = view.extra.get('email_notify', False) im_address = api.im_get_actor(request.user, view.nick) im_notify = view.extra.get('im_notify', False) mobile = api.mobile_get_actor(request.user, request.user.nick) sms_notify = view.extra.get('sms_notify', False) sms_confirm = sms_notify and not view.extra.get('sms_confirmed', False) # TODO(termie): remove this once we can actually receive sms sms_confirm = False elif page == 'profile': # check if we already have an email email = api.email_get_actor(request.user, view.nick) # otherwise look for an unconfirmed one if not email: unconfirmeds = api.activation_get_actor_email(api.ROOT, view.nick) if unconfirmeds: unconfirmed_email = unconfirmeds[0].content elif page == 'photo': avatars = display.DEFAULT_AVATARS small_photos = api.image_get_all_keys(request.user, view.nick, size='f') # TODO(tyler): Fix this avatar nonsense! own_photos = [{ 'path': small_photo.key().name(), 'name': small_photo.key().name()[len('image/'):-len('_f.jpg')], } for small_photo in small_photos] elif page == 'privacy': PRIVACY_PUBLIC = api.PRIVACY_PUBLIC PRIVACY_CONTACTS = api.PRIVACY_CONTACTS elif page in ['password', 'delete']: # Catch for remaining pages before we generate a 404. pass else: return common_views.common_404(request) # rendering c = template.RequestContext(request, locals()) t = loader.get_template('actor/templates/settings_%s.html' % page) return http.HttpResponse(t.render(c))
def actor_settings(request, nick, page="index"): """ just a static page that links to the rest""" nick = clean.nick(nick) view = api.actor_lookup_nick(api.ROOT, nick) if not api.actor_owns_actor(request.user, view): raise exception.ApiOwnerRequired( "Operation not allowed: %s does not own %s" % (request.user and request.user.nick or "(nobody)", view.nick) ) handled = common_views.handle_view_action( request, { "activation_activate_mobile": view.url("/settings/mobile"), "activation_request_email": view.url("/settings/email"), "activation_request_mobile": view.url("/settings/mobile"), "settings_change_notify": view.url("/settings/notifications"), "settings_change_privacy": request.path, "settings_update_account": view.url("/settings/profile"), "actor_remove": "/logout", #'oauth_remove_consumer': request.path, #'oauth_remove_access_token': request.path }, ) if handled: return handled # TODO(tyler/termie): This conflicts with the global settings import. # Also, this seems fishy. Do none of the settings.* items work in templates? import settings # TODO(tyler): Merge this into handle_view_action, if possible if "password" in request.POST: try: validate.nonce(request, "change_password") password = request.POST.get("password", "") confirm = request.POST.get("confirm", "") validate.password_and_confirm(password, confirm, field="password") api.settings_change_password(request.user, view.nick, password) response = util.RedirectFlash(view.url() + "/settings/password", "Password updated") request.user.password = util.hash_password(request.user.nick, password) # TODO(mikie): change when cookie-auth is changed user.set_user_cookie(response, request.user) return response except: exception.handle_exception(request) if page == "feeds": try: if not settings.FEEDS_ENABLED: raise exception.DisabledFeatureError("Feeds are currently disabled") except: exception.handle_exception(request) if page == "photo": redirect_to = view.url() + "/settings/photo" handled = common_views.common_photo_upload(request, redirect_to) if handled: return handled area = "settings" full_page = page.capitalize() if page == "mobile": full_page = "Mobile Number" mobile = api.mobile_get_actor(request.user, view.nick) sms_notify = view.extra.get("sms_notify", False) elif page == "im": full_page = "IM Address" im_address = api.im_get_actor(request.user, view.nick) im_notify = view.extra.get("im_notify", False) elif page == "index": email = api.email_get_actor(request.user, view.nick) email_notify = view.extra.get("email_notify", False) im_address = api.im_get_actor(request.user, view.nick) im_notify = view.extra.get("im_notify", False) elif page == "feeds": full_page = "Web Feeds" elif page == "email": full_page = "Email Address" email_notify = view.extra.get("email_notify", False) # check if we already have an email email = api.email_get_actor(request.user, view.nick) # otherwise look for an unconfirmed one if not email: unconfirmeds = api.activation_get_actor_email(api.ROOT, view.nick) if unconfirmeds: unconfirmed_email = unconfirmeds[0].content elif page == "design": redirect_to = view.url() + "/settings/design" handled = common_views.common_design_update(request, redirect_to, view.nick) if handled: return handled full_page = "Look and Feel" elif page == "notifications": email = api.email_get_actor(request.user, view.nick) email_notify = view.extra.get("email_notify", False) im_address = api.im_get_actor(request.user, view.nick) im_notify = view.extra.get("im_notify", False) mobile = api.mobile_get_actor(request.user, request.user.nick) sms_notify = view.extra.get("sms_notify", False) sms_confirm = sms_notify and not view.extra.get("sms_confirmed", False) # TODO(termie): remove this once we can actually receive sms sms_confirm = False elif page == "profile": # check if we already have an email email = api.email_get_actor(request.user, view.nick) # otherwise look for an unconfirmed one if not email: unconfirmeds = api.activation_get_actor_email(api.ROOT, view.nick) if unconfirmeds: unconfirmed_email = unconfirmeds[0].content elif page == "photo": avatars = display.DEFAULT_AVATARS small_photos = api.image_get_all_keys(request.user, view.nick, size="f") # TODO(tyler): Fix this avatar nonsense! own_photos = [ {"path": small_photo.key().name(), "name": small_photo.key().name()[len("images/") : -len("_f.jpg")]} for small_photo in small_photos ] elif page == "privacy": PRIVACY_PUBLIC = api.PRIVACY_PUBLIC PRIVACY_CONTACTS = api.PRIVACY_CONTACTS elif page == "jsbadge": full_page = "Javascript Badges" elif page == "badge": badges = [ { "id": "badge-stream", "width": "200", "height": "300", "src": "/themes/%s/badge.swf" % settings.DEFAULT_THEME, "title": "Stream", }, { "id": "badge-map", "width": "200", "height": "255", "src": "/themes/%s/badge-map.swf" % settings.DEFAULT_THEME, "title": "Map", }, { "id": "badge-simple", "width": "200", "height": "200", "src": "/themes/%s/badge-simple.swf" % settings.DEFAULT_THEME, "title": "Simple", }, ] elif page in ["password", "delete"]: # Catch for remaining pages before we generate a 404. pass else: return common_views.common_404(request) # rendering c = template.RequestContext(request, locals()) t = loader.get_template("actor/templates/settings_%s.html" % page) return http.HttpResponse(t.render(c))
def join_join(request): if request.user: raise exception.AlreadyLoggedInException() redirect_to = get_clean_redirect(request) # 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', '') homepage = request.REQUEST.get('homepage', '') 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/templates/join.html') return http.HttpResponse(t.render(c))