Merge lp:~jesse-andries/referencer/referencer into lp:referencer

Proposed by jesse andries
Status: Merged
Merge reported by: Mads Chr. Olesen
Merged at revision: not available
Proposed branch: lp:~jesse-andries/referencer/referencer
Merge into: lp:referencer
Diff against target: 60 lines (+28/-4)
2 files modified
plugins/ads.py (+2/-1)
src/DocumentProperties.C (+26/-3)
To merge this branch: bzr merge lp:~jesse-andries/referencer/referencer
Reviewer Review Type Date Requested Status
Mads Chr. Olesen Approve
Review via email: mp+151124@code.launchpad.net

Description of the change

Case normalisation issues in ADS-plugin and in adding fields through the Document Properties dialogue, as discussed in comment 8 in bug 1099754)

ADS-plugin: Additional fields and normalised case of the Month field

Normalised case of the fields added through the document properties dialog (see comment 8 in bug 1099754). Also added a check which refuses to create a field that already exists even though there are differences in the case of the field-key. This was done to resolve the following problem: It used to be possible to create different versions (different case of the key) of the same field thus holding different values. These were then only subsequently collapsed (retaining the first appearing version of the field-key with the last appearing value) when hitting the Save button, without warning to the user.

To post a comment you must log in.
Revision history for this message
Mads Chr. Olesen (shiyee) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/ads.py'
2--- plugins/ads.py 2013-01-20 02:03:38 +0000
3+++ plugins/ads.py 2013-02-28 23:15:25 +0000
4@@ -55,8 +55,9 @@
5 fields.append (["volume", get_field(xmldoc, "volume")])
6 fields.append (["issue", get_field(xmldoc, "issue")])
7 fields.append (["year", get_field(xmldoc, "pubdate").partition(' ')[2]])
8- fields.append (["month", str.lower(get_field(xmldoc, "pubdate").partition(' ')[0])])
9+ fields.append (["Month", str.lower(get_field(xmldoc, "pubdate").partition(' ')[0])])
10 fields.append (["Adsurl", xmldoc.getElementsByTagName('url')[-1].childNodes[0].data.encode("utf-8")])
11+ fields.append (["Adsbibcode", get_field(xmldoc, "bibcode")])
12
13 authors = xmldoc.getElementsByTagName('author')
14 authorString = ""
15
16=== modified file 'src/DocumentProperties.C'
17--- src/DocumentProperties.C 2012-11-03 09:11:50 +0000
18+++ src/DocumentProperties.C 2013-02-28 23:15:25 +0000
19@@ -24,6 +24,7 @@
20 #include "ThumbnailGenerator.h"
21 #include "RefWindow.h"
22
23+#include "Utility.h"
24 #include "DocumentProperties.h"
25
26
27@@ -378,9 +379,31 @@
28 vbox->set_border_width (12);
29
30 if (dialog.run () == Gtk::RESPONSE_ACCEPT) {
31- Gtk::ListStore::iterator row = extrafieldsstore_->append ();
32- (*row)[extrakeycol_] = entry.get_text ();
33- (*row)[extravalcol_] = "";
34+
35+ Gtk::ListStore::iterator it = extrafieldsstore_->children().begin ();
36+ Gtk::ListStore::iterator const end = extrafieldsstore_->children().end ();
37+ bool key_isnew = true;
38+ for (; it != end; ++it)
39+ if (Utility::firstCap ((*it)[extrakeycol_]) == Utility::firstCap (entry.get_text ())) {
40+ key_isnew = false;
41+ }
42+ if ( key_isnew ) {
43+ Gtk::ListStore::iterator row = extrafieldsstore_->append ();
44+ (*row)[extrakeycol_] = Utility::firstCap (entry.get_text ());
45+ (*row)[extravalcol_] = "";
46+ } else {
47+ Glib::ustring message;
48+ message = String::ucompose (
49+ "<b><big>%1</big></b>",
50+ _("This key already exists.\n"));
51+ Gtk::MessageDialog dialog (
52+
53+ message, true,
54+ Gtk::MESSAGE_ERROR, Gtk::BUTTONS_CLOSE, true);
55+
56+ dialog.run ();
57+
58+ }
59 }
60 }
61

Subscribers

People subscribed via source and target branches