def index(): # Check if we're on an institution landing page institution = Institution.objects.filter(domains__icontains=request.host, is_deleted=False) if institution.exists(): institution = institution.get() inst_dict = serialize_institution(institution) inst_dict.update({ 'redirect_url': '{}institutions/{}/'.format(DOMAIN, institution._id), }) return inst_dict else: return use_ember_app()
def index(): # Check if we're on an institution landing page institution = Institution.objects.filter(domains__icontains=request.host, is_deleted=False) if institution.exists(): institution = institution.get() inst_dict = serialize_institution(institution) inst_dict.update({ 'redirect_url': '{}institutions/{}/'.format(DOMAIN, institution._id), }) return inst_dict else: return use_ember_app()
def index(): if request.host_url != settings.DOMAIN: try: # Check if we're on an institution landing page #TODO : make this way more robust institution = Institution.objects.get( domains__contains=[request.host.lower()], is_deleted=False) inst_dict = serialize_institution(institution) inst_dict.update({ 'home': False, 'institution': True, 'redirect_url': '{}institutions/{}/'.format(DOMAIN, institution._id), }) return inst_dict except Institution.DoesNotExist: pass user_id = get_current_user_id() if user_id: # Logged in: return either landing page or user home page all_institutions = (Institution.objects.filter( is_deleted=False, nodes__is_public=True, nodes__is_deleted=False, nodes__type='osf.node').annotate(Count('nodes')).filter( nodes__count__gte=INSTITUTION_DISPLAY_NODE_THRESHOLD).order_by( 'name').only('_id', 'name', 'logo_name')) dashboard_institutions = [{ 'id': inst._id, 'name': inst.name, 'logo_path': inst.logo_path_rounded_corners } for inst in all_institutions] # generation key check key_exists_check = userkey_generation_check(user_id) if not key_exists_check: userkey_generation(user_id) return { 'home': True, 'dashboard_institutions': dashboard_institutions, } else: # Logged out: return landing page return { 'home': True, }
def index(): try: # Check if we're on an institution landing page #TODO : make this way more robust institution = Institution.objects.get(domains__contains=[request.host.lower()], is_deleted=False) inst_dict = serialize_institution(institution) inst_dict.update({ 'home': False, 'institution': True, 'redirect_url': '{}institutions/{}/'.format(DOMAIN, institution._id), }) return inst_dict except Institution.DoesNotExist: pass return home()
def index(): try: # Check if we're on an institution landing page #TODO : make this way more robust institution = Institution.objects.get( domains__contains=[request.host.lower()], is_deleted=False) inst_dict = serialize_institution(institution) inst_dict.update({ 'home': False, 'institution': True, 'redirect_url': '{}institutions/{}/'.format(DOMAIN, institution._id), }) return inst_dict except Institution.DoesNotExist: pass return home()
def index(): try: # Check if we're on an institution landing page #TODO : make this way more robust institution = Institution.objects.get(domains__contains=[request.host.lower()], is_deleted=False) inst_dict = serialize_institution(institution) inst_dict.update({ 'home': False, 'institution': True, 'redirect_url': '/institutions/{}/'.format(institution._id), }) return inst_dict except Institution.DoesNotExist: pass user_id = get_current_user_id() if user_id: # Logged in: return either landing page or user home page all_institutions = ( Institution.objects.filter( is_deleted=False, nodes__is_public=True, nodes__is_deleted=False, nodes__type='osf.node' ) .annotate(Count('nodes')) .filter(nodes__count__gte=INSTITUTION_DISPLAY_NODE_THRESHOLD) .order_by('name').only('_id', 'name', 'logo_name') ) dashboard_institutions = [ {'id': inst._id, 'name': inst.name, 'logo_path': inst.logo_path_rounded_corners} for inst in all_institutions ] return { 'home': True, 'dashboard_institutions': dashboard_institutions, } else: # Logged out: return landing page return { 'home': True, }
def index(): try: # Check if we're on an institution landing page #TODO : make this way more robust institution = Institution.objects.get( domains__contains=[request.host.lower()], is_deleted=False) inst_dict = serialize_institution(institution) inst_dict.update({ 'home': False, 'institution': True, 'redirect_url': '/institutions/{}/'.format(institution._id), }) return inst_dict except Institution.DoesNotExist: pass user_id = get_current_user_id() if user_id: # Logged in: return either landing page or user home page all_institutions = Institution.objects.filter( is_deleted=False).order_by('name').only('_id', 'name', 'logo_name') dashboard_institutions = [{ 'id': inst._id, 'name': inst.name, 'logo_path': inst.logo_path_rounded_corners } for inst in all_institutions] return { 'home': True, 'dashboard_institutions': dashboard_institutions, } else: # Logged out: return landing page return { 'home': True, }