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

Python shortcuts.render_to_response函数代码示例

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

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



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

示例1: locations_import_preview

def locations_import_preview(request, id, template_name='locations/import-map-fields.html'):
    """
    This will generate a form based on the uploaded CSV for field mapping.
    A preview will be generated based on the mapping given.
    """
    locport = get_object_or_404(LocationImport, pk=id)

    if request.method == 'POST':
        form = ImportMapForm(request.POST, locport=locport)

        if form.is_valid():
            # Show the user a preview based on the mapping
            cleaned_data = form.cleaned_data
            #file_path = os.path.join(settings.MEDIA_ROOT, locport.get_file().file.name)
            file_path = locport.get_file().file.name
            locations, stats = parse_locs_from_csv(file_path, cleaned_data)

            # return the form to use it for the confirm view
            template_name = 'locations/import-preview.html'
            return render_to_response(template_name, {
                'locations': locations,
                'stats': stats,
                'locport': locport,
                'form': form,
                'now': datetime.now(),
            }, context_instance=RequestContext(request))

    else:
        form = ImportMapForm(locport=locport)

    return render_to_response(template_name, {
        'form': form,
        'locport': locport,
        'now': datetime.now(),
        }, context_instance=RequestContext(request))
开发者ID:BIGGANI,项目名称:tendenci,代码行数:35,代码来源:views.py


示例2: memberphotos

def memberphotos(request, username, template_name="photos/memberphotos.html", group_slug=None, bridge=None):
    """ Get the members photos and display them """

    if bridge:
        try:
            group = bridge.get_group(group_slug)
        except ObjectDoesNotExist:
            raise Http404
    else:
        group = None

    user = get_object_or_404(User, username=username)

    photos = Image.objects.filter(
        member__username = username,
        is_public = True
    )

    if group:
        photos = group.content_objects(photos, join="pool")
    else:
        photos = photos.filter(pool__object_id=None)

    photos = photos.order_by("-date_added")

    return render_to_response(template_name, {
        "group": group,
        "photos": photos,
    }, context_instance=RequestContext(request))
开发者ID:goetzk,项目名称:tendenci,代码行数:29,代码来源:views.py


示例3: delete

def delete(request, id, template_name="directories/delete.html"):
    directory = get_object_or_404(Directory, pk=id)

    if has_perm(request.user,'directories.delete_directory'):
        if request.method == "POST":
            msg_string = 'Successfully deleted %s' % directory
            messages.add_message(request, messages.SUCCESS, _(msg_string))

            # send notification to administrators
            recipients = get_notice_recipients('module', 'directories', 'directoryrecipients')
            if recipients:
                if notification:
                    extra_context = {
                        'object': directory,
                        'request': request,
                    }
                    notification.send_emails(recipients,'directory_deleted', extra_context)

            directory.delete()

            return HttpResponseRedirect(reverse('directory.search'))

        return render_to_response(template_name, {'directory': directory},
            context_instance=RequestContext(request))
    else:
        raise Http403
开发者ID:RMUCapstone-MIS590,项目名称:tendenci,代码行数:26,代码来源:views.py


示例4: edit

def edit(request, id, form_class=DirectoryForm, template_name="directories/edit.html"):
    directory = get_object_or_404(Directory, pk=id)

    if not has_perm(request.user,'directories.change_directory', directory):
        raise Http403

    form = form_class(request.POST or None, request.FILES or None,
                      instance=directory,
                      user=request.user)

    del form.fields['payment_method']
    if not request.user.profile.is_superuser:
        del form.fields['pricing']
        del form.fields['list_type']

    if request.method == "POST":
        if form.is_valid():
            directory = form.save(commit=False)

            if directory.logo:
                try:
                    directory.logo.file.seek(0)
                except IOError:
                    directory.logo = None
            # update all permissions and save the model
            directory = update_perms_and_save(request, form, directory)
            msg_string = 'Successfully updated %s' % directory
            messages.add_message(request, messages.SUCCESS, _(msg_string))

            return HttpResponseRedirect(reverse('directory', args=[directory.slug]))


    return render_to_response(template_name, {'directory': directory, 'form':form},
        context_instance=RequestContext(request))
开发者ID:RMUCapstone-MIS590,项目名称:tendenci,代码行数:34,代码来源:views.py


示例5: edit_meta

def edit_meta(request, id, form_class=MetaForm, template_name="pages/edit-meta.html"):
    """
    Return page that allows you to edit meta-html information.
    """
    # check permission
    page = get_object_or_404(Page, pk=id)
    if not has_perm(request.user, "pages.change_page", page):
        raise Http403

    defaults = {
        "title": page.get_title(),
        "description": page.get_description(),
        "keywords": page.get_keywords(),
        "canonical_url": page.get_canonical_url(),
    }
    page.meta = MetaTags(**defaults)

    if request.method == "POST":
        form = form_class(request.POST, instance=page.meta)
        if form.is_valid():
            page.meta = form.save()  # save meta
            page.save()  # save relationship

            messages.add_message(
                request, messages.SUCCESS, _("Successfully updated meta for %(p)s" % {"p": unicode(page)})
            )

            return HttpResponseRedirect(reverse("page", args=[page.slug]))
    else:
        form = form_class(instance=page.meta)

    return render_to_response(template_name, {"page": page, "form": form}, context_instance=RequestContext(request))
开发者ID:a2call,项目名称:tendenci,代码行数:32,代码来源:views.py


示例6: delete

def delete(request, id, template_name="news/delete.html"):
    news = get_object_or_404(News, pk=id)

    # check permission
    if not has_perm(request.user, 'news.delete_news'):
        raise Http403

    if request.method == "POST":
        msg_string = 'Successfully deleted %s' % unicode(news)
        messages.add_message(request, messages.SUCCESS, _(msg_string))

        # send notification to administrators
        recipients = get_notice_recipients('module', 'news', 'newsrecipients')
        if recipients:
            if notification:
                extra_context = {
                    'object': news,
                    'request': request,
                }
                notification.send_emails(recipients, 'news_deleted', extra_context)

        news.delete()
        return HttpResponseRedirect(reverse('news.search'))

    return render_to_response(template_name, {'news': news},
        context_instance=RequestContext(request))
开发者ID:goetzk,项目名称:tendenci,代码行数:26,代码来源:views.py


示例7: pricing_add

def pricing_add(request, form_class=JobPricingForm,
                    template_name="jobs/pricing-add.html"):

    if has_perm(request.user, 'jobs.add_jobpricing'):
        if request.method == "POST":
            form = form_class(request.POST)
            if form.is_valid():
                job_pricing = form.save(commit=False)
                job_pricing.status = 1
                job_pricing.save(request.user)

                EventLog.objects.log(instance=job_pricing)

                if "_popup" in request.REQUEST:
                    return HttpResponse('<script type="text/javascript">opener.dismissAddAnotherPopup(window, "%s", "%s");</script>' % (escape(job_pricing.pk), escape(job_pricing)))

                return HttpResponseRedirect(
                    reverse('job_pricing.view', args=[job_pricing.id]))
        else:
            form = form_class()

        if "_popup" in request.REQUEST:
            template_name="jobs/pricing-add-popup.html"

        return render_to_response(template_name, {'form': form},
            context_instance=RequestContext(request))
    else:
        raise Http403
开发者ID:ediaz1,项目名称:tendenci,代码行数:28,代码来源:views.py


示例8: mark_as_paid

def mark_as_paid(request, id, template_name="invoices/mark-as-paid.html"):
    """
    Makes a payment-record with a specified date/time
    payment method and payment amount.
    """
    invoice = get_object_or_404(Invoice, pk=id)

    if not has_perm(request.user, "payments.change_payment"):
        raise Http403

    if request.method == "POST":
        form = MarkAsPaidForm(request.POST)

        if form.is_valid():

            # make payment record
            payment = form.save(user=request.user, invoice=invoice, commit=False)

            payment = update_perms_and_save(request, form, payment)

            # update invoice; make accounting entries
            action_taken = invoice.make_payment(payment.creator, payment.amount)
            if action_taken:
                EventLog.objects.log(instance=invoice)
                messages.add_message(request, messages.SUCCESS, _("Payment successfully made"))

            return redirect(invoice)

    else:
        form = MarkAsPaidForm(initial={"amount": invoice.balance, "submit_dt": datetime.now()})

    return render_to_response(
        template_name, {"invoice": invoice, "form": form}, context_instance=RequestContext(request)
    )
开发者ID:ZHW123,项目名称:tendenci,代码行数:34,代码来源:views.py


示例9: add

def add(request, form_class=LocationForm, template_name="locations/add.html"):
    if has_perm(request.user,'locations.add_location'):
        if request.method == "POST":
            form = form_class(request.POST, request.FILES, user=request.user)
            if form.is_valid():
                location = form.save(commit=False)

                # update all permissions and save the model
                location = update_perms_and_save(request, form, location)

                if 'photo_upload' in form.cleaned_data:
                    photo = form.cleaned_data['photo_upload']
                    if photo:
                        location.save(photo=photo)
                msg_string = 'Successfully added %s' % location
                messages.add_message(request, messages.SUCCESS, _(msg_string))

                return HttpResponseRedirect(reverse('location', args=[location.slug]))
        else:
            form = form_class(user=request.user)

        return render_to_response(template_name, {'form':form},
            context_instance=RequestContext(request))
    else:
        raise Http403
开发者ID:BIGGANI,项目名称:tendenci,代码行数:25,代码来源:views.py


示例10: detail

def detail(request, id, template_name="discounts/view.html"):
    discount = get_object_or_404(Discount, id=id)

    if not has_perm(request.user, 'discounts.view_discount', discount):
        raise Http403

    registrations = Registration.objects.filter(invoice__discount_code=discount.discount_code)
    registrant_list = []
    for registration in registrations:
        registrant_list += registration.registrant_set.filter(discount_amount__gt=0)

    memberships = MembershipSet.objects.filter(invoice__discount_code=discount.discount_code)
    membership_list = []
    for membership in memberships:
        count = DiscountUse.objects.filter(invoice=membership.invoice).count()
        membership_list += membership.membershipdefault_set.all()[:count]

    EventLog.objects.log(instance=discount)

    return render_to_response(
        template_name,
        {'discount':discount,
         'registrant_list':registrant_list,
         'membership_list':membership_list},
        context_instance=RequestContext(request)
    )
开发者ID:ediaz1,项目名称:tendenci,代码行数:26,代码来源:views.py


示例11: photoset_zip

def photoset_zip(request, id, template_name="photos/photo-set/zip.html"):
    """ Generate zip file for the entire photo set
    for admins only.
    """

    photo_set = get_object_or_404(PhotoSet, id=id)

    #admin only
    if not request.user.profile.is_superuser:
        raise Http403

    file_path = ""
    task_id = ""
    if not settings.CELERY_IS_ACTIVE:
        task = ZipPhotoSetTask()
        file_path = task.run(photo_set)
    else:
        task = ZipPhotoSetTask.delay(photo_set)
        task_id = task.task_id

    return render_to_response(template_name, {
        "photo_set": photo_set,
        "task_id":task_id,
        "file_path":file_path,
    }, context_instance=RequestContext(request))
开发者ID:goetzk,项目名称:tendenci,代码行数:25,代码来源:views.py


示例12: photoset_details

def photoset_details(request, id, template_name="photos/photo-set/details.html"):
    """ View photos in photo set """
    photo_set = get_object_or_404(PhotoSet, id=id)
    if not has_view_perm(request.user, 'photos.view_photoset', photo_set):
        raise Http403

    order = get_setting('module', 'photos', 'photoordering')
    #if order == 'descending':
    #    photos = photo_set.get_images(user=request.user).order_by('-pk')
    #else:
    #    photos = photo_set.get_images(user=request.user).order_by('pk')
    photos = photo_set.get_images(user=request.user).order_by("position")

    EventLog.objects.log(**{
        'event_id': 991500,
        'event_data': '%s (%d) viewed by %s' % (photo_set._meta.object_name, photo_set.pk, request.user),
        'description': '%s viewed' % photo_set._meta.object_name,
        'user': request.user,
        'request': request,
        'instance': photo_set,
    })

    return render_to_response(template_name, {
        "photos": photos,
        "photo_set": photo_set,
    }, context_instance=RequestContext(request))
开发者ID:goetzk,项目名称:tendenci,代码行数:26,代码来源:views.py


示例13: photoset_add

def photoset_add(request, form_class=PhotoSetAddForm, template_name="photos/photo-set/add.html"):
    """ Add a photo set """
    # if no permission; permission exception
    if not has_perm(request.user,'photos.add_photoset'):
        raise Http403

    if request.method == "POST":
        if request.POST["action"] == "add":

            form = form_class(request.POST, user=request.user)
            if form.is_valid():
                photo_set = form.save(commit=False)

                photo_set.author = request.user

                # update all permissions and save the model
                photo_set = update_perms_and_save(request, form, photo_set)
                checklist_update('add-album')

                messages.add_message(request, messages.SUCCESS, _('Successfully added photo set!'))
                return HttpResponseRedirect(reverse('photos_batch_add', kwargs={'photoset_id':photo_set.id}))
    else:
        form = form_class(user=request.user)

    return render_to_response(template_name, {
        "photoset_form": form,
    }, context_instance=RequestContext(request))
开发者ID:goetzk,项目名称:tendenci,代码行数:27,代码来源:views.py


示例14: approve

def approve(request, id, template_name="resumes/approve.html"):
    if not request.user.profile.is_superuser:
        raise Http403
    resume = get_object_or_404(Resume, pk=id)

    if request.method == "POST":
        resume.activation_dt = datetime.now()
        resume.allow_anonymous_view = True
        resume.status = True
        resume.status_detail = 'active'

        if not resume.creator:
            resume.creator = request.user
            resume.creator_username = request.user.username

        if not resume.owner:
            resume.owner = request.user
            resume.owner_username = request.user.username

        resume.save()

        messages.add_message(request, messages.SUCCESS, _('Successfully approved %(r)s' % {'r':resume}))

        return HttpResponseRedirect(reverse('resume', args=[resume.slug]))

    return render_to_response(template_name, {'resume': resume},
            context_instance=RequestContext(request))
开发者ID:goetzk,项目名称:tendenci,代码行数:27,代码来源:views.py


示例15: search

def search(request, template_name="resumes/search.html"):
    """
    This page lists out all resumes from newest to oldest.
    If a search index is available, this page will also
    have the option to search through resumes.
    """
    has_index = get_setting('site', 'global', 'searchindex')
    query = request.GET.get('q', None)

    if has_index and query:
        resumes = Resume.objects.search(query, user=request.user)
    else:
        filters = get_query_filters(request.user, 'resumes.view_resume')
        resumes = Resume.objects.filter(filters).distinct()
        if request.user.is_authenticated():
            resumes = resumes.select_related()
    resumes = resumes.order_by('-create_dt')

    EventLog.objects.log(**{
        'event_id' : 354000,
        'event_data': '%s searched by %s' % ('Resume', request.user),
        'description': '%s searched' % 'Resume',
        'user': request.user,
        'request': request,
        'source': 'resumes'
    })

    return render_to_response(template_name, {'resumes':resumes},
        context_instance=RequestContext(request))
开发者ID:goetzk,项目名称:tendenci,代码行数:29,代码来源:views.py


示例16: locations_import_upload

def locations_import_upload(request, template_name='locations/import-upload-file.html'):
    """
    This is the upload view for the location imports.
    This will upload the location import file and then redirect the user
    to the import mapping/preview page of the import file
    """
    if request.method == 'POST':
        form = UploadForm(request.POST, request.FILES)
        if form.is_valid():

            locport = LocationImport.objects.create(creator=request.user)
            csv = File.objects.save_files_for_instance(request, locport)[0]
            file_path = str(csv.file.name)
            import_valid, import_errs = is_import_valid(file_path)

            if not import_valid:
                for err in import_errs:
                    messages.add_message(request, messages.ERROR, err)
                locport.delete()
                return redirect('locations_import_upload_file')
            EventLog.objects.log()
            # reset the password_promt session
            del request.session['password_promt']
            return redirect('locations_import_preview', locport.id)
    else:
        form = UploadForm()

    return render_to_response(template_name, {
            'form': form,
            'now': datetime.now(),
        }, context_instance=RequestContext(request))
开发者ID:BIGGANI,项目名称:tendenci,代码行数:31,代码来源:views.py


示例17: add

def add(request, form_class=FormForm, template_name="forms/add.html"):
    if not has_perm(request.user,'forms.add_form'):
        raise Http403

    PricingFormSet = inlineformset_factory(Form, Pricing, form=PricingForm, extra=2, can_delete=False)

    formset = PricingFormSet()
    if request.method == "POST":
        form = form_class(request.POST, user=request.user)
        if form.is_valid():
            form_instance = form.save(commit=False)
            # save form and associated pricings
            form_instance = update_perms_and_save(request, form, form_instance)
            formset = PricingFormSet(request.POST, instance=form_instance)
            if formset.is_valid():
                # update_perms_and_save does not appear to consider ManyToManyFields
                for method in form.cleaned_data['payment_methods']:
                    form_instance.payment_methods.add(method)

                formset.save()

                messages.add_message(request, messages.SUCCESS, _('Successfully added %(f)s' % {'f':form_instance}))
                return HttpResponseRedirect(reverse('form_field_update', args=[form_instance.pk]))
    else:
        form = form_class(user=request.user)

    return render_to_response(template_name, {
        'form':form,
        'formset': formset,
    }, context_instance=RequestContext(request))
开发者ID:goetzk,项目名称:tendenci,代码行数:30,代码来源:views.py


示例18: locations_import_confirm

def locations_import_confirm(request, id, template_name='locations/import-confirm.html'):
    """
    Confirm the locations import and continue with the process.
    This can only be accessed via a hidden post form from the preview page.
    That will hold the original mappings selected by the user.
    """
    locport = get_object_or_404(LocationImport, pk=id)

    if request.method == "POST":
        form = ImportMapForm(request.POST, locport=locport)

        if form.is_valid():
            cleaned_data = form.cleaned_data
            file_path = str(locport.get_file().file.name)

            if not settings.CELERY_IS_ACTIVE:
                # if celery server is not present
                # evaluate the result and render the results page
                result = ImportLocationsTask()
                locations, stats = result.run(request.user, file_path, cleaned_data)
                return render_to_response(template_name, {
                    'locations': locations,
                    'stats': stats,
                    'now': datetime.now(),
                }, context_instance=RequestContext(request))
            else:
                result = ImportLocationsTask.delay(request.user, file_path, cleaned_data)

            return redirect('locations_import_status', result.task_id)
    else:
        return redirect('locations_import_preview', locport.id)
开发者ID:BIGGANI,项目名称:tendenci,代码行数:31,代码来源:views.py


示例19: edit_meta

def edit_meta(request, id, form_class=MetaForm, template_name="news/edit-meta.html"):
    # check permission
    news = get_object_or_404(News, pk=id)
    if not has_perm(request.user, 'news.change_news', news):
        raise Http403

    defaults = {
        'title': news.get_title(),
        'description': news.get_description(),
        'keywords': news.get_keywords(),
        'canonical_url': news.get_canonical_url(),
    }
    news.meta = MetaTags(**defaults)

    if request.method == "POST":
        form = form_class(request.POST, instance=news.meta)
        if form.is_valid():
            news.meta = form.save()  # save meta
            news.save()  # save relationship
            msg_string = 'Successfully updated meta for %s' % unicode(news)
            messages.add_message(request, messages.SUCCESS, _(msg_string))

            return HttpResponseRedirect(reverse('news.detail', args=[news.slug]))
    else:
        form = form_class(instance=news.meta)

    return render_to_response(template_name, {'news': news, 'form': form},
        context_instance=RequestContext(request))
开发者ID:goetzk,项目名称:tendenci,代码行数:28,代码来源:views.py


示例20: export

def export(request, template_name="locations/export.html"):
    """Export Locations"""

    if not request.user.is_superuser:
        raise Http403

    if request.method == 'POST':
        # initilize initial values
        fields = [
            'guid',
            'location_name',
            'description',
            'contact',
            'address',
            'address2',
            'city',
            'state',
            'zipcode',
            'country',
            'phone',
            'fax',
            'email',
            'website',
            'latitude',
            'longitude',
            'hq',
            'entity',
        ]

        export_id = run_export_task('locations', 'location', fields)
        EventLog.objects.log()
        return redirect('export.status', export_id)

    return render_to_response(template_name, {
    }, context_instance=RequestContext(request))
开发者ID:BIGGANI,项目名称:tendenci,代码行数:35,代码来源:views.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python models.Group类代码示例发布时间:2022-05-27
下一篇:
Python shortcuts.render_to_resp函数代码示例发布时间: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