本文整理汇总了Python中reviewboard.changedescs.models.ChangeDescription.save方法的典型用法代码示例。如果您正苦于以下问题:Python ChangeDescription.save方法的具体用法?Python ChangeDescription.save怎么用?Python ChangeDescription.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类reviewboard.changedescs.models.ChangeDescription
的用法示例。
在下文中一共展示了ChangeDescription.save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: reopen
# 需要导入模块: from reviewboard.changedescs.models import ChangeDescription [as 别名]
# 或者: from reviewboard.changedescs.models.ChangeDescription import save [as 别名]
def reopen(self, user=None):
"""Reopens the review request for review."""
from reviewboard.reviews.models.review_request_draft import \
ReviewRequestDraft
if (user and not self.is_mutable_by(user) and
not user.has_perm("reviews.can_change_status", self.local_site)):
raise PermissionError
if self.status != self.PENDING_REVIEW:
changedesc = ChangeDescription()
changedesc.record_field_change('status', self.status,
self.PENDING_REVIEW)
if self.status == self.DISCARDED:
# A draft is needed if reopening a discarded review request.
self.public = False
changedesc.save()
draft = ReviewRequestDraft.create(self)
draft.changedesc = changedesc
draft.save()
else:
changedesc.public = True
changedesc.save()
self.changedescs.add(changedesc)
self.status = self.PENDING_REVIEW
self.save(update_counts=True)
review_request_reopened.send(sender=self.__class__, user=user,
review_request=self)
示例2: test_get_with_site
# 需要导入模块: from reviewboard.changedescs.models import ChangeDescription [as 别名]
# 或者: from reviewboard.changedescs.models.ChangeDescription import save [as 别名]
def test_get_with_site(self):
"""Testing the GET review-requests/<id>/changes/ API
with access to a local site
"""
review_request = self.create_review_request(publish=True,
with_local_site=True)
self._login_user(local_site=True)
now = timezone.now()
change1 = ChangeDescription(public=True,
timestamp=now)
change1.record_field_change('summary', 'foo', 'bar')
change1.save()
review_request.changedescs.add(change1)
change2 = ChangeDescription(public=True,
timestamp=now + timedelta(seconds=1))
change2.record_field_change('description', 'foo', 'bar')
change2.save()
review_request.changedescs.add(change2)
rsp = self.apiGet(
get_change_list_url(review_request, self.local_site_name),
expected_mimetype=change_list_mimetype)
self.assertEqual(rsp['stat'], 'ok')
self.assertEqual(len(rsp['changes']), 2)
self.assertEqual(rsp['changes'][0]['id'], change2.pk)
self.assertEqual(rsp['changes'][1]['id'], change1.pk)
示例3: test_get_change_not_modified
# 需要导入模块: from reviewboard.changedescs.models import ChangeDescription [as 别名]
# 或者: from reviewboard.changedescs.models.ChangeDescription import save [as 别名]
def test_get_change_not_modified(self):
"""Testing the GET review-requests/<id>/changes/<id>/ API with Not Modified response"""
review_request = self.create_review_request()
changedesc = ChangeDescription(public=True)
changedesc.save()
review_request.changedescs.add(changedesc)
self._testHttpCaching(get_change_item_url(changedesc), check_last_modified=True)
示例4: close
# 需要导入模块: from reviewboard.changedescs.models import ChangeDescription [as 别名]
# 或者: from reviewboard.changedescs.models.ChangeDescription import save [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()
示例5: close
# 需要导入模块: from reviewboard.changedescs.models import ChangeDescription [as 别名]
# 或者: from reviewboard.changedescs.models.ChangeDescription import save [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()
示例6: test_get_with_site_no_access
# 需要导入模块: from reviewboard.changedescs.models import ChangeDescription [as 别名]
# 或者: from reviewboard.changedescs.models.ChangeDescription import save [as 别名]
def test_get_with_site_no_access(self):
"""Testing the GET review-requests/<id>/changes/<id>/ API
without access to a local site
"""
review_request = self.create_review_request(publish=True,
with_local_site=True)
now = timezone.now()
change = ChangeDescription(public=True, timestamp=now)
change.record_field_change('summary', 'foo', 'bar')
change.save()
review_request.changedescs.add(change)
rsp = self.apiGet(
get_change_item_url(change, self.local_site_name),
expected_status=403)
self.assertEqual(rsp['stat'], 'fail')
self.assertEqual(rsp['err']['code'], PERMISSION_DENIED.code)
示例7: reopen
# 需要导入模块: from reviewboard.changedescs.models import ChangeDescription [as 别名]
# 或者: from reviewboard.changedescs.models.ChangeDescription import save [as 别名]
def reopen(self, user=None):
"""Reopens the review request for review."""
from reviewboard.reviews.models.review_request_draft import \
ReviewRequestDraft
if (user and not self.is_mutable_by(user) and
not user.has_perm("reviews.can_change_status", self.local_site)):
raise PermissionError
old_status = self.status
old_public = self.public
if old_status != self.PENDING_REVIEW:
# The reopening signal is only fired when actually making a status
# change since the main consumers (extensions) probably only care
# about changes.
review_request_reopening.send(sender=self.__class__,
user=user,
review_request=self)
changedesc = ChangeDescription(user=user or self.submitter)
status_field = get_review_request_field('status')(self)
status_field.record_change_entry(changedesc, old_status,
self.PENDING_REVIEW)
if old_status == self.DISCARDED:
# A draft is needed if reopening a discarded review request.
self.public = False
changedesc.save()
draft = ReviewRequestDraft.create(self)
draft.changedesc = changedesc
draft.save()
else:
changedesc.public = True
changedesc.save()
self.changedescs.add(changedesc)
self.status = self.PENDING_REVIEW
self.save(update_counts=True)
review_request_reopened.send(sender=self.__class__, user=user,
review_request=self,
old_status=old_status,
old_public=old_public)
示例8: test_get_changes
# 需要导入模块: from reviewboard.changedescs.models import ChangeDescription [as 别名]
# 或者: from reviewboard.changedescs.models.ChangeDescription import save [as 别名]
def test_get_changes(self):
"""Testing the GET review-requests/<id>/changes/ API"""
review_request = self.create_review_request(publish=True)
now = timezone.now()
change1 = ChangeDescription(public=True, timestamp=now)
change1.record_field_change("summary", "foo", "bar")
change1.save()
review_request.changedescs.add(change1)
change2 = ChangeDescription(public=True, timestamp=now + timedelta(seconds=1))
change2.record_field_change("description", "foo", "bar")
change2.save()
review_request.changedescs.add(change2)
rsp = self.apiGet(get_change_list_url(review_request), expected_mimetype=change_list_mimetype)
self.assertEqual(rsp["stat"], "ok")
self.assertEqual(len(rsp["changes"]), 2)
self.assertEqual(rsp["changes"][0]["id"], change2.pk)
self.assertEqual(rsp["changes"][1]["id"], change1.pk)
示例9: create
# 需要导入模块: from reviewboard.changedescs.models import ChangeDescription [as 别名]
# 或者: from reviewboard.changedescs.models.ChangeDescription import save [as 别名]
def create(review_request):
"""
Creates a draft based on a review request.
This will copy over all the details of the review request that
we care about. If a draft already exists for the review request,
the draft will be returned.
"""
draft, draft_is_new = \
ReviewRequestDraft.objects.get_or_create(
review_request=review_request,
defaults={
'summary': review_request.summary,
'description': review_request.description,
'testing_done': review_request.testing_done,
'bugs_closed': review_request.bugs_closed,
'branch': review_request.branch,
})
if draft.changedesc is None and review_request.public:
changedesc = ChangeDescription()
changedesc.save()
draft.changedesc = changedesc
if draft_is_new:
map(draft.target_groups.add, review_request.target_groups.all())
map(draft.target_people.add, review_request.target_people.all())
for screenshot in review_request.screenshots.all():
screenshot.draft_caption = screenshot.caption
screenshot.save()
draft.screenshots.add(screenshot)
for screenshot in review_request.inactive_screenshots.all():
screenshot.draft_caption = screenshot.caption
screenshot.save()
draft.inactive_screenshots.add(screenshot)
draft.save();
return draft
示例10: save_autolandrequest_id
# 需要导入模块: from reviewboard.changedescs.models import ChangeDescription [as 别名]
# 或者: from reviewboard.changedescs.models.ChangeDescription import save [as 别名]
def save_autolandrequest_id(self, fieldname, rr, autoland_request_id):
# TODO: this method is only required while we are using change
# descriptions to render autoland results. Once Bug 1176330 is
# fixed this code can be removed.
# There's possibly a race condition here with multiple web-heads. If
# two requests come in at the same time to this endpoint, the request
# that saves their value first here will get overwritten by the second
# but the first request will have their changedescription come below
# the second. In that case you'd have the "most recent" try build stats
# appearing at the top be for a changedescription that has a different
# try build below it (Super rare, not a big deal really).
old_request_id = rr.extra_data.get(fieldname, None)
rr.extra_data[fieldname] = autoland_request_id
rr.save()
# In order to display the fact that a build was kicked off in the UI,
# we construct a change description that our TryField can render.
changedesc = ChangeDescription(public=True, text="", rich_text=False)
changedesc.record_field_change(fieldname, old_request_id, autoland_request_id)
changedesc.save()
rr.changedescs.add(changedesc)
示例11: test_determine_user_for_review_request
# 需要导入模块: from reviewboard.changedescs.models import ChangeDescription [as 别名]
# 或者: from reviewboard.changedescs.models.ChangeDescription import save [as 别名]
def test_determine_user_for_review_request(self):
"""Testing ChangeDescription.get_user for change descriptions for
review requests
"""
review_request = self.create_review_request(publish=True)
doc = review_request.submitter
grumpy = User.objects.get(username='grumpy')
change1 = ChangeDescription()
change1.record_field_change('foo', ['bar'], ['baz'])
change1.save()
review_request.changedescs.add(change1)
change2 = ChangeDescription()
change2.record_field_change('submitter', doc, grumpy, 'username')
change2.save()
review_request.changedescs.add(change2)
change3 = ChangeDescription()
change3.record_field_change('foo', ['bar'], ['baz'])
change3.save()
review_request.changedescs.add(change3)
change4 = ChangeDescription()
change4.record_field_change('submitter', grumpy, doc, 'username')
change4.save()
review_request.changedescs.add(change4)
self.assertIsNone(change1.user)
self.assertIsNone(change2.user)
self.assertIsNone(change3.user)
self.assertIsNone(change4.user)
self.assertEqual(change1.get_user(review_request), doc)
self.assertEqual(change2.get_user(review_request), doc)
self.assertEqual(change3.get_user(review_request), grumpy)
self.assertEqual(change4.get_user(review_request), grumpy)
self.assertEqual(change1.user, doc)
self.assertEqual(change2.user, doc)
self.assertEqual(change3.user, grumpy)
self.assertEqual(change4.user, grumpy)
示例12: ReviewRequestDraft
# 需要导入模块: from reviewboard.changedescs.models import ChangeDescription [as 别名]
# 或者: from reviewboard.changedescs.models.ChangeDescription import save [as 别名]
class ReviewRequestDraft(models.Model):
"""
A draft of a review request.
When a review request is being modified, a special draft copy of it is
created containing all the details of the review request. This copy can
be modified and eventually saved or discarded. When saved, the new
details are copied back over to the originating ReviewRequest.
"""
review_request = models.ForeignKey(ReviewRequest,
related_name="draft",
verbose_name=_("review request"),
unique=True)
last_updated = ModificationTimestampField(_("last updated"))
summary = models.CharField(_("summary"), max_length=300)
description = models.TextField(_("description"))
testing_done = models.TextField(_("testing done"))
bugs_closed = models.CommaSeparatedIntegerField(_("bugs"),
max_length=300, blank=True)
diffset = models.ForeignKey(DiffSet, verbose_name=_('diff set'),
blank=True, null=True,
related_name='review_request_draft')
changedesc = models.ForeignKey(ChangeDescription,
verbose_name=_('change description'),
blank=True, null=True)
branch = models.CharField(_("branch"), max_length=300, blank=True)
target_groups = models.ManyToManyField(Group,
related_name="drafts",
verbose_name=_("target groups"),
blank=True)
target_people = models.ManyToManyField(User,
verbose_name=_("target people"),
related_name="directed_drafts",
blank=True)
screenshots = models.ManyToManyField(Screenshot,
related_name="drafts",
verbose_name=_("screenshots"),
blank=True)
inactive_screenshots = models.ManyToManyField(Screenshot,
verbose_name=_("inactive screenshots"),
related_name="inactive_drafts",
blank=True)
submitter = property(lambda self: self.review_request.submitter)
# Set this up with a ConcurrencyManager to help prevent race conditions.
objects = ConcurrencyManager()
def get_bug_list(self):
"""
Returns a sorted list of bugs associated with this review request.
"""
if self.bugs_closed == "":
return []
bugs = re.split(r"[, ]+", self.bugs_closed)
# First try a numeric sort, to show the best results for the majority
# case of bug trackers with numeric IDs. If that fails, sort
# alphabetically.
try:
bugs.sort(cmp=lambda x,y: cmp(int(x), int(y)))
except ValueError:
bugs.sort()
return bugs
def __unicode__(self):
return self.summary
def save(self, **kwargs):
self.bugs_closed = self.bugs_closed.strip()
self.summary = truncate(self.summary, MAX_SUMMARY_LENGTH)
super(ReviewRequestDraft, self).save()
@staticmethod
def create(review_request):
"""
Creates a draft based on a review request.
This will copy over all the details of the review request that
we care about. If a draft already exists for the review request,
the draft will be returned.
"""
draft, draft_is_new = \
ReviewRequestDraft.objects.get_or_create(
review_request=review_request,
defaults={
'summary': review_request.summary,
'description': review_request.description,
'testing_done': review_request.testing_done,
'bugs_closed': review_request.bugs_closed,
'branch': review_request.branch,
})
if draft.changedesc is None and review_request.public:
changedesc = ChangeDescription()
changedesc.save()
draft.changedesc = changedesc
#.........这里部分代码省略.........
示例13: ReviewRequestDraft
# 需要导入模块: from reviewboard.changedescs.models import ChangeDescription [as 别名]
# 或者: from reviewboard.changedescs.models.ChangeDescription import save [as 别名]
class ReviewRequestDraft(BaseReviewRequestDetails):
"""A draft of a review request.
When a review request is being modified, a special draft copy of it is
created containing all the details of the review request. This copy can
be modified and eventually saved or discarded. When saved, the new
details are copied back over to the originating ReviewRequest.
"""
summary = models.CharField(
_("summary"),
max_length=BaseReviewRequestDetails.MAX_SUMMARY_LENGTH)
owner = models.ForeignKey(
User,
verbose_name=_('owner'),
null=True,
related_name='draft')
review_request = models.ForeignKey(
ReviewRequest,
related_name="draft",
verbose_name=_("review request"),
unique=True)
last_updated = ModificationTimestampField(
_("last updated"))
diffset = models.ForeignKey(
DiffSet,
verbose_name=_('diff set'),
blank=True,
null=True,
related_name='review_request_draft')
changedesc = models.ForeignKey(
ChangeDescription,
verbose_name=_('change description'),
blank=True,
null=True)
target_groups = models.ManyToManyField(
Group,
related_name="drafts",
verbose_name=_("target groups"),
blank=True)
target_people = models.ManyToManyField(
User,
verbose_name=_("target people"),
related_name="directed_drafts",
blank=True)
screenshots = models.ManyToManyField(
Screenshot,
related_name="drafts",
verbose_name=_("screenshots"),
blank=True)
inactive_screenshots = models.ManyToManyField(
Screenshot,
verbose_name=_("inactive screenshots"),
related_name="inactive_drafts",
blank=True)
file_attachments = models.ManyToManyField(
FileAttachment,
related_name="drafts",
verbose_name=_("file attachments"),
blank=True)
inactive_file_attachments = models.ManyToManyField(
FileAttachment,
verbose_name=_("inactive files"),
related_name="inactive_drafts",
blank=True)
submitter = property(lambda self: self.owner or
self.review_request.owner)
repository = property(lambda self: self.review_request.repository)
local_site = property(lambda self: self.review_request.local_site)
depends_on = models.ManyToManyField('ReviewRequest',
blank=True, null=True,
verbose_name=_('Dependencies'),
related_name='draft_blocks')
screenshots_count = RelationCounterField(
'screenshots',
verbose_name=_('screenshots count'))
inactive_screenshots_count = RelationCounterField(
'inactive_screenshots',
verbose_name=_('inactive screenshots count'))
file_attachments_count = RelationCounterField(
'file_attachments',
verbose_name=_('file attachments count'))
inactive_file_attachments_count = RelationCounterField(
'inactive_file_attachments',
verbose_name=_('inactive file attachments count'))
# Set this up with a ConcurrencyManager to help prevent race conditions.
objects = ConcurrencyManager()
commit = property(lambda self: self.commit_id,
lambda self, value: setattr(self, 'commit_id', value))
def get_latest_diffset(self):
#.........这里部分代码省略.........
示例14: close
# 需要导入模块: from reviewboard.changedescs.models import ChangeDescription [as 别名]
# 或者: from reviewboard.changedescs.models.ChangeDescription import save [as 别名]
def close(self, close_type=None, user=None, description=None,
rich_text=False, **kwargs):
"""Closes the review request.
Args:
close_type (unicode):
How the close occurs. This should be one of
:py:attr:`SUBMITTED` or :py:attr:`DISCARDED`.
user (django.contrib.auth.models.User):
The user who is closing the review request.
description (unicode):
An optional description that indicates why the review request
was closed.
rich_text (bool):
Indicates whether or not that the description is rich text.
Raises:
ValueError:
The provided close type is not a valid value.
PermissionError:
The user does not have permission to close the review request.
TypeError:
Keyword arguments were supplied to the function.
.. 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
#.........这里部分代码省略.........
示例15: ReviewRequestDraft
# 需要导入模块: from reviewboard.changedescs.models import ChangeDescription [as 别名]
# 或者: from reviewboard.changedescs.models.ChangeDescription import save [as 别名]
class ReviewRequestDraft(BaseReviewRequestDetails):
"""A draft of a review request.
When a review request is being modified, a special draft copy of it is
created containing all the details of the review request. This copy can
be modified and eventually saved or discarded. When saved, the new
details are copied back over to the originating ReviewRequest.
"""
summary = models.CharField(
_("summary"),
max_length=BaseReviewRequestDetails.MAX_SUMMARY_LENGTH)
review_request = models.ForeignKey(
ReviewRequest,
related_name="draft",
verbose_name=_("review request"),
unique=True)
last_updated = ModificationTimestampField(
_("last updated"))
diffset = models.ForeignKey(
DiffSet,
verbose_name=_('diff set'),
blank=True,
null=True,
related_name='review_request_draft')
changedesc = models.ForeignKey(
ChangeDescription,
verbose_name=_('change description'),
blank=True,
null=True)
target_groups = models.ManyToManyField(
Group,
related_name="drafts",
verbose_name=_("target groups"),
blank=True)
target_people = models.ManyToManyField(
User,
verbose_name=_("target people"),
related_name="directed_drafts",
blank=True)
screenshots = models.ManyToManyField(
Screenshot,
related_name="drafts",
verbose_name=_("screenshots"),
blank=True)
inactive_screenshots = models.ManyToManyField(
Screenshot,
verbose_name=_("inactive screenshots"),
related_name="inactive_drafts",
blank=True)
file_attachments = models.ManyToManyField(
FileAttachment,
related_name="drafts",
verbose_name=_("file attachments"),
blank=True)
inactive_file_attachments = models.ManyToManyField(
FileAttachment,
verbose_name=_("inactive files"),
related_name="inactive_drafts",
blank=True)
submitter = property(lambda self: self.review_request.submitter)
repository = property(lambda self: self.review_request.repository)
local_site = property(lambda self: self.review_request.local_site)
depends_on = models.ManyToManyField('ReviewRequest',
blank=True, null=True,
verbose_name=_('Dependencies'),
related_name='draft_blocks')
# Set this up with a ConcurrencyManager to help prevent race conditions.
objects = ConcurrencyManager()
commit = property(lambda self: self.commit_id,
lambda self, value: setattr(self, 'commit_id', value))
def get_latest_diffset(self):
"""Returns the diffset for this draft."""
return self.diffset
def is_accessible_by(self, user):
"""Returns whether or not the user can access this draft."""
return self.is_mutable_by(user)
def is_mutable_by(self, user):
"""Returns whether or not the user can modify this draft."""
return self.review_request.is_mutable_by(user)
@staticmethod
def create(review_request):
"""Creates a draft based on a review request.
This will copy over all the details of the review request that
we care about. If a draft already exists for the review request,
the draft will be returned.
"""
draft, draft_is_new = \
ReviewRequestDraft.objects.get_or_create(
review_request=review_request,
#.........这里部分代码省略.........