def redirect_profile(): """Redirect method for profile.""" if current_user.is_anonymous(): # pragma: no cover return redirect_content_type(url_for('.signin'), status='not_signed_in') if (request.headers.get('Content-Type') == 'application/json') and current_user.is_authenticated(): form = None if current_app.config.upref_mdata: form_data = cached_users.get_user_pref_metadata(current_user.name) form = UserPrefMetadataForm(**form_data) form.set_upref_mdata_choices() return _show_own_profile(current_user, form) else: return redirect_content_type(url_for('.profile', name=current_user.name))
def redirect_profile(): """Redirect method for profile.""" if current_user.is_anonymous: # pragma: no cover return redirect_content_type(url_for('.signin'), status='not_signed_in') if (request.headers.get('Content-Type') == 'application/json') and current_user.is_authenticated: form = None if current_app.config.upref_mdata: form_data = cached_users.get_user_pref_metadata(current_user.name) form = UserPrefMetadataForm(**form_data) form.set_upref_mdata_choices() return _show_own_profile(current_user, form, current_user) else: return redirect_content_type(url_for('.profile', name=current_user.name))
def profile(name): """ Get user profile. Returns a Jinja2 template with the user information. """ user = user_repo.get_by_name(name=name) if user is None: raise abort(404) form = None if current_app.config.upref_mdata: form_data = cached_users.get_user_pref_metadata(user.name) form = UserPrefMetadataForm(**form_data) form.set_upref_mdata_choices() if current_user.is_anonymous() or (user.id != current_user.id): return _show_public_profile(user, form) if current_user.is_authenticated() and user.id == current_user.id: return _show_own_profile(user, form, current_user)
def profile(name): """ Get user profile. Returns a Jinja2 template with the user information. """ user = user_repo.get_by_name(name=name) if user is None: raise abort(404) form = None if current_app.config.upref_mdata: form_data = cached_users.get_user_pref_metadata(user.name) form = UserPrefMetadataForm(**form_data) form.set_upref_mdata_choices() if current_user.is_anonymous() or (user.id != current_user.id): return _show_public_profile(user, form) if current_user.is_authenticated() and user.id == current_user.id: return _show_own_profile(user, form)
def profile(name): """ Get user profile. Returns a Jinja2 template with the user information. """ user = user_repo.get_by_name(name=name) if user is None or current_user.is_anonymous: raise abort(404) form = None (can_update, disabled_fields, hidden_fields) = can_update_user_info(current_user, user) if app_settings.upref_mdata: form_data = cached_users.get_user_pref_metadata(user.name) form = UserPrefMetadataForm(can_update=(can_update, disabled_fields, hidden_fields), **form_data) form.set_upref_mdata_choices() if user.id != current_user.id: return _show_public_profile(user, form, can_update) else: return _show_own_profile(user, form, current_user, can_update)