Changeset 742

Show
Ignore:
Timestamp:
07/25/08 03:11:34 (4 months ago)
Author:
sylvain
Message:

General metadata are now saved properly

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • oss/jlib/jlib/gui/atom/entry.py

    r737 r742  
    7676        if id_element: 
    7777            self.atomID.setText(QtCore.QString(str(id_element))) 
     78            # Since we have an ID already 
     79            # let's prevent the user from changing it 
    7880            self.atomID.setEnabled(False) 
     81            self.withUuid.hide() 
    7982 
    8083        title_element = entry.get_child('title', ATOM10_NS) 
     
    120123        self.links.verticalHeader().hide() 
    121124 
     125        # In edition mode we don't want to allow the user 
     126        # from changing the dates 
    122127        self.publication.setEnabled(False) 
    123         self.withUuid.hide(
     128        self.edition.setEnabled(False
    124129 
    125130    def saveEntry(self): 
     
    130135        title_element.xml_text = unicode(self.title.text()) 
    131136 
     137        subtitle_element = self.entry.get_child('subtitle', ATOM10_NS) 
     138        if not subtitle_element and not self.subtitle.text().isEmpty(): 
     139            E(u'subtitle', namespace=ATOM10_NS, prefix=ATOM10_PREFIX, 
     140              attributes={u'type': u'text'}, 
     141              content=unicode(self.subtitle.text()), 
     142              parent=self.entry) 
     143        elif subtitle_element and not self.subtitle.text().isEmpty(): 
     144            subtitle_element.xml_text = unicode(self.subtitle.text()) 
     145        elif subtitle_element and self.subtitle.text().isEmpty(): 
     146            subtitle_element.forget() 
     147 
     148        rights_element = self.entry.get_child('rights', ATOM10_NS) 
     149        if not rights_element and not self.rights.text().isEmpty(): 
     150            E(u'rights', namespace=ATOM10_NS, prefix=ATOM10_PREFIX, 
     151              attributes={u'type': u'text'}, 
     152              content=unicode(self.rights.text()), 
     153              parent=self.entry) 
     154        elif rights_element and not self.rights.text().isEmpty(): 
     155            rights_element.xml_text = unicode(self.rights.text()) 
     156        elif rights_element and self.rights.text().isEmpty(): 
     157            # When no rights were provided we remove the atom:rights element 
     158            rights_element.forget() 
     159 
     160        summary_element = self.entry.get_child('summary', ATOM10_NS) 
     161        text = self.summary.toPlainText() 
     162        if not summary_element and not text.isEmpty(): 
     163            E(u'summary', namespace=ATOM10_NS, prefix=ATOM10_PREFIX, 
     164              attributes={u'type': u'text'}, content=unicode(text), 
     165              parent=self.entry) 
     166        elif summary_element and not text.isEmpty(): 
     167            summary_element.xml_text = unicode(text) 
     168        elif summary_element and text.isEmpty(): 
     169            summary_element.xml_text = u'' 
     170 
     171        content_element = self.entry.get_child('content', ATOM10_NS) 
     172        text = self.content.toPlainText() 
     173        if not content_element and not text.isEmpty(): 
     174            E(u'content', namespace=ATOM10_NS, prefix=ATOM10_PREFIX, 
     175              attributes={u'type': u'text'}, content=unicode(text), 
     176              parent=self.entry) 
     177        elif content_element and not text.isEmpty(): 
     178            content_element.xml_text = unicode(text) 
     179        elif content_element and text.isEmpty(): 
     180            content_element.xml_text = u'' 
     181 
    132182        updated_element = self.entry.get_child('updated', ATOM10_NS) 
    133         updated_element.xml_text = unicode(datetime.datetime.utcnow().isoformat()) + u'Z' 
     183        updated_element.xml_text = unicode(QtCore.QDateTime.currentDateTime().toString(QtCore.Qt.ISODate)) 
    134184         
    135185        self.emit(QtCore.SIGNAL("itemReady(PyQt_PyObject, PyQt_PyObject, PyQt_PyObject)"),