Exemple #1
0
def get_identity(request):
    """
    Return "(Affiliations: <affiliations>, <campus codes>)"
    """
    res = "(Affiliations:"
    no_affiliation_lengthmark = len(res)
    affi = get_all_affiliations(request)
    if affi["grad"]:
        res += ' Grad'
    if affi["undergrad"]:
        res += ' Undergrad'
    if affi["pce"]:
        res += ' Pce'
    if affi["employee"]:
        res += ' Employee'
    if affi["faculty"]:
        res += ' Faculty'
    if len(res) == no_affiliation_lengthmark:
        res += 'None'
    res += ', Campuses:'
    no_campus_lengthmark = len(res)
    if affi["seattle"]:
        res += ' Seattle'
    if affi["bothell"]:
        res += ' Bothell'
    if affi["tacoma"]:
        res += ' Tacoma'
    if len(res) == no_campus_lengthmark:
        res += 'None'
    res += ') '
    return res
Exemple #2
0
    def test_eos_enrollment(self):
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS,
                           RESTCLIENTS_PWS_DAO_CLASS=FDAO_PWS):
            now_request = RequestFactory().get("/")
            now_request.session = {}

            user = User.objects.create_user(username='******',
                                            email='*****@*****.**',
                                            password='')

            now_request.user = user
            UserServiceMiddleware().process_request(now_request)
            affiliations = get_all_affiliations(now_request)
Exemple #3
0
def index(request,
          year=None,
          quarter=None,
          summer_term=None):

    netid = UserService().get_user()
    if not netid:
        log_invalid_netid_response(logger, timer)
        return invalid_session()

    if _is_mobile(request):
        # On mobile devices, all students get the current myuw.  Non-students
        # are sent to the legacy site.
        if not is_student():
            return redirect_to_legacy_site()
    else:
        # On the desktop, we're migrating users over.  There are 2 classes of
        # users - mandatory and opt-in switchers.  The mandatory users, who
        # are users who haven't been at the UW long enough to be accustomed to
        # the existing myuw.
        # The other class of users can opt to use the legacy myuw instead.
        # Check to see if they have a set preference, and if not, keep them on
        # the new version
        if not is_mandatory_switch_user():
            if is_optin_switch_user():
                if has_legacy_preference():
                    return redirect_to_legacy_site()
            else:
                return redirect_to_legacy_site()

    timer = Timer()
    logger = logging.getLogger('myuw.views.page.index')

    context = {
        "year": year,
        "quarter": quarter,
        "summer_term": summer_term,
        "home_url": "/",
        "err": None,
        "user": {
            "netid": None,
            "affiliations": get_all_affiliations(request)
        },
        "card_display_dates": get_card_visibilty_date_values(request),
    }

    context["user"]["session_key"] = request.session.session_key
    log_session(netid, request.session.session_key, request)
    my_uwemail_forwarding = get_email_forwarding_for_current_user()
    if my_uwemail_forwarding is not None and my_uwemail_forwarding.is_active():
        c_user = context["user"]
        c_user["email_is_uwgmail"] = my_uwemail_forwarding.is_uwgmail()
        c_user["email_is_uwlive"] = my_uwemail_forwarding.is_uwlive()

    context["user"]["netid"] = netid
    if year is None or quarter is None:
        cur_term = get_current_quarter(request)
        if cur_term is None:
            context["err"] = "No current quarter data!"
            log_data_not_found_response(logger, timer)
        else:
            context["year"] = cur_term.year
            context["quarter"] = cur_term.quarter
    else:
        pass
    log_success_response_with_affiliation(logger, timer, request)
    return render_to_response("index.html",
                              context,
                              context_instance=RequestContext(request))
Exemple #4
0
def get_links_for_category(search_category_id, request):
    return _get_links_by_category_and_campus(search_category_id,
                                             get_base_campus(request),
                                             get_all_affiliations(request))
Exemple #5
0
def index(request,
          year=None,
          quarter=None,
          summer_term=None):

    timer = Timer()
    netid = UserService().get_user()
    if not netid:
        log_invalid_netid_response(logger, timer)
        return invalid_session()

    if _is_mobile(request):
        # On mobile devices, all students get the current myuw.  Non-students
        # are sent to the legacy site.
        try:
            if not is_student():
                logger.info("%s not a student, redirect to legacy!" % netid)
                return redirect_to_legacy_site()
        except Exception:
            log_exception(logger,
                          '%s is_student' % netid,
                          traceback.format_exc())
            logger.info("%s, redirected to legacy!" % netid)
            return redirect_to_legacy_site()

    else:
        if is_oldmyuw_user():
            return redirect_to_legacy_site()

    context = {
        "year": year,
        "quarter": quarter,
        "summer_term": summer_term,
        "home_url": "/",
        "err": None,
        "user": {
            "netid": None,
            "affiliations": get_all_affiliations(request)
        },
        "card_display_dates": get_card_visibilty_date_values(request),
    }

    context["user"]["session_key"] = request.session.session_key
    log_session(netid, request.session.session_key, request)
    try:
        my_uwemail_forwarding = get_email_forwarding_for_current_user()
        if my_uwemail_forwarding.is_active():
            c_user = context["user"]
            c_user["email_is_uwgmail"] = my_uwemail_forwarding.is_uwgmail()
            c_user["email_is_uwlive"] = my_uwemail_forwarding.is_uwlive()
    except Exception:
        log_exception(logger,
                      'get_email_forwarding_for_current_user',
                      traceback.format_exc())
        pass

    context["user"]["netid"] = netid
    if year is None or quarter is None:
        cur_term = get_current_quarter(request)
        if cur_term is None:
            context["err"] = "No current quarter data!"
        else:
            context["year"] = cur_term.year
            context["quarter"] = cur_term.quarter
    else:
        pass
    log_success_response_with_affiliation(logger, timer, request)
    return render_to_response("index.html",
                              context,
                              context_instance=RequestContext(request))
Exemple #6
0
def get_links_for_category(search_category_id, request):
    return _get_links_by_category_and_campus(search_category_id,
                                             get_base_campus(request),
                                             get_all_affiliations(request))