Added fault tolerance to wall coments and reposts
This commit is contained in:
parent
cf0e001cfc
commit
926db6007a
@ -340,19 +340,34 @@ class Controller(object):
|
|||||||
buffer.get_items()
|
buffer.get_items()
|
||||||
|
|
||||||
def post_failed(self, parent_endpoint, child_endpoint, from_buffer=None, attachments_list=[], post_arguments={}):
|
def post_failed(self, parent_endpoint, child_endpoint, from_buffer=None, attachments_list=[], post_arguments={}):
|
||||||
""" Function to be called when the post (using the pubsub method) will fail. It takes the same params than post() and use the parent and child endpoints to call the appropiate dialogs. """
|
""" Function to be called when the post (using the pubsub method) fails. It takes the same params than post() and use the parent and child endpoints to call the appropiate dialogs. """
|
||||||
# Ask the user if he/she wants to attempt to post the same again.
|
# Ask the user if he/she wants to attempt to post the same again.
|
||||||
msgdialog = commonMessages.post_failed()
|
msgdialog = commonMessages.post_failed()
|
||||||
if msgdialog != widgetUtils.YES: # Cancelled.
|
if msgdialog != widgetUtils.YES: # Cancelled.
|
||||||
return
|
return
|
||||||
# Let's check which kind of post has failed, and do something about it.
|
# Let's check which kind of post has failed, and do something about it.
|
||||||
if parent_endpoint == "wall": # A wall post has failed, so let's create it in a dialogue.
|
if parent_endpoint == "wall":
|
||||||
p = presenters.createPostPresenter(session=self.session, interactor=interactors.createPostInteractor(), view=views.createPostDialog(title=_("Write your post"), message="", text=post_arguments.get("message")))
|
if child_endpoint == "post": # A wall post has failed, so let's create it in a dialogue.
|
||||||
if hasattr(p, "text") or hasattr(p, "privacy"):
|
p = presenters.createPostPresenter(session=self.session, interactor=interactors.createPostInteractor(), view=views.createPostDialog(title=_("Write your post"), message="", text=post_arguments.get("message")))
|
||||||
post_arguments.update(privacy=p.privacy, message=p.text)
|
if hasattr(p, "text") or hasattr(p, "privacy"):
|
||||||
if hasattr(p, "attachments"):
|
post_arguments.update(privacy=p.privacy, message=p.text)
|
||||||
attachments_list = p.attachments
|
if hasattr(p, "attachments"):
|
||||||
call_threaded(pub.sendMessage, "post", parent_endpoint=parent_endpoint, child_endpoint=child_endpoint, from_buffer=from_buffer, attachments_list=attachments_list, post_arguments=post_arguments)
|
attachments_list = p.attachments
|
||||||
|
call_threaded(pub.sendMessage, "post", parent_endpoint=parent_endpoint, child_endpoint=child_endpoint, from_buffer=from_buffer, attachments_list=attachments_list, post_arguments=post_arguments)
|
||||||
|
elif child_endpoint == "repost": # repost
|
||||||
|
p = presenters.createPostPresenter(session=self.session, interactor=interactors.createPostInteractor(), view=views.createPostDialog(title=_("Repost"), message="", text=post_arguments.get("message"), mode="comment"))
|
||||||
|
if hasattr(p, "text") or hasattr(p, "privacy"):
|
||||||
|
post_arguments.update(message=p.text)
|
||||||
|
if hasattr(p, "attachments"):
|
||||||
|
attachments_list = p.attachments
|
||||||
|
call_threaded(pub.sendMessage, "post", parent_endpoint=parent_endpoint, child_endpoint=child_endpoint, from_buffer=from_buffer, attachments_list=attachments_list, post_arguments=post_arguments)
|
||||||
|
elif child_endpoint == "createComment": # comments.
|
||||||
|
p = presenters.createPostPresenter(session=self.session, interactor=interactors.createPostInteractor(), view=views.createPostDialog(title=_("Add a comment"), message="", text=post_arguments.get("message"), mode="comment"))
|
||||||
|
if hasattr(p, "text") or hasattr(p, "privacy"):
|
||||||
|
post_arguments.update(message=p.text)
|
||||||
|
if hasattr(p, "attachments"):
|
||||||
|
attachments_list = p.attachments
|
||||||
|
call_threaded(pub.sendMessage, "post", parent_endpoint=parent_endpoint, child_endpoint=child_endpoint, from_buffer=from_buffer, attachments_list=attachments_list, post_arguments=post_arguments)
|
||||||
elif parent_endpoint == "board": # topic creation and comments.
|
elif parent_endpoint == "board": # topic creation and comments.
|
||||||
if child_endpoint == "addTopic":
|
if child_endpoint == "addTopic":
|
||||||
p = presenters.createPostPresenter(session=self.session, interactor=interactors.createPostInteractor(), view=views.createTopicDialog(title=_("Create topic"), message="", topic_title=post_arguments.get("title"), text=post_arguments.get("text")))
|
p = presenters.createPostPresenter(session=self.session, interactor=interactors.createPostInteractor(), view=views.createTopicDialog(title=_("Create topic"), message="", topic_title=post_arguments.get("title"), text=post_arguments.get("text")))
|
||||||
@ -364,9 +379,7 @@ class Controller(object):
|
|||||||
elif parent_endpoint == "messages": # Private messages
|
elif parent_endpoint == "messages": # Private messages
|
||||||
if child_endpoint == "send":
|
if child_endpoint == "send":
|
||||||
buffer = self.search(from_buffer)
|
buffer = self.search(from_buffer)
|
||||||
print(buffer)
|
|
||||||
buffer_window = self.window.search(buffer.name)
|
buffer_window = self.window.search(buffer.name)
|
||||||
print(buffer_window)
|
|
||||||
self.window.change_buffer(buffer_window)
|
self.window.change_buffer(buffer_window)
|
||||||
buffer.tab.text.SetValue(post_arguments.get("message"))
|
buffer.tab.text.SetValue(post_arguments.get("message"))
|
||||||
buffer.tab.text.SetFocus()
|
buffer.tab.text.SetFocus()
|
||||||
|
Loading…
Reference in New Issue
Block a user