当前位置: 首页>>代码示例>>Python>>正文


Python ENV.get_template方法代码示例

本文整理汇总了Python中askbot.skins.loaders.ENV.get_template方法的典型用法代码示例。如果您正苦于以下问题:Python ENV.get_template方法的具体用法?Python ENV.get_template怎么用?Python ENV.get_template使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在askbot.skins.loaders.ENV的用法示例。


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

示例1: send_email_key

# 需要导入模块: from askbot.skins.loaders import ENV [as 别名]
# 或者: from askbot.skins.loaders.ENV import get_template [as 别名]
def send_email_key(request):
    """
    url = /email/sendkey/

    view that is shown right after sending email key
    email sending is called internally

    raises 404 if email validation is off
    if current email is valid shows 'key_not_sent' view of 
    authopenid/changeemail.html template
    """
    if askbot_settings.EMAIL_VALIDATION == True:
        if request.user.email_isvalid:
            template = ENV.get_template("authopenid/changeemail.html")
            data = {
                "email": request.user.email,
                "action_type": "key_not_sent",
                "change_link": reverse("user_changeemail"),
            }
            context = RequestContext(request, data)
            return HttpResponse(template.render(context))
        else:
            send_new_email_key(request.user)
            return validation_email_sent(request)
    else:
        raise Http404
开发者ID:reebot,项目名称:Askandget,代码行数:28,代码来源:views.py

示例2: user_favorites

# 需要导入模块: from askbot.skins.loaders import ENV [as 别名]
# 或者: from askbot.skins.loaders.ENV import get_template [as 别名]
def user_favorites(request, user):
    favorited_q_id_list= models.FavoriteQuestion.objects.filter(
                                    user = user
                                ).values_list('question__id', flat=True)
    questions = models.Question.objects.filter(
                                    id__in=favorited_q_id_list
                                ).order_by(
                                    '-score', '-last_activity_at'
                                ).select_related(
                                    'last_activity_by__id',
                                    'last_activity_by__username',
                                    'last_activity_by__reputation',
                                    'last_activity_by__gold',
                                    'last_activity_by__silver',
                                    'last_activity_by__bronze'
                                )[:const.USER_VIEW_DATA_SIZE]
    data = {
        'active_tab':'users',
        'tab_name' : 'favorites',
        'tab_description' : _('users favorite questions'),
        'page_title' : _('profile - favorite questions'),
        'questions' : questions,
        'favorited_myself': favorited_q_id_list,
        'view_user' : user
    }
    context = RequestContext(request, data)
    template = ENV.get_template('user_profile/user_favorites.html')
    return HttpResponse(template.render(context))
开发者ID:exezaid,项目名称:askbot-devel,代码行数:30,代码来源:users.py

示例3: reopen

# 需要导入模块: from askbot.skins.loaders import ENV [as 别名]
# 或者: from askbot.skins.loaders.ENV import get_template [as 别名]
def reopen(request, id):#re-open question
    """view to initiate and process 
    question close

    this is not an ajax view
    """

    question = get_object_or_404(models.Question, id=id)
    # open question
    try:
        if request.method == 'POST' :
            request.user.reopen_question(question)
            return HttpResponseRedirect(question.get_absolute_url())
        else:
            request.user.assert_can_reopen_question(question)
            closed_by_profile_url = question.closed_by.get_profile_url()
            closed_by_username = question.closed_by.username
            data = {
                'question' : question,
                'closed_by_profile_url': closed_by_profile_url,
                'closed_by_username': closed_by_username,
            }
            context = RequestContext(request, data)
            template = ENV.get_template('reopen.html')
            return HttpResponse(template.render(context))
            
    except exceptions.PermissionDenied, e:
        request.user.message_set.create(message = unicode(e))
        return HttpResponseRedirect(question.get_absolute_url())
开发者ID:exezaid,项目名称:askbot-devel,代码行数:31,代码来源:commands.py

示例4: close

# 需要导入模块: from askbot.skins.loaders import ENV [as 别名]
# 或者: from askbot.skins.loaders.ENV import get_template [as 别名]
def close(request, id):#close question
    """view to initiate and process 
    question close
    """
    question = get_object_or_404(models.Question, id=id)
    try:
        if request.method == 'POST':
            form = CloseForm(request.POST)
            if form.is_valid():
                reason = form.cleaned_data['reason']

                request.user.close_question(
                                        question = question,
                                        reason = reason
                                    )
            return HttpResponseRedirect(question.get_absolute_url())
        else:
            request.user.assert_can_close_question(question)
            form = CloseForm()
            template = ENV.get_template('close.html')
            data = {'form': form, 'question': question}
            context = RequestContext(request, data)
            return HttpResponse(template.render(context))
    except exceptions.PermissionDenied, e:
        request.user.message_set.create(message = unicode(e))
        return HttpResponseRedirect(question.get_absolute_url())
开发者ID:exezaid,项目名称:askbot-devel,代码行数:28,代码来源:commands.py

示例5: validation_email_sent

# 需要导入模块: from askbot.skins.loaders import ENV [as 别名]
# 或者: from askbot.skins.loaders.ENV import get_template [as 别名]
def validation_email_sent(request):
    """this function is called only if EMAIL_VALIDATION setting is
    set to True bolean value, basically dead now"""
    assert askbot_settings.EMAIL_VALIDATION == True
    logging.debug("")
    template = ENV.get_template("authopenid/changeemail.html")
    data = {"email": request.user.email, "change_email_url": reverse("user_changeemail"), "action_type": "validate"}
    context = RequestContext(request, data)
    return HttpResponse(template.render(context))
开发者ID:reebot,项目名称:Askandget,代码行数:11,代码来源:views.py

示例6: edit_answer

# 需要导入模块: from askbot.skins.loaders import ENV [as 别名]
# 或者: from askbot.skins.loaders.ENV import get_template [as 别名]
def edit_answer(request, id):
    answer = get_object_or_404(models.Answer, id=id)
    try:
        request.user.assert_can_edit_answer(answer)
        latest_revision = answer.get_latest_revision()
        if request.method == "POST":
            if 'select_revision' in request.POST:
                # user has changed revistion number
                revision_form = forms.RevisionForm(
                                                answer, 
                                                latest_revision,
                                                request.POST
                                            )
                if revision_form.is_valid():
                    # Replace with those from the selected revision
                    rev = revision_form.cleaned_data['revision']
                    selected_revision = models.AnswerRevision.objects.get(
                                                            answer = answer,
                                                            revision = rev
                                                        )
                    form = forms.EditAnswerForm(answer, selected_revision)
                else:
                    form = forms.EditAnswerForm(
                                            answer,
                                            latest_revision,
                                            request.POST
                                        )
            else:
                form = forms.EditAnswerForm(answer, latest_revision, request.POST)
                if form.is_valid():
                    if form.has_changed():
                        request.user.edit_answer(
                                answer = answer,
                                body_text = form.cleaned_data['text'],
                                revision_comment = form.cleaned_data['summary'],
                                wiki = form.cleaned_data.get('wiki', answer.wiki),
                                #todo: add wiki field to form
                            )
                    return HttpResponseRedirect(answer.get_absolute_url())
        else:
            revision_form = forms.RevisionForm(answer, latest_revision)
            form = forms.EditAnswerForm(answer, latest_revision)
        template = ENV.get_template('answer_edit.html')
        data = {
            'active_tab': 'questions',
            'answer': answer,
            'revision_form': revision_form,
            'form': form,
        }
        context = RequestContext(request, data)
        return HttpResponse(template.render(context))

    except exceptions.PermissionDenied, e:
        request.user.message_set.create(message = unicode(e))
        return HttpResponseRedirect(answer.get_absolute_url())
开发者ID:exezaid,项目名称:askbot-devel,代码行数:57,代码来源:writers.py

示例7: faq

# 需要导入模块: from askbot.skins.loaders import ENV [as 别名]
# 或者: from askbot.skins.loaders.ENV import get_template [as 别名]
def faq(request):
    template = ENV.get_template('faq.html')
    data = {
        'view_name':'faq',
        'gravatar_faq_url': reverse('faq') + '#gravatar',
        #'send_email_key_url': reverse('send_email_key'),
        'ask_question_url': reverse('ask'),
        'page_class': 'meta',
    }
    context = RequestContext(request, data)
    return HttpResponse(template.render(context))
开发者ID:exezaid,项目名称:askbot-devel,代码行数:13,代码来源:meta.py

示例8: _send_email_key

# 需要导入模块: from askbot.skins.loaders import ENV [as 别名]
# 或者: from askbot.skins.loaders.ENV import get_template [as 别名]
def _send_email_key(user):
    """private function. sends email containing validation key
    to user's email address
    """
    subject = _("Recover your %(site)s account") % {"site": askbot_settings.APP_SHORT_NAME}
    message_template = ENV.get_template("authopenid/email_validation.txt")
    import settings

    message_context = Context(
        {"validation_link": askbot_settings.APP_URL + reverse("user_account_recover", kwargs={"key": user.email_key})}
    )
    message = message_template.render(message_context)
    send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, [user.email])
开发者ID:reebot,项目名称:Askandget,代码行数:15,代码来源:views.py

示例9: validation_email_sent

# 需要导入模块: from askbot.skins.loaders import ENV [as 别名]
# 或者: from askbot.skins.loaders.ENV import get_template [as 别名]
def validation_email_sent(request):
    """this function is called only if EMAIL_VALIDATION setting is
    set to True bolean value, basically dead now"""
    assert(askbot_settings.EMAIL_VALIDATION == True)
    logging.debug('')
    template = ENV.get_template('authopenid/changeemail.html')
    data = {
        'email': request.user.email,
        'change_email_url': reverse('user_changeemail'),
        'action_type': 'validate'
    }
    context = RequestContext(request, data)
    return HttpResponse(template.render(context))
开发者ID:exezaid,项目名称:askbot-devel,代码行数:15,代码来源:views.py

示例10: retag_question

# 需要导入模块: from askbot.skins.loaders import ENV [as 别名]
# 或者: from askbot.skins.loaders.ENV import get_template [as 别名]
def retag_question(request, id):
    """retag question view
    """
    question = get_object_or_404(models.Question, id = id)

    try:
        request.user.assert_can_retag_question(question)
        if request.method == 'POST':
            form = forms.RetagQuestionForm(question, request.POST)
            if form.is_valid():
                if form.has_changed():
                    request.user.retag_question(
                                        question = question,
                                        tags = form.cleaned_data['tags']
                                    )
                if request.is_ajax():
                    response_data = {'success': True}
                    data = simplejson.dumps(response_data)
                    return HttpResponse(data, mimetype="application/json")
                else:
                    return HttpResponseRedirect(question.get_absolute_url())
            elif request.is_ajax():
                response_data = {
                    'message': unicode(form.errors['tags']),
                    'success': False
                }
                data = simplejson.dumps(response_data)
                return HttpResponse(data, mimetype="application/json")
        else:
            form = forms.RetagQuestionForm(question)

        data = {
            'active_tab': 'questions',
            'question': question,
            'form' : form,
            'tags' : _get_tags_cache_json(),
        }
        context = RequestContext(request, data)
        template = ENV.get_template('question_retag.html')
        return HttpResponse(template.render(context))
    except exceptions.PermissionDenied, e:
        if request.is_ajax():
            response_data = {
                'message': unicode(e),
                'success': False
            }
            data = simplejson.dumps(response_data)
            return HttpResponse(data, mimetype="application/json")
        else:
            request.user.message_set.create(message = unicode(e))
            return HttpResponseRedirect(question.get_absolute_url())
开发者ID:exezaid,项目名称:askbot-devel,代码行数:53,代码来源:writers.py

示例11: edit_question

# 需要导入模块: from askbot.skins.loaders import ENV [as 别名]
# 或者: from askbot.skins.loaders.ENV import get_template [as 别名]
def edit_question(request, id):
    """edit question view
    """
    question = get_object_or_404(models.Question, id = id)
    latest_revision = question.get_latest_revision()
    revision_form = None
    try:
        request.user.assert_can_edit_question(question)
        if request.method == 'POST':
            if 'select_revision' in request.POST:#revert-type edit
                # user has changed revistion number
                revision_form = forms.RevisionForm(question, latest_revision, request.POST)
                if revision_form.is_valid():
                    # Replace with those from the selected revision
                    form = forms.EditQuestionForm(question,
                        models.QuestionRevision.objects.get(question=question,
                            revision=revision_form.cleaned_data['revision']))
                else:
                    form = forms.EditQuestionForm(question, latest_revision, request.POST)
            else:#new content edit
                # Always check modifications against the latest revision
                form = forms.EditQuestionForm(question, latest_revision, request.POST)
                if form.is_valid():
                    if form.has_changed():
                        request.user.edit_question(
                                            question = question,
                                            title = form.cleaned_data['title'],
                                            body_text = form.cleaned_data['text'],
                                            revision_comment = form.cleaned_data['summary'],
                                            tags = form.cleaned_data['tags'],
                                            wiki = form.cleaned_data.get('wiki', question.wiki)
                                        )
                    return HttpResponseRedirect(question.get_absolute_url())
        else:
            revision_form = forms.RevisionForm(question, latest_revision)
            form = forms.EditQuestionForm(question, latest_revision)

        data = {
            'active_tab': 'questions',
            'question': question,
            'revision_form': revision_form,
            'form' : form,
            'tags' : _get_tags_cache_json()
        }
        context = RequestContext(request, data)
        template = ENV.get_template('question_edit.html')
        return HttpResponse(template.render(context))

    except exceptions.PermissionDenied, e:
        request.user.message_set.create(message = unicode(e))
        return HttpResponseRedirect(question.get_absolute_url())
开发者ID:exezaid,项目名称:askbot-devel,代码行数:53,代码来源:writers.py

示例12: _send_email_key

# 需要导入模块: from askbot.skins.loaders import ENV [as 别名]
# 或者: from askbot.skins.loaders.ENV import get_template [as 别名]
def _send_email_key(user):
    """private function. sends email containing validation key
    to user's email address
    """
    subject = _("Email verification subject line")
    message_template = ENV.get_template('authopenid/email_validation.txt')
    import settings
    message_context = Context({
    'validation_link': askbot_settings.APP_URL + reverse(
                                                    'user_account_recover',
                                                    kwargs={'key':user.email_key}
                                                )
    })
    message = message_template.render(message_context)
    send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, [user.email])
开发者ID:exezaid,项目名称:askbot-devel,代码行数:17,代码来源:views.py

示例13: logout

# 需要导入模块: from askbot.skins.loaders import ENV [as 别名]
# 或者: from askbot.skins.loaders.ENV import get_template [as 别名]
def logout(request):#refactor/change behavior?
#currently you click logout and you get
#to this view which actually asks you again - do you really want to log out?
#I guess rationale was to tell the user that s/he may be still logged in
#through their external login sytem and we'd want to remind them about it
#however it might be a little annoying
#why not just show a message: you are logged out of forum, but
#if you really want to log out -> go to your openid provider
    data = {
        'view_name':'logout',
        'next' : get_next_url(request),
        'page_class': 'meta',
    }
    context = RequestContext(request, data)
    template = ENV.get_template('logout.html')
    return HttpResponse(template.render(context))
开发者ID:exezaid,项目名称:askbot-devel,代码行数:18,代码来源:meta.py

示例14: process_exception

# 需要导入模块: from askbot.skins.loaders import ENV [as 别名]
# 或者: from askbot.skins.loaders.ENV import get_template [as 别名]
 def process_exception(self, request, exception):
     #todo: move this to separate middleware
     exc_type, exc_value, exc_traceback = sys.exc_info()
     logging.critical(''.join(traceback.format_tb(exc_traceback)))
     logging.critical(exc_type)
     logging.critical(exc_value)
     if exc_type == Http404:
         return None
     if getattr(settings, 'DEBUG', False) == True:
         return None
     else:
         #todo - we have a strange requirement - maybe remove 
         #500.html needs RequestContext, while handler500 only receives Context
         from askbot.skins.loaders import ENV
         template = ENV.get_template('500.jinja.html')
         return HttpResponse(template.render(RequestContext(request)))
开发者ID:exezaid,项目名称:askbot-devel,代码行数:18,代码来源:pagesize.py

示例15: tags

# 需要导入模块: from askbot.skins.loaders import ENV [as 别名]
# 或者: from askbot.skins.loaders.ENV import get_template [as 别名]
def tags(request):#view showing a listing of available tags - plain list
    stag = ""
    is_paginated = True
    sortby = request.GET.get('sort', 'used')
    try:
        page = int(request.GET.get('page', '1'))
    except ValueError:
        page = 1

    if request.method == "GET":
        stag = request.GET.get("q", "").strip()
        if stag != '':
            objects_list = Paginator(models.Tag.objects.filter(deleted=False).exclude(used_count=0).extra(where=['name like %s'], params=['%' + stag + '%']), DEFAULT_PAGE_SIZE)
        else:
            if sortby == "name":
                objects_list = Paginator(models.Tag.objects.all().filter(deleted=False).exclude(used_count=0).order_by("name"), DEFAULT_PAGE_SIZE)
            else:
                objects_list = Paginator(models.Tag.objects.all().filter(deleted=False).exclude(used_count=0).order_by("-used_count"), DEFAULT_PAGE_SIZE)

    try:
        tags = objects_list.page(page)
    except (EmptyPage, InvalidPage):
        tags = objects_list.page(objects_list.num_pages)

    paginator_data = {
        'is_paginated' : is_paginated,
        'pages': objects_list.num_pages,
        'page': page,
        'has_previous': tags.has_previous(),
        'has_next': tags.has_next(),
        'previous': tags.previous_page_number(),
        'next': tags.next_page_number(),
        'base_url' : reverse('tags') + '?sort=%s&' % sortby
    }
    paginator_context = extra_tags.cnprog_paginator(paginator_data)
    data = {
        'view_name':'tags',
        'active_tab': 'tags',
        'tags' : tags,
        'stag' : stag,
        'tab_id' : sortby,
        'keywords' : stag,
        'paginator_context' : paginator_context
    }
    context = RequestContext(request, data)
    template = ENV.get_template('tags.html')
    return HttpResponse(template.render(context))
开发者ID:exezaid,项目名称:askbot-devel,代码行数:49,代码来源:readers.py


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