Modified GUI postMenu to display a delete optoin if user has permissions
This commit is contained in:
parent
81f7a5f25b
commit
6cd4b6c549
@ -192,10 +192,15 @@ class baseBuffer(object):
|
|||||||
|
|
||||||
def get_menu(self):
|
def get_menu(self):
|
||||||
""" Returns contextual menu options. They will change according to the focused item"""
|
""" Returns contextual menu options. They will change according to the focused item"""
|
||||||
m = menus.postMenu()
|
|
||||||
p = self.get_post()
|
p = self.get_post()
|
||||||
if p == None:
|
if p == None:
|
||||||
return
|
return
|
||||||
|
# determine if the current user is able to delete the object.
|
||||||
|
if "can_delete" in p:
|
||||||
|
can_delete = True==p["can_delete"]
|
||||||
|
else:
|
||||||
|
can_delete = False
|
||||||
|
m = menus.postMenu(can_delete=can_delete)
|
||||||
if ("likes" in p) == False:
|
if ("likes" in p) == False:
|
||||||
m.like.Enable(False)
|
m.like.Enable(False)
|
||||||
elif p["likes"]["user_likes"] == 1:
|
elif p["likes"]["user_likes"] == 1:
|
||||||
@ -207,7 +212,8 @@ class baseBuffer(object):
|
|||||||
widgetUtils.connect_event(m, widgetUtils.MENU, self.do_like, menuitem=m.like)
|
widgetUtils.connect_event(m, widgetUtils.MENU, self.do_like, menuitem=m.like)
|
||||||
widgetUtils.connect_event(m, widgetUtils.MENU, self.do_dislike, menuitem=m.dislike)
|
widgetUtils.connect_event(m, widgetUtils.MENU, self.do_dislike, menuitem=m.dislike)
|
||||||
widgetUtils.connect_event(m, widgetUtils.MENU, self.do_comment, menuitem=m.comment)
|
widgetUtils.connect_event(m, widgetUtils.MENU, self.do_comment, menuitem=m.comment)
|
||||||
widgetUtils.connect_event(m, widgetUtils.MENU, self.open_person_profile, menuitem=m.view_profile)
|
if hasattr(m, "view_profile"):
|
||||||
|
widgetUtils.connect_event(m, widgetUtils.MENU, self.open_person_profile, menuitem=m.view_profile)
|
||||||
return m
|
return m
|
||||||
|
|
||||||
def do_like(self, *args, **kwargs):
|
def do_like(self, *args, **kwargs):
|
||||||
|
@ -3,7 +3,7 @@ from __future__ import unicode_literals
|
|||||||
import wx
|
import wx
|
||||||
|
|
||||||
class postMenu(wx.Menu):
|
class postMenu(wx.Menu):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, can_delete=False, *args, **kwargs):
|
||||||
super(postMenu, self).__init__(*args, **kwargs)
|
super(postMenu, self).__init__(*args, **kwargs)
|
||||||
self.open = wx.MenuItem(self, wx.NewId(), _("Open"))
|
self.open = wx.MenuItem(self, wx.NewId(), _("Open"))
|
||||||
self.Append(self.open)
|
self.Append(self.open)
|
||||||
@ -14,11 +14,15 @@ class postMenu(wx.Menu):
|
|||||||
self.Append(self.dislike)
|
self.Append(self.dislike)
|
||||||
self.comment = wx.MenuItem(self, wx.NewId(), _("Add comment"))
|
self.comment = wx.MenuItem(self, wx.NewId(), _("Add comment"))
|
||||||
self.Append(self.comment)
|
self.Append(self.comment)
|
||||||
self.post_in_wall = wx.MenuItem(self, wx.NewId(), _("Post to this profile"))
|
if can_delete:
|
||||||
self.post_in_wall.Enable(False)
|
self.delete = wx.MenuItem(self, wx.NewId(), _("Delete"))
|
||||||
self.Append(self.post_in_wall)
|
self.Append(self.delete)
|
||||||
self.view_profile = wx.MenuItem(self, wx.NewId(), _("View user profile"))
|
else:
|
||||||
self.Append(self.view_profile)
|
self.post_in_wall = wx.MenuItem(self, wx.NewId(), _("Post to this profile"))
|
||||||
|
self.post_in_wall.Enable(False)
|
||||||
|
self.Append(self.post_in_wall)
|
||||||
|
self.view_profile = wx.MenuItem(self, wx.NewId(), _("View user profile"))
|
||||||
|
self.Append(self.view_profile)
|
||||||
|
|
||||||
def create_specific_post_options(self):
|
def create_specific_post_options(self):
|
||||||
self.update = wx.MenuItem(self, wx.NewId(), _("Update"))
|
self.update = wx.MenuItem(self, wx.NewId(), _("Update"))
|
||||||
|
Loading…
Reference in New Issue
Block a user