本文整理汇总了Python中reviewboard.reviews.models.BaseComment.issue_status_to_string方法的典型用法代码示例。如果您正苦于以下问题:Python BaseComment.issue_status_to_string方法的具体用法?Python BaseComment.issue_status_to_string怎么用?Python BaseComment.issue_status_to_string使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类reviewboard.reviews.models.BaseComment
的用法示例。
在下文中一共展示了BaseComment.issue_status_to_string方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: file_attachment_comments
# 需要导入模块: from reviewboard.reviews.models import BaseComment [as 别名]
# 或者: from reviewboard.reviews.models.BaseComment import issue_status_to_string [as 别名]
def file_attachment_comments(context, file_attachment):
"""Returns a JSON array of current comments for a file attachment."""
comments = []
user = context.get("user", None)
for comment in file_attachment.get_comments():
review = comment.get_review()
if review and (review.public or review.user == user):
comments.append(
{
"comment_id": comment.id,
"text": normalize_text_for_edit(user, comment.text, comment.rich_text),
"rich_text": comment.rich_text,
"user": {
"username": escape(review.user.username),
"name": escape(review.user.get_full_name() or review.user.username),
},
"url": comment.get_review_url(),
"localdraft": review.user == user and not review.public,
"review_id": review.id,
"issue_opened": comment.issue_opened,
"issue_status": escape(BaseComment.issue_status_to_string(comment.issue_status)),
}
)
return json.dumps(comments)
示例2: file_attachment_comments
# 需要导入模块: from reviewboard.reviews.models import BaseComment [as 别名]
# 或者: from reviewboard.reviews.models.BaseComment import issue_status_to_string [as 别名]
def file_attachment_comments(context, file_attachment):
"""Returns a JSON array of current comments for a file attachment."""
comments = []
user = context.get('user', None)
for comment in file_attachment.get_comments():
review = comment.get_review()
if review and (review.public or review.user == user):
comments.append({
'comment_id': comment.id,
'text': escape(comment.text),
'user': {
'username': review.user.username,
'name': (review.user.get_full_name() or
review.user.username),
},
'url': comment.get_review_url(),
'localdraft': review.user == user and not review.public,
'review_id': review.id,
'issue_opened': comment.issue_opened,
'issue_status': BaseComment.issue_status_to_string(
comment.issue_status),
})
return json.dumps(comments)
示例3: screenshotcommentcounts
# 需要导入模块: from reviewboard.reviews.models import BaseComment [as 别名]
# 或者: from reviewboard.reviews.models.BaseComment import issue_status_to_string [as 别名]
def screenshotcommentcounts(context, screenshot):
"""
Returns a JSON array of current comments for a screenshot.
Each entry in the array has a dictionary containing the following keys:
================== ====================================================
Key Description
================== ====================================================
text The text of the comment
localdraft True if this is the current user's draft comment
x The X location of the comment's region
y The Y location of the comment's region
w The width of the comment's region
h The height of the comment's region
review_id The ID of the review this comment is associated with
review_request_id The ID of the review request this comment is
associated with
================== ====================================================
"""
comments = {}
user = context.get("user", None)
for comment in screenshot.comments.all():
review = get_object_or_none(comment.review)
if review and (review.public or review.user == user):
position = "%dx%d+%d+%d" % (comment.w, comment.h, comment.x, comment.y)
comments.setdefault(position, []).append(
{
"comment_id": comment.id,
"text": comment.text,
"user": {
"username": review.user.username,
"name": review.user.get_full_name() or review.user.username,
},
"url": comment.get_review_url(),
"localdraft": review.user == user and not review.public,
"x": comment.x,
"y": comment.y,
"w": comment.w,
"h": comment.h,
"review_id": review.id,
"review_request_id": review.review_request.id,
"issue_opened": comment.issue_opened,
"issue_status": BaseComment.issue_status_to_string(comment.issue_status),
}
)
return simplejson.dumps(comments)
示例4: screenshotcommentcounts
# 需要导入模块: from reviewboard.reviews.models import BaseComment [as 别名]
# 或者: from reviewboard.reviews.models.BaseComment import issue_status_to_string [as 别名]
def screenshotcommentcounts(context, screenshot):
"""
Returns a JSON array of current comments for a screenshot.
Each entry in the array has a dictionary containing the following keys:
================== ====================================================
Key Description
================== ====================================================
text The text of the comment
localdraft True if this is the current user's draft comment
x The X location of the comment's region
y The Y location of the comment's region
w The width of the comment's region
h The height of the comment's region
review_id The ID of the review this comment is associated with
================== ====================================================
"""
comments = {}
user = context.get('user', None)
for comment in screenshot.get_comments():
review = comment.get_review()
if review and (review.public or review.user == user):
position = '%dx%d+%d+%d' % (comment.w, comment.h,
comment.x, comment.y)
comments.setdefault(position, []).append({
'comment_id': comment.id,
'text': escape(comment.text),
'user': {
'username': review.user.username,
'name': (review.user.get_full_name() or
review.user.username),
},
'url': comment.get_review_url(),
'localdraft': review.user == user and not review.public,
'x': comment.x,
'y': comment.y,
'w': comment.w,
'h': comment.h,
'review_id': review.id,
'issue_opened': comment.issue_opened,
'issue_status': BaseComment.issue_status_to_string(
comment.issue_status),
})
return simplejson.dumps(comments)
示例5: comment_issue
# 需要导入模块: from reviewboard.reviews.models import BaseComment [as 别名]
# 或者: from reviewboard.reviews.models.BaseComment import issue_status_to_string [as 别名]
def comment_issue(context, review_request, comment, comment_type):
"""
Renders the code responsible for handling comment issue statuses.
"""
issue_status = BaseComment.issue_status_to_string(comment.issue_status)
user = context.get('user', None)
return {
'comment': comment,
'comment_type': comment_type,
'issue_status': issue_status,
'review': comment.get_review(),
'interactive': comment.can_change_issue_status(user),
}
示例6: comment_issue
# 需要导入模块: from reviewboard.reviews.models import BaseComment [as 别名]
# 或者: from reviewboard.reviews.models.BaseComment import issue_status_to_string [as 别名]
def comment_issue(context, review_request, comment, comment_type):
"""
Renders the code responsible for handling comment issue statuses.
"""
issue_status = BaseComment.issue_status_to_string(comment.issue_status)
user = context.get("user", None)
interactive = "false"
if user and user.is_authenticated() and user == review_request.submitter:
interactive = "true"
return {
"comment": comment,
"comment_type": comment_type,
"issue_status": issue_status,
"review": comment.review.get(),
"interactive": interactive,
}
示例7: comment_issue
# 需要导入模块: from reviewboard.reviews.models import BaseComment [as 别名]
# 或者: from reviewboard.reviews.models.BaseComment import issue_status_to_string [as 别名]
def comment_issue(context, review_request, comment, comment_type):
"""
Renders the code responsible for handling comment issue statuses.
"""
issue_status = BaseComment.issue_status_to_string(comment.issue_status)
user = context.get('user', None)
interactive = 'false'
if user and user.is_authenticated() and \
user == review_request.submitter:
interactive = 'true'
return {
'comment': comment,
'comment_type': comment_type,
'issue_status': issue_status,
'review': comment.get_review(),
'interactive': interactive,
}
示例8: pretty_print_issue_status
# 需要导入模块: from reviewboard.reviews.models import BaseComment [as 别名]
# 或者: from reviewboard.reviews.models.BaseComment import issue_status_to_string [as 别名]
def pretty_print_issue_status(status):
"""Turns an issue status code into a human-readable status string."""
return BaseComment.issue_status_to_string(status)
示例9: serialize_issue_status_field
# 需要导入模块: from reviewboard.reviews.models import BaseComment [as 别名]
# 或者: from reviewboard.reviews.models.BaseComment import issue_status_to_string [as 别名]
def serialize_issue_status_field(self, obj, **kwargs):
return BaseComment.issue_status_to_string(obj.issue_status)
示例10: comment_counts
# 需要导入模块: from reviewboard.reviews.models import BaseComment [as 别名]
# 或者: from reviewboard.reviews.models.BaseComment import issue_status_to_string [as 别名]
def comment_counts(user, all_comments, filediff, interfilediff=None):
"""
Returns an array of current comments for a filediff, sorted by line number.
Each entry in the array has a dictionary containing the following keys:
=========== ==================================================
Key Description
=========== ==================================================
comment_id The ID of the comment
text The plain or rich text of the comment
rich_text The rich text flag for the comment
line The first line number
num_lines The number of lines this comment spans
user A dictionary containing "username" and "name" keys
for the user
url The URL to the comment
localdraft True if this is the current user's draft comment
review_id The ID of the review this comment is associated with
==============================================================
"""
comment_dict = {}
if interfilediff:
key = (filediff.pk, interfilediff.pk)
else:
key = (filediff.pk, None)
comments = all_comments.get(key, [])
for comment in comments:
review = comment.get_review()
if review and (review.public or review.user == user):
key = (comment.first_line, comment.num_lines)
comment_dict.setdefault(key, []).append({
'comment_id': comment.id,
'text': normalize_text_for_edit(user, comment.text,
comment.rich_text),
'html': markdown_render_conditional(comment.text,
comment.rich_text),
'rich_text': comment.rich_text,
'line': comment.first_line,
'num_lines': comment.num_lines,
'user': {
'username': review.user.username,
'name': (review.user.get_full_name() or
review.user.username),
},
'url': comment.get_review_url(),
'localdraft': (review.user == user and
not review.public),
'review_id': review.id,
'issue_opened': comment.issue_opened,
'issue_status': BaseComment.issue_status_to_string(
comment.issue_status),
'reply_to_id': comment.reply_to_id,
})
comments_array = []
for key, value in six.iteritems(comment_dict):
comments_array.append({
'linenum': key[0],
'num_lines': key[1],
'comments': value,
})
comments_array.sort(
cmp=lambda x, y: (cmp(x['linenum'], y['linenum'] or
cmp(x['num_lines'], y['num_lines']))))
return comments_array
示例11: review_detail
# 需要导入模块: from reviewboard.reviews.models import BaseComment [as 别名]
# 或者: from reviewboard.reviews.models.BaseComment import issue_status_to_string [as 别名]
#.........这里部分代码省略.........
bug_url = review_request.repository.bug_tracker
for field in info:
for i, buginfo in enumerate(info[field]):
try:
full_bug_url = bug_url % buginfo[0]
info[field][i] = (buginfo[0], full_bug_url)
except TypeError:
logging.warning("Invalid bugtracker url format")
elif 'old' in info or 'new' in info:
change_type = 'changed'
multiline = (name == "description" or name == "testing_done")
# Branch text is allowed to have entities, so mark it safe.
if name == "branch":
if 'old' in info:
info['old'][0] = mark_safe(info['old'][0])
if 'new' in info:
info['new'][0] = mark_safe(info['new'][0])
# Make status human readable.
if name == 'status':
if 'old' in info:
info['old'][0] = status_to_string(info['old'][0])
if 'new' in info:
info['new'][0] = status_to_string(info['new'][0])
elif name == "screenshot_captions":
change_type = 'screenshot_captions'
elif name == "file_captions":
change_type = 'file_captions'
else:
# No clue what this is. Bail.
continue
fields_changed.append({
'title': fields_changed_name_map.get(name, name),
'multiline': multiline,
'info': info,
'type': change_type,
})
# Expand the latest review change
state = ''
# Mark as collapsed if the change is older than a newer change
if latest_timestamp and changedesc.timestamp < latest_timestamp:
state = 'collapsed'
entries.append({
'changeinfo': fields_changed,
'changedesc': changedesc,
'timestamp': changedesc.timestamp,
'class': state,
})
entries.sort(key=lambda item: item['timestamp'])
close_description = ''
if latest_changedesc and 'status' in latest_changedesc.fields_changed:
status = latest_changedesc.fields_changed['status']['new'][0]
if status in (ReviewRequest.DISCARDED, ReviewRequest.SUBMITTED):
close_description = latest_changedesc.text
issues = {
'total': 0,
'open': 0,
'resolved': 0,
'dropped': 0
}
for entry in entries:
if 'review' in entry:
for comment in entry['review'].get_all_comments(issue_opened=True):
issues['total'] += 1
issues[BaseComment.issue_status_to_string(
comment.issue_status)] += 1
response = render_to_response(
template_name,
RequestContext(request, _make_review_request_context(review_request, {
'draft': draft,
'detail_hooks': ReviewRequestDetailHook.hooks,
'review_request_details': draft or review_request,
'entries': entries,
'last_activity_time': last_activity_time,
'review': review,
'request': request,
'latest_changedesc': latest_changedesc,
'close_description': close_description,
'PRE_CREATION': PRE_CREATION,
'issues': issues,
})))
set_etag(response, etag)
return response
示例12: commentcounts
# 需要导入模块: from reviewboard.reviews.models import BaseComment [as 别名]
# 或者: from reviewboard.reviews.models.BaseComment import issue_status_to_string [as 别名]
def commentcounts(context, filediff, interfilediff=None):
"""
Returns a JSON array of current comments for a filediff, sorted by
line number.
Each entry in the array has a dictionary containing the following keys:
=========== ==================================================
Key Description
=========== ==================================================
comment_id The ID of the comment
text The text of the comment
line The first line number
num_lines The number of lines this comment spans
user A dictionary containing "username" and "name" keys
for the user
url The URL to the comment
localdraft True if this is the current user's draft comment
review_id The ID of the review this comment is associated with
==============================================================
"""
comment_dict = {}
user = context.get("user", None)
if interfilediff:
query = Comment.objects.filter(filediff=filediff, interfilediff=interfilediff)
else:
query = Comment.objects.filter(filediff=filediff, interfilediff__isnull=True)
for comment in query:
review = get_object_or_none(comment.review)
if review and (review.public or review.user == user):
key = (comment.first_line, comment.num_lines)
comment_dict.setdefault(key, []).append(
{
"comment_id": comment.id,
"text": comment.text,
"line": comment.first_line,
"num_lines": comment.num_lines,
"user": {
"username": review.user.username,
"name": review.user.get_full_name() or review.user.username,
},
#'timestamp': comment.timestamp,
"url": comment.get_review_url(),
"localdraft": review.user == user and not review.public,
"review_id": review.id,
"review_request_id": review.review_request.id,
"issue_opened": comment.issue_opened,
"issue_status": BaseComment.issue_status_to_string(comment.issue_status),
}
)
comments_array = []
for key, value in comment_dict.iteritems():
comments_array.append({"linenum": key[0], "num_lines": key[1], "comments": value})
comments_array.sort(cmp=lambda x, y: cmp(x["linenum"], y["linenum"] or cmp(x["num_lines"], y["num_lines"])))
return simplejson.dumps(comments_array)