Subversion Repositories basico

Compare Revisions

Ignore whitespace Rev 359 → Rev 360

/branches/BR-0.4/basico/services/srv_annot.py
74,6 → 74,36
self.log.info("Annotation '%s' (%s) created" % (title, annotation['AID']))
 
 
def update_metadata(self, metadata):
# Update annotation metadata
ANNOTATION_FILE_METADATA = LPATH['ANNOTATIONS'] + metadata['AID'] + '.json'
annotation = self.get_metadata_from_file(ANNOTATION_FILE_METADATA)
for key in metadata:
annotation[key] = metadata[key]
annotation['Timestamp'] = self.srvutl.timestamp()
# Write annotation metadata
with open(ANNOTATION_FILE_METADATA, 'w') as fa:
json.dump(annotation, fa)
 
title = self.get_title(annotation['AID'])
self.log.info("Annotation '%s' (%s) updated" % (title, annotation['AID']))
 
 
def update_timestamp(self, aid):
# Update annotation timestamp
ANNOTATION_FILE_METADATA = LPATH['ANNOTATIONS'] + aid + '.json'
annotation = self.get_metadata_from_file(ANNOTATION_FILE_METADATA)
annotation['Timestamp'] = self.srvutl.timestamp()
# Write annotation metadata
with open(ANNOTATION_FILE_METADATA, 'w') as fa:
json.dump(annotation, fa)
 
title = self.get_title(annotation['AID'])
self.log.info("Annotation '%s' (%s) updated" % (title, annotation['AID']))
def update(self, annotation):
ANNOTATION_FILE_METADATA = LPATH['ANNOTATIONS'] + annotation['AID'] + '.json'
ANNOTATION_FILE_CONTENT = LPATH['ANNOTATIONS'] + annotation['AID'] + '.adoc'
/branches/BR-0.4/basico/services/srv_attachment.py
61,6 → 61,8
 
self.log.info("Attachment '%s' (%s) created" % (metadata['Title'], metadata['TID']))
 
return tid
 
def delete(self, aid):
sid = self.get_sid(aid)
/branches/BR-0.4/basico/services/srv_callbacks.py
866,24 → 866,124
vpaned.set_position(600)
 
 
def gui_attachment_add(self, *args):
visor = self.srvgui.get_widget('visor_attachments')
# Get Annotation ID (AID) from widget, if any
widget_annotation = self.srvgui.get_widget('widget_annotation')
def gui_attachment_add_to_sapnote(self, button, sid):
visor_attachemnts = self.srvgui.get_widget('visor_attachments')
visor_annotations = self.srvgui.get_widget('visor_annotations')
visor_sapnotes = self.srvgui.get_widget('visor_sapnotes')
# Create annotation
aid = self.srvant.gen_aid(sid)
annotation = {}
annotation["AID"] = aid
annotation["Title"] = "Attachments added for SAP Note %s" % str(int(sid))
annotation["Component"] = "Annotation"
annotation["Type"] = "Note"
annotation["Category"] = "Inbox"
annotation["Priority"] = "Low"
annotation["Link"] = ""
annotation["LinkType"] = "Website"
annotation["Origin"] = "Service-Attachment"
# Get attachments from filechooser dialog
attachments = self.gui_attachment_show_filechooser()
# Add them to Basico database
if attachments is not None:
content = '== Attachments\n\n'
for attachment in attachments:
# only allow files (avoid directories)
if os.path.isfile(attachment):
content += "* %s\n" % attachment
tid = self.srvatc.create(attachment, aid)
annotation["TID"] = tid
# ~ self.log.debug(annotation)
annotation["Content"] = content
self.srvant.create(annotation)
visor_attachemnts.populate_attachments()
visor_annotations.populate_annotations()
visor_sapnotes.populate_sapnotes()
else:
self.log.warning("No files selected to attach")
 
 
def gui_attachment_add_to_annotation(self, button):
visor_attachemnts = self.srvgui.get_widget('visor_attachments')
visor_annotations = self.srvgui.get_widget('visor_annotations')
aid = widget_annotation.get_aid_from_widget()
 
# Get attachments fro filechooser dialog
# Create annotation
sid = self.srvant.get_sid(aid)
new_aid = self.srvant.gen_aid(sid)
annotation = {}
annotation["AID"] = new_aid
annotation["Title"] = "Attachments added for annotation: %s" % self.srvant.get_title(aid)
annotation["Component"] = "Annotation"
annotation["Type"] = "Note"
annotation["Category"] = "Inbox"
annotation["Priority"] = "Low"
annotation["Link"] = ""
annotation["LinkType"] = "Website"
annotation["Origin"] = "Service-Attachment"
# Get attachments from filechooser dialog
attachments = self.gui_attachment_show_filechooser()
 
# Add them to Basico database
if attachments is not None:
content = '== Attachments\n\n'
for attachment in attachments:
# only allow files (avoid directories)
if os.path.isfile(attachment):
self.srvatc.create(attachment, aid)
visor.populate_attachments()
content += "* %s\n" % attachment
tid = self.srvatc.create(attachment, aid)
annotation["TID"] = tid
# ~ self.log.debug(annotation)
annotation["Content"] = content
self.srvant.create(annotation)
self.srvant.update_timestamp(aid)
visor_attachemnts.populate_attachments()
visor_annotations.populate_annotations()
else:
self.log.warning("No files selected to attach")
def gui_attachment_add(self, button):
visor_attachemnts = self.srvgui.get_widget('visor_attachments')
visor_annotations = self.srvgui.get_widget('visor_annotations')
visor_sapnotes = self.srvgui.get_widget('visor_sapnotes')
# Create annotation
aid = self.srvant.gen_aid('0000000000')
annotation = {}
annotation["AID"] = aid
annotation["Title"] = "Attachments added"
annotation["Component"] = "Annotation"
annotation["Type"] = "Note"
annotation["Category"] = "Inbox"
annotation["Priority"] = "Low"
annotation["Link"] = ""
annotation["LinkType"] = "Website"
annotation["Origin"] = "Service-Attachment"
# Get attachments from filechooser dialog
attachments = self.gui_attachment_show_filechooser()
# Add them to Basico database
if attachments is not None:
content = '== Attachments\n\n'
for attachment in attachments:
# only allow files (avoid directories)
if os.path.isfile(attachment):
content += "* %s\n" % attachment
tid = self.srvatc.create(attachment, aid)
annotation["TID"] = tid
# ~ self.log.debug(annotation)
annotation["Content"] = content
self.srvant.create(annotation)
visor_attachemnts.populate_attachments()
visor_annotations.populate_annotations()
else:
self.log.warning("No files selected to attach")
 
def gui_attachment_show_filechooser(self):
filenames = None
/branches/BR-0.4/basico/widgets/wdg_annot.py
149,7 → 149,7
tool.set_icon_name('basico-attachment')
tool.set_tooltip_markup('<b>Attach any document to this annotation</b>')
popover = self.srvgui.add_widget('gtk_button_annotation_toolbar_attachment', Gtk.Popover.new(tool))
tool.connect('clicked', self.srvclb.gui_attachment_add)
tool.connect('clicked', self.srvclb.gui_attachment_add_to_annotation)
self.tool_bar.insert(tool, -1)
 
# Separator
/branches/BR-0.4/basico/widgets/wdg_visor_attachments.py
415,9 → 415,8
sid = str(int(sid))
if sid == '0':
sid = ''
self.log.debug("Description: %s", metadata['Description'])
node = self.get_node( metadata['TID'],
self.srvicm.find_mime_type_pixbuf(metadata['Mimetype']),
self.srvicm.find_mime_type_pixbuf(metadata['Mimetype'], 36, 36),
metadata['Doctype'],
metadata['Description'],
metadata['Title'],
/branches/BR-0.4/basico/widgets/wdg_visor_sapnotes.py
535,6 → 535,12
button.connect('clicked', self.srvclb.gui_annotation_widget_show, sid, 'create')
box.pack_start(button, False, False, 0)
 
# Popover button "Add attachments"
button = get_popover_button("<b>Add attachments</b> to SAP Note %d" % isid, 'basico-attachment')
button.show_all()
button.connect('clicked', self.srvclb.gui_attachment_add_to_sapnote, sid)
box.pack_start(button, False, False, 0)
# Popover button "Open SAP Note"
button = get_popover_button("<b>Browse</b> SAP Note %d" % isid, 'basico-browse')
button.connect('clicked', self.srvclb.sapnote_browse, sid)