Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

undo changes to adding a reply to the gui #295

Merged
merged 1 commit into from
Apr 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions securedrop_client/gui/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from typing import List
from uuid import uuid4

from securedrop_client.db import Source, Message, File, Reply
from securedrop_client.db import Source, Message, File
from securedrop_client.logic import Client
from securedrop_client.resources import load_svg, load_image
from securedrop_client.utils import humanize_filesize
Expand Down Expand Up @@ -807,7 +807,12 @@ def update_conversation(self, collection: list) -> None:
if conversation_item.filename.endswith('msg.gpg'):
self.add_message(conversation_item)
elif conversation_item.filename.endswith('reply.gpg'):
self.add_reply(conversation_item)
self.controller.session.refresh(conversation_item)
if conversation_item.content is not None:
content = conversation_item.content
else:
content = '<Message not yet available>'
self.add_reply(conversation_item.uuid, content)
else:
self.add_file(self.source, conversation_item)

Expand Down Expand Up @@ -843,18 +848,12 @@ def add_message(self, message: Message) -> None:
self.conversation_layout.addWidget(
MessageWidget(message.uuid, content, self.controller.message_sync.message_ready))

def add_reply(self, reply: Reply) -> None:
def add_reply(self, uuid: str, content: str) -> None:
"""
Add a reply from a journalist.
"""
self.controller.session.refresh(reply)
if reply.content is not None:
content = reply.content
else:
content = '<Reply not yet available>'

self.conversation_layout.addWidget(
ReplyWidget(reply.uuid,
ReplyWidget(uuid,
content,
self.controller.reply_sync.reply_ready,
self.controller.reply_succeeded,
Expand Down
4 changes: 2 additions & 2 deletions tests/gui/test_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -976,7 +976,7 @@ def test_ConversationView_add_reply(mocker, homedir, session, source):
mock_reply_widget = mocker.patch('securedrop_client.gui.widgets.ReplyWidget',
return_value=mock_reply_widget_res)

cv.add_reply(reply)
cv.add_reply(reply.uuid, content)

# check that we built the widget was called with the correct args
mock_reply_widget.assert_called_once_with(
Expand Down Expand Up @@ -1019,7 +1019,7 @@ def test_ConversationView_add_reply_no_content(mocker, homedir, session, source)
mock_reply_widget = mocker.patch('securedrop_client.gui.widgets.ReplyWidget',
return_value=mock_reply_widget_res)

cv.add_reply(reply)
cv.add_reply(reply.uuid, '<Reply not yet available>')

# check that we built the widget was called with the correct args
mock_reply_widget.assert_called_once_with(
Expand Down