• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python middleware.MicrositeConfiguration类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中microsite_configuration.middleware.MicrositeConfiguration的典型用法代码示例。如果您正苦于以下问题:Python MicrositeConfiguration类的具体用法?Python MicrositeConfiguration怎么用?Python MicrositeConfiguration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了MicrositeConfiguration类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: index

def index(request):
    """
    Redirects to main page -- info page if user authenticated, or marketing if not
    """

    if settings.COURSEWARE_ENABLED and request.user.is_authenticated():
        return redirect(reverse("dashboard"))

    if settings.FEATURES.get("AUTH_USE_MIT_CERTIFICATES"):
        from external_auth.views import ssl_login

        return ssl_login(request)

    enable_mktg_site = MicrositeConfiguration.get_microsite_configuration_value(
        "ENABLE_MKTG_SITE", settings.FEATURES.get("ENABLE_MKTG_SITE", False)
    )

    if enable_mktg_site:
        return redirect(settings.MKTG_URLS.get("ROOT"))

    university = MicrositeConfiguration.match_university(request.META.get("HTTP_HOST"))

    # keep specialized logic for Edge until we can migrate over Edge to fully use
    # microsite definitions
    if university == "edge":
        context = {"suppress_toplevel_navigation": True}
        return render_to_response("university_profile/edge.html", context)

    #  we do not expect this case to be reached in cases where
    #  marketing and edge are enabled
    return student.views.index(request, user=request.user)
开发者ID:,项目名称:,代码行数:31,代码来源:


示例2: get_logo_url

def get_logo_url():
    """
    Return the url for the branded logo image to be used
    """

    # if the MicrositeConfiguration has a value for the logo_image_url
    # let's use that
    image_url = MicrositeConfiguration.get_microsite_configuration_value('logo_image_url')
    if image_url:
        return '{static_url}{image_url}'.format(
            static_url=settings.STATIC_URL,
            image_url=image_url
        )

    # otherwise, use the legacy means to configure this
    university = MicrositeConfiguration.get_microsite_configuration_value('university')

    if university is None:
        return '{static_url}images/header-logo.png'.format(
            static_url=settings.STATIC_URL
        )

    return '{static_url}images/{uni}-on-edx-logo.png'.format(
        static_url=settings.STATIC_URL, uni=university
    )
开发者ID:YoshidaKS,项目名称:edx-platform,代码行数:25,代码来源:__init__.py


示例3: get_visible_courses

def get_visible_courses():
    """
    Return the set of CourseDescriptors that should be visible in this branded instance
    """
    _courses = modulestore().get_courses()

    courses = [c for c in _courses
               if isinstance(c, CourseDescriptor)]
    courses = sorted(courses, key=lambda course: course.number)

    subdomain = MicrositeConfiguration.get_microsite_configuration_value('subdomain', 'default')

    # See if we have filtered course listings in this domain
    filtered_visible_ids = None

    # this is legacy format which is outside of the microsite feature -- also handle dev case, which should not filter
    if hasattr(settings, 'COURSE_LISTINGS') and subdomain in settings.COURSE_LISTINGS and not settings.DEBUG:
        filtered_visible_ids = frozenset(settings.COURSE_LISTINGS[subdomain])

    filtered_by_org = MicrositeConfiguration.get_microsite_configuration_value('course_org_filter')

    if filtered_by_org:
        return [course for course in courses if course.location.org == filtered_by_org]
    if filtered_visible_ids:
        return [course for course in courses if course.id in filtered_visible_ids]
    else:
        # Let's filter out any courses in an "org" that has been declared to be
        # in a Microsite
        org_filter_out_set = MicrositeConfiguration.get_all_microsite_orgs()
        return [course for course in courses if course.location.org not in org_filter_out_set]
开发者ID:YoshidaKS,项目名称:edx-platform,代码行数:30,代码来源:__init__.py


示例4: nav_institute_register

def nav_institute_register(request, extra_context=None):
    """
    This view will display the institute registration form
    """
    #if request.user.is_authenticated():
    #   return redirect(reverse('dashboard'))
    #if settings.FEATURES.get('AUTH_USE_MIT_CERTIFICATES_IMMEDIATE_SIGNUP'):
        # Redirect to branding to process their certificate if SSL is enabled
        # and registration is disabled.
    #    return redirect(reverse('root'))

    context = {
        'course_id': request.GET.get('course_id'),
        'enrollment_action': request.GET.get('enrollment_action'),
        'platform_name': MicrositeConfiguration.get_microsite_configuration_value(
            'platform_name',
            settings.PLATFORM_NAME
        ),
    }
    if extra_context is not None:
        context.update(extra_context)

    #if context.get("extauth_domain", '').startswith(external_auth.views.SHIBBOLETH_DOMAIN_PREFIX):
    #      return render_to_response('register-shib.html', context)
    return render_to_response('institute_register.html', context)
开发者ID:anuragkanungo,项目名称:mooc,代码行数:25,代码来源:views_backup.py


示例5: marketing_link

def marketing_link(name):
    """Returns the correct URL for a link to the marketing site
    depending on if the marketing site is enabled

    Since the marketing site is enabled by a setting, we have two
    possible URLs for certain links. This function is to decides
    which URL should be provided.
    """

    # link_map maps URLs from the marketing site to the old equivalent on
    # the Django site
    link_map = settings.MKTG_URL_LINK_MAP
    enable_mktg_site = MicrositeConfiguration.get_microsite_configuration_value(
        'ENABLE_MKTG_SITE',
        settings.FEATURES.get('ENABLE_MKTG_SITE', False)
    )

    if enable_mktg_site and name in settings.MKTG_URLS:
        # special case for when we only want the root marketing URL
        if name == 'ROOT':
            return settings.MKTG_URLS.get('ROOT')
        return settings.MKTG_URLS.get('ROOT') + settings.MKTG_URLS.get(name)
    # only link to the old pages when the marketing site isn't on
    elif not enable_mktg_site and name in link_map:
        # don't try to reverse disabled marketing links
        if link_map[name] is not None:
            return reverse(link_map[name])
    else:
        log.warning("Cannot find corresponding link for name: {name}".format(name=name))
        return '#'
开发者ID:HyHaa,项目名称:edx-platform,代码行数:30,代码来源:shortcuts.py


示例6: render_to_string

def render_to_string(template_name, dictionary, context=None, namespace='main'):

    # see if there is an override template defined in the microsite
    template_name = MicrositeConfiguration.get_microsite_template_path(template_name)

    context_instance = Context(dictionary)
    # add dictionary to context_instance
    context_instance.update(dictionary or {})
    # collapse context_instance to a single dictionary for mako
    context_dictionary = {}
    context_instance['settings'] = settings
    context_instance['EDX_ROOT_URL'] = settings.EDX_ROOT_URL
    context_instance['marketing_link'] = marketing_link

    # In various testing contexts, there might not be a current request context.
    if edxmako.middleware.requestcontext is not None:
        for d in edxmako.middleware.requestcontext:
            context_dictionary.update(d)
    for d in context_instance:
        context_dictionary.update(d)
    if context:
        context_dictionary.update(context)
    # fetch and render template
    template = edxmako.lookup[namespace].get_template(template_name)
    return template.render_unicode(**context_dictionary)
开发者ID:ServboltSystems,项目名称:edx-platform,代码行数:25,代码来源:shortcuts.py


示例7: student_approve

def student_approve(request,post_override=None):
    """
    This view will allow the Institute coordinater to approve registered students
    """
    if not request.user.is_authenticated:
        raise Http404

    post_vars = post_override if post_override else request.POST
    student_id = post_vars['student_id']
    status = post_vars['student_status']

    try:
        Student_object = Student_Institute.objects.filter(id=student_id)[0]
        status_id = int ( Institute_Status.objects.filter(name=status)[0].id )
        Student_object.status_id = status_id
        Student_object.save() 
         
    except:
        raise

    context= { }
    if status=="Approved" :
        # composes Approve Student email
        subject = render_to_string('emails/approve_student_email_subject.txt',context)
        # Email subject *must not* contain newlines
        subject = ''.join(subject.splitlines())
        message = render_to_string('emails/approve_student_email_body.txt',context)
    else :
        #composes Reject Student email
        subject = render_to_string('emails/reject_student_email_subject.txt',context)
        # Email subject *must not* contain newlines
        subject = ''.join(subject.splitlines())
        message = render_to_string('emails/reject_student_email_body.txt',context)


    # don't send email if we are doing load testing or random user generation for some reason
    if not (settings.FEATURES.get('AUTOMATIC_AUTH_FOR_TESTING')):
        from_address = MicrositeConfiguration.get_microsite_configuration_value(
            'email_from_address',
            settings.DEFAULT_FROM_EMAIL
        )
        try:
            _res = Student_object.user.email_user(subject, message, from_address)

        except:
            log.warning('Unable to send Approve/Reject email to user', exc_info=True)
            js['value'] = _('Could not send Approve/Reject e-mail.')
            # What is the correct status code to use here? I think it's 500, because
            # the problem is on the server's end -- but also, the account was created.
            # Seems like the core part of the request was successful.
            return JsonResponse(js, status=500)     


    return HttpResponse(json.dumps({'success': True}))
开发者ID:anuragkanungo,项目名称:mooc,代码行数:54,代码来源:views_backup.py


示例8: render_to_response

def render_to_response(template_name, dictionary=None, context_instance=None, namespace='main', **kwargs):
    """
    Returns a HttpResponse whose content is filled with the result of calling
    lookup.get_template(args[0]).render with the passed arguments.
    """

    # see if there is an override template defined in the microsite
    template_name = MicrositeConfiguration.get_microsite_template_path(template_name)

    dictionary = dictionary or {}
    return HttpResponse(render_to_string(template_name, dictionary, context_instance, namespace), **kwargs)
开发者ID:ServboltSystems,项目名称:edx-platform,代码行数:11,代码来源:shortcuts.py


示例9: safe_get_host

def safe_get_host(request):
    """
    Get the host name for this request, as safely as possible.

    If ALLOWED_HOSTS is properly set, this calls request.get_host;
    otherwise, this returns whatever settings.SITE_NAME is set to.

    This ensures we will never accept an untrusted value of get_host()
    """
    if isinstance(settings.ALLOWED_HOSTS, (list, tuple)) and "*" not in settings.ALLOWED_HOSTS:
        return request.get_host()
    else:
        return MicrositeConfiguration.get_microsite_configuration_value("site_domain", settings.SITE_NAME)
开发者ID:ndiayesamba,项目名称:edx-platform,代码行数:13,代码来源:request.py


示例10: login_page

def login_page(request):
    """
    Display the login form.
    """
    csrf_token = csrf(request)["csrf_token"]
    return render_to_response(
        "login.html",
        {
            "csrf": csrf_token,
            "forgot_password_link": "//{base}/login#forgot-password-modal".format(base=settings.LMS_BASE),
            "platform_name": MicrositeConfiguration.get_microsite_configuration_value(
                "platform_name", settings.PLATFORM_NAME
            ),
        },
    )
开发者ID:ndiayesamba,项目名称:edx-platform,代码行数:15,代码来源:public.py


示例11: settings_handler

def settings_handler(request, tag=None, package_id=None, branch=None, version_guid=None, block=None):
    """
    Course settings for dates and about pages
    GET
        html: get the page
        json: get the CourseDetails model
    PUT
        json: update the Course and About xblocks through the CourseDetails model
    """
    locator, course_module = _get_locator_and_course(
        package_id, branch, version_guid, block, request.user
    )
    if 'text/html' in request.META.get('HTTP_ACCEPT', '') and request.method == 'GET':
        upload_asset_url = locator.url_reverse('assets/')

        # see if the ORG of this course can be attributed to a 'Microsite'. In that case, the
        # course about page should be editable in Studio
        about_page_editable = not MicrositeConfiguration.get_microsite_configuration_value_for_org(
            course_module.location.org,
            'ENABLE_MKTG_SITE',
            settings.FEATURES.get('ENABLE_MKTG_SITE', False)
        )

        short_description_editable = settings.FEATURES.get('EDITABLE_SHORT_DESCRIPTION', True)

        return render_to_response('settings.html', {
            'context_course': course_module,
            'course_locator': locator,
            'lms_link_for_about_page': utils.get_lms_link_for_about_page(course_module.location),
            'course_image_url': utils.course_image_url(course_module),
            'details_url': locator.url_reverse('/settings/details/'),
            'about_page_editable': about_page_editable,
            'short_description_editable': short_description_editable,
            'upload_asset_url': upload_asset_url
        })
    elif 'application/json' in request.META.get('HTTP_ACCEPT', ''):
        if request.method == 'GET':
            return JsonResponse(
                CourseDetails.fetch(locator),
                # encoder serializes dates, old locations, and instances
                encoder=CourseSettingsEncoder
            )
        else:  # post or put, doesn't matter.
            return JsonResponse(
                CourseDetails.update_from_json(locator, request.json, request.user),
                encoder=CourseSettingsEncoder
            )
开发者ID:robertlight,项目名称:edx-platform,代码行数:47,代码来源:course.py


示例12: refund_cert_callback

    def refund_cert_callback(sender, course_enrollment=None, **kwargs):
        """
        When a CourseEnrollment object calls its unenroll method, this function checks to see if that unenrollment
        occurred in a verified certificate that was within the refund deadline.  If so, it actually performs the
        refund.

        Returns the refunded certificate on a successful refund; else, it returns nothing.
        """

        # Only refund verified cert unenrollments that are within bounds of the expiration date
        if not course_enrollment.refundable():
            return

        target_certs = CertificateItem.objects.filter(course_id=course_enrollment.course_id, user_id=course_enrollment.user, status='purchased', mode='verified')
        try:
            target_cert = target_certs[0]
        except IndexError:
            log.error("Matching CertificateItem not found while trying to refund.  User %s, Course %s", course_enrollment.user, course_enrollment.course_id)
            return
        target_cert.status = 'refunded'
        target_cert.refund_requested_time = datetime.now(pytz.utc)
        target_cert.save()
        target_cert.order.status = 'refunded'
        target_cert.order.save()

        order_number = target_cert.order_id
        # send billing an email so they can handle refunding
        subject = _("[Refund] User-Requested Refund")
        message = "User {user} ({user_email}) has requested a refund on Order #{order_number}.".format(user=course_enrollment.user,
                                                                                                       user_email=course_enrollment.user.email,
                                                                                                       order_number=order_number)
        to_email = [settings.PAYMENT_SUPPORT_EMAIL]
        from_email = [MicrositeConfiguration.get_microsite_configuration_value(
            'payment_support_email',
            settings.PAYMENT_SUPPORT_EMAIL
        )]
        try:
            send_mail(subject, message, from_email, to_email, fail_silently=False)
        except (smtplib.SMTPException, BotoServerError):
            err_str = 'Failed sending email to billing request a refund for verified certiciate (User {user}, Course {course}, CourseEnrollmentID {ce_id}, Order #{order})'
            log.error(err_str.format(
                user=course_enrollment.user,
                course=course_enrollment.course_id,
                ce_id=course_enrollment.id,
                order=order_number))

        return target_cert
开发者ID:Chitrank-Dixit,项目名称:edx-platform,代码行数:47,代码来源:models.py


示例13: course_about

def course_about(request, course_id):

    if MicrositeConfiguration.get_microsite_configuration_value(
        'ENABLE_MKTG_SITE',
        settings.FEATURES.get('ENABLE_MKTG_SITE', False)
    ):
        raise Http404

    course = get_course_with_access(request.user, course_id, 'see_exists')
    registered = registered_for_course(course, request.user)

    if has_access(request.user, course, 'load'):
        course_target = reverse('info', args=[course.id])
    else:
        course_target = reverse('about_course', args=[course.id])

    show_courseware_link = (has_access(request.user, course, 'load') or
                            settings.FEATURES.get('ENABLE_LMS_MIGRATION'))

    # Note: this is a flow for payment for course registration, not the Verified Certificate flow.
    registration_price = 0
    in_cart = False
    reg_then_add_to_cart_link = ""
    if (settings.FEATURES.get('ENABLE_SHOPPING_CART') and
        settings.FEATURES.get('ENABLE_PAID_COURSE_REGISTRATION')):
        registration_price = CourseMode.min_course_price_for_currency(course_id,
                                                                      settings.PAID_COURSE_REGISTRATION_CURRENCY[0])
        if request.user.is_authenticated():
            cart = shoppingcart.models.Order.get_cart_for_user(request.user)
            in_cart = shoppingcart.models.PaidCourseRegistration.contained_in_order(cart, course_id)

        reg_then_add_to_cart_link = "{reg_url}?course_id={course_id}&enrollment_action=add_to_cart".format(
            reg_url=reverse('register_user'), course_id=course.id)

    # see if we have already filled up all allowed enrollments
    is_course_full = CourseEnrollment.is_course_full(course)

    return render_to_response('courseware/course_about.html',
                              {'course': course,
                               'registered': registered,
                               'course_target': course_target,
                               'registration_price': registration_price,
                               'in_cart': in_cart,
                               'reg_then_add_to_cart_link': reg_then_add_to_cart_link,
                               'show_courseware_link': show_courseware_link,
                               'is_course_full': is_course_full})
开发者ID:Chitrank-Dixit,项目名称:edx-platform,代码行数:46,代码来源:views.py


示例14: course_about

def course_about(request, course_id):

    if MicrositeConfiguration.get_microsite_configuration_value(
        "ENABLE_MKTG_SITE", settings.FEATURES.get("ENABLE_MKTG_SITE", False)
    ):
        raise Http404

    course = get_course_with_access(request.user, course_id, "see_exists")
    registered = registered_for_course(course, request.user)

    if has_access(request.user, course, "load"):
        course_target = reverse("info", args=[course.id])
    else:
        course_target = reverse("about_course", args=[course.id])

    show_courseware_link = has_access(request.user, course, "load") or settings.FEATURES.get("ENABLE_LMS_MIGRATION")

    # Note: this is a flow for payment for course registration, not the Verified Certificate flow.
    registration_price = 0
    in_cart = False
    reg_then_add_to_cart_link = ""
    if settings.FEATURES.get("ENABLE_SHOPPING_CART") and settings.FEATURES.get("ENABLE_PAID_COURSE_REGISTRATION"):
        registration_price = CourseMode.min_course_price_for_currency(
            course_id, settings.PAID_COURSE_REGISTRATION_CURRENCY[0]
        )
        if request.user.is_authenticated():
            cart = shoppingcart.models.Order.get_cart_for_user(request.user)
            in_cart = shoppingcart.models.PaidCourseRegistration.contained_in_order(cart, course_id)

        reg_then_add_to_cart_link = "{reg_url}?course_id={course_id}&enrollment_action=add_to_cart".format(
            reg_url=reverse("register_user"), course_id=course.id
        )

    return render_to_response(
        "courseware/course_about.html",
        {
            "course": course,
            "registered": registered,
            "course_target": course_target,
            "registration_price": registration_price,
            "in_cart": in_cart,
            "reg_then_add_to_cart_link": reg_then_add_to_cart_link,
            "show_courseware_link": show_courseware_link,
        },
    )
开发者ID:ndiayesamba,项目名称:edx-platform,代码行数:45,代码来源:views.py


示例15: courses

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)
开发者ID:,项目名称:,代码行数:19,代码来源:


示例16: ins_selection

def ins_selection(request, post_override=None):
    """ 
    This view allows Student to select Institute in Student Dashboard 
    """
    if not request.user.is_authenticated:
        raise Http404

    user = request.user
    post_vars = post_override if post_override else request.POST
    institute_id = post_vars['ins_id']
    status=Institute_Status.objects.filter(name="Pending")[0].id

    try:    
        Student_Institute(user=user, institute_id=institute_id,status_id=status).save()    
    except:
        raise

    # composes Institute Selection Information Mail
    subject = render_to_string('emails/select_institute_subject.txt',{})
    # Email subject *must not* contain newlines
    subject = ''.join(subject.splitlines())
    message = render_to_string('emails/select_institute_body.txt',{})
    
    # don't send email if we are doing load testing or random user generation for some reason
    if not (settings.FEATURES.get('AUTOMATIC_AUTH_FOR_TESTING')):
        from_address = MicrositeConfiguration.get_microsite_configuration_value(
            'email_from_address',
            settings.DEFAULT_FROM_EMAIL
        )
        try:
             ic_role_id = Role.objects.filter(name="Institute Coordinator")[0].id
             Institute_Designation_object = Institute_Designation.objects.filter(institute_id=institute_id, role_id=ic_role_id)[0]
             _res = Institute_Designation_object.user.email_user(subject, message, from_address)

        except:
            log.warning('Unable to send email to institute coordinator', exc_info=True)
            js['value'] = _('Could not send e-mail.')
            # What is the correct status code to use here? I think it's 500, because
            # the problem is on the server's end -- but also, the account was created.
            # Seems like the core part of the request was successful.
            return JsonResponse(js, status=500)     

    return HttpResponse(json.dumps({'success': True}))
开发者ID:anuragkanungo,项目名称:mooc,代码行数:43,代码来源:views_backup.py


示例17: login_page

def login_page(request):
    """
    Display the login form.
    """
    csrf_token = csrf(request)['csrf_token']
    if (settings.FEATURES['AUTH_USE_CERTIFICATES'] and
            ssl_get_cert_from_request(request)):
        # SSL login doesn't require a login view, so redirect
        # to course now that the user is authenticated via
        # the decorator.
        return redirect('/course')
    return render_to_response(
        'login.html',
        {
            'csrf': csrf_token,
            'forgot_password_link': "//{base}/login#forgot-password-modal".format(base=settings.LMS_BASE),
            'platform_name': MicrositeConfiguration.get_microsite_configuration_value('platform_name', settings.PLATFORM_NAME),
        }
    )
开发者ID:Chitrank-Dixit,项目名称:edx-platform,代码行数:19,代码来源:public.py


示例18: settings_handler

def settings_handler(request, tag=None, package_id=None, branch=None, version_guid=None, block=None):
    """
    Course settings for dates and about pages
    GET
        html: get the page
        json: get the CourseDetails model
    PUT
        json: update the Course and About xblocks through the CourseDetails model
    """
    locator, course_module = _get_locator_and_course(package_id, branch, version_guid, block, request.user)
    if "text/html" in request.META.get("HTTP_ACCEPT", "") and request.method == "GET":
        upload_asset_url = locator.url_reverse("assets/")

        # see if the ORG of this course can be attributed to a 'Microsite'. In that case, the
        # course about page should be editable in Studio
        about_page_editable = not MicrositeConfiguration.get_microsite_configuration_value_for_org(
            course_module.location.org, "ENABLE_MKTG_SITE", settings.FEATURES.get("ENABLE_MKTG_SITE", False)
        )

        return render_to_response(
            "settings.html",
            {
                "context_course": course_module,
                "course_locator": locator,
                "lms_link_for_about_page": utils.get_lms_link_for_about_page(course_module.location),
                "course_image_url": utils.course_image_url(course_module),
                "details_url": locator.url_reverse("/settings/details/"),
                "about_page_editable": about_page_editable,
                "upload_asset_url": upload_asset_url,
            },
        )
    elif "application/json" in request.META.get("HTTP_ACCEPT", ""):
        if request.method == "GET":
            return JsonResponse(
                CourseDetails.fetch(locator),
                # encoder serializes dates, old locations, and instances
                encoder=CourseSettingsEncoder,
            )
        else:  # post or put, doesn't matter.
            return JsonResponse(CourseDetails.update_from_json(locator, request.json), encoder=CourseSettingsEncoder)
开发者ID:Bachmann1234,项目名称:edx-platform,代码行数:40,代码来源:course.py


示例19: platform_name

def platform_name():
    """
    Django template tag that outputs the current platform name:
    {% platform_name %}
    """
    return MicrositeConfiguration.get_microsite_configuration_value('platform_name', settings.PLATFORM_NAME)
开发者ID:Bachmann1234,项目名称:edx-platform,代码行数:6,代码来源:microsite.py


示例20: send_mail_to_student

def send_mail_to_student(student, param_dict):
    """
    Construct the email using templates and then send it.
    `student` is the student's email address (a `str`),

    `param_dict` is a `dict` with keys
    [
        `site_name`: name given to edX instance (a `str`)
        `registration_url`: url for registration (a `str`)
        `course_id`: id of course (a `str`)
        `auto_enroll`: user input option (a `str`)
        `course_url`: url of course (a `str`)
        `email_address`: email of student (a `str`)
        `full_name`: student full name (a `str`)
        `message`: type of email to send and template to use (a `str`)
        `is_shib_course`: (a `boolean`)
    ]

    Returns a boolean indicating whether the email was sent successfully.
    """

    # add some helpers and microconfig subsitutions
    if 'course' in param_dict:
        param_dict['course_name'] = param_dict['course'].display_name_with_default

    param_dict['site_name'] = MicrositeConfiguration.get_microsite_configuration_value(
        'SITE_NAME',
        param_dict['site_name']
    )

    subject = None
    message = None

    # see if we are running in a microsite and that there is an
    # activation email template definition available as configuration, if so, then render that
    message_type = param_dict['message']

    email_template_dict = {
        'allowed_enroll': (
            'emails/enroll_email_allowedsubject.txt',
            'emails/enroll_email_allowedmessage.txt'
        ),
        'enrolled_enroll': (
            'emails/enroll_email_enrolledsubject.txt',
            'emails/enroll_email_enrolledmessage.txt'
        ),
        'allowed_unenroll': (
            'emails/unenroll_email_subject.txt',
            'emails/unenroll_email_allowedmessage.txt'
        ),
        'enrolled_unenroll': (
            'emails/unenroll_email_subject.txt',
            'emails/unenroll_email_enrolledmessage.txt'
        )
    }

    subject_template, message_template = email_template_dict.get(message_type, (None, None))
    if subject_template is not None and message_template is not None:
        subject = render_to_string(subject_template, param_dict)
        message = render_to_string(message_template, param_dict)

    if subject and message:
        # Remove leading and trailing whitespace from body
        message = message.strip()

        # Email subject *must not* contain newlines
        subject = ''.join(subject.splitlines())
        from_address = MicrositeConfiguration.get_microsite_configuration_value(
            'email_from_address',
            settings.DEFAULT_FROM_EMAIL
        )

        send_mail(subject, message, from_address, [student], fail_silently=False)
开发者ID:Chitrank-Dixit,项目名称:edx-platform,代码行数:73,代码来源:enrollment.py



注:本文中的microsite_configuration.middleware.MicrositeConfiguration类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python microsofttranslator.Translator类代码示例发布时间:2022-05-27
下一篇:
Python microsite.set_by_domain函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap