Fixed a condition that was raising a traceback when adding an audio attachment
This commit is contained in:
parent
ba14699dfb
commit
ca3873f055
@ -5,11 +5,11 @@ import logging
|
|||||||
import widgetUtils
|
import widgetUtils
|
||||||
from wxUI.dialogs import attach as gui
|
from wxUI.dialogs import attach as gui
|
||||||
from wxUI.dialogs import selector
|
from wxUI.dialogs import selector
|
||||||
log = logging.getLogger("controller.attach")
|
log = logging.getLogger(__file__)
|
||||||
|
|
||||||
class attachFromLocal(object):
|
class attachFromLocal(object):
|
||||||
""" Controller used in some sections of the application, mainly for uploading photos from the local computer to VK.
|
""" Controller used in some sections of the application, mainly for uploading photos from the local computer to VK.
|
||||||
This controller will not upload the contents by itself, but will generate the data structures for being send over the VK API.
|
This controller will not upload the contents by itself, but will generate the data structures for being sent over the VK API.
|
||||||
At the current time, only photo uploading is supported."""
|
At the current time, only photo uploading is supported."""
|
||||||
|
|
||||||
def __init__(self, voice_messages=False):
|
def __init__(self, voice_messages=False):
|
||||||
@ -77,8 +77,8 @@ class attachFromOnline(object):
|
|||||||
|
|
||||||
def add_audio(self, *args, **kwargs):
|
def add_audio(self, *args, **kwargs):
|
||||||
""" Allow adding an audio directly from the user's audio library."""
|
""" Allow adding an audio directly from the user's audio library."""
|
||||||
list_of_audios = self.session.vk.client_audio.get()
|
# Let's reuse the already downloaded audios.
|
||||||
# list_of_audios = list_of_audios["items"]
|
list_of_audios = self.session.db["me_audio"]["items"]
|
||||||
audios = []
|
audios = []
|
||||||
for i in list_of_audios:
|
for i in list_of_audios:
|
||||||
audios.append(u"{0}, {1}".format(i["title"], i["artist"]))
|
audios.append(u"{0}, {1}".format(i["title"], i["artist"]))
|
||||||
|
@ -130,11 +130,14 @@ class selectAttachment(widgetUtils.BaseDialog):
|
|||||||
if selection in self.attachments_list:
|
if selection in self.attachments_list:
|
||||||
self.attachments.Append(selection)
|
self.attachments.Append(selection)
|
||||||
self.indexes.append(self.cb.GetSelection())
|
self.indexes.append(self.cb.GetSelection())
|
||||||
|
self.remove.Enable(True)
|
||||||
|
|
||||||
def remove_attachment(self, *args, **kwargs):
|
def remove_attachment(self, *args, **kwargs):
|
||||||
n = self.attachments.GetSelection()
|
n = self.attachments.GetSelection()
|
||||||
self.attachments.Delete(n)
|
self.attachments.Delete(n)
|
||||||
self.indexes.remove(n)
|
self.indexes.pop(n)
|
||||||
|
if len(self.indexes) == 0:
|
||||||
|
self.remove.Enable(False)
|
||||||
|
|
||||||
def get_all_attachments(self):
|
def get_all_attachments(self):
|
||||||
return self.indexes
|
return self.indexes
|
Loading…
Reference in New Issue
Block a user