本文整理汇总了Python中reviewboard.changedescs.models.ChangeDescription.timestamp方法的典型用法代码示例。如果您正苦于以下问题:Python ChangeDescription.timestamp方法的具体用法?Python ChangeDescription.timestamp怎么用?Python ChangeDescription.timestamp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类reviewboard.changedescs.models.ChangeDescription
的用法示例。
在下文中一共展示了ChangeDescription.timestamp方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: close
# 需要导入模块: from reviewboard.changedescs.models import ChangeDescription [as 别名]
# 或者: from reviewboard.changedescs.models.ChangeDescription import timestamp [as 别名]
def close(self, type, user=None, description=None, rich_text=False):
"""Closes the review request.
The type must be one of SUBMITTED or DISCARDED.
"""
if (user and not self.is_mutable_by(user) and
not user.has_perm("reviews.can_change_status", self.local_site)):
raise PermissionError
if type not in [self.SUBMITTED, self.DISCARDED]:
raise AttributeError("%s is not a valid close type" % type)
draft = get_object_or_none(self.draft)
if self.status != type:
if (draft is not None and
not self.public and type == self.DISCARDED):
# Copy over the draft information if this is a private discard.
draft.copy_fields_to_request(self)
# TODO: Use the user's default for rich_text.
changedesc = ChangeDescription(public=True,
text=description or "",
rich_text=rich_text or False)
status_field = get_review_request_field('status')(self)
status_field.record_change_entry(changedesc, self.status, type)
changedesc.save()
self.changedescs.add(changedesc)
if type == self.SUBMITTED:
if not self.public:
raise PublishError("The draft must be public first.")
else:
self.commit_id = None
self.status = type
self.save(update_counts=True)
review_request_closed.send(sender=self.__class__, user=user,
review_request=self,
type=type)
else:
# Update submission description.
changedesc = self.changedescs.filter(public=True).latest()
changedesc.timestamp = timezone.now()
changedesc.text = description or ""
changedesc.rich_text = rich_text
changedesc.save()
# Needed to renew last-update.
self.save()
# Delete the associated draft review request.
if draft is not None:
draft.delete()
示例2: close
# 需要导入模块: from reviewboard.changedescs.models import ChangeDescription [as 别名]
# 或者: from reviewboard.changedescs.models.ChangeDescription import timestamp [as 别名]
def close(self, type, user=None, description=None, rich_text=False):
"""Closes the review request.
The type must be one of SUBMITTED or DISCARDED.
"""
if (user and not self.is_mutable_by(user) and
not user.has_perm("reviews.can_change_status", self.local_site)):
raise PermissionError
if type not in [self.SUBMITTED, self.DISCARDED]:
raise AttributeError("%s is not a valid close type" % type)
if self.status != type:
# TODO: Use the user's default for rich_text.
changedesc = ChangeDescription(public=True,
text=description or "",
rich_text=rich_text or False)
changedesc.record_field_change('status', self.status, type)
changedesc.save()
self.changedescs.add(changedesc)
if type == self.SUBMITTED:
self.public = True
else:
self.commit_id = None
self.status = type
self.save(update_counts=True)
review_request_closed.send(sender=self.__class__, user=user,
review_request=self,
type=type)
else:
# Update submission description.
changedesc = self.changedescs.filter(public=True).latest()
changedesc.timestamp = timezone.now()
changedesc.text = description or ""
changedesc.rich_text = rich_text
changedesc.save()
# Needed to renew last-update.
self.save()
try:
draft = self.draft.get()
except ObjectDoesNotExist:
pass
else:
draft.delete()
示例3: close
# 需要导入模块: from reviewboard.changedescs.models import ChangeDescription [as 别名]
# 或者: from reviewboard.changedescs.models.ChangeDescription import timestamp [as 别名]
#.........这里部分代码省略.........
.. versionchanged:: 3.0
The ``type`` argument is deprecated: ``close_type`` should be used
instead.
This method raises :py:exc:`ValueError` instead of
:py:exc:`AttributeError` when the ``close_type`` has an incorrect
value.
"""
if close_type is None:
try:
close_type = kwargs.pop('type')
except KeyError:
raise AttributeError('close_type must be provided')
warnings.warn(
'The "type" argument was deprecated in Review Board 3.0 and '
'will be removed in a future version. Use "close_type" '
'instead.'
)
if kwargs:
raise TypeError('close() does not accept keyword arguments.')
if (user and not self.is_mutable_by(user) and
not user.has_perm("reviews.can_change_status", self.local_site)):
raise PermissionError
if close_type not in [self.SUBMITTED, self.DISCARDED]:
raise ValueError("%s is not a valid close type" % type)
review_request_closing.send(
sender=type(self),
user=user,
review_request=self,
close_type=close_type,
type=deprecated_signal_argument(
signal_name='review_request_closing',
old_name='type',
new_name='close_type',
value=close_type),
description=description,
rich_text=rich_text)
draft = get_object_or_none(self.draft)
if self.status != close_type:
if (draft is not None and
not self.public and close_type == self.DISCARDED):
# Copy over the draft information if this is a private discard.
draft.copy_fields_to_request(self)
# TODO: Use the user's default for rich_text.
changedesc = ChangeDescription(public=True,
text=description or "",
rich_text=rich_text or False,
user=user or self.submitter)
status_field = get_review_request_field('status')(self)
status_field.record_change_entry(changedesc, self.status,
close_type)
changedesc.save()
self.changedescs.add(changedesc)
if close_type == self.SUBMITTED:
if not self.public:
raise PublishError("The draft must be public first.")
else:
self.commit_id = None
self.status = close_type
self.save(update_counts=True)
review_request_closed.send(
sender=type(self),
user=user,
review_request=self,
close_type=close_type,
type=deprecated_signal_argument(
signal_name='review_request_closed',
old_name='type',
new_name='close_type',
value=close_type),
description=description,
rich_text=rich_text)
else:
# Update submission description.
changedesc = self.changedescs.filter(public=True).latest()
changedesc.timestamp = timezone.now()
changedesc.text = description or ""
changedesc.rich_text = rich_text
changedesc.save()
# Needed to renew last-update.
self.save()
# Delete the associated draft review request.
if draft is not None:
draft.delete()