Added creation of wall timelines too

This commit is contained in:
Manuel Cortez 2016-04-14 17:23:08 -05:00
parent 73d9400dc8
commit 8820e59276
4 changed files with 41 additions and 11 deletions

View File

@ -179,6 +179,21 @@ class feedBuffer(baseBuffer):
[self.insert(i) for i in self.session.db[self.name]["items"][:num]] [self.insert(i) for i in self.session.db[self.name]["items"][:num]]
return retrieved return retrieved
def remove_buffer(self, mandatory=False):
if "me_feed" == self.name:
output.speak(_(u"This buffer can't be deleted"))
return False
else:
if mandatory == False:
dlg = commonMessages.remove_buffer()
else:
dlg = widgetUtils.YES
if dlg == widgetUtils.YES:
self.session.db.pop(self.name)
return True
else:
return False
class audioBuffer(feedBuffer): class audioBuffer(feedBuffer):
def create_tab(self, parent): def create_tab(self, parent):
self.tab = home.audioTab(parent) self.tab = home.audioTab(parent)
@ -206,7 +221,7 @@ class audioBuffer(feedBuffer):
audios = [i for i in self.session.db[self.name]["items"][selected:]] audios = [i for i in self.session.db[self.name]["items"][selected:]]
pub.sendMessage("play-audios", audios=audios) pub.sendMessage("play-audios", audios=audios)
def remove_buffer(self, mandatory): def remove_buffer(self, mandatory=False):
if "me_audio" == self.name or "popular_audio" == self.name or "recommended_audio" == self.name: if "me_audio" == self.name or "popular_audio" == self.name or "recommended_audio" == self.name:
output.speak(_(u"This buffer can't be deleted")) output.speak(_(u"This buffer can't be deleted"))
return False return False
@ -236,4 +251,4 @@ class empty(object):
def get_more_items(self, *args, **kwargs): def get_more_items(self, *args, **kwargs):
output.speak(_(u"This buffer doesn't support getting more items.")) output.speak(_(u"This buffer doesn't support getting more items."))
def remove_buffer(self, mandatory): return False def remove_buffer(self, mandatory=False): return False

View File

@ -171,7 +171,7 @@ class Controller(object):
def update_status_bar(self, status): def update_status_bar(self, status):
self.window.change_status(status) self.window.change_status(status)
def remove_buffer(self, mandatory=False, *args, **kwargs): def remove_buffer(self, event, mandatory=False, *args, **kwargs):
buffer = self.get_current_buffer() buffer = self.get_current_buffer()
buff = self.window.search(buffer.name) buff = self.window.search(buffer.name)
answer = buffer.remove_buffer(mandatory) answer = buffer.remove_buffer(mandatory)
@ -215,9 +215,13 @@ class Controller(object):
commonMessages.no_user_exist() commonMessages.no_user_exist()
return return
if buffertype == "audio": if buffertype == "audio":
audio = buffers.audioBuffer(parent=self.window.tb, name="{0}_audio".format(user_id,), composefunc="compose_audio", session=self.session, endpoint="get", parent_endpoint="audio", full_list=True, count=self.session.settings["buffers"]["count_for_audio_buffers"], user_id=user_id) buffer = buffers.audioBuffer(parent=self.window.tb, name="{0}_audio".format(user_id,), composefunc="compose_audio", session=self.session, endpoint="get", parent_endpoint="audio", full_list=True, count=self.session.settings["buffers"]["count_for_audio_buffers"], user_id=user_id)
self.buffers.append(audio) name_ = _(u"{0}'s audios").format(user,)
call_threaded(self.complete_buffer_creation, buffer=audio, name_=_(u"{0}'s audios").format(user,), position=self.window.search("timelines")) elif buffertype == "wall":
buffer = buffers.feedBuffer(parent=self.window.tb, name="{0}_feed".format(user_id,), composefunc="compose_status", session=self.session, endpoint="get", parent_endpoint="wall", extended=1, count=self.session.settings["buffers"]["count_for_wall_buffers"], owner_id=user_id)
name_ = _(u"{0}'s wall posts").format(user,)
self.buffers.append(buffer)
call_threaded(self.complete_buffer_creation, buffer=buffer, name_=name_, position=self.window.search("timelines"))
def complete_buffer_creation(self, buffer, name_, position): def complete_buffer_creation(self, buffer, name_, position):
answer = buffer.get_items() answer = buffer.get_items()

View File

@ -59,9 +59,13 @@ class postController(object):
if self.post.has_key("source_id"): if self.post.has_key("source_id"):
self.user_identifier = "source_id" self.user_identifier = "source_id"
self.post_identifier = "post_id" self.post_identifier = "post_id"
# print self.post["type"]
else: else:
self.user_identifier = "from_id" # In wall's posts, if someone has posted in user's wall, owner_id should be used instead from_id
# This will help for retrieving comments, do likes, etc.
if not self.post.has_key("owner_id"):
self.user_identifier = "from_id"
else:
self.user_identifier = "owner_id"
self.post_identifier = "id" self.post_identifier = "id"
self.dialog = postDialogs.post() self.dialog = postDialogs.post()
# self.dialog.comments.list.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.show_comment) # self.dialog.comments.list.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.show_comment)
@ -97,7 +101,10 @@ class postController(object):
if self.post.has_key("copy_history"): if self.post.has_key("copy_history"):
title = _(u"repost from {0}").format(from_,) title = _(u"repost from {0}").format(from_,)
else: else:
title = _(u"Post from {0}").format(from_,) if self.post.has_key("from_id") and self.post.has_key("owner_id"):
title = _(u"Post from {0} in the {1}'s wall").format(self.session.get_user_name(self.post["from_id"]), self.session.get_user_name(self.post["owner_id"]))
else:
title = _(u"Post from {0}").format(from_,)
self.dialog.set_title(title) self.dialog.set_title(title)
message = u"" message = u""
message = get_message(self.post) message = get_message(self.post)

View File

@ -15,8 +15,10 @@ class timelineDialog(widgetUtils.BaseDialog):
userSizer.Add(userLabel, 0, wx.ALL, 5) userSizer.Add(userLabel, 0, wx.ALL, 5)
userSizer.Add(self.cb, 0, wx.ALL, 5) userSizer.Add(self.cb, 0, wx.ALL, 5)
actionsstatic = wx.StaticBox(panel, label=_(u"Buffer type")) actionsstatic = wx.StaticBox(panel, label=_(u"Buffer type"))
self.audio = wx.RadioButton(panel, wx.NewId(), _(u"&Audios"), style=wx.RB_GROUP) self.wall = wx.RadioButton(panel, wx.NewId(), _(u"&Wall posts"), style=wx.RB_GROUP)
self.audio = wx.RadioButton(panel, wx.NewId(), _(u"&Audio"))
radioSizer = wx.StaticBoxSizer(actionsstatic, wx.HORIZONTAL) radioSizer = wx.StaticBoxSizer(actionsstatic, wx.HORIZONTAL)
radioSizer.Add(self.wall, 0, wx.ALL, 5)
radioSizer.Add(self.audio, 0, wx.ALL, 5) radioSizer.Add(self.audio, 0, wx.ALL, 5)
sizer.Add(radioSizer, 0, wx.ALL, 5) sizer.Add(radioSizer, 0, wx.ALL, 5)
ok = wx.Button(panel, wx.ID_OK, _(u"&OK")) ok = wx.Button(panel, wx.ID_OK, _(u"&OK"))
@ -34,4 +36,6 @@ class timelineDialog(widgetUtils.BaseDialog):
def get_buffer_type(self): def get_buffer_type(self):
if self.audio.GetValue() == True: if self.audio.GetValue() == True:
return "audio" return "audio"
elif self.wall.GetValue() == True:
return "wall"