Be more careful with null accounts
Extend the checks for null/empty account names to message authors and the change screen. Change-Id: Ia71d5dc8ce098c8d6dd60928ad2348a2eff98264
This commit is contained in:
parent
aedec159c7
commit
2e991f2d92
25
gertty/db.py
25
gertty/db.py
@ -266,6 +266,19 @@ class Change(object):
|
|||||||
session.flush()
|
session.flush()
|
||||||
return l
|
return l
|
||||||
|
|
||||||
|
@property
|
||||||
|
def owner_name(self):
|
||||||
|
owner_name = 'Anonymous Coward'
|
||||||
|
if self.owner:
|
||||||
|
if self.owner.name:
|
||||||
|
owner_name = self.owner.name
|
||||||
|
elif self.owner.username:
|
||||||
|
owner_name = self.owner.username
|
||||||
|
elif self.owner.email:
|
||||||
|
owner_name = self.owner.email
|
||||||
|
return owner_name
|
||||||
|
|
||||||
|
|
||||||
class Revision(object):
|
class Revision(object):
|
||||||
def __init__(self, change, number, message, commit, parent,
|
def __init__(self, change, number, message, commit, parent,
|
||||||
fetch_auth, fetch_ref, pending_message=False):
|
fetch_auth, fetch_ref, pending_message=False):
|
||||||
@ -328,6 +341,18 @@ class Message(object):
|
|||||||
self.draft = draft
|
self.draft = draft
|
||||||
self.pending = pending
|
self.pending = pending
|
||||||
|
|
||||||
|
@property
|
||||||
|
def author_name(self):
|
||||||
|
author_name = 'Anonymous Coward'
|
||||||
|
if self.author:
|
||||||
|
if self.author.name:
|
||||||
|
author_name = self.author.name
|
||||||
|
elif self.author.username:
|
||||||
|
author_name = self.author.username
|
||||||
|
elif self.author.email:
|
||||||
|
author_name = self.author.email
|
||||||
|
return author_name
|
||||||
|
|
||||||
class Comment(object):
|
class Comment(object):
|
||||||
def __init__(self, revision, id, author, in_reply_to, created, file, parent, line, message, draft=False):
|
def __init__(self, revision, id, author, in_reply_to, created, file, parent, line, message, draft=False):
|
||||||
self.revision_key = revision.key
|
self.revision_key = revision.key
|
||||||
|
@ -327,7 +327,7 @@ class ChangeMessageBox(mywid.HyperText):
|
|||||||
if message.draft:
|
if message.draft:
|
||||||
lines.insert(0, '')
|
lines.insert(0, '')
|
||||||
lines.insert(0, 'Patch Set %s:' % (message.revision.number,))
|
lines.insert(0, 'Patch Set %s:' % (message.revision.number,))
|
||||||
text = [('change-message-name', message.author.name),
|
text = [('change-message-name', message.author_name),
|
||||||
('change-message-header', ': '+lines.pop(0)),
|
('change-message-header', ': '+lines.pop(0)),
|
||||||
('change-message-header',
|
('change-message-header',
|
||||||
message.created.strftime(' (%Y-%m-%d %H:%M:%S%z)'))]
|
message.created.strftime(' (%Y-%m-%d %H:%M:%S%z)'))]
|
||||||
@ -501,7 +501,7 @@ class ChangeView(urwid.WidgetWrap):
|
|||||||
self.change_rest_id = change.id
|
self.change_rest_id = change.id
|
||||||
|
|
||||||
self.change_id_label.set_text(('change-data', change.change_id))
|
self.change_id_label.set_text(('change-data', change.change_id))
|
||||||
self.owner_label.set_text(('change-data', change.owner.name))
|
self.owner_label.set_text(('change-data', change.owner_name))
|
||||||
self.project_label.set_text(('change-data', change.project.name))
|
self.project_label.set_text(('change-data', change.project.name))
|
||||||
self.branch_label.set_text(('change-data', change.branch))
|
self.branch_label.set_text(('change-data', change.branch))
|
||||||
self.topic_label.set_text(('change-data', self.topic))
|
self.topic_label.set_text(('change-data', self.topic))
|
||||||
@ -588,7 +588,8 @@ class ChangeView(urwid.WidgetWrap):
|
|||||||
display_messages = []
|
display_messages = []
|
||||||
result_systems = {}
|
result_systems = {}
|
||||||
for message in change.messages:
|
for message in change.messages:
|
||||||
if message.revision == change.revisions[-1]:
|
if (message.revision == change.revisions[-1] and
|
||||||
|
message.author and message.author.name):
|
||||||
for commentlink in self.app.config.commentlinks:
|
for commentlink in self.app.config.commentlinks:
|
||||||
results = commentlink.getTestResults(self.app, message.message)
|
results = commentlink.getTestResults(self.app, message.message)
|
||||||
if results:
|
if results:
|
||||||
@ -596,7 +597,7 @@ class ChangeView(urwid.WidgetWrap):
|
|||||||
result_systems[message.author.name] = result_system
|
result_systems[message.author.name] = result_system
|
||||||
result_system.update(results)
|
result_system.update(results)
|
||||||
skip = False
|
skip = False
|
||||||
if self.hide_comments:
|
if self.hide_comments and message.author and message.author.name:
|
||||||
for regex in self.app.config.hide_comments:
|
for regex in self.app.config.hide_comments:
|
||||||
if regex.match(message.author.name):
|
if regex.match(message.author.name):
|
||||||
skip = True
|
skip = True
|
||||||
|
@ -57,15 +57,7 @@ class ChangeRow(urwid.Button):
|
|||||||
self.subject.set_text(change.subject)
|
self.subject.set_text(change.subject)
|
||||||
self.number.set_text(str(change.number))
|
self.number.set_text(str(change.number))
|
||||||
self.project.set_text(change.project.name.split('/')[-1])
|
self.project.set_text(change.project.name.split('/')[-1])
|
||||||
owner_name = 'Anonymous Coward'
|
self.owner.set_text(change.owner_name)
|
||||||
if change.owner:
|
|
||||||
if change.owner.name:
|
|
||||||
owner_name = change.owner.name
|
|
||||||
elif change.owner.username:
|
|
||||||
owner_name = change.owner.username
|
|
||||||
elif change.owner.email:
|
|
||||||
owner_name = change.owner.email
|
|
||||||
self.owner.set_text(owner_name)
|
|
||||||
del self.columns.contents[self.num_columns:]
|
del self.columns.contents[self.num_columns:]
|
||||||
for category in categories:
|
for category in categories:
|
||||||
v = change.getMaxForCategory(category)
|
v = change.getMaxForCategory(category)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user