Example #1
0
def _footer_business_links(language=settings.LANGUAGE_CODE):
    """Return the business links to display in the footer. """
    platform_name = configuration_helpers.get_value('platform_name', settings.PLATFORM_NAME)
    links = [
        ("about", (marketing_link("ABOUT"), _("About"))),
        ("enterprise", (
            marketing_link("ENTERPRISE"),
            _(u"{platform_name} for Business").format(platform_name=platform_name)
        )),
    ]

    if language == settings.LANGUAGE_CODE:
        links.append(('affiliates', (marketing_link("AFFILIATES"), _("Affiliates"))))
        links.append(('openedx', (_footer_openedx_link()["url"], _("Open edX"))))
        links.append(('careers', (marketing_link("CAREERS"), _("Careers"))))
        links.append(("news", (marketing_link("NEWS"), _("News"))))

    return [
        {
            "name": link_name,
            "title": link_title,
            "url": link_url,
        }
        for link_name, (link_url, link_title) in links
        if link_url and link_url != "#"
    ]
Example #2
0
 def test_marketing_link(self):
     # test marketing site on
     with patch.dict('django.conf.settings.FEATURES', {'ENABLE_MKTG_SITE': True}):
         expected_link = 'dummy-root/about-us'
         link = marketing_link('ABOUT')
         self.assertEquals(link, expected_link)
     # test marketing site off
     with patch.dict('django.conf.settings.FEATURES', {'ENABLE_MKTG_SITE': False}):
         # we are using login because it is common across both cms and lms
         expected_link = reverse('login')
         link = marketing_link('ABOUT')
         self.assertEquals(link, expected_link)
Example #3
0
    def _add_honor_code_field(self, form_desc, required=True):
        """Add an honor code field to a form description.

        Arguments:
            form_desc: A form description

        Keyword Arguments:
            required (bool): Whether this field is required; defaults to True

        """
        # Separate terms of service and honor code checkboxes
        if self._is_field_visible("terms_of_service"):
            terms_label = _(u"Honor Code")
            terms_link = marketing_link("HONOR")
            terms_text = _(u"Review the Honor Code")

        # Combine terms of service and honor code checkboxes
        else:
            # Translators: This is a legal document users must agree to
            # in order to register a new account.
            terms_label = _(u"Terms of Service and Honor Code")
            terms_link = marketing_link("HONOR")
            terms_text = _(u"Review the Terms of Service and Honor Code")

        # Translators: "Terms of Service" is a legal document users must agree to
        # in order to register a new account.
        label = _(u"I agree to the {platform_name} {terms_of_service}").format(
            platform_name=configuration_helpers.get_value("PLATFORM_NAME", settings.PLATFORM_NAME),
            terms_of_service=terms_label
        )

        # Translators: "Terms of Service" is a legal document users must agree to
        # in order to register a new account.
        error_msg = _(u"You must agree to the {platform_name} {terms_of_service}").format(
            platform_name=configuration_helpers.get_value("PLATFORM_NAME", settings.PLATFORM_NAME),
            terms_of_service=terms_label
        )

        form_desc.add_field(
            "honor_code",
            label=label,
            field_type="checkbox",
            default=False,
            required=required,
            error_messages={
                "required": error_msg
            },
            supplementalLink=terms_link,
            supplementalText=terms_text
        )
Example #4
0
def _footer_more_info_links():
    """Return the More Information footer links (e.g. terms of service). """

    links = [
        ("terms_of_service_and_honor_code", marketing_link("TOS_AND_HONOR"), _("Terms of Service & Honor Code")),
        ("privacy_policy", marketing_link("PRIVACY"), _("Privacy Policy")),
        ("accessibility_policy", marketing_link("ACCESSIBILITY"), _("Accessibility Policy")),
        ("trademarks", marketing_link("TRADEMARKS"), _("Trademark Policy")),
        ("sitemap", marketing_link("SITE_MAP"), _("Sitemap")),
    ]

    # Backwards compatibility: If a combined "terms of service and honor code"
    # link isn't provided, add separate TOS and honor code links.
    tos_and_honor_link = marketing_link("TOS_AND_HONOR")
    if not (tos_and_honor_link and tos_and_honor_link != "#"):
        links.extend([
            ("terms_of_service", marketing_link("TOS"), _("Terms of Service")),
            ("honor_code", marketing_link("HONOR"), _("Honor Code")),
        ])

    return [
        {
            "name": link_name,
            "title": link_title,
            "url": link_url,
        }
        for link_name, link_url, link_title in links
        if link_url and link_url != "#"
    ]
Example #5
0
def _footer_legal_links(language=settings.LANGUAGE_CODE):
    """Return the legal footer links (e.g. terms of service). """

    links = [
        ("terms_of_service_and_honor_code", (marketing_link("TOS_AND_HONOR"), _("Terms of Service & Honor Code"))),
        ("privacy_policy", (marketing_link("PRIVACY"), _("Privacy Policy"))),
        ("accessibility_policy", (marketing_link("ACCESSIBILITY"), _("Accessibility Policy"))),
        ("media_kit", (marketing_link("MEDIA_KIT"), _("Media Kit"))),
    ]

    # Backwards compatibility: If a combined "terms of service and honor code"
    # link isn't provided, add separate TOS and honor code links.
    tos_and_honor_link = marketing_link("TOS_AND_HONOR")
    if not (tos_and_honor_link and tos_and_honor_link != "#"):
        links.extend([
            ("terms_of_service", (marketing_link("TOS"), _("Terms of Service"))),
            ("honor_code", (marketing_link("HONOR"), _("Honor Code"))),
        ])

    if language == settings.LANGUAGE_CODE:
        position = _find_position_of_link(links, 'accessibility_policy')
        links.insert(position, ("sitemap", (marketing_link("SITE_MAP"), _("Sitemap"))))

    return [
        {
            "name": link_name,
            "title": link_title,
            "url": link_url,
        }
        for link_name, (link_url, link_title) in links
        if link_url and link_url != "#"
    ]
Example #6
0
def _footer_more_info_links(language=settings.LANGUAGE_CODE):
    """Return the More Information footer links (e.g. terms of service). """

    links = [
        ("terms_of_service_and_honor_code",
         (marketing_link("TOS_AND_HONOR"),
          _("Terms of Service & Honor Code"))),
        ("privacy_policy", (marketing_link("PRIVACY"), _("Privacy Policy"))),
        ("accessibility_policy", (marketing_link("ACCESSIBILITY"),
                                  _("Accessibility Policy"))),
    ]

    # Backwards compatibility: If a combined "terms of service and honor code"
    # link isn't provided, add separate TOS and honor code links.
    tos_and_honor_link = marketing_link("TOS_AND_HONOR")
    if not (tos_and_honor_link and tos_and_honor_link != "#"):
        links.extend([
            ("terms_of_service", (marketing_link("TOS"),
                                  _("Terms of Service"))),
            ("honor_code", (marketing_link("HONOR"), _("Honor Code"))),
        ])

    if language == settings.LANGUAGE_CODE:
        links.append(("trademarks", (marketing_link("TRADEMARKS"),
                                     _("Trademark Policy"))))
        links.append(("sitemap", (marketing_link("SITE_MAP"), _("Sitemap"))))

    return [{
        "name": link_name,
        "title": link_title,
        "url": link_url,
    } for link_name, (link_url, link_title) in links
            if link_url and link_url != "#"]
Example #7
0
    def _add_honor_code_field(self, form_desc, required=True):
        """Add an honor code field to a form description.

        Arguments:
            form_desc: A form description

        Keyword Arguments:
            required (bool): Whether this field is required; defaults to True

        """
        # Separate terms of service and honor code checkboxes
        if self._is_field_visible("terms_of_service"):
            terms_label = _(u"Honor Code")
            terms_link = marketing_link("HONOR")
            terms_text = _(u"Review the Honor Code")

        # Combine terms of service and honor code checkboxes
        else:
            # Translators: This is a legal document users must agree to
            # in order to register a new account.
            terms_label = _(u"Terms of Service and Honor Code")
            terms_link = marketing_link("HONOR")
            terms_text = _(u"Review the Terms of Service and Honor Code")

        # Translators: "Terms of Service" is a legal document users must agree to
        # in order to register a new account.
        label = _(u"I agree to the {platform_name} {terms_of_service}").format(
            platform_name=configuration_helpers.get_value("PLATFORM_NAME", settings.PLATFORM_NAME),
            terms_of_service=terms_label
        )

        # Translators: "Terms of Service" is a legal document users must agree to
        # in order to register a new account.
        error_msg = _(u"You must agree to the {platform_name} {terms_of_service}").format(
            platform_name=configuration_helpers.get_value("PLATFORM_NAME", settings.PLATFORM_NAME),
            terms_of_service=terms_label
        )

        form_desc.add_field(
            "honor_code",
            label=label,
            field_type="checkbox",
            default=False,
            required=required,
            error_messages={
                "required": error_msg
            },
            supplementalLink=terms_link,
            supplementalText=terms_text
        )
Example #8
0
def _footer_connect_links():
    """Return the connect links to display in the footer. """

    return [{
        "name": link_name,
        "title": link_title,
        "url": link_url,
    } for link_name, link_url, link_title in [
        ("blog", marketing_link("BLOG"), _("Blog")),
        ("contact", _build_support_form_url(), _("Contact Us")),
        ("help-center", settings.SUPPORT_SITE_LINK, _("Help Center")),
        ("media_kit", marketing_link("MEDIA_KIT"), _("Media Kit")),
        ("donate", marketing_link("DONATE"), _("Donate")),
    ] if link_url and link_url != "#"]
Example #9
0
 def test_marketing_link(self):
     # test marketing site on
     with patch.dict('django.conf.settings.FEATURES',
                     {'ENABLE_MKTG_SITE': True}):
         expected_link = 'dummy-root/about-us'
         link = marketing_link('ABOUT')
         self.assertEquals(link, expected_link)
     # test marketing site off
     with patch.dict('django.conf.settings.FEATURES',
                     {'ENABLE_MKTG_SITE': False}):
         # we are using login because it is common across both cms and lms
         expected_link = reverse('login')
         link = marketing_link('ABOUT')
         self.assertEquals(link, expected_link)
Example #10
0
def _footer_legal_links(language=settings.LANGUAGE_CODE):
    """Return the legal footer links (e.g. terms of service). """

    links = [
        ("terms_of_service_and_honor_code", (marketing_link("TOS_AND_HONOR"), _("Terms of Service & Honor Code"))),
        ("privacy_policy", (marketing_link("PRIVACY"), _("Privacy Policy"))),
        ("accessibility_policy", (marketing_link("ACCESSIBILITY"), _("Accessibility Policy"))),
        ("media_kit", (marketing_link("MEDIA_KIT"), _("Media Kit"))),
    ]

    # Backwards compatibility: If a combined "terms of service and honor code"
    # link isn't provided, add separate TOS and honor code links.
    tos_and_honor_link = marketing_link("TOS_AND_HONOR")
    if not (tos_and_honor_link and tos_and_honor_link != "#"):
        links.extend([
            ("terms_of_service", (marketing_link("TOS"), _("Terms of Service"))),
            ("honor_code", (marketing_link("HONOR"), _("Honor Code"))),
        ])

    if language == settings.LANGUAGE_CODE:
        position = _find_position_of_link(links, 'accessibility_policy')
        links.insert(position, ("sitemap", (marketing_link("SITE_MAP"), _("Sitemap"))))

    return [
        {
            "name": link_name,
            "title": link_title,
            "url": link_url,
        }
        for link_name, (link_url, link_title) in links
        if link_url and link_url != "#"
    ]
Example #11
0
File: tests.py Project: saadow123/1
 def test_marketing_link(self):
     with override_settings(
             MKTG_URL_LINK_MAP={'ABOUT': self._get_test_url_name()}):
         # test marketing site on
         with patch.dict('django.conf.settings.FEATURES',
                         {'ENABLE_MKTG_SITE': True}):
             expected_link = 'https://dummy-root/about-us'
             link = marketing_link('ABOUT')
             self.assertEqual(link, expected_link)
         # test marketing site off
         with patch.dict('django.conf.settings.FEATURES',
                         {'ENABLE_MKTG_SITE': False}):
             expected_link = reverse(self._get_test_url_name())
             link = marketing_link('ABOUT')
             self.assertEqual(link, expected_link)
Example #12
0
def get_base_template_context(site):
    """
    Dict with entries needed for all templates that use the base template.
    """
    # When on LMS and a dashboard is available, use that as the dashboard url.
    # Otherwise, use the home url instead.
    try:
        dashboard_url = reverse('dashboard')
    except NoReverseMatch:
        dashboard_url = reverse('home')

    return {
        # Platform information
        'homepage_url': marketing_link('ROOT'),
        'dashboard_url': dashboard_url,
        'template_revision': getattr(settings, 'EDX_PLATFORM_REVISION', None),
        'platform_name': get_config_value_from_site_or_settings(
            'PLATFORM_NAME',
            site=site,
            site_config_name='platform_name',
        ),
        'contact_email': get_config_value_from_site_or_settings(
            'CONTACT_EMAIL', site=site, site_config_name='contact_email'),
        'contact_mailing_address': get_config_value_from_site_or_settings(
            'CONTACT_MAILING_ADDRESS', site=site, site_config_name='contact_mailing_address'),
        'social_media_urls': get_config_value_from_site_or_settings('SOCIAL_MEDIA_FOOTER_URLS', site=site),
        'mobile_store_urls': get_config_value_from_site_or_settings('MOBILE_STORE_URLS', site=site),
    }
Example #13
0
def _footer_navigation_links():
    """Return the navigation links to display in the footer. """
    platform_name = configuration_helpers.get_value('platform_name',
                                                    settings.PLATFORM_NAME)
    return [
        {
            "name": link_name,
            "title": link_title,
            "url": link_url,
        } for link_name, link_url, link_title in [
            #("about", "http://navoica.edu.pl/", _("About the project")),
            ("faq", "/faq", _("FAQ")),
            ("legend", "/legend", _("Legend_title")),
            #("partners", marketing_link("PARTNERS"), _("Partners")),
            #("cooperation", marketing_link("COOPERATION"), _("Cooperation")),
            #("enterprise", marketing_link("ENTERPRISE"),
            # _("{platform_name} for Business").format(platform_name=platform_name)),
            #("blog", marketing_link("BLOG"), _("Blog")),
            #("news", marketing_link("NEWS"), _("News")),
            #("help-center", settings.SUPPORT_SITE_LINK, _("Help Center")),
            ("contact", marketing_link("CONTACT"), _("Contact")),
            #("careers", marketing_link("CAREERS"), _("Careers")),
            #("donate", marketing_link("DONATE"), _("Donate")),
        ] if link_url and link_url != "#"
    ]
Example #14
0
def get_base_template_context(site):
    """
    Dict with entries needed for all templates that use the base template.
    """
    # When on LMS and a dashboard is available, use that as the dashboard url.
    # Otherwise, use the home url instead.
    try:
        dashboard_url = reverse('dashboard')
    except NoReverseMatch:
        dashboard_url = reverse('home')

    return {
        # Platform information
        'homepage_url': marketing_link('ROOT'),
        'dashboard_url': dashboard_url,
        'template_revision': getattr(settings, 'EDX_PLATFORM_REVISION', None),
        'platform_name': get_config_value_from_site_or_settings(
            'PLATFORM_NAME',
            site=site,
            site_config_name='platform_name',
        ),
        'contact_email': get_config_value_from_site_or_settings(
            'CONTACT_EMAIL', site=site, site_config_name='contact_email'),
        'contact_mailing_address': get_config_value_from_site_or_settings(
            'CONTACT_MAILING_ADDRESS', site=site, site_config_name='contact_mailing_address'),
        'social_media_urls': get_config_value_from_site_or_settings('SOCIAL_MEDIA_FOOTER_URLS', site=site),
        'mobile_store_urls': get_config_value_from_site_or_settings('MOBILE_STORE_URLS', site=site),
    }
Example #15
0
def _recurring_nudge_schedules_for_hour(site, target_hour, org_list, exclude_orgs=False):
    beginning_of_day = target_hour.replace(hour=0, minute=0, second=0)
    users = User.objects.filter(
        courseenrollment__schedule__start__gte=beginning_of_day,
        courseenrollment__schedule__start__lt=beginning_of_day + datetime.timedelta(days=1),
        courseenrollment__is_active=True,
    ).annotate(
        first_schedule=Min('courseenrollment__schedule__start')
    ).filter(
        first_schedule__gte=target_hour,
        first_schedule__lt=target_hour + datetime.timedelta(minutes=60)
    )

    schedules = Schedule.objects.select_related(
        'enrollment__user__profile',
        'enrollment__course',
    ).filter(
        enrollment__user__in=users,
        start__gte=beginning_of_day,
        start__lt=beginning_of_day + datetime.timedelta(days=1),
        enrollment__is_active=True,
    ).order_by('enrollment__user__id')

    if org_list is not None:
        if exclude_orgs:
            schedules = schedules.exclude(enrollment__course__org__in=org_list)
        else:
            schedules = schedules.filter(enrollment__course__org__in=org_list)

    if "read_replica" in settings.DATABASES:
        schedules = schedules.using("read_replica")

    LOG.debug('Scheduled Nudge: Query = %r', schedules.query.sql_with_params())

    dashboard_relative_url = reverse('dashboard')

    for (user, user_schedules) in groupby(schedules, lambda s: s.enrollment.user):
        user_schedules = list(user_schedules)
        course_id_strs = [str(schedule.enrollment.course_id) for schedule in user_schedules]

        first_schedule = user_schedules[0]
        template_context = {
            'student_name': user.profile.name,

            'course_name': first_schedule.enrollment.course.display_name,
            'course_url': absolute_url(site, reverse('course_root', args=[str(first_schedule.enrollment.course_id)])),

            # This is used by the bulk email optout policy
            'course_ids': course_id_strs,

            # Platform information
            'homepage_url': encode_url(marketing_link('ROOT')),
            'dashboard_url': absolute_url(site, dashboard_relative_url),
            'template_revision': settings.EDX_PLATFORM_REVISION,
            'platform_name': settings.PLATFORM_NAME,
            'contact_mailing_address': settings.CONTACT_MAILING_ADDRESS,
            'social_media_urls': encode_urls_in_dict(getattr(settings, 'SOCIAL_MEDIA_FOOTER_URLS', {})),
            'mobile_store_urls': encode_urls_in_dict(getattr(settings, 'MOBILE_STORE_URLS', {})),
        }
        yield (user, first_schedule.enrollment.course.language, template_context)
Example #16
0
    def _add_terms_of_service_field(self, form_desc, required=True):
        """Add a terms of service field to a form description.

        Arguments:
            form_desc: A form description

        Keyword Arguments:
            required (bool): Whether this field is required; defaults to True

        """
        # Translators: This is a legal document users must agree to
        # in order to register a new account.
        terms_text = _(u"Terms of Service")
        terms_link = u'<a href="{url}">{terms_text}</a>'.format(url=marketing_link("TOS"), terms_text=terms_text)

        # Translators: "Terms of service" is a legal document users must agree to
        # in order to register a new account.
        label = _(u"I agree to the {platform_name} {terms_of_service}.").format(
            platform_name=settings.PLATFORM_NAME, terms_of_service=terms_link
        )

        # Translators: "Terms of service" is a legal document users must agree to
        # in order to register a new account.
        error_msg = _(u"You must agree to the {platform_name} {terms_of_service}.").format(
            platform_name=settings.PLATFORM_NAME, terms_of_service=terms_link
        )

        form_desc.add_field(
            "terms_of_service",
            label=label,
            field_type="checkbox",
            default=False,
            required=required,
            error_messages={"required": error_msg},
        )
Example #17
0
def _footer_connect_links():
    """Return the connect links to display in the footer. """
    return [
        {
            "name": link_name,
            "title": link_title,
            "url": link_url,
        }
        for link_name, link_url, link_title in [
            ("blog", marketing_link("BLOG"), _("Blog")),
            ("contact", marketing_link("CONTACT"), _("Contact Us")),
            ("help-center", settings.SUPPORT_SITE_LINK, _("Help Center")),
            ("media_kit", marketing_link("MEDIA_KIT"), _("Media Kit")),
            ("donate", marketing_link("DONATE"), _("Donate")),
        ]
        if link_url and link_url != "#"
    ]
Example #18
0
def _footer_legal_links():
    """Return the legal footer links (e.g. terms of service). """

    links = [
        ("terms_of_service_and_honor_code", marketing_link("TOS_AND_HONOR"),
         _("Terms of Service & Honor Code")),
        ("privacy_policy", marketing_link("PRIVACY"), _("Privacy Policy")),
        ("accessibility_policy", marketing_link("ACCESSIBILITY"),
         _("Accessibility Policy")),
        ("sitemap", marketing_link("SITE_MAP"), _("Sitemap")),
    ]

    # Backwards compatibility: If a combined "terms of service and honor code"
    # link isn't provided, add separate TOS and honor code links.
    tos_and_honor_link = marketing_link("TOS_AND_HONOR")
    if not (tos_and_honor_link and tos_and_honor_link != "#"):
        links.extend([
            ("terms_of_service", marketing_link("TOS"), _("Terms of Service")),
            ("honor_code", marketing_link("HONOR"), _("Honor Code")),
        ])

    return [{
        "name": link_name,
        "title": link_title,
        "url": link_url,
    } for link_name, link_url, link_title in links
            if link_url and link_url != "#"]
Example #19
0
def course_info(request, course_id):
    """
    Display the course's info.html, or 404 if there is no such course.

    Assumes the course_id is in a valid format.
    """

    course_key = SlashSeparatedCourseKey.from_deprecated_string(course_id)

    with modulestore().bulk_operations(course_key):
        course = get_course_with_access(request.user, 'load', course_key)

        # check to see if there is a required survey that must be taken before
        # the user can access the course.
        if request.user.is_authenticated() and survey.utils.must_answer_survey(
                course, request.user):
            return redirect(reverse('course_survey',
                                    args=[unicode(course.id)]))

        staff_access = has_access(request.user, 'staff', course)
        masq = setup_masquerade(
            request,
            staff_access)  # allow staff to toggle masquerade on info page
        reverifications = fetch_reverify_banner_info(request, course_key)
        studio_url = get_studio_url(course, 'course_info')

        # link to where the student should go to enroll in the course:
        # about page if there is not marketing site, SITE_NAME if there is
        url_to_enroll = reverse(course_about, args=[course_id])
        if settings.FEATURES.get('ENABLE_MKTG_SITE'):
            url_to_enroll = marketing_link('COURSES')

        show_enroll_banner = request.user.is_authenticated(
        ) and not CourseEnrollment.is_enrolled(request.user, course.id)

        context = {
            'request': request,
            'course_id': course_key.to_deprecated_string(),
            'cache': None,
            'course': course,
            'staff_access': staff_access,
            'masquerade': masq,
            'studio_url': studio_url,
            'reverifications': reverifications,
            'show_enroll_banner': show_enroll_banner,
            'url_to_enroll': url_to_enroll,
        }

        now = datetime.now(UTC())
        effective_start = _adjust_start_date_for_beta_testers(
            request.user, course, course_key)
        if staff_access and now < effective_start:
            # Disable student view button if user is staff and
            # course is not yet visible to students.
            context['disable_student_access'] = True

        return render_to_response('courseware/info.html', context)
Example #20
0
def learner_profile_context(request, profile_username, user_is_staff):
    """Context for the learner profile page.

    Args:
        logged_in_user (object): Logged In user.
        profile_username (str): username of user whose profile is requested.
        user_is_staff (bool): Logged In user has staff access.
        build_absolute_uri_func ():

    Returns:
        dict

    Raises:
        ObjectDoesNotExist: the specified profile_username does not exist.
    """
    profile_user = User.objects.get(username=profile_username)
    logged_in_user = request.user

    own_profile = (logged_in_user.username == profile_username)

    account_settings_data = get_account_settings(request, profile_username)

    preferences_data = get_user_preferences(profile_user, profile_username)

    context = {
        'data': {
            'profile_user_id': profile_user.id,
            'default_public_account_fields': settings.ACCOUNT_VISIBILITY_CONFIGURATION['public_fields'],
            'default_visibility': settings.ACCOUNT_VISIBILITY_CONFIGURATION['default_visibility'],
            'accounts_api_url': reverse("accounts_api", kwargs={'username': profile_username}),
            'preferences_api_url': reverse('preferences_api', kwargs={'username': profile_username}),
            'preferences_data': preferences_data,
            'account_settings_data': account_settings_data,
            'profile_image_upload_url': reverse('profile_image_upload', kwargs={'username': profile_username}),
            'profile_image_remove_url': reverse('profile_image_remove', kwargs={'username': profile_username}),
            'profile_image_max_bytes': settings.PROFILE_IMAGE_MAX_BYTES,
            'profile_image_min_bytes': settings.PROFILE_IMAGE_MIN_BYTES,
            'account_settings_page_url': reverse('account_settings'),
            'has_preferences_access': (logged_in_user.username == profile_username or user_is_staff),
            'own_profile': own_profile,
            'country_options': list(countries),
            'find_courses_url': marketing_link('COURSES'),
            'language_options': settings.ALL_LANGUAGES,
            'badges_logo': staticfiles_storage.url('certificates/images/backpack-logo.png'),
            'badges_icon': staticfiles_storage.url('certificates/images/ico-mozillaopenbadges.png'),
            'backpack_ui_img': staticfiles_storage.url('certificates/images/backpack-ui.png'),
            'platform_name': microsite.get_value('platform_name', settings.PLATFORM_NAME),
        },
        'disable_courseware_js': True,
        'show_program_listing': ProgramsApiConfig.current().show_program_listing,
    }

    if badges_enabled():
        context['data']['badges_api_url'] = reverse("badges_api:user_assertions", kwargs={'username': profile_username})

    return context
Example #21
0
def get_base_template_context(site):
    """
    Dict with entries needed for all templates that use the base template.
    """
    # When on LMS and a dashboard is available, use that as the dashboard url.
    # Otherwise, use the home url instead.
    try:
        dashboard_url = reverse('dashboard')
    except NoReverseMatch:
        dashboard_url = reverse('home')

    contact_mailing_address = configuration_helpers.get_value(
        'CONTACT_MAILING_ADDRESS')

    if not contact_mailing_address:
        contact_mailing_address = get_config_value_from_site_or_settings(
            'CONTACT_MAILING_ADDRESS',
            site=site,
            site_config_name='CONTACT_MAILING_ADDRESS')

    return {
        # Platform information
        'homepage_url':
        marketing_link('ROOT'),
        'dashboard_url':
        dashboard_url,
        'template_revision':
        getattr(settings, 'EDX_PLATFORM_REVISION', None),
        'platform_name':
        get_config_value_from_site_or_settings(
            'PLATFORM_NAME',
            site=site,
            site_config_name='platform_name',
        ),
        'contact_email':
        get_config_value_from_site_or_settings(
            'CONTACT_EMAIL', site=site, site_config_name='contact_email'),
        'contact_mailing_address':
        contact_mailing_address,
        'social_media_urls':
        get_config_value_from_site_or_settings('SOCIAL_MEDIA_FOOTER_URLS',
                                               site=site),
        'mobile_store_urls':
        get_config_value_from_site_or_settings('MOBILE_STORE_URLS', site=site),

        # Context processor values for dynamic theming
        'edly_colors_config':
        get_theme_colors(),
        'edly_fonts_config':
        configuration_helpers.get_dict('FONTS', DEFAULT_FONTS_DICT),
        'edly_branding_config':
        configuration_helpers.get_dict('BRANDING', DEFAULT_BRANDING_DICT),
        # Context processor value for edly app
        'edly_copyright_text':
        configuration_helpers.get_value('EDLY_COPYRIGHT_TEXT')
    }
Example #22
0
def _footer_business_links():
    """Return the business links to display in the footer. """
    platform_name = configuration_helpers.get_value('platform_name',
                                                    settings.PLATFORM_NAME)

    return [{
        "name": link_name,
        "title": link_title,
        "url": link_url,
    } for link_name, link_url, link_title in [
        ("about", marketing_link("ABOUT"), _("About")),
        ("enterprise", marketing_link("ENTERPRISE"),
         _("{platform_name} for Business").format(
             platform_name=platform_name)),
        ("affiliates", marketing_link("AFFILIATES"), _("Affiliates")),
        ("openedx", _footer_openedx_link()["url"], _("Open edX")),
        ("careers", marketing_link("CAREERS"), _("Careers")),
        ("news", marketing_link("NEWS"), _("News")),
    ] if link_url and link_url != "#"]
Example #23
0
def _footer_connect_links(language=settings.LANGUAGE_CODE):
    """Return the connect links to display in the footer. """
    links = [
        ("blog", (marketing_link("BLOG"), _("Blog"))),
        ("contact", (_build_support_form_url(), _("Contact Us"))),
        ("help-center", (settings.SUPPORT_SITE_LINK, _("Help Center"))),
    ]

    if language == settings.LANGUAGE_CODE:
        links.append(
            ("media_kit", (marketing_link("MEDIA_KIT"), _("Media Kit"))))
        links.append(("donate", (marketing_link("DONATE"), _("Donate"))))

    return [{
        "name": link_name,
        "title": link_title,
        "url": link_url,
    } for link_name, (link_url, link_title) in links
            if link_url and link_url != "#"]
Example #24
0
def learner_profile_context(request, profile_username, user_is_staff):
    """Context for the learner profile page.

    Args:
        logged_in_user (object): Logged In user.
        profile_username (str): username of user whose profile is requested.
        user_is_staff (bool): Logged In user has staff access.
        build_absolute_uri_func ():

    Returns:
        dict

    Raises:
        ObjectDoesNotExist: the specified profile_username does not exist.
    """
    profile_user = User.objects.get(username=profile_username)
    logged_in_user = request.user

    own_profile = (logged_in_user.username == profile_username)

    account_settings_data = get_account_settings(request, [profile_username])[0]

    preferences_data = get_user_preferences(profile_user, profile_username)

    context = {
        'data': {
            'profile_user_id': profile_user.id,
            'default_public_account_fields': settings.ACCOUNT_VISIBILITY_CONFIGURATION['public_fields'],
            'default_visibility': settings.ACCOUNT_VISIBILITY_CONFIGURATION['default_visibility'],
            'accounts_api_url': reverse("accounts_api", kwargs={'username': profile_username}),
            'preferences_api_url': reverse('preferences_api', kwargs={'username': profile_username}),
            'preferences_data': preferences_data,
            'account_settings_data': account_settings_data,
            'profile_image_upload_url': reverse('profile_image_upload', kwargs={'username': profile_username}),
            'profile_image_remove_url': reverse('profile_image_remove', kwargs={'username': profile_username}),
            'profile_image_max_bytes': settings.PROFILE_IMAGE_MAX_BYTES,
            'profile_image_min_bytes': settings.PROFILE_IMAGE_MIN_BYTES,
            'account_settings_page_url': reverse('account_settings'),
            'has_preferences_access': (logged_in_user.username == profile_username or user_is_staff),
            'own_profile': own_profile,
            'country_options': list(countries),
            'find_courses_url': marketing_link('COURSES'),
            'language_options': settings.ALL_LANGUAGES,
            'badges_logo': staticfiles_storage.url('certificates/images/backpack-logo.png'),
            'badges_icon': staticfiles_storage.url('certificates/images/ico-mozillaopenbadges.png'),
            'backpack_ui_img': staticfiles_storage.url('certificates/images/backpack-ui.png'),
            'platform_name': configuration_helpers.get_value('PLATFORM_NAME', settings.PLATFORM_NAME),
        },
        'disable_courseware_js': True,
    }

    if badges_enabled():
        context['data']['badges_api_url'] = reverse("badges_api:user_assertions", kwargs={'username': profile_username})

    return context
Example #25
0
def get_home_url():
    """
    Lookup and return home page url, lookup is performed in the following order

    1. return marketing root URL, If marketing is enabled
    2. Otherwise return dashboard URL.
    """
    if settings.FEATURES.get('ENABLE_MKTG_SITE', False):
        return marketing_link('ROOT')

    return reverse('dashboard')
Example #26
0
def render_marketing_link(context, name):
    __M_caller = context.caller_stack._push_frame()
    try:
        __M_writer = context.writer()

        link = marketing_link(name)
        return "/" if link == "#" else link

        return ''
    finally:
        context.caller_stack._pop_frame()
Example #27
0
def get_home_url():
    """
    Lookup and return home page url, lookup is performed in the following order

    1. return marketing root URL, If marketing is enabled
    2. Otherwise return dashboard URL.
    """
    if settings.FEATURES.get('ENABLE_MKTG_SITE', False):
        return marketing_link('ROOT')

    return reverse('dashboard')
Example #28
0
def get_base_template_context(site):
    """Dict with entries needed for all templates that use the base template"""
    return {
        # Platform information
        'homepage_url': encode_url(marketing_link('ROOT')),
        'dashboard_url': absolute_url(site, reverse('dashboard')),
        'template_revision': settings.EDX_PLATFORM_REVISION,
        'platform_name': settings.PLATFORM_NAME,
        'contact_mailing_address': settings.CONTACT_MAILING_ADDRESS,
        'social_media_urls': encode_urls_in_dict(getattr(settings, 'SOCIAL_MEDIA_FOOTER_URLS', {})),
        'mobile_store_urls': encode_urls_in_dict(getattr(settings, 'MOBILE_STORE_URLS', {})),
    }
Example #29
0
def _footer_connect_links(language=settings.LANGUAGE_CODE):
    """Return the connect links to display in the footer. """
    links = [
        ("blog", (marketing_link("BLOG"), _("Blog"))),
        ("contact", (_build_support_form_url(full_path=True), _("Contact Us"))),
        ("help-center", (settings.SUPPORT_SITE_LINK, _("Help Center"))),
    ]

    if language == settings.LANGUAGE_CODE:
        links.append(("media_kit", (marketing_link("MEDIA_KIT"), _("Media Kit"))))
        links.append(("donate", (marketing_link("DONATE"), _("Donate"))))

    return [
        {
            "name": link_name,
            "title": link_title,
            "url": link_url,
        }
        for link_name, (link_url, link_title) in links
        if link_url and link_url != "#"
    ]
Example #30
0
    def _add_honor_code_field(self, form_desc, required=True):
        """Add an honor code field to a form description.

        Arguments:
            form_desc: A form description

        Keyword Arguments:
            required (Boolean): Whether this field is required; defaults to True

        """
        # Separate terms of service and honor code checkboxes
        if self._is_field_visible("terms_of_service"):
            terms_text = _(u"Honor Code")

        # Combine terms of service and honor code checkboxes
        else:
            # Translators: This is a legal document users must agree to
            # in order to register a new account.
            terms_text = _(u"Terms of Service and Honor Code")

        terms_link = u"<a href=\"{url}\">{terms_text}</a>".format(
            url=marketing_link("HONOR"),
            terms_text=terms_text
        )

        # Translators: "Terms of Service" is a legal document users must agree to
        # in order to register a new account.
        label = _(
            u"I agree to the {platform_name} {terms_of_service}."
        ).format(
            platform_name=settings.PLATFORM_NAME,
            terms_of_service=terms_link
        )

        # Translators: "Terms of Service" is a legal document users must agree to
        # in order to register a new account.
        error_msg = _(
            u"You must agree to the {platform_name} {terms_of_service}."
        ).format(
            platform_name=settings.PLATFORM_NAME,
            terms_of_service=terms_link
        )

        form_desc.add_field(
            "honor_code",
            label=label,
            field_type="checkbox",
            default=False,
            required=required,
            error_messages={
                "required": error_msg
            }
        )
def get_base_template_context(site):
    """Dict with entries needed for all templates that use the base template"""
    return {
        # Platform information
        'homepage_url': encode_url(marketing_link('ROOT')),
        'dashboard_url': absolute_url(site, reverse('dashboard')),
        'template_revision': settings.EDX_PLATFORM_REVISION,
        'platform_name': settings.PLATFORM_NAME,
        'contact_mailing_address': settings.CONTACT_MAILING_ADDRESS,
        'social_media_urls': encode_urls_in_dict(getattr(settings, 'SOCIAL_MEDIA_FOOTER_URLS', {})),
        'mobile_store_urls': encode_urls_in_dict(getattr(settings, 'MOBILE_STORE_URLS', {})),
    }
Example #32
0
def course_info(request, course_id):
    """
    Display the course's info.html, or 404 if there is no such course.

    Assumes the course_id is in a valid format.
    """

    course_key = SlashSeparatedCourseKey.from_deprecated_string(course_id)

    with modulestore().bulk_operations(course_key):
        course = get_course_with_access(request.user, "load", course_key)

        # check to see if there is a required survey that must be taken before
        # the user can access the course.
        if request.user.is_authenticated() and survey.utils.must_answer_survey(course, request.user):
            return redirect(reverse("course_survey", args=[unicode(course.id)]))

        staff_access = has_access(request.user, "staff", course)
        masquerade = setup_masquerade(request, course_key, staff_access)  # allow staff to masquerade on the info page
        reverifications = fetch_reverify_banner_info(request, course_key)
        studio_url = get_studio_url(course, "course_info")

        # link to where the student should go to enroll in the course:
        # about page if there is not marketing site, SITE_NAME if there is
        url_to_enroll = reverse(course_about, args=[course_id])
        if settings.FEATURES.get("ENABLE_MKTG_SITE"):
            url_to_enroll = marketing_link("COURSES")

        show_enroll_banner = request.user.is_authenticated() and not CourseEnrollment.is_enrolled(
            request.user, course.id
        )

        context = {
            "request": request,
            "course_id": course_key.to_deprecated_string(),
            "cache": None,
            "course": course,
            "staff_access": staff_access,
            "masquerade": masquerade,
            "studio_url": studio_url,
            "reverifications": reverifications,
            "show_enroll_banner": show_enroll_banner,
            "url_to_enroll": url_to_enroll,
        }

        now = datetime.now(UTC())
        effective_start = _adjust_start_date_for_beta_testers(request.user, course, course_key)
        if staff_access and now < effective_start:
            # Disable student view button if user is staff and
            # course is not yet visible to students.
            context["disable_student_access"] = True

        return render_to_response("courseware/info.html", context)
Example #33
0
    def _add_honor_code_field(self, form_desc, required=True):
        """Add an honor code field to a form description.

        Arguments:
            form_desc: A form description

        Keyword Arguments:
            required (Boolean): Whether this field is required; defaults to True

        """
        # Separate terms of service and honor code checkboxes
        if self._is_field_visible("terms_of_service"):
            terms_text = _(u"Honor Code")

        # Combine terms of service and honor code checkboxes
        else:
            # Translators: This is a legal document users must agree to
            # in order to register a new account.
            terms_text = _(u"Terms of Service and Honor Code")

        terms_link = u"<a href=\"{url}\">{terms_text}</a>".format(
            url=marketing_link("HONOR"),
            terms_text=terms_text
        )

        # Translators: "Terms of Service" is a legal document users must agree to
        # in order to register a new account.
        label = _(
            u"I agree to the {platform_name} {terms_of_service}."
        ).format(
            platform_name=settings.PLATFORM_NAME,
            terms_of_service=terms_link
        )

        # Translators: "Terms of Service" is a legal document users must agree to
        # in order to register a new account.
        error_msg = _(
            u"You must agree to the {platform_name} {terms_of_service}."
        ).format(
            platform_name=settings.PLATFORM_NAME,
            terms_of_service=terms_link
        )

        form_desc.add_field(
            "honor_code",
            label=label,
            field_type="checkbox",
            default=False,
            required=required,
            error_messages={
                "required": error_msg
            }
        )
Example #34
0
def _footer_business_links():
    """Return the business links to display in the footer. """
    platform_name = configuration_helpers.get_value('platform_name', settings.PLATFORM_NAME)

    return [
        {
            "name": link_name,
            "title": link_title,
            "url": link_url,
        }
        for link_name, link_url, link_title in [
            ("about", marketing_link("ABOUT"), _("About")),
            ("enterprise", marketing_link("ENTERPRISE"),
             _("{platform_name} for Business").format(platform_name=platform_name)),
            ("affiliates", marketing_link("AFFILIATES"), _("Affiliates")),
            ("openedx", _footer_openedx_link()["url"], _("Open edX")),
            ("careers", marketing_link("CAREERS"), _("Careers")),
            ("news", marketing_link("NEWS"), _("News")),
        ]
        if link_url and link_url != "#"
    ]
Example #35
0
class EdlyAppContextProcessorTests(TestCase):
    """
    Unit tests for Edly Context processor.
    """
    @with_site_configuration(
        configuration={
            'EDLY_COPYRIGHT_TEXT': 'test@copyrights',
            'SERVICES_NOTIFICATIONS_COOKIE_EXPIRY': 60,
            'nav_menu_url': marketing_link('NAV_MENU'),
            'zendesk_widget_url': marketing_link('ZENDESK-WIDGET'),
            'footer_url': marketing_link('FOOTER'),
        })
    def test_default_edly_app_context(self):
        request = RequestFactory().get('/')
        context = edly_app_context(request)
        self.assertEqual(context['services_notifications_cookie_expiry'], 60)
        self.assertEqual(context['edly_copyright_text'], "test@copyrights")
        self.assertEqual(context['nav_menu_url'], marketing_link('NAV_MENU'))
        self.assertEqual(context['zendesk_widget_url'],
                         marketing_link('ZENDESK-WIDGET'))
        self.assertEqual(context['footer_url'], marketing_link('FOOTER'))
    def test_context_data_courses_url(self):
        view, kwargs = self.get_initialized_view()

        with patch.dict(settings.FEATURES, ENABLE_MKTG_SITE=False):
            data_disabled = view.get_context_data(**kwargs)
            url_disabled = reverse('about_course', args=[self.course.id])
            self.assertEquals(data_disabled['url_to_enroll'], url_disabled)

        with patch.dict(settings.FEATURES, ENABLE_MKTG_SITE=True):
            url_enabled = marketing_link('COURSES')
            data_enabled = view.get_context_data(**kwargs)
            self.assertEquals(data_enabled['url_to_enroll'], url_enabled)
Example #37
0
def _footer_navigation_links():
    """Return the navigation links to display in the footer. """
    platform_name = configuration_helpers.get_value('platform_name', settings.PLATFORM_NAME)
    return [
        {
            "name": link_name,
            "title": link_title,
            "url": link_url,
        }
        for link_name, link_url, link_title in [
            ("about", marketing_link("ABOUT"), _("About")),
            #("enterprise", marketing_link("ENTERPRISE"),
            # _("{platform_name} for Business").format(platform_name=platform_name)),
            #("blog", marketing_link("BLOG"), _("Blog")),
            #("news", marketing_link("NEWS"), _("News")),
            #("help-center", settings.SUPPORT_SITE_LINK, _("Help Center")),
            ("contact", marketing_link("CONTACT"), _("Contact")),
            #("careers", marketing_link("CAREERS"), _("Careers")),
            #("donate", marketing_link("DONATE"), _("Donate")),
            ("terms_of_service", marketing_link("TOS"), _("Terms of Use")),
            ("honor_code", marketing_link("HONOR"), _("Honor Code")),
            ("privacy_policy", marketing_link("PRIVACY"), _("Privacy Policy")),
            ("disclaimer",marketing_link("DISCLAIMER"),_("Disclaimer")),
        ]
        if link_url and link_url != "#"
    ]
Example #38
0
def _footer_navigation_links(language=settings.LANGUAGE_CODE):
    """Return the navigation links to display in the footer. """
    platform_name = configuration_helpers.get_value('platform_name', settings.PLATFORM_NAME)
    links = [
        ("about", (marketing_link("ABOUT"), _("About"))),
        ("enterprise", (
            marketing_link("ENTERPRISE"),
            _(u"{platform_name} for Business").format(platform_name=platform_name)
        )),
        ("blog", (marketing_link("BLOG"), _("Blog"))),
        ("help-center", (settings.SUPPORT_SITE_LINK, _("Help Center"))),
        ("contact", (_build_support_form_url(), _("Contact"))),
        ("careers", (marketing_link("CAREERS"), _("Careers"))),
        ("donate", (marketing_link("DONATE"), _("Donate"))),
    ]

    if language == settings.LANGUAGE_CODE:
        position = _find_position_of_link(links, 'blog')
        links.insert(position, ("news", (marketing_link("NEWS"), _("News"))))

    return [
        {
            "name": link_name,
            "title": link_title,
            "url": link_url,
        }
        for link_name, (link_url, link_title) in links
        if link_url and link_url != "#"
    ]
Example #39
0
def _footer_navigation_links(language=settings.LANGUAGE_CODE):
    """Return the navigation links to display in the footer. """
    platform_name = configuration_helpers.get_value('platform_name',
                                                    settings.PLATFORM_NAME)
    links = [
        ("about", (marketing_link("ABOUT"), _("About"))),
        ("enterprise", (marketing_link("ENTERPRISE"),
                        _(u"{platform_name} for Business").format(
                            platform_name=platform_name))),
        ("blog", (marketing_link("BLOG"), _("Blog"))),
        ("help-center", (_build_help_center_url(language), _("Help Center"))),
        ("contact", (_build_support_form_url(), _("Contact"))),
        ("careers", (marketing_link("CAREERS"), _("Careers"))),
        ("donate", (marketing_link("DONATE"), _("Donate"))),
    ]

    if language == settings.LANGUAGE_CODE:
        position = _find_position_of_link(links, 'blog')
        links.insert(position, ("news", (marketing_link("NEWS"), _("News"))))

    return [{
        "name": link_name,
        "title": link_title,
        "url": link_url,
    } for link_name, (link_url, link_title) in links
            if link_url and link_url != "#"]
Example #40
0
def _footer_navigation_links():
    """Return the navigation links to display in the footer. """
    platform_name = configuration_helpers.get_value('platform_name',
                                                    settings.PLATFORM_NAME)
    return [
        {
            "name": link_name,
            "title": link_title,
            "url": link_url,
        } for link_name, link_url, link_title in [
            ("about", marketing_link("ABOUT"), _("About")),
            ("enterprise", marketing_link("ENTERPRISE"),
             _("{platform_name} for Business").format(
                 platform_name=platform_name)),
            # ("blog", marketing_link("BLOG"), _("Blog")),
            ("news", marketing_link("NEWS"), _("News")),
            ("help-center", settings.SUPPORT_SITE_LINK, _("Help Center")),
            ("contact", marketing_link("CONTACT"), _("Contact")),
            ("careers", marketing_link("CAREERS"), _("Careers")),
            # ("donate", marketing_link("DONATE"), _("Donate")),
        ] if link_url and link_url != "#"
    ]
Example #41
0
def _footer_navigation_links():
    """Return the navigation links to display in the footer. """
    return [{
        "name": link_name,
        "title": link_title,
        "url": link_url,
    } for link_name, link_url, link_title in [
        ("about", marketing_link("ABOUT"), _("About")),
        ("blog", marketing_link("BLOG"), _("Blog")),
        ("news", marketing_link("NEWS"), _("News")),
        ("faq", marketing_link("FAQ"), _("FAQs")),
        ("contact", marketing_link("CONTACT"), _("Contact")),
        ("jobs", marketing_link("JOBS"), _("Jobs")),
        ("donate", marketing_link("DONATE"), _("Donate")),
        ("sitemap", marketing_link("SITE_MAP"), _("Sitemap")),
    ] if link_url and link_url != "#"]
Example #42
0
def courses(request):
    """
    Render the "find courses" page. If the marketing site is enabled, redirect
    to that. Otherwise, if subdomain branding is on, this is the university
    profile page. Otherwise, it's the edX courseware.views.courses page
    """
    if settings.FEATURES.get('ENABLE_MKTG_SITE', False):
        return redirect(marketing_link('COURSES'), permanent=True)

    if not settings.FEATURES.get('COURSES_ARE_BROWSABLE'):
        raise Http404

    #  we do not expect this case to be reached in cases where
    #  marketing is enabled or the courses are not browsable
    return courseware.views.courses(request)
Example #43
0
def courses(request):
    """
    Render the "find courses" page. If the marketing site is enabled, redirect
    to that. Otherwise, if subdomain branding is on, this is the university
    profile page. Otherwise, it's the edX courseware.views.courses page
    """
    if settings.FEATURES.get('ENABLE_MKTG_SITE', False):
        return redirect(marketing_link('COURSES'), permanent=True)

    if not settings.FEATURES.get('COURSES_ARE_BROWSABLE'):
        raise Http404

    #  we do not expect this case to be reached in cases where
    #  marketing is enabled or the courses are not browsable
    return courseware.views.courses(request)
Example #44
0
def course_info(request, course_id):
    """
    Display the course's info.html, or 404 if there is no such course.

    Assumes the course_id is in a valid format.
    """

    course_key = SlashSeparatedCourseKey.from_deprecated_string(course_id)

    with modulestore().bulk_operations(course_key):
        course = get_course_with_access(request.user, 'load', course_key)
        staff_access = has_access(request.user, 'staff', course)
        masq = setup_masquerade(request, staff_access)    # allow staff to toggle masquerade on info page
        reverifications = fetch_reverify_banner_info(request, course_key)
        studio_url = get_studio_url(course, 'course_info')

        # link to where the student should go to enroll in the course:
        # about page if there is not marketing site, SITE_NAME if there is
        url_to_enroll = reverse(course_about, args=[course_id])
        if settings.FEATURES.get('ENABLE_MKTG_SITE'):
            url_to_enroll = marketing_link('COURSES')

        show_enroll_banner = request.user.is_authenticated() and not CourseEnrollment.is_enrolled(request.user, course.id)

        context = {
            'request': request,
            'course_id': course_key.to_deprecated_string(),
            'cache': None,
            'course': course,
            'staff_access': staff_access,
            'masquerade': masq,
            'studio_url': studio_url,
            'reverifications': reverifications,
            'show_enroll_banner': show_enroll_banner,
            'url_to_enroll': url_to_enroll,
        }

        now = datetime.now(UTC())
        effective_start = _adjust_start_date_for_beta_testers(request.user, course, course_key)
        if staff_access and now < effective_start:
            # Disable student view button if user is staff and
            # course is not yet visible to students.
            context['disable_student_access'] = True

        return render_to_response('courseware/info.html', context)
Example #45
0
def _footer_navigation_links():
    """Return the navigation links to display in the footer. """
    return [{
        "name": link_name,
        "title": link_title,
        "url": link_url,
    } for link_name, link_url, link_title in [
        ("about", marketing_link("ABOUT"), _("About")),
        ("blog", marketing_link("BLOG"), _("Blog")),
        ("news", marketing_link("NEWS"), _("News")),
        ("help-center", settings.SUPPORT_SITE_LINK, _("Help Center")),
        ("contact", marketing_link("CONTACT"), _("Contact")),
        ("careers", marketing_link("CAREERS"), _("Careers")),
        ("donate", marketing_link("DONATE"), _("Donate")),
        ("sitemap", marketing_link("SITE_MAP"), _("Sitemap")),
    ] if link_url and link_url != "#"]
Example #46
0
def _footer_navigation_links():
    """Return the navigation links to display in the footer. """
    return [
        {"name": link_name, "title": link_title, "url": link_url}
        for link_name, link_url, link_title in [
            ("about", marketing_link("ABOUT"), _("About")),
            ("blog", marketing_link("BLOG"), _("Blog")),
            ("news", marketing_link("NEWS"), _("News")),
            ("help-center", settings.SUPPORT_SITE_LINK, _("Help Center")),
            ("contact", marketing_link("CONTACT"), _("Contact")),
            ("careers", marketing_link("CAREERS"), _("Careers")),
            ("donate", marketing_link("DONATE"), _("Donate")),
            ("sitemap", marketing_link("SITE_MAP"), _("Sitemap")),
        ]
        if link_url and link_url != "#"
    ]
Example #47
0
def get_url(name):
    """
    Lookup and return page url, lookup is performed in the following order

    1. get microsite url, If microsite URL override exists, return it
    2. Otherwise return the marketing URL.

    :return: string containing page url.
    """
    # If a microsite URL override exists, return it.  Otherwise return the marketing URL.
    microsite_url = get_microsite_url(name)
    if microsite_url != EMPTY_URL:
        return microsite_url

    # get marketing link, if marketing is disabled then platform url will be used instead.
    url = marketing_link(name)

    return url or EMPTY_URL
Example #48
0
def get_url(name):
    """
    Lookup and return page url, lookup is performed in the following order

    1. get url, If configuration URL override exists, return it
    2. Otherwise return the marketing URL.

    :return: string containing page url.
    """
    # If a configuration URL override exists, return it.  Otherwise return the marketing URL.
    configuration_url = get_configuration_url(name)
    if configuration_url != EMPTY_URL:
        return configuration_url

    # get marketing link, if marketing is disabled then platform url will be used instead.
    url = marketing_link(name)

    return url or EMPTY_URL
Example #49
0
File: api.py Project: rhndg/openedx
def _footer_navigation_links():
    """Return the navigation links to display in the footer. """
    return [
        {
            "name": link_name,
            "title": link_title,
            "url": link_url,
        }
        for link_name, link_url, link_title in [
            ("about", marketing_link("ABOUT"), _("About")),
            ("blog", marketing_link("BLOG"), _("Blog")),
            ("news", marketing_link("NEWS"), _("News")),
            ("faq", marketing_link("FAQ"), _("FAQs")),
            ("contact", marketing_link("CONTACT"), _("Contact")),
            ("jobs", marketing_link("JOBS"), _("Jobs")),
            ("donate", marketing_link("DONATE"), _("Donate")),
            ("sitemap", marketing_link("SITE_MAP"), _("Sitemap")),
        ]
        if link_url and link_url != "#"
    ]
Example #50
0
    def _add_honor_code_field(self, form_desc, required=True):
        """Add an honor code field to a form description.

        Arguments:
            form_desc: A form description

        Keyword Arguments:
            required (bool): Whether this field is required; defaults to True

        """
        # Separate terms of service and honor code checkboxes
        if self._is_field_visible("terms_of_service"):
            terms_label = _(u"Honor Code")
            terms_link = marketing_link("HONOR")
            terms_text = _(u"Review the Honor Code")

        # Combine terms of service and honor code checkboxes
        else:
            # Translators: This is a legal document users must agree to
            # in order to register a new account.
            terms_label = _(u"Terms of Service and Honor Code")
            terms_link = "https://philanthropyu.org/terms-of-use/"
            terms_text = _(u"Terms of Use")

        # Translators: "Terms of Service" is a legal document users must agree to
        # in order to register a new account.
        label = _(
            u"Check here if you agree to be bound by, and to comply with, our "
        )

        # Translators: "Terms of Service" is a legal document users must agree to
        # in order to register a new account.
        error_msg = "Please accept our Terms and Conditions by checking the Terms and Conditions" \
                    " checkbox before creating an account."

        form_desc.add_field("honor_code",
                            label=label,
                            field_type="checkbox",
                            default=False,
                            required=required,
                            error_messages={"required": error_msg},
                            supplementalLink=terms_link,
                            supplementalText=terms_text)
Example #51
0
def fetch_courses_marketing_details(request, course_ids):
    """
    Sends a request to the marketing site's API to retrieve all
    course details for course ids in passed in course_ids and saves
    the details in the cache.

    :param request:
    :param course_ids: a list of course_id strings
    :return: a list of course detail dictionaries. an empty list if
    no courses where retrieved from the marketing API
    """
    language = request.META.get(
        'ORIGINAL_HTTP_ACCEPT_LANGUAGE', settings.LANGUAGE_CODE)
    headers = {'Accept-Language': language}

    # Get the marketing url
    marketing_root = marketing_link('ROOT')
    # Marketing API path
    marketing_api = 'api/marketing/courses/'
    url = urljoin(marketing_root, marketing_api)

    response = requests.get(url, headers=headers, params={'ids': course_ids})
    if response.status_code != 200:
        return []

    courses = response.json().get('results')
    for course in courses:
        cache_key = COURSE_MKTG_DETAILS_CACHE_KEY.format(
            course_id=course['id']
        )
        try:
            cache_time_out = getattr(
                settings,
                'ENROLLMENT_COURSE_DETAILS_CACHE_TIMEOUT',
                60
            )
            cache.set(cache_key, course, cache_time_out)
        except Exception:
            log.exception(
                u"Error occurred while caching course enrollment details for course %s",
                course
            )
    return courses
Example #52
0
def courses(request):
    """
    Render the "find courses" page. If the marketing site is enabled, redirect
    to that. Otherwise, if subdomain branding is on, this is the university
    profile page. Otherwise, it's the edX courseware.views.courses page
    """
    enable_mktg_site = settings.FEATURES.get(
        "ENABLE_MKTG_SITE"
    ) or MicrositeConfiguration.get_microsite_configuration_value("ENABLE_MKTG_SITE", False)

    if enable_mktg_site:
        return redirect(marketing_link("COURSES"), permanent=True)

    if not settings.FEATURES.get("COURSES_ARE_BROWSABLE"):
        raise Http404

    #  we do not expect this case to be reached in cases where
    #  marketing is enabled or the courses are not browsable
    return courseware.views.courses(request)
Example #53
0
    def _add_privacy_policy_field(self, form_desc, required=True):
        """Add a privacy policy field to a form description.

        Arguments:
            form_desc: A form description

        Keyword Arguments:
            required (bool): Whether this field is required; defaults to True

        """
        # Translators: This is a legal document users must agree to
        # in order to register a new account.
        privacy_label = _(u'Privacy Policy')
        privacy_link = marketing_link("PRIVACY")
        privacy_text = _(u"Review the Privacy Policy")

        # Translators: "Privacy Policy" is a legal document users must agree to
        # in order to register a new account.
        label = _(u"I agree to the {platform_name} {privacy}").format(
            platform_name=configuration_helpers.get_value("PLATFORM_NAME", settings.PLATFORM_NAME),
            privacy=privacy_label
        )

        # Translators: "Privacy Policy" is a legal document users must agree to
        # in order to register a new account.
        error_msg = _(u"You must agree to the {platform_name} {privacy}").format(
            platform_name=configuration_helpers.get_value("PLATFORM_NAME", settings.PLATFORM_NAME),
            privacy=privacy_label
        )

        form_desc.add_field(
            "privacy_policy",
            label=label,
            field_type="checkbox",
            default=False,
            required=required,
            error_messages={
                "required": error_msg
            },
            supplementalLink=privacy_link,
            supplementalText=privacy_text
        )
Example #54
0
    def get_marketing_data(self):
        """
        This method gets the current marketing details for a specific
        course.
        :returns a course details from the marketing API or None if
        no marketing details found.
        """
        course_key = self.kwargs['course_key_string']
        language = self.request.META.get(
            'ORIGINAL_HTTP_ACCEPT_LANGUAGE', settings.LANGUAGE_CODE)
        headers = {'Accept-Language': language}

        # Get the marketing url
        marketing_root = marketing_link('ROOT')
        # Marketing API path
        marketing_api = 'api/marketing/courses/{}'.format(course_key)
        url = urljoin(marketing_root, marketing_api)

        response = requests.get(url, headers=headers)
        if response.status_code != 200:
            return None
        return response.json()
Example #55
0
    def _add_terms_of_service_field(self, form_desc, required=True):
        """Add a terms of service field to a form description.
        Arguments:
            form_desc: A form description
        Keyword Arguments:
            required (bool): Whether this field is required; defaults to True
        """
        # Translators: This is a legal document users must agree to
        # in order to register a new account.
        terms_label = _(u"Terms of Service")
        terms_link = marketing_link("TOS")

        # Translators: "Terms of service" is a legal document users must agree to
        # in order to register a new account.
        label = Text(_(u"I agree to the {platform_name} {tos_link_start}{terms_of_service}{tos_link_end}")).format(
            platform_name=configuration_helpers.get_value("PLATFORM_NAME", settings.PLATFORM_NAME),
            terms_of_service=terms_label,
            tos_link_start=HTML("<a href='{terms_link}' target='_blank'>").format(terms_link=terms_link),
            tos_link_end=HTML("</a>"),
        )

        # Translators: "Terms of service" is a legal document users must agree to
        # in order to register a new account.
        error_msg = _(u"You must agree to the {platform_name} {terms_of_service}").format(
            platform_name=configuration_helpers.get_value("PLATFORM_NAME", settings.PLATFORM_NAME),
            terms_of_service=terms_label
        )

        form_desc.add_field(
            "terms_of_service",
            label=label,
            field_type="checkbox",
            default=False,
            required=required,
            error_messages={
                "required": error_msg
            },
        )
Example #56
0
    def assertChangeEmailSent(self, test_body_type):
        """
        Assert that the correct email was sent to confirm an email change, the same
        email contents should be sent to both old and new addresses
        """
        self.check_confirm_email_change('email_change_successful.html', {
            'old_email': self.user.email,
            'new_email': self.pending_change_request.new_email
        })

        # Must have two items in outbox: one for old email, another for new email
        self.assertEqual(len(mail.outbox), 2)

        use_https = self.request.is_secure()
        if settings.FEATURES['ENABLE_MKTG_SITE']:
            contact_link = marketing_link('CONTACT')
        else:
            contact_link = '{protocol}://{site}{link}'.format(
                protocol='https' if use_https else 'http',
                site=settings.SITE_NAME,
                link=reverse('contact'),
            )

        # Verifying contents
        for msg in mail.outbox:
            self.assertEqual(msg.subject, self.email_subject)

            body_text = {
                'plain_text': msg.body,
                'html': msg.alternatives[0][0]
            }
            assert test_body_type in body_text

            body_to_be_tested = body_text[test_body_type]
            for fragment in self.email_fragments:
                self.assertIn(fragment, body_to_be_tested)

            self.assertIn(contact_link, body_to_be_tested)
Example #57
0
def course_info(request, course_id):
    """
    Display the course's info.html, or 404 if there is no such course.

    Assumes the course_id is in a valid format.
    """

    course_key = SlashSeparatedCourseKey.from_deprecated_string(course_id)

    course = get_course_with_access(request.user, 'load', course_key)
    staff_access = has_access(request.user, 'staff', course)
    masq = setup_masquerade(request, staff_access)    # allow staff to toggle masquerade on info page
    reverifications = fetch_reverify_banner_info(request, course_key)
    studio_url = get_studio_url(course, 'course_info')

    # link to where the student should go to enroll in the course:
    # about page if there is not marketing site, SITE_NAME if there is
    url_to_enroll = reverse(course_about, args=[course_id])
    if settings.FEATURES.get('ENABLE_MKTG_SITE'):
        url_to_enroll = marketing_link('COURSES')

    show_enroll_banner = request.user.is_authenticated() and not CourseEnrollment.is_enrolled(request.user, course.id)

    context = {
        'request': request,
        'course_id': course_key.to_deprecated_string(),
        'cache': None,
        'course': course,
        'staff_access': staff_access,
        'masquerade': masq,
        'studio_url': studio_url,
        'reverifications': reverifications,
        'show_enroll_banner': show_enroll_banner,
        'url_to_enroll': url_to_enroll,
    }

    return render_to_response('courseware/info.html', context)
Example #58
0
def _footer_navigation_links():
    """Return the navigation links to display in the footer. """
    platform_name = configuration_helpers.get_value('platform_name', settings.PLATFORM_NAME)
    return [
        {
            "name": link_name,
            "title": link_title,
            "url": link_url,
        }
        for link_name, link_url, link_title in [
            ("about", marketing_link("ABOUT"), _("About")),
            ("enterprise", marketing_link("ENTERPRISE"),
             _("{platform_name} for Business").format(platform_name=platform_name)),
            ("blog", marketing_link("BLOG"), _("Blog")),
            ("news", marketing_link("NEWS"), _("News")),
            ("help-center", settings.SUPPORT_SITE_LINK, _("Help Center")),
            ("contact", marketing_link("CONTACT"), _("Contact")),
            ("careers", marketing_link("CAREERS"), _("Careers")),
            ("donate", marketing_link("DONATE"), _("Donate")),
        ]
        if link_url and link_url != "#"
    ]
Example #59
0
    def _add_honor_code_field(self, form_desc, required=True):
        """Add an honor code field to a form description.
        Arguments:
            form_desc: A form description
        Keyword Arguments:
            required (bool): Whether this field is required; defaults to True
        """

        separate_honor_and_tos = self._is_field_visible("terms_of_service")
        # Separate terms of service and honor code checkboxes
        if separate_honor_and_tos:
            terms_label = _(u"Honor Code")
            terms_link = marketing_link("HONOR")

        # Combine terms of service and honor code checkboxes
        else:
            # Translators: This is a legal document users must agree to
            # in order to register a new account.
            terms_label = _(u"Terms of Service and Honor Code")
            terms_link = marketing_link("HONOR")

        # Translators: "Terms of Service" is a legal document users must agree to
        # in order to register a new account.
        label = Text(_(
            u"I agree to the {platform_name} {terms_of_service_link_start}{terms_of_service}{terms_of_service_link_end}"
        )).format(
            platform_name=configuration_helpers.get_value("PLATFORM_NAME", settings.PLATFORM_NAME),
            terms_of_service=terms_label,
            terms_of_service_link_start=HTML("<a href='{terms_link}' target='_blank'>").format(terms_link=terms_link),
            terms_of_service_link_end=HTML("</a>"),
        )

        # Translators: "Terms of Service" is a legal document users must agree to
        # in order to register a new account.
        error_msg = _(u"You must agree to the {platform_name} {terms_of_service}").format(
            platform_name=configuration_helpers.get_value("PLATFORM_NAME", settings.PLATFORM_NAME),
            terms_of_service=terms_label
        )
        field_type = 'checkbox'

        if ENABLE_GDPR_COMPAT_FLAG.is_enabled_without_course_context() and not separate_honor_and_tos:
            field_type = 'plaintext'
            pp_link = marketing_link("PRIVACY")
            label = Text(_(
                u"By creating an account with {platform_name}, you agree \
                  to abide by our {platform_name} \
                  {terms_of_service_link_start}{terms_of_service}{terms_of_service_link_end} \
                  and agree to our {privacy_policy_link_start}Privacy Policy{privacy_policy_link_end}."
            )).format(
                platform_name=configuration_helpers.get_value("PLATFORM_NAME", settings.PLATFORM_NAME),
                terms_of_service=terms_label,
                terms_of_service_link_start=HTML("<a href='{terms_url}' target='_blank'>").format(terms_url=terms_link),
                terms_of_service_link_end=HTML("</a>"),
                privacy_policy_link_start=HTML("<a href='{pp_url}' target='_blank'>").format(pp_url=pp_link),
                privacy_policy_link_end=HTML("</a>"),
            )

        form_desc.add_field(
            "honor_code",
            label=label,
            field_type=field_type,
            default=False,
            required=required,
            error_messages={
                "required": error_msg
            },
        )