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

Python view.log函数代码示例

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

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



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

示例1: delete_study

def delete_study(request, pk):
    try:
        study = Study.objects.get(pk=pk)
    except ObjectDoesNotExist:
        msg = "Error study matching query does not exist."
        messages.add_message(request, messages.ERROR, ugettext(msg))
        return redirect('/lifespan/studies/')
    form = DeleteStudyForm(request.POST or None)
    if request.method == "POST" and form.is_valid:
        if 'cancel' in request.POST:
            return redirect('/lifespan/study/%s' % pk)
        else:
            with reversion.create_revision():
                try:
                    if 'delete_study' in request.POST:
                        study.delete()
                    if 'delete_reference' in request.POST:
                        study.delete()
                        study.reference.delete()
                except AttributeError:
                    msg = "Error study did not have a reference associated."
                    messages.add_message(request, messages.ERROR, ugettext(msg))
                reversion.set_user(request.user)
                comment = request.POST['comment'] or "Deleted study"
                reversion.set_comment(comment)
                log(request, study, comment)
                return redirect('/lifespan/studies/')
    ctx = {'study': study, 'form': form}
    return render_to_response('lifespan/delete_study.html', ctx,
                context_instance=RequestContext(request))
开发者ID:AaronMBrown,项目名称:denigma,代码行数:30,代码来源:views.py


示例2: form_valid

 def form_valid(self, form):
     with reversion.create_revision():
         self.object = form.save(commit=False)
         if isinstance(self.request.user, AnonymousUser):
             self.request.user = User.objects.get(username="Anonymous")
         comment = self.request.POST["comment"] or self.comment
         reversion.set_comment(comment)
         self.object.comment = comment
         self.object.save()
         log(self.request, self.object, comment, 1)
         reversion.set_user(self.request.user)
         form.save_m2m()
         self.success_url = self.success_url or self.object.get_absolute_url()
         messages.add_message(self.request, messages.SUCCESS, _(self.message % self.object))
         return HttpResponseRedirect(self.get_success_url())
开发者ID:AaronMBrown,项目名称:denigma,代码行数:15,代码来源:views.py


示例3: edit_factor

def edit_factor(request, pk):
    factor = Factor.objects.get(pk=pk)
    form = FactorForm(request.POST or None, instance=factor)
    if request.method == "POST" and form.is_valid():
        if "cancel" in request.POST:
            return redirect("/lifespan/factor/%s" % pk)
        with reversion.create_revision():
            form.save()
            reversion.set_user(request.user)
            comment = request.POST["comment"] or "Changed factor"
            reversion.set_comment(comment)
            log(request, factor, comment)
            return redirect("/lifespan/factor/%s" % pk)
    ctx = {"factor": factor, "form": form, "action": "Edit"}
    return render_to_response("lifespan/factor_form.html", ctx, context_instance=RequestContext(request))
开发者ID:pombredanne,项目名称:denigma,代码行数:15,代码来源:views.py


示例4: edit_experiment

def edit_experiment(request, pk):
    experiment = Experiment.objects.get(pk=pk)
    form = ExperimentForm(request.POST or None, instance=experiment)
    if request.method == "POST" and form.is_valid():
        if "cancel" in request.POST:
            return redirect("/lifespan/experiments/")
        with reversion.create_revision():
            form.save()
            reversion.set_user(request.user)
            comment = request.POST["comment"] or "Changed experiment"
            reversion.set_comment(comment)
            log(request, experiment, comment)
        return redirect("/lifespan/experiment/%s" % pk)
    ctx = {"experiment": experiment, "form": form}
    return render_to_response("lifespan/edit_experiment.html", ctx, context_instance=RequestContext(request))
开发者ID:pombredanne,项目名称:denigma,代码行数:15,代码来源:views.py


示例5: delete_intervention

def delete_intervention(request, pk):
    intervention = Intervention.objects.get(pk=pk)
    form = DeleteInterventionForm(request.POST or None)
    if request.method == "POST" and form.is_valid():
        if "cancel" in request.POST:
            return redirect("/lifespan/intervention/%s" % pk)
        elif "delete" in request.POST:
            with reversion.create_revision():
                intervention.delete()
                comment = request.POST["comment"] or "Delete intervention"
                reversion.set_comment(comment)
                log(request, intervention, comment)
                return redirect("/lifespan/interventions/")
    ctx = {"intervention": intervention, "form": form}
    return render_to_response("lifespan/delete_intervention.html", ctx, context_instance=RequestContext(request))
开发者ID:pombredanne,项目名称:denigma,代码行数:15,代码来源:views.py


示例6: delete_intervention

def delete_intervention(request, pk):
    intervention = Intervention.objects.get(pk=pk)
    form = DeleteInterventionForm(request.POST or None)
    if request.method == "POST" and form.is_valid():
        if 'cancel' in request.POST:
            return redirect('/lifespan/intervention/%s' % pk)
        elif 'delete' in request.POST:
            with reversion.create_revision():
                intervention.delete()
                comment = request.POST['comment'] or "Delete intervention"
                reversion.set_comment(comment)
                log(request, intervention, comment)
                return redirect('/lifespan/interventions/')
    ctx = {'intervention': intervention, 'form': form}
    return render_to_response('lifespan/delete_intervention.html', ctx,
        context_instance=RequestContext(request))
开发者ID:AaronMBrown,项目名称:denigma,代码行数:16,代码来源:views.py


示例7: delete

 def delete(self, request, *args, **kwargs):
     #print("data.views.Delete.delete()")
     with reversion.create_revision():
         self.object = self.get_object()
         if isinstance(self.request.user, AnonymousUser):
             self.request.user = User.objects.get(username='Anonymous')
         self.object.user = self.request.user
         comment = self.request.POST['comment'] or self.comment
         reversion.set_comment(comment)
         self.object.delete()
         log(self.request, self.object, comment, 3)
         reversion.set_user(self.request.user)
         self.success_url = self.success_url or self.object.get_absolute_url()
         messages.add_message(self.request, messages.SUCCESS,
             _(self.message % self.object))
         return HttpResponseRedirect(self.get_success_url())
开发者ID:pombredanne,项目名称:denigma,代码行数:16,代码来源:views.py


示例8: edit_tissue

def edit_tissue(request, pk):
    tissue = Tissue.objects.get(pk=pk)
    form = TissueForm(request.POST or None, instance=tissue)
    if request.method == "POST" and form.is_valid():
        if "cancel" in request.POST:
            return redirect('/annotations/tissue/%s' % pk)
        with reversion.create_revision():
            form.save()
            reversion.set_user(request.user)
            comment = request.POST['comment'] or "Changed tissue."
            reversion.set_comment(comment)
            log(request, tissue, comment)
            return redirect('/annotations/tissue/%s' % pk)
    ctx = {'tissue': tissue, 'form': form, 'action': 'Edit'}
    return render_to_response('annotations/tissue_form.html', ctx,
        context_instance=RequestContext(request))
开发者ID:denigma,项目名称:denigma,代码行数:16,代码来源:views.py


示例9: edit_species

def edit_species(request, pk):
    species = Species.objects.get(pk=pk)
    form = SpeciesForm(request.POST or None, instance=species)
    if request.method == "POST" and form.is_valid():
        if "cancel" in request.POST:
            return redirect('/annotations/species/%s' % pk)
        with reversion.create_revision():
            form.save()
            reversion.set_user(request.user)
            comment = request.POST['comment'] or "Changed tissue"
            reversion.set_comment(comment)
            log(request, species, comment)
            return redirect('/annotations/species/%s.html' % pk)
    ctx = {'species': species, 'form': form, 'action': 'Edit'}
    return render_to_response('annotations/species_form.html', ctx,
        context_instance=RequestContext(request))
开发者ID:denigma,项目名称:denigma,代码行数:16,代码来源:views.py


示例10: edit_factor

def edit_factor(request, pk):
    factor = Factor.objects.get(pk=pk)
    form = FactorForm(request.POST or None, instance=factor)
    if request.method == "POST" and form.is_valid():
        if "cancel" in request.POST:
            return redirect('/lifespan/factor/%s' % pk)
        with reversion.create_revision():
            form.save()
            reversion.set_user(request.user)
            comment = request.POST['comment'] or "Changed factor"
            reversion.set_comment(comment)
            log(request, factor, comment)
            return redirect('/lifespan/factor/%s' % pk)
    ctx = {'factor': factor, 'form': form, 'action': 'Edit'}
    return render_to_response('lifespan/factor_form.html', ctx,
        context_instance=RequestContext(request))
开发者ID:AaronMBrown,项目名称:denigma,代码行数:16,代码来源:views.py


示例11: handlePopAdd

def handlePopAdd(request, addForm, field, template="form/popadd.html"):
    if request.method == "POST":
        form = addForm(request.POST)
        if form.is_valid():
            try:
                with reversion.create_revision():
                    newObject = form.save()
                    reversion.set_user(request.user)
                    comment = request.POST['comment'] or 'Added.'
                    reversion.set_comment(comment)
                    log(request, newObject, comment)
            except forms.ValidationError, error:
                newObject = None
            if newObject:
                return HttpResponse('<script type="text/javascript">opener.dismissAddAnotherPopup(window, "%s", "%s");</script>' %\
                                    (escape(newObject._get_pk_val()), escape(newObject)))
开发者ID:AaronMBrown,项目名称:denigma,代码行数:16,代码来源:forms.py


示例12: delete_experiment

def delete_experiment(request, pk):
    experiment = Experiment.objects.get(pk=pk)
    form = DeleteExperimentForm(request.POST or None)
    if request.method == "POST" and form.is_valid():
        if 'cancel' in request.POST:
            return redirect('/lifespan/experiment/%s' % pk)
        elif 'delete_experiment' in request.POST:
            with reversion.create_revision():
                experiment.delete()
                reversion.set_user(request.user)
                comment = request.POST['comment'] or "Deleted experiment"
                reversion.set_comment(comment)
                log(request, experiment, comment)
                return redirect('/lifespan/experiments/')
    ctx = {'experiment': experiment, 'form': form}
    return render_to_response('lifespan/delete_experiment.html', ctx,
        context_instance=RequestContext(request))
开发者ID:AaronMBrown,项目名称:denigma,代码行数:17,代码来源:views.py


示例13: add_classification

def add_classification(request, template='annotations/classification_form.html'):
    form = ClassificationForm(request.POST or None)
    if request.method == "POST" and form.is_valid():
        with reversion.create_revision():
            classification = form.save(commit=False)
            form.save()
            if isinstance(request.user, AnonymousUser):
                request.user = User.objects.get(username="Anonymous")
            reversion.set_user(request.user)
            comment = request.POST['comment'] or "Added classification"
            reversion.set_comment(comment)
            log(request, classification, comment)
            msg = "Successfully added classification."
            messages.add_message(request, messages.SUCCESS, _(msg))
            return redirect('/annotations/classification/%s' %
                            classification.pk)
    return render(request, template, {'form': form, 'action': 'Add'})
开发者ID:denigma,项目名称:denigma,代码行数:17,代码来源:views.py


示例14: add_factor

def add_factor(request):
    form = FactorForm(request.POST or None)
    if request.method == "POST" and form.is_valid():
        with reversion.create_revision():
            factor = form.save(commit=False)
            form.save()
            if isinstance(request.user, AnonymousUser):
                request.user = User.objects.get(username="Anonymous")
            reversion.set_user(request.user)
            comment = "Added factor. %s" % request.POST["comment"] or ""
            reversion.set_comment(comment)
            log(request, factor, comment)
            msg = "Successfully added factor."
            messages.add_message(request, messages.SUCCESS, ugettext(msg))
            return redirect("/lifespan/factor/%s" % factor.pk)
    ctx = {"form": form, "action": "Add"}
    return render_to_response("lifespan/factor_form.html", ctx, context_instance=RequestContext(request))
开发者ID:pombredanne,项目名称:denigma,代码行数:17,代码来源:views.py


示例15: add_intervention

def add_intervention(request):
    form = InterventionForm(request.POST or None)
    if request.method == "POST" and form.is_valid():
        with reversion.create_revision():
            intervention = form.save(commit=False)
            form.save()
            if isinstance(request.user, AnonymousUser):
                request.user = User.objects.get(username="Anonymous")
            reversion.set_user(request.user)
            comment = "Added intervention. %s" % request.POST['comment'] or ''
            reversion.set_comment(comment)
            log(request, intervention, comment)
            msg = "Successfully added intervention."
            messages.add_message(request, messages.SUCCESS, ugettext(msg))
            return redirect('/lifespan/intervention/%s' % intervention.pk)
    ctx = {'form': form, 'action': 'Add'}
    return render_to_response('lifespan/intervention_form.html', ctx,
        context_instance=RequestContext(request))
开发者ID:AaronMBrown,项目名称:denigma,代码行数:18,代码来源:views.py


示例16: edit_classification

def edit_classification(request, pk):
    classification = Classification.objects.get(pk=pk)
    form = ClassificationForm(request.POST or None, instance=classification)
    if request.method == "POST" and form.is_valid():
        if "cancel" in request.POST:
            return redirect('/annotations/classifications/')
        with reversion.create_revision():
            form.save()
            reversion.set_user(request.user)
            comment = request.POST['comment'] or "Changed classification"
            reversion.set_comment(comment)
            log(request, classification, comment)
        return redirect('/annotations/classification/%s' % pk)
    ctx = {'classification': classification,
           'form': form,
           'action': 'Edit'}
    return render_to_response('annotations/classification_form.html', ctx,
        context_instance=RequestContext(request))
开发者ID:denigma,项目名称:denigma,代码行数:18,代码来源:views.py


示例17: add_experiment

def add_experiment(request, pk):
    form = ExperimentForm(request.POST or None, pk=pk)  # A form bound to the POST data
    if request.method == "POST" and form.is_valid():  # All validation rules pass
        with reversion.create_revision():
            experiment = form.save(commit=False)
            # print("Experiment id: %s" % experiment.id)
            # print form
            form.save()
            if isinstance(request.user, AnonymousUser):
                request.user = User.objects.get(username="Anonymous")
            reversion.set_user(request.user)
            comment = "Added experiment."
            reversion.set_comment(comment)
            log(request, experiment, comment)
            msg = "Successfully added experiment."
            messages.add_message(request, messages.SUCCESS, ugettext(msg))
            return redirect("/lifespan/experiment/%s" % experiment.pk)
    return render_to_response("lifespan/add_experiment.html", {"form": form}, context_instance=RequestContext(request))
开发者ID:pombredanne,项目名称:denigma,代码行数:18,代码来源:views.py


示例18: delete_classification

def delete_classification(request, pk):
    classification = Classification.objects.get(pk=pk)
    form = DeleteClassificationForm(request.POST or None)
    if request.method == "POST" and form.is_valid():
        if "cancel" in request.POST:
            return redirect('/annotations/classification/%s' % pk)
        elif "delete_classification" in request.POST:
            with reversion.create_revision():
                classification.delete()
                reversion.set_user(request.user)
                comment = request.POST['comment'] or "Delete classification"
                log(request, classification, comment)
                msg = "Successfully deleted classification %s." % classification.title
                messages.add_message(request, messages.SUCCESS, _(msg))
                return redirect('/annotations/classifications/')
    ctx = {'classification': classification, 'form': form}
    return render_to_response('annotations/delete_classification.html', ctx,
        context_instance=RequestContext(request))
开发者ID:pombredanne,项目名称:denigma,代码行数:18,代码来源:views.py


示例19: delete_tissue

def delete_tissue(request, pk):
    tissue = Tissue.objects.get(pk=pk)
    form = DeleteTissueForm(request.POST or None)

    if request.method == "POST" and form.is_valid():

        if "cancel" in request.POST:
            return redirect('/annotations/tissue/%s' % pk)
        elif "delete" in request.POST:
            #print tissue, form.is_valid()
            with reversion.create_revision():
                tissue.delete()
                reversion.set_user(request.user)
                comment = request.POST['comment'] or "Changed tissue"
                reversion.set_comment(comment)
                log(request, tissue, comment)
                return redirect('/annotations/tissues/')
    ctx = {'tissue': tissue, 'form': form}
    return render_to_response('annotations/delete_tissue.html', ctx,
        context_instance=RequestContext(request))
开发者ID:denigma,项目名称:denigma,代码行数:20,代码来源:views.py


示例20: edit_study

def edit_study(request, pk):
    study = Study.objects.get(pk=pk)
    if request.method == "GET":
        form = EditStudyForm(instance=study)
    elif request.method == "POST":
        if "cancel" in request.POST:
            return redirect("/lifespan/studies/")
        with reversion.create_revision():
            form = EditStudyForm(request.POST, instance=study)

            if form.is_valid():
                form.save()
                reversion.set_user(request.user)
                comment = request.POST["comment"] or "Changed study"
                reversion.set_comment(comment)
                log(request, study, comment)
                return redirect("/lifespan/study/%s" % pk)
    else:
        form = EditStudyForm(instance=study)
    ctx = {"form": form, "study": study}
    return render_to_response("lifespan/edit_study.html", ctx, context_instance=RequestContext(request))
开发者ID:pombredanne,项目名称:denigma,代码行数:21,代码来源:views.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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