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

Python response.render_to_response函数代码示例

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

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



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

示例1: change_pass

def change_pass(request):
    form = auth_forms.ChangePassForm(request.form)
    user = request.user

    if request.method == 'POST' and form.validate():

        if not tools.bcrypt_check_password(
                form.old_password.data, user.pw_hash):
            form.old_password.errors.append(
                _('Wrong password'))

            return render_to_response(
                request,
                'mediagoblin/plugins/recaptcha/change_pass.html',
                {'form': form,
                 'user': user})

        # Password matches
        user.pw_hash = tools.bcrypt_gen_password_hash(
            form.new_password.data)
        user.save()

        messages.add_message(
            request, messages.SUCCESS,
            _('Your password was changed successfully'))

        return redirect(request, 'mediagoblin.edit.account')

    return render_to_response(
        request,
        'mediagoblin/plugins/recaptcha/change_pass.html',
        {'form': form,
         'user': user})
开发者ID:goblinrefuge,项目名称:goblinrefuge-mediagoblin,代码行数:33,代码来源:views.py


示例2: user_home

def user_home(request, page):
    """'Homepage' of a User()"""
    user = request.db.User.find_one({
            'username': request.matchdict['user']})
    if not user:
        return render_404(request)
    elif user.status != u'active':
        return render_to_response(
            request,
            'mediagoblin/user_pages/user.html',
            {'user': user})

    cursor = request.db.MediaEntry.find(
        {'uploader': user._id,
         'state': u'processed'}).sort('created', DESCENDING)

    pagination = Pagination(page, cursor)
    media_entries = pagination()

    #if no data is available, return NotFound
    if media_entries == None:
        return render_404(request)

    user_gallery_url = request.urlgen(
        'mediagoblin.user_pages.user_gallery',
        user=user.username)

    return render_to_response(
        request,
        'mediagoblin/user_pages/user.html',
        {'user': user,
         'user_gallery_url': user_gallery_url,
         'media_entries': media_entries,
         'pagination': pagination})
开发者ID:3rdwiki,项目名称:mediagoblin,代码行数:34,代码来源:views.py


示例3: user_home

def user_home(request, page):
    """'Homepage' of a User()"""
    user = User.query.filter_by(username=request.matchdict['user']).first()
    if not user:
        return render_404(request)
    elif not user.has_privilege(u'active'):
        return render_to_response(
            request,
            'mediagoblin/user_pages/user_nonactive.html',
            {'user': user})

    cursor = MediaEntry.query.\
        filter_by(uploader = user.id,
                  state = u'processed').order_by(MediaEntry.created.desc())

    pagination = Pagination(page, cursor)
    media_entries = pagination()

    #if no data is available, return NotFound
    if media_entries == None:
        return render_404(request)

    user_gallery_url = request.urlgen(
        'mediagoblin.user_pages.user_gallery',
        user=user.username)

    return render_to_response(
        request,
        'mediagoblin/user_pages/user.html',
        {'user': user,
         'user_gallery_url': user_gallery_url,
         'media_entries': media_entries,
         'pagination': pagination})
开发者ID:goblinrefuge,项目名称:goblinrefuge-mediagoblin,代码行数:33,代码来源:views.py


示例4: user_home

def user_home(request, page):
    """'Homepage' of a User()"""
    # TODO: decide if we only want homepages for active users, we can
    # then use the @get_active_user decorator and also simplify the
    # template html.
    user = User.query.filter_by(username=request.matchdict["user"]).first()
    if not user:
        return render_404(request)
    elif user.status != u"active":
        return render_to_response(request, "mediagoblin/user_pages/user.html", {"user": user})

    cursor = MediaEntry.query.filter_by(uploader=user.id, state=u"processed").order_by(MediaEntry.created.desc())

    pagination = Pagination(page, cursor)
    media_entries = pagination()

    # if no data is available, return NotFound
    if media_entries == None:
        return render_404(request)

    user_gallery_url = request.urlgen("mediagoblin.user_pages.user_gallery", user=user.username)

    return render_to_response(
        request,
        "mediagoblin/user_pages/user.html",
        {"user": user, "user_gallery_url": user_gallery_url, "media_entries": media_entries, "pagination": pagination},
    )
开发者ID:aurelienmaury,项目名称:JoshuaGoblin,代码行数:27,代码来源:views.py


示例5: processing_panel

def processing_panel(request):
    """
    Show to the user what media is still in conversion/processing...
    and what failed, and why!
    """
    # Get the user
    user = request.db.User.find_one(
        {'username': request.matchdict['user'],
         'status': u'active'})

    # Make sure the user exists and is active
    if not user:
        return render_404(request)
    elif user.status != u'active':
        return render_to_response(
            request,
            'mediagoblin/user_pages/user.html',
            {'user': user})

    # XXX: Should this be a decorator?
    #
    # Make sure we have permission to access this user's panel.  Only
    # admins and this user herself should be able to do so.
    if not (user._id == request.user._id
            or request.user.is_admin):
        # No?  Let's simply redirect to this user's homepage then.
        return redirect(
            request, 'mediagoblin.user_pages.user_home',
            user=request.matchdict['user'])

    # Get media entries which are in-processing
    processing_entries = request.db.MediaEntry.find(
        {'uploader': user._id,
         'state': u'processing'}).sort('created', DESCENDING)

    # Get media entries which have failed to process
    failed_entries = request.db.MediaEntry.find(
        {'uploader': user._id,
         'state': u'failed'}).sort('created', DESCENDING)

    processed_entries = request.db.MediaEntry.find(
            {'uploader': user._id,
                'state': u'processed'}).sort('created', DESCENDING).limit(10)

    # Render to response
    return render_to_response(
        request,
        'mediagoblin/user_pages/processing_panel.html',
        {'user': user,
         'processing_entries': processing_entries,
         'failed_entries': failed_entries,
         'processed_entries': processed_entries})
开发者ID:3rdwiki,项目名称:mediagoblin,代码行数:52,代码来源:views.py


示例6: login

def login(request):
    login_form = forms.LoginForm(request.form)

    login_failed = False

    if request.method == 'POST' and login_form.validate():
        l = LDAP()
        username, email = l.login(login_form.username.data,
                                  login_form.password.data)

        if username:
            user = LocalUser.query.filter(
                LocalUser.username==username
            ).first()

            if user:
                # set up login in session
                request.session['user_id'] = six.text_type(user.id)
                request.session.save()

                if request.form.get('next'):
                    return redirect(request, location=request.form['next'])
                else:
                    return redirect(request, "index")
            else:
                if not mg_globals.app.auth:
                    messages.add_message(
                        request,
                        messages.WARNING,
                        _('Sorry, authentication is disabled on this '
                          'instance.'))
                    return redirect(request, 'index')

                register_form = forms.RegisterForm(username=username,
                                                   email=email)

                return render_to_response(
                    request,
                    'mediagoblin/auth/register.html',
                    {'register_form': register_form,
                    'post_url': request.urlgen('mediagoblin.plugins.ldap.register')})

        login_failed = True

    return render_to_response(
        request,
        'mediagoblin/auth/login.html',
        {'login_form': login_form,
         'next': request.GET.get('next') or request.form.get('next'),
         'login_failed': login_failed,
         'post_url': request.urlgen('mediagoblin.plugins.ldap.login'),
         'allow_registration': mg_globals.app_config["allow_registration"]})
开发者ID:ausbin,项目名称:mediagoblin,代码行数:52,代码来源:views.py


示例7: start_edit

def start_edit(request):
    """Starts the process of adding an openid url to a users account"""
    form = auth_forms.LoginForm(request.form)

    if request.method == 'POST' and form.validate():
        query = OpenIDUserURL.query.filter_by(
            openid_url=form.openid.data
            ).first()
        user = query.user if query else None

        if not user:
            return_to = request.urlgen('mediagoblin.plugins.openid.finish_edit')
            success = _start_verification(request, form, return_to, False)

            if success:
                return success
        else:
            form.openid.errors.append(
                _('Sorry, an account is already registered to that OpenID.'))

    return render_to_response(
        request,
        'mediagoblin/plugins/openid/add.html',
        {'form': form,
         'post_url': request.urlgen('mediagoblin.plugins.openid.edit')})
开发者ID:ausbin,项目名称:mediagoblin,代码行数:25,代码来源:views.py


示例8: register

def register(request):
    """OpenID Registration View"""
    if request.method == 'GET':
        # Need to connect to openid provider before registering a user to
        # get the users openid url. If method is 'GET', then this page was
        # acessed without logging in first.
        return redirect(request, 'mediagoblin.plugins.openid.login')

    register_form = auth_forms.RegistrationForm(request.form)

    if register_form.validate():
        user = register_user(request, register_form)

        if user:
            # redirect the user to their homepage... there will be a
            # message waiting for them to verify their email
            return redirect(
                request, 'mediagoblin.user_pages.user_home',
                user=user.username)

    return render_to_response(
        request,
        'mediagoblin/auth/register.html',
        {'register_form': register_form,
         'post_url': request.urlgen('mediagoblin.plugins.openid.register')})
开发者ID:ausbin,项目名称:mediagoblin,代码行数:25,代码来源:views.py


示例9: activity_view

def activity_view(request):
    """ /<username>/activity/<id> - Display activity

    This should display a HTML presentation of the activity
    this is NOT an API endpoint.
    """
    # Get the user object.
    username = request.matchdict["username"]
    user = LocalUser.query.filter_by(username=username).first()

    activity_id = request.matchdict["id"]

    if request.user is None:
        return render_404(request)

    activity = Activity.query.filter_by(
        id=activity_id,
        author=user.id
    ).first()

    # There isn't many places to check that the public_id is filled so this
    # will do, it really should be, lets try and fix that if it isn't.
    activity.get_public_id(request.urlgen)

    if activity is None:
        return render_404(request)

    return render_to_response(
        request,
        "mediagoblin/api/activity.html",
        {"activity": activity}
    )
开发者ID:tofay,项目名称:mediagoblin,代码行数:32,代码来源:views.py


示例10: collection_list

def collection_list(request, url_user=None):
    """A User-defined Collection"""
    collections = Collection.query.filter_by(get_creator=url_user)

    return render_to_response(
        request, "mediagoblin/user_pages/collection_list.html", {"user": url_user, "collections": collections}
    )
开发者ID:aurelienmaury,项目名称:JoshuaGoblin,代码行数:7,代码来源:views.py


示例11: media_home

def media_home(request, media, page, **kwargs):
    """
    'Homepage' of a MediaEntry()
    """
    comment_id = request.matchdict.get("comment", None)
    if comment_id:
        if request.user:
            mark_comment_notification_seen(comment_id, request.user)

        pagination = Pagination(
            page, media.get_comments(mg_globals.app_config["comments_ascending"]), MEDIA_COMMENTS_PER_PAGE, comment_id
        )
    else:
        pagination = Pagination(
            page, media.get_comments(mg_globals.app_config["comments_ascending"]), MEDIA_COMMENTS_PER_PAGE
        )

    comments = pagination()

    comment_form = user_forms.MediaCommentForm(request.form)

    media_template_name = media.media_manager.display_template

    return render_to_response(
        request,
        media_template_name,
        {
            "media": media,
            "comments": comments,
            "pagination": pagination,
            "comment_form": comment_form,
            "app_config": mg_globals.app_config,
        },
    )
开发者ID:aurelienmaury,项目名称:JoshuaGoblin,代码行数:34,代码来源:views.py


示例12: edit_account

def edit_account(request):
    user = request.user
    form = forms.EditAccountForm(request.form,
        wants_comment_notification=user.wants_comment_notification,
        license_preference=user.license_preference,
        wants_notifications=user.wants_notifications)

    if request.method == 'POST' and form.validate():
        user.wants_comment_notification = form.wants_comment_notification.data
        user.wants_notifications = form.wants_notifications.data

        user.license_preference = form.license_preference.data

        user.save()
        messages.add_message(request,
                             messages.SUCCESS,
                             _("Account settings saved"))
        return redirect(request,
                        'mediagoblin.user_pages.user_home',
                        user=user.username)

    return render_to_response(
        request,
        'mediagoblin/edit/edit_account.html',
        {'user': user,
         'form': form})
开发者ID:incorpusyehtee,项目名称:mediagoblin,代码行数:26,代码来源:views.py


示例13: user_collection

def user_collection(request, page, url_user=None):
    """A User-defined Collection"""
    collection = Collection.query.filter_by(
        get_creator=url_user,
        slug=request.matchdict['collection']).first()

    if not collection:
        return render_404(request)

    cursor = collection.get_collection_items()

    pagination = Pagination(page, cursor)
    collection_items = pagination()

    # if no data is available, return NotFound
    # TODO: Should an empty collection really also return 404?
    if collection_items == None:
        return render_404(request)

    return render_to_response(
        request,
        'mediagoblin/user_pages/collection.html',
        {'user': url_user,
         'collection': collection,
         'collection_items': collection_items,
         'pagination': pagination})
开发者ID:goblinrefuge,项目名称:goblinrefuge-mediagoblin,代码行数:26,代码来源:views.py


示例14: register_client

def register_client(request):
    '''
    Register an OAuth client
    '''
    form = ClientRegistrationForm(request.form)

    if request.method == 'POST' and form.validate():
        client = OAuthClient()
        client.name = unicode(request.form['name'])
        client.description = unicode(request.form['description'])
        client.type = unicode(request.form['type'])
        client.owner_id = request.user.id
        client.redirect_uri = unicode(request.form['redirect_uri'])

        client.generate_identifier()
        client.generate_secret()

        client.save()

        add_message(request, SUCCESS, _('The client {0} has been registered!')\
                .format(
                    client.name))

        return redirect(request, 'mediagoblin.plugins.oauth.list_clients')

    return render_to_response(
            request,
            'oauth/client/register.html',
            {'form': form})
开发者ID:3rdwiki,项目名称:mediagoblin,代码行数:29,代码来源:views.py


示例15: deauthorize_applications

def deauthorize_applications(request):
    """ Deauthroize OAuth applications """
    if request.method == 'POST' and "application" in request.form:
        token = request.form["application"]
        access_token = AccessToken.query.filter_by(token=token).first()
        if access_token is None:
            messages.add_message(
                request,
                messages.ERROR,
                _("Unknown application, not able to deauthorize")
            )
        else:
            access_token.delete()
            messages.add_message(
                request,
                messages.SUCCESS,
                _("Application has been deauthorized")
            )

    access_tokens = AccessToken.query.filter_by(user=request.user.id)
    applications = [(a.get_requesttoken, a) for a in access_tokens]

    return render_to_response(
        request,
        'mediagoblin/edit/deauthorize_applications.html',
        {'applications': applications}
    )
开发者ID:goblinrefuge,项目名称:goblinrefuge-mediagoblin,代码行数:27,代码来源:views.py


示例16: media_home

def media_home(request, media, page, **kwargs):
    """
    'Homepage' of a MediaEntry()
    """
    if request.matchdict.get('comment', None):
        pagination = Pagination(
            page, media.get_comments(
                mg_globals.app_config['comments_ascending']),
            MEDIA_COMMENTS_PER_PAGE,
            request.matchdict.get('comment'))
    else:
        pagination = Pagination(
            page, media.get_comments(
                mg_globals.app_config['comments_ascending']),
            MEDIA_COMMENTS_PER_PAGE)

    comments = pagination()

    comment_form = user_forms.MediaCommentForm(request.form)

    media_template_name = media.media_manager['display_template']

    return render_to_response(
        request,
        media_template_name,
        {'media': media,
         'comments': comments,
         'pagination': pagination,
         'comment_form': comment_form,
         'app_config': mg_globals.app_config})
开发者ID:orblivion,项目名称:mediagoblin-quickstart-openshift,代码行数:30,代码来源:views.py


示例17: register

def register(request):
    """The registration view.

    Note that usernames will always be lowercased. Email domains are lowercased while
    the first part remains case-sensitive.
    """
    if 'pass_auth' not in request.template_env.globals:
        redirect_name = hook_handle('auth_no_pass_redirect')
        if redirect_name:
            return redirect(request, 'mediagoblin.plugins.{0}.register'.format(
                redirect_name))
        else:
            return redirect(request, 'index')

    register_form = hook_handle("auth_get_registration_form", request)

    if request.method == 'POST' and register_form.validate():
        # TODO: Make sure the user doesn't exist already
        user = register_user(request, register_form)

        if user:
            # redirect the user to their homepage... there will be a
            # message waiting for them to verify their email
            return redirect(
                request, 'mediagoblin.user_pages.user_home',
                user=user.username)

    return render_to_response(
        request,
        'mediagoblin/auth/register.html',
        {'register_form': register_form,
         'post_url': request.urlgen('mediagoblin.auth.register')})
开发者ID:ausbin,项目名称:mediagoblin,代码行数:32,代码来源:views.py


示例18: register_client

def register_client(request):
    '''
    Register an OAuth client
    '''
    form = ClientRegistrationForm(request.form)

    if request.method == 'POST' and form.validate():
        client = OAuthClient()
        client.name = six.text_type(form.name.data)
        client.description = six.text_type(form.description.data)
        client.type = six.text_type(form.type.data)
        client.owner_id = request.user.id
        client.redirect_uri = six.text_type(form.redirect_uri.data)

        client.save()

        add_message(request, SUCCESS, _('The client {0} has been registered!')\
                .format(
                    client.name))

        return redirect(request, 'mediagoblin.plugins.oauth.list_clients')

    return render_to_response(
            request,
            'oauth/client/register.html',
            {'form': form})
开发者ID:goblinrefuge,项目名称:goblinrefuge-mediagoblin,代码行数:26,代码来源:views.py


示例19: authorize_client

def authorize_client(request):
    form = AuthorizationForm(request.form)

    client = OAuthClient.query.filter(OAuthClient.id ==
        form.client_id.data).first()

    if not client:
        _log.error('No such client id as received from client authorization \
form.')
        raise BadRequest()

    if form.validate():
        relation = OAuthUserClient()
        relation.user_id = request.user.id
        relation.client_id = form.client_id.data
        if form.allow.data:
            relation.state = u'approved'
        elif form.deny.data:
            relation.state = u'rejected'
        else:
            raise BadRequest()

        relation.save()

        return redirect(request, location=form.next.data)

    return render_to_response(
        request,
        'oauth/authorize.html',
        {'form': form,
            'client': client})
开发者ID:goblinrefuge,项目名称:goblinrefuge-mediagoblin,代码行数:31,代码来源:views.py


示例20: user_gallery

def user_gallery(request, page, url_user=None):
    """'Gallery' of a User()"""
    tag = request.matchdict.get('tag', None)
    cursor = MediaEntry.query.filter_by(
        uploader=url_user.id,
        state=u'processed').order_by(MediaEntry.created.desc())

    # Filter potentially by tag too:
    if tag:
        cursor = cursor.filter(
            MediaEntry.tags_helper.any(
                MediaTag.slug == request.matchdict['tag']))

    # Paginate gallery
    pagination = Pagination(page, cursor)
    media_entries = pagination()

    #if no data is available, return NotFound
    # TODO: Should we really also return 404 for empty galleries?
    if media_entries == None:
        return render_404(request)

    return render_to_response(
        request,
        'mediagoblin/user_pages/gallery.html',
        {'user': url_user, 'tag': tag,
         'media_entries': media_entries,
         'pagination': pagination})
开发者ID:goblinrefuge,项目名称:goblinrefuge-mediagoblin,代码行数:28,代码来源:views.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python template.clear_test_template_context函数代码示例发布时间:2022-05-27
下一篇:
Python response.render_404函数代码示例发布时间: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