本文整理汇总了Python中reversion.models.Revision方法的典型用法代码示例。如果您正苦于以下问题:Python models.Revision方法的具体用法?Python models.Revision怎么用?Python models.Revision使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类reversion.models
的用法示例。
在下文中一共展示了models.Revision方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from reversion import models [as 别名]
# 或者: from reversion.models import Revision [as 别名]
def post(self, request, *args, **kwargs):
self.object = self.get_object()
page = self.get_comment_page()
if self.is_comment_locked():
return HttpResponseForbidden()
parent = request.POST.get('parent')
if parent:
if len(parent) > 10:
return HttpResponseBadRequest()
try:
parent = int(parent)
except ValueError:
return HttpResponseNotFound()
else:
if not Comment.objects.filter(hidden=False, id=parent, page=page).exists():
return HttpResponseNotFound()
form = CommentForm(request, request.POST)
if form.is_valid():
comment = form.save(commit=False)
comment.author = request.profile
comment.page = page
with LockModel(write=(Comment, Revision, Version), read=(ContentType,)), revisions.create_revision():
revisions.set_user(request.user)
revisions.set_comment(_('Posted comment'))
comment.save()
return HttpResponseRedirect(request.path)
context = self.get_context_data(object=self.object, comment_form=form)
return self.render_to_response(context)
示例2: revision
# 需要导入模块: from reversion import models [as 别名]
# 或者: from reversion.models import Revision [as 别名]
def revision(self):
"""
Proxy wrapper Revision-->FeatureVersion
:return:
"""
rev = super(FeatureVersionProxy, self).revision
return FeatureRevisionProxy.objects.get(id=rev.id)