def UpdateAuthorList(self, event=None): oldvalue = self.txtAuthor.GetValue() self.txtAuthor.Clear() for name in appdata.vcards.keys(): self.txtAuthor.Append(name, appdata.vcards[name]) oldorg = self.txtOrganization.GetValue() self.txtOrganization.Clear() for name in appdata.vcards.keys(): self.txtOrganization.Append(name, appdata.vcards[name]) if oldvalue != "": self.txtAuthor.SetValue(oldvalue) else: if isinstance(self.node, conman.conman.ConNode): for person in self.content.metadata.lifecycle.contributors: if person.role == "Author": self.txtAuthor.SetValue(person.entity.fname.value) if person.date != "": self.txtDate.SetValue(person.date) elif person.role == "Content Provider": self.txtOrganization.SetValue(person.entity.fname.value) elif isinstance(self.node, ims.contentpackage.Item): lang = appdata.projectLanguage for person in self.content.metadata.lom.lifecycle.contributors: if person.role.value.getKeyOrEmptyString(lang) == "Author": vcard = conman.vcard.VCard() vcard.parseString(person.centity.vcard.text) self.txtAuthor.SetValue(vcard.fname.value) if person.date.datetime.text and person.date.datetime.text != "": self.txtDate.SetValue(person.date.datetime.text) if oldorg != "": self.txtOrganization.SetValue(oldorg) else: if isinstance(self.node, conman.conman.ConNode): for person in self.content.metadata.lifecycle.contributors: if person.role == "Content Provider": self.txtOrganization.SetValue(person.entity.fname.value) elif isinstance(self.node, ims.contentpackage.Item): lang = appdata.projectLanguage for person in self.content.metadata.lom.lifecycle.contributors: if person.role.value.getKeyOrEmptyString(lang) == "Content Provider": vcard = conman.vcard.VCard() vcard.parseString(person.centity.vcard.text) self.txtOrganization.SetValue(vcard.fname.value)
def btnOKClicked(self, event): if self.txtTitle.GetValue() == "": wx.MessageBox(_("Please enter a name for your page.")) return if self.txtExistingFile.GetValue() == "": wx.MessageBox(_("Please select a file to provide the content for this page.")) return lang = appdata.projectLanguage assert self.txtTitle.GetValue() is not None and self.txtTitle.GetValue() != "" self.node.title.text = self.txtTitle.GetValue() self.content.metadata.lom.general.description[lang] = self.txtDescription.GetValue() self.content.metadata.lom.general.keyword[lang] = self.txtKeywords.GetValue() self.content.metadata.lom.rights.description[lang] = self.txtCredit.GetValue() filename = self.txtExistingFile.GetValue() self.content.setFilename(filename.replace("\\", "/")) for person in self.content.metadata.lom.lifecycle.contributors: role = person.role.value.getKeyOrEmptyString(lang) if role in ["Author", "Content Provider"]: if (role == "Author" and self.txtAuthor.GetValue() == "" and self.txtDate.GetValue() == "") \ or (role == "Content Provider" and self.txtOrganization.GetValue() == ""): self.content.metadata.lom.lifecycle.contributors.remove(person) else: vcard = conman.vcard.VCard() vcard.parseString(person.centity.vcard.text) if role == "Author": vcard.fname.value = self.txtAuthor.GetValue() if self.txtDate.GetValue() != "": person.date.datetime.text = self.txtDate.GetValue() else: vcard.fname.value = self.txtOrganization.GetValue() if not self.txtAuthor.GetValue() == "": self.UpdateContactInfo(self.txtAuthor.GetValue(), "Author") if not self.txtOrganization.GetValue() == "": self.UpdateContactInfo(self.txtOrganization.GetValue(), "Content Provider") self.EndModal(wx.ID_OK)