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


Python view.log函数代码示例

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


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


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