[ckan-changes] commit/ckanextiati: 5 new changesets

Bitbucket commits-noreply at bitbucket.org
Thu Sep 22 13:40:34 UTC 2011


5 new changesets in ckanextiati:

http://bitbucket.org/okfn/ckanextiati/changeset/a395133df580/
changeset:   a395133df580
user:        amercader
date:        2011-09-21 11:56:00
summary:     [forms] Hide unneeded fields
affected #:  3 files (-1 bytes)

--- a/ckanext/iati/controllers/package_iati.py	Mon Sep 19 16:45:49 2011 +0100
+++ b/ckanext/iati/controllers/package_iati.py	Wed Sep 21 10:56:00 2011 +0100
@@ -34,12 +34,8 @@
     def _form_to_db_schema(self):
         schema = package_form_schema()
         schema.update({
-            'department': [unicode,convert_to_extras,ignore_missing],
             'filetype': [convert_to_extras],
             'country': [convert_to_extras, ignore_missing],
-            'donors': [unicode, convert_from_comma_list, convert_to_extras, ignore_missing],
-            'donors_type': [unicode, convert_from_comma_list, convert_to_extras, ignore_missing],
-            'donors_country': [unicode, convert_from_comma_list, convert_to_extras, ignore_missing],
             'record_updated': [date_to_db, convert_to_extras,ignore_missing],
             'data_updated': [date_to_db, convert_to_extras,ignore_missing],
             'activity_period-from': [date_to_db, convert_to_extras,ignore_missing],
@@ -54,12 +50,8 @@
     def _db_to_form_schema(self):
         schema = package_form_schema()
         schema.update({
-            'department': [convert_from_extras,ignore_missing],
             'filetype': [convert_from_extras, ignore_missing],
             'country': [convert_from_extras, ignore_missing],
-            'donors': [ignore_missing, convert_from_extras, convert_to_comma_list],
-            'donors_type': [ignore_missing, convert_from_extras, convert_to_comma_list],
-            'donors_country': [ignore_missing, convert_from_extras, convert_to_comma_list],
             'record_updated': [convert_from_extras,ignore_missing, date_to_form],
             'data_updated': [convert_from_extras,ignore_missing, date_to_form],
             'activity_period-from': [convert_from_extras,ignore_missing, date_to_form],


--- a/ckanext/iati/templates/package/form_iati.html	Mon Sep 19 16:45:49 2011 +0100
+++ b/ckanext/iati/templates/package/form_iati.html	Wed Sep 21 10:56:00 2011 +0100
@@ -33,16 +33,9 @@
             <dd class="instructions basic">A short descriptive title for the data set.</dd><dd class="instructions further">It should not be a description though - save that for the Notes field. Do not give a trailing full stop.</dd>
 
-            <dt><label class="field_opt" for="author">Contact</label></dt>
-            <dd><input id="author" name="author" type="text" value="${data.get('author', '')}" /></dd>
-            <dd class="instructions basic">The name of the main contact, for enquiries about this particular dataset, using the e-mail address in the following field.</dd>
-
             <dt><label class="field_opt" for="author_email">Contact e-mail</label></dt><dd><input id="author_email" name="author_email" type="text" value="${data.get('author_email', '')}" /></dd>
 
-            <dt><label class="field_opt" for="department">Department</label></dt>
-            <dd><input id="department" name="department" size="40" type="text" value="${data.get('department', '')}" /></dd>
-
             <dt><label class="field_opt" for="state">File type</label></dt><dd><select id="filetype" name="filetype">
@@ -101,18 +94,6 @@
                 </py:with></dd>
 
-            <dt><label class="field_opt" for="donors">Donors</label></dt>
-            <dd><input id="donors" name="donors" type="text" value="${data.get('donors', '')}" /></dd>
-            <dd class="instructions basic">Separate multiple entries using commas.</dd>
-
-            <dt><label class="field_opt" for="donors_type">Donor type</label></dt>
-            <dd><input id="donors_type" name="donors_type" type="text" value="${data.get('donors_type', '')}" /></dd>
-            <dd class="instructions basic">Separate multiple entries using commas.</dd>
-
-            <dt><label class="field_opt" for="donors_country">Donor country</label></dt>
-            <dd><input id="donors_country" name="donors_country" type="text" value="${data.get('donors_country', '')}" /></dd>
-            <dd class="instructions basic">Separate multiple entries using commas.</dd>
-
             <dt><label class="field_opt" for="record_updated">Record updated</label></dt><dd><input id="record_updated" name="record_updated" size="40" type="text" value="${data.get('record_updated', '')}" /></dd><dd class="instructions basic">Acceptable formats: 'DD/MM/YYYY HH:MM', 'DD/MM/YYYY', 'MM/YYYY', 'YYYY'.</dd>


--- a/ckanext/iati/templates/package/read_core.html	Mon Sep 19 16:45:49 2011 +0100
+++ b/ckanext/iati/templates/package/read_core.html	Wed Sep 21 10:56:00 2011 +0100
@@ -89,13 +89,7 @@
     <table width="100%"><tbody>
         ${details_item('File Type', h.file_type_title(c.pkg.extras.get('filetype', '-')))}
-        ${details_item('Contact', c.pkg_author_link)}
-        <!--${details_item('Maintainer', c.pkg_maintainer_link)}
-        ${details_item('Version', c.pkg.version)}-->
-        ${details_list('Donors', c.pkg.extras.get('donors', '-'))}
-        ${details_list('Donor types', c.pkg.extras.get('donors_type', []))}
-        ${details_list('Donor countries', [h.country_name(x) for x in c.pkg.extras.get('donors_country', [])])}
-        ${details_item('Recipient Country', h.country_name(c.pkg.extras.get('country', '(Unknown)')))}
+       ${details_item('Recipient Country', h.country_name(c.pkg.extras.get('country', '(Unknown)')))}
 
         ${details_asbool('Verified', c.pkg.extras.get('verified', False))}
         ${details_asbool('Archive File', c.pkg.extras.get('archive_file', False))}


http://bitbucket.org/okfn/ckanextiati/changeset/88ccf9e6eabf/
changeset:   88ccf9e6eabf
user:        amercader
date:        2011-09-21 17:24:03
summary:     Use custom logic functions to modify the package serialization. We still need the monkey patch because the indexing does not use them. Also move the publisher type to extras and rename it.
affected #:  5 files (-1 bytes)

--- a/ckanext/iati/patch.py	Wed Sep 21 10:56:00 2011 +0100
+++ b/ckanext/iati/patch.py	Wed Sep 21 16:24:03 2011 +0100
@@ -10,27 +10,19 @@
 
 log = logging.getLogger(__name__)
 
-######### 
+#########
 log.warn("Monkey-patching package serialization format!")
 
+# This needs to be done until the search indexing uses the logic
+# functions (See #1352)
+
 old_as_dict = Package.as_dict
 def as_dict_with_groups_types(self):
     _dict = old_as_dict(self)
-    _dict['groups_types'] = "".join([g.extras.get('type', '') for g in self.groups])
+    _dict['extras']['publishertype'] = ''.join([g.extras.get('type', '') for g in self.groups])
     return _dict
 
 Package.as_dict = as_dict_with_groups_types
-
-from ckan.lib.dictization import model_dictize
-
-old_package_dictize = model_dictize.package_dictize
-def package_dictize_with_group_types(pkg,context):
-    _dict = old_package_dictize(pkg,context)
-    _dict['groups_types'] = "".join([g.extras.get('type', '') for g in pkg.groups])
-    return _dict
-
-model_dictize.package_dictize = package_dictize_with_group_types
-
 ######### 
 
 FILE_TYPES = {


--- a/ckanext/iati/plugin.py	Wed Sep 21 10:56:00 2011 +0100
+++ b/ckanext/iati/plugin.py	Wed Sep 21 16:24:03 2011 +0100
@@ -5,6 +5,7 @@
 from ckan.plugins import implements, SingletonPlugin
 from ckan.plugins import IRoutes
 from ckan.plugins import IConfigurer
+from ckan.plugins import IActions
 
 import ckanext.iati
 
@@ -52,3 +53,16 @@
     def update_config(self, config):
         configure_template_directory(config, 'templates')
 
+class IatiActions(SingletonPlugin):
+
+    implements(IActions)
+
+    def get_actions(self):
+        from ckanext.iati.logic.action.get import (package_show as package_show_iati,
+                                                   package_show_rest as package_show_rest_iati)
+
+        return {
+            'package_show':package_show_iati,
+            'package_show_rest':package_show_rest_iati
+        }
+


--- a/ckanext/iati/templates/package/read_core.html	Wed Sep 21 10:56:00 2011 +0100
+++ b/ckanext/iati/templates/package/read_core.html	Wed Sep 21 16:24:03 2011 +0100
@@ -62,6 +62,28 @@
         </tr></py:def>
 
+    <py:def function="details_extras_item(label, key, default)">
+        <tr py:if="[e['key'] for e in c.pkg_dict['extras'] if e['key'] == key]">
+          <td class="package-label">
+            ${label}
+          </td>
+          <py:with vars="value = [e['value'] for e in c.pkg_dict['extras'] if e['key'] == key and e['value'] is not None and len(e['value']) > 0][0]">
+          <py:choose>
+              <py:when test="value">
+              <td class="package-details">
+                ${value}
+              </td>
+              </py:when>
+              <py:otherwise>
+              <td class="package-details">
+                ${default}
+                </td>
+              </py:otherwise>
+          </py:choose>
+          </py:with>
+        </tr>
+    </py:def>
+
     <py:def function="details_asbool(label, value)"><tr><td class="package-label">
@@ -88,12 +110,13 @@
     <h4>Details</h4><table width="100%"><tbody>
+
+        ${details_extras_item('Publisher Type','groups_types','-')}
         ${details_item('File Type', h.file_type_title(c.pkg.extras.get('filetype', '-')))}
-       ${details_item('Recipient Country', h.country_name(c.pkg.extras.get('country', '(Unknown)')))}
+        ${details_item('Recipient Country', h.country_name(c.pkg.extras.get('country', '(Unknown)')))}
 
         ${details_asbool('Verified', c.pkg.extras.get('verified', False))}
         ${details_asbool('Archive File', c.pkg.extras.get('archive_file', False))}
-        ${details_item('Department', c.pkg.extras.get('department', '-'))}
 
         ${details_item('Data updated', c.pkg.extras.get('data_updated', '-'))}
         ${details_item('Record updated', c.pkg.extras.get('record_updated', '-'))}


--- a/ckanext/iati/templates/package/search_form.html	Wed Sep 21 10:56:00 2011 +0100
+++ b/ckanext/iati/templates/package/search_form.html	Wed Sep 21 16:24:03 2011 +0100
@@ -12,7 +12,7 @@
     any = ('', 'Any')
     country_options = [(o, h.country_name(o) + " (%s)" % n) for o, n in global_facets.get('extras_country', {}).items() if o != ""]
     groups_options = [(o, h.group_title(o) + " (%s)" % n) for o, n in global_facets.get('groups', {}).items() if o != ""]
-    types_options = [(o, o + " (%s)" % n) for o, n in global_facets.get('groups_types', {}).items() if o != ""]
+    types_options = [(o, o + " (%s)" % n) for o, n in global_facets.get('extras_publishertype', {}).items() if o != ""]
     file_types_options = [(o, h.file_type_title(o) + " (%s)" % n) for o, n in global_facets.get('extras_filetype', {}).items() if o != ""]
 
     country_options.sort(key=lambda name: name[1])
@@ -28,7 +28,7 @@
   <table border="0" class="facets"><tr><td>Source:</td>
-        <td>${h.select('groups_types', dict(c.fields).get('groups_types', '') if c.facets else '', types_options)}</td>
+        <td>${h.select('extras_publishertype', dict(c.fields).get('extras_publishertype', '') if c.facets else '', types_options)}</td></tr><tr><td>Publisher:</td>


--- a/setup.py	Wed Sep 21 10:56:00 2011 +0100
+++ b/setup.py	Wed Sep 21 16:24:03 2011 +0100
@@ -32,10 +32,7 @@
       iati_group_authz = ckanext.iati.authz:IatiGroupAuthzExtension
       iati_package_authz = ckanext.iati.authz:IatiPackageAuthzExtension
       iati_forms = ckanext.iati.plugin:IatiForms
-
-      [ckan.forms]
-      iati_package = ckanext.iati.forms:get_iati_package_fieldset
-      iati_group = ckanext.iati.forms:get_iati_group_fieldset
+      iati_actions = ckanext.iati.plugin:IatiActions
       
       [paste.paster_command]
       create-iati-fixtures = ckanext.iati.fixtures:CreateIatiFixtures


http://bitbucket.org/okfn/ckanextiati/changeset/fd58e5bf2d05/
changeset:   fd58e5bf2d05
user:        amercader
date:        2011-09-22 15:00:07
summary:     Forgot to add these files to the last commit
affected #:  3 files (-1 bytes)

--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ckanext/iati/logic/__init__.py	Thu Sep 22 14:00:07 2011 +0100
@@ -0,0 +1,1 @@
+


--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ckanext/iati/logic/action/__init__.py	Thu Sep 22 14:00:07 2011 +0100
@@ -0,0 +1,1 @@
+


--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ckanext/iati/logic/action/get.py	Thu Sep 22 14:00:07 2011 +0100
@@ -0,0 +1,36 @@
+from ckan.logic.action.get import package_show as package_show_core
+from ckan.logic.action.get import package_show_rest as package_show_rest_core
+
+def package_show(context, data_dict):
+
+    package_dict = package_show_core(context, data_dict)
+    group = context['package'].groups[0] if len(context['package'].groups) else None
+    if group:
+        new_extras = [
+            {'key': 'publishertype', 'value': group.extras.get('type', '')},
+            {'key': 'publisher_organization_type', 'value': group.extras.get('publisher_organization_type', '')},
+            {'key': 'publisher_country', 'value': group.extras.get('publisher_country', '')},
+            {'key': 'publisher_iati_id', 'value': group.extras.get('publisher_iati_id', '')},
+        ]
+    
+    package_dict['extras'].extend(new_extras)
+
+    return package_dict
+
+def package_show_rest(context, data_dict):
+
+    package_dict = package_show_rest_core(context, data_dict)
+
+    group = context['package'].groups[0] if len(context['package'].groups) else None
+    if group:
+        new_extras = {
+            'publishertype':group.extras.get('type', ''),
+            'publisher_organization_type':group.extras.get('publisher_organization_type', ''),
+            'publisher_country':group.extras.get('publisher_country', ''),
+            'publisher_iati_id':group.extras.get('publisher_iati_id', ''),
+        }
+
+    package_dict['extras'].update(new_extras)
+
+    return package_dict
+


http://bitbucket.org/okfn/ckanextiati/changeset/b4f893774b13/
changeset:   b4f893774b13
user:        amercader
date:        2011-09-22 15:00:45
summary:     Add new fields to the package and group forms
affected #:  6 files (-1 bytes)

--- a/ckanext/iati/controllers/group_iati.py	Thu Sep 22 14:00:07 2011 +0100
+++ b/ckanext/iati/controllers/group_iati.py	Thu Sep 22 14:00:45 2011 +0100
@@ -7,8 +7,22 @@
 from ckan.logic.converters import convert_from_extras, convert_to_extras
 from ckan.controllers.group import GroupController
 
-PUBLISHER_TYPES = ['Primary source', 'Secondary source']
+from countries import COUNTRIES
 
+PUBLISHER_SOURCE_TYPES = ['Primary source', 'Secondary source']
+
+ORGANIZATION_TYPES = [
+    ('80', 'Academic, Training and Research'),
+    ('60', 'Foundation'),
+    ('10', 'Government'),
+    ('21', 'International NGO'),
+    ('40', 'Multilateral'),
+    ('22', 'National NGO'),
+    ('15', 'Other Public Sector'),
+    ('70', 'Private Sector'),
+    ('30', 'Public Private Partnership'),
+    ('23', 'Regional NGO'),
+]
 
 class GroupIatiController(GroupController):
 
@@ -20,11 +34,17 @@
 
         c.licences = [('', '')] + model.Package.get_license_options()
 
+        c.organization_types = ORGANIZATION_TYPES
+
+        c.countries = [(v, k) for k, v in COUNTRIES]
+
     def _form_to_db_schema(self):
         schema = group_form_schema()
         schema.update({
-            'type': [not_empty, publisher_type_validator, convert_to_extras],
+            'type': [not_empty, publisher_source_type_validator, convert_to_extras],
             'license_id': [convert_to_extras],
+            'publisher_iati_id': [convert_to_extras, ignore_missing],
+            'publisher_country': [convert_to_extras, ignore_missing],
             'publisher_segmentation': [unicode, convert_to_extras, ignore_missing],
             'publisher_ui': [unicode, convert_to_extras, ignore_missing],
             'publisher_frequency': [unicode, convert_to_extras, ignore_missing],
@@ -39,6 +59,7 @@
             'publisher_refs': [unicode, convert_to_extras, ignore_missing],
             'publisher_constraints': [unicode, convert_to_extras, ignore_missing],
             'publisher_data_quality': [unicode, convert_to_extras, ignore_missing],
+            'publisher_organization_type': [unicode, convert_to_extras, ignore_missing],
         })
 
         return schema
@@ -48,6 +69,8 @@
         schema.update({
             'type': [convert_from_extras],
             'license_id': [convert_from_extras],
+            'publisher_country': [convert_from_extras],
+            'publisher_iati_id': [convert_from_extras, ignore_missing],
             'publisher_segmentation': [convert_from_extras],
             'publisher_ui': [convert_from_extras],
             'publisher_frequency': [convert_from_extras],
@@ -62,6 +85,7 @@
             'publisher_refs': [convert_from_extras],
             'publisher_constraints': [convert_from_extras],
             'publisher_data_quality': [convert_from_extras],
+            'publisher_organization_type': [convert_from_extras],
         })
 
         return schema
@@ -70,7 +94,7 @@
         return
 
 
-def publisher_type_validator(value,context):
-    if not value in PUBLISHER_TYPES:
-        raise Invalid('Unknown publisher type, allowed values: [%s]' % ', '.join(PUBLISHER_TYPES))
+def publisher_source_type_validator(value,context):
+    if not value in PUBLISHER_SOURCE_TYPES:
+        raise Invalid('Unknown publisher source type, allowed values: [%s]' % ', '.join(PUBLISHER_SOURCE_TYPES))
     return value


--- a/ckanext/iati/controllers/package_iati.py	Thu Sep 22 14:00:07 2011 +0100
+++ b/ckanext/iati/controllers/package_iati.py	Thu Sep 22 14:00:45 2011 +0100
@@ -43,6 +43,7 @@
             'activity_count': [integer,convert_to_extras,ignore_missing],
             'archive_file': [checkbox_value, convert_to_extras,ignore_missing],
             'verified': [checkbox_value, convert_to_extras,ignore_missing],
+            'language': [convert_to_extras, ignore_missing],
         })
 
         return schema
@@ -59,6 +60,7 @@
             'activity_count': [convert_from_extras,ignore_missing],
             'archive_file': [convert_from_extras,ignore_missing],
             'verified': [convert_from_extras,ignore_missing],
+            'language': [convert_from_extras, ignore_missing],
         })
 
         return schema


--- a/ckanext/iati/patch.py	Thu Sep 22 14:00:07 2011 +0100
+++ b/ckanext/iati/patch.py	Thu Sep 22 14:00:45 2011 +0100
@@ -25,6 +25,8 @@
 Package.as_dict = as_dict_with_groups_types
 ######### 
 
+from ckanext.iati.controllers.group_iati import ORGANIZATION_TYPES
+
 FILE_TYPES = {
     'activity':'Activity',
     'organisation':'Organisation',
@@ -48,6 +50,12 @@
     else:
         return name
 
+def organization_type_title(code):
+    for k,v in ORGANIZATION_TYPES:
+        if k == code:
+            return v
+    return code
+
 def am_authorized_with_publisher(c, action, domain_object=None):
     from ckan import model
     from ckan.authz import Authorizer
@@ -77,6 +85,7 @@
 h.country_name = country_name
 h.group_title = group_title
 h.file_type_title = file_type_title
+h.organization_type_title = organization_type_title
 h.publisher_record_fields = fields
 h.my_group = my_group
 h.my_group_license = my_group_license


--- a/ckanext/iati/templates/group/form_iati.html	Thu Sep 22 14:00:07 2011 +0100
+++ b/ckanext/iati/templates/group/form_iati.html	Thu Sep 22 14:00:45 2011 +0100
@@ -47,6 +47,31 @@
                 </select></dd>
 
+            <dt><label class="field_opt" for="publisher_organization_type">Organization Type</label></dt> 
+            <dd>
+                <select id="publisher_organization_type" name="publisher_organization_type">
+                    <py:for each="value, title in c.organization_types">
+                        <option value="${value}" py:attrs="{'selected': 'selected' if data.get('organization_type', '') == value else None}" >${title}</option>
+                    </py:for>
+
+                </select>
+            </dd>
+            <dd class="instructions basic"></dd>
+
+            <dt><label class="field_opt" for="publisher_country">Country</label></dt>
+            <dd>
+                <py:with vars="country = data.get('publisher_country','')">
+                <select id="publisher_country" name="publisher_country">
+                    <py:for each="name,id in c.countries">
+                    <option value="${id}" py:attrs="{'selected': 'selected' if country == id else None}">${name}</option>
+                    </py:for>
+                </select>
+                </py:with>
+            </dd>
+
+            <dt><label class="field_opt" for="publisher_iati_id">IATI Identifier</label></dt>
+            <dd><input id="publisher_iati_id" name="publisher_iati_id" type="text" value="${data.get('publisher_iati_id', '')}" /></dd>
+
             <py:choose><py:when test="c.is_sysadmin"><dt><label class="field_opt" for="state">State</label></dt> 


--- a/ckanext/iati/templates/package/form_iati.html	Thu Sep 22 14:00:07 2011 +0100
+++ b/ckanext/iati/templates/package/form_iati.html	Thu Sep 22 14:00:45 2011 +0100
@@ -102,6 +102,10 @@
             <dd><input id="data_updated" name="data_updated" size="40" type="text" value="${data.get('data_updated', '')}"/></dd><dd class="instructions basic">Acceptable formats: 'DD/MM/YYYY HH:MM', 'DD/MM/YYYY', 'MM/YYYY', 'YYYY'.</dd>
 
+            <dt><label class="field_opt" for="record_updated">Language</label></dt>
+            <dd><input id="language" name="language" size="40" type="text" value="${data.get('language', '')}" /></dd>
+            <dd class="instructions basic">The ISO 639-1 code for the language of the file (e.g. 'en')</dd>
+
             <dt><label class="field_opt" for="license_id">License</label></dt><dd><select id="license_id" name="license_id">


--- a/ckanext/iati/templates/package/read_core.html	Thu Sep 22 14:00:07 2011 +0100
+++ b/ckanext/iati/templates/package/read_core.html	Thu Sep 22 14:00:45 2011 +0100
@@ -50,6 +50,12 @@
       </table><table py:otherwise=""><tr><th>Resources</th><td>None given for this package.</td></tr></table></py:choose>
+    
+    <?python
+        extras = {}
+        for extra in c.pkg_dict['extras']:
+            extras[extra['key']] = extra['value']
+    ?><py:def function="details_item(label, value)"><tr py:if="value is not None and len(value) > 0">
@@ -62,24 +68,23 @@
         </tr></py:def>
 
-    <py:def function="details_extras_item(label, key, default)">
-        <tr py:if="[e['key'] for e in c.pkg_dict['extras'] if e['key'] == key]">
+    <py:def function="details_extras_item(label, key, default, func = None)">
+        <tr py:if="key in extras.keys()"><td class="package-label">
             ${label}
           </td>
-          <py:with vars="value = [e['value'] for e in c.pkg_dict['extras'] if e['key'] == key and e['value'] is not None and len(e['value']) > 0][0]">
+          <py:with vars="value = extras[key] if extras[key] is not None and len(extras[key]) > 0 else None">
+          <td class="package-details"><py:choose><py:when test="value">
-              <td class="package-details">
-                ${value}
-              </td>
+                ${func(value) if func else value}
               </py:when><py:otherwise>
-              <td class="package-details">
                 ${default}
-                </td></py:otherwise></py:choose>
+
+          </td></py:with></tr></py:def>
@@ -111,15 +116,20 @@
     <table width="100%"><tbody>
 
-        ${details_extras_item('Publisher Type','groups_types','-')}
-        ${details_item('File Type', h.file_type_title(c.pkg.extras.get('filetype', '-')))}
-        ${details_item('Recipient Country', h.country_name(c.pkg.extras.get('country', '(Unknown)')))}
+        ${details_extras_item('File Type', 'filetype', '-', h.file_type_title)}
+        ${details_extras_item('Language','language','-')}
+        ${details_extras_item('Recipient Country', 'country', '(Unknown)', h.country_name)}
+
+        ${details_extras_item('Publisher Type','publishertype','-')}
+        ${details_extras_item('Publisher Organization Type','publisher_organization_type','-',h.organization_type_title)}
+        ${details_extras_item('Publisher Identifier','publisher_iati_id','-')}
+        ${details_extras_item('Publisher Country','publisher_country','(Unknown)',h.country_name)}
 
         ${details_asbool('Verified', c.pkg.extras.get('verified', False))}
         ${details_asbool('Archive File', c.pkg.extras.get('archive_file', False))}
 
-        ${details_item('Data updated', c.pkg.extras.get('data_updated', '-'))}
-        ${details_item('Record updated', c.pkg.extras.get('record_updated', '-'))}
+        ${details_extras_item('Data updated', 'data_updated', '-')}
+        ${details_extras_item('Record updated', 'record_updated', '-')}
 
         <tr><td class="package-label">


http://bitbucket.org/okfn/ckanextiati/changeset/d3aba633dd41/
changeset:   d3aba633dd41
user:        amercader
date:        2011-09-22 15:40:23
summary:     Clean up lists and publisher type extra
affected #:  8 files (-1 bytes)

--- a/ckanext/iati/controllers/countries.py	Thu Sep 22 14:00:45 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,6 +0,0 @@
-# -*- coding: UTF-8 -*-
-
-# This Python file uses the following encoding: utf-8
-# Country and regions names and codes sent by Bill Anderson on 2011-06-28
-
-COUNTRIES = (("", u"(No country assigned)"), ("AF",u"Afghanistan"),("AX",u"Åland Islands"),("AL",u"Albania"),("DZ",u"Algeria"),("AS",u"American Samoa"),("AD",u"Andorra"),("AO",u"Angola"),("AI",u"Anguilla"),("AQ",u"Antarctica"),("AG",u"Antigua And Barbuda"),("AR",u"Argentina"),("AM",u"Armenia"),("AW",u"Aruba"),("AU",u"Australia"),("AT",u"Austria"),("AZ",u"Azerbaijan"),("BS",u"Bahamas"),("BH",u"Bahrain"),("BD",u"Bangladesh"),("BB",u"Barbados"),("BY",u"Belarus"),("BE",u"Belgium"),("BZ",u"Belize"),("BJ",u"Benin"),("BM",u"Bermuda"),("BT",u"Bhutan"),("BO",u"Bolivia, Plurinational State Of"),("BQ",u"Bonaire, Sint Eustatius And Saba"),("BA",u"Bosnia And Herzegovina"),("BW",u"Botswana"),("BV",u"Bouvet Island"),("BR",u"Brazil"),("IO",u"British Indian Ocean Territory"),("BN",u"Brunei Darussalam"),("BG",u"Bulgaria"),("BF",u"Burkina Faso"),("BI",u"Burundi"),("KH",u"Cambodia"),("CM",u"Cameroon"),("CA",u"Canada"),("CV",u"Cape Verde"),("KY",u"Cayman Islands"),("CF",u"Central African Republic"),("TD",u"Chad"),("CL",u"Chile"),("CN",u"China"),("CX",u"Christmas Island"),("CC",u"Cocos (Keeling) Islands"),("CO",u"Colombia"),("KM",u"Comoros"),("CG",u"Congo"),("CD",u"Congo, The Democratic Republic Of The"),("CK",u"Cook Islands"),("CR",u"Costa Rica"),("CI",u"Côte D'Ivoire"),("HR",u"Croatia"),("CU",u"Cuba"),("CW",u"Curaçao"),("CY",u"Cyprus"),("CZ",u"Czech Republic"),("DK",u"Denmark"),("DJ",u"Djibouti"),("DM",u"Dominica"),("DO",u"Dominican Republic"),("EC",u"Ecuador"),("EG",u"Egypt"),("SV",u"El Salvador"),("GQ",u"Equatorial Guinea"),("ER",u"Eritrea"),("EE",u"Estonia"),("ET",u"Ethiopia"),("FK",u"Falkland Islands (Malvinas)"),("FO",u"Faroe Islands"),("FJ",u"Fiji"),("FI",u"Finland"),("FR",u"France"),("GF",u"French Guiana"),("PF",u"French Polynesia"),("TF",u"French Southern Territories"),("GA",u"Gabon"),("GM",u"Gambia"),("GE",u"Georgia"),("DE",u"Germany"),("GH",u"Ghana"),("GI",u"Gibraltar"),("GR",u"Greece"),("GL",u"Greenland"),("GD",u"Grenada"),("GP",u"Guadeloupe"),("GU",u"Guam"),("GT",u"Guatemala"),("GG",u"Guernsey"),("GN",u"Guinea"),("GW",u"Guinea-Bissau"),("GY",u"Guyana"),("HT",u"Haiti"),("HM",u"Heard Island And Mcdonald Islands"),("VA",u"Holy See (Vatican City State)"),("HN",u"Honduras"),("HK",u"Hong Kong"),("HU",u"Hungary"),("IS",u"Iceland"),("IN",u"India"),("ID",u"Indonesia"),("IR",u"Iran, Islamic Republic Of"),("IQ",u"Iraq"),("IE",u"Ireland"),("IM",u"Isle Of Man"),("IL",u"Israel"),("IT",u"Italy"),("JM",u"Jamaica"),("JP",u"Japan"),("JE",u"Jersey"),("JO",u"Jordan"),("KZ",u"Kazakhstan"),("KE",u"Kenya"),("KI",u"Kiribati"),("KP",u"Korea, Democratic People's Republic Of"),("KR",u"Korea, Republic Of"),("XK",u"Kosovo"),("KW",u"Kuwait"),("KG",u"Kyrgyzstan"),("LA",u"Lao People's Democratic Republic"),("LV",u"Latvia"),("LB",u"Lebanon"),("LS",u"Lesotho"),("LR",u"Liberia"),("LY",u"Libyan Arab Jamahiriya"),("LI",u"Liechtenstein"),("LT",u"Lithuania"),("LU",u"Luxembourg"),("MO",u"Macao"),("MK",u"Macedonia, The Former Yugoslav Republic Of"),("MG",u"Madagascar"),("MW",u"Malawi"),("MY",u"Malaysia"),("MV",u"Maldives"),("ML",u"Mali"),("MT",u"Malta"),("MH",u"Marshall Islands"),("MQ",u"Martinique"),("MR",u"Mauritania"),("MU",u"Mauritius"),("YT",u"Mayotte"),("MX",u"Mexico"),("FM",u"Micronesia, Federated States Of"),("MD",u"Moldova, Republic Of"),("MC",u"Monaco"),("MN",u"Mongolia"),("ME",u"Montenegro"),("MS",u"Montserrat"),("MA",u"Morocco"),("MZ",u"Mozambique"),("MM",u"Myanmar"),("NA",u"Namibia"),("NR",u"Nauru"),("NP",u"Nepal"),("NL",u"Netherlands"),("NC",u"New Caledonia"),("NZ",u"New Zealand"),("NI",u"Nicaragua"),("NE",u"Niger"),("NG",u"Nigeria"),("NU",u"Niue"),("NF",u"Norfolk Island"),("MP",u"Northern Mariana Islands"),("NO",u"Norway"),("OM",u"Oman"),("PK",u"Pakistan"),("PW",u"Palau"),("PS",u"Palestinian Territory, Occupied"),("PA",u"Panama"),("PG",u"Papua New Guinea"),("PY",u"Paraguay"),("PE",u"Peru"),("PH",u"Philippines"),("PN",u"Pitcairn"),("PL",u"Poland"),("PT",u"Portugal"),("PR",u"Puerto Rico"),("QA",u"Qatar"),("RE",u"Réunion"),("RO",u"Romania"),("RU",u"Russian Federation"),("RW",u"Rwanda"),("BL",u"Saint Barthélemy"),("SH",u"Saint Helena, Ascension And Tristan Da Cunha"),("KN",u"Saint Kitts And Nevis"),("LC",u"Saint Lucia"),("MF",u"Saint Martin (French Part)"),("PM",u"Saint Pierre And Miquelon"),("VC",u"Saint Vincent And The Grenadines"),("WS",u"Samoa"),("SM",u"San Marino"),("ST",u"Sao Tome And Principe"),("SA",u"Saudi Arabia"),("SN",u"Senegal"),("RS",u"Serbia"),("SC",u"Seychelles"),("SL",u"Sierra Leone"),("SG",u"Singapore"),("SX",u"Sint Maarten (Dutch Part)"),("SK",u"Slovakia"),("SI",u"Slovenia"),("SB",u"Solomon Islands"),("SO",u"Somalia"),("ZA",u"South Africa"),("GS",u"South Georgia And The South Sandwich Islands"),("ES",u"Spain"),("LK",u"Sri Lanka"),("SD",u"Sudan"),("SR",u"Suriname"),("SJ",u"Svalbard And Jan Mayen"),("SZ",u"Swaziland"),("SE",u"Sweden"),("CH",u"Switzerland"),("SY",u"Syrian Arab Republic"),("TW",u"Taiwan, Province Of China"),("TJ",u"Tajikistan"),("TZ",u"Tanzania, United Republic Of"),("TH",u"Thailand"),("TL",u"Timor-Leste"),("TG",u"Togo"),("TK",u"Tokelau"),("TO",u"Tonga"),("TT",u"Trinidad And Tobago"),("TN",u"Tunisia"),("TR",u"Turkey"),("TM",u"Turkmenistan"),("TC",u"Turks And Caicos Islands"),("TV",u"Tuvalu"),("UG",u"Uganda"),("UA",u"Ukraine"),("AE",u"United Arab Emirates"),("GB",u"United Kingdom"),("US",u"United States"),("UM",u"United States Minor Outlying Islands"),("UY",u"Uruguay"),("UZ",u"Uzbekistan"),("VU",u"Vanuatu"),("VE",u"Venezuela, Bolivarian Republic Of"),("VN",u"Viet Nam"),("VG",u"Virgin Islands, British"),("VI",u"Virgin Islands, U.S."),("WF",u"Wallis And Futuna"),("EH",u"Western Sahara"),("YE",u"Yemen"),("ZM",u"Zambia"),("ZW",u"Zimbabwe"),("298",u"Africa"),("189",u"Africa - North"),("289",u"Africa - Sub-Saharan"),("089",u"Europe"),("498",u"America"),("389",u"America - North & Central"),("489",u"America - South"),("380",u"West Indies"),("589",u"Middle East"),("798",u"Asia"),("619",u"Asia - Central"),("679",u"Asia - South"),("689",u"Asia - South & Central"),("789",u"Asia - Far East"),("889",u"Oceania"),("998",u"Unspecified"),)


--- a/ckanext/iati/controllers/group_iati.py	Thu Sep 22 14:00:45 2011 +0100
+++ b/ckanext/iati/controllers/group_iati.py	Thu Sep 22 14:40:23 2011 +0100
@@ -2,27 +2,13 @@
 from ckan import model
 
 from ckan.lib.navl.validators import ignore_missing, not_empty
+from ckan.lib.navl.dictization_functions import Invalid
 
 from ckan.logic.schema import group_form_schema
 from ckan.logic.converters import convert_from_extras, convert_to_extras
 from ckan.controllers.group import GroupController
 
-from countries import COUNTRIES
-
-PUBLISHER_SOURCE_TYPES = ['Primary source', 'Secondary source']
-
-ORGANIZATION_TYPES = [
-    ('80', 'Academic, Training and Research'),
-    ('60', 'Foundation'),
-    ('10', 'Government'),
-    ('21', 'International NGO'),
-    ('40', 'Multilateral'),
-    ('22', 'National NGO'),
-    ('15', 'Other Public Sector'),
-    ('70', 'Private Sector'),
-    ('30', 'Public Private Partnership'),
-    ('23', 'Regional NGO'),
-]
+from ckanext.iati.lists import ORGANIZATION_TYPES, COUNTRIES, PUBLISHER_SOURCE_TYPES
 
 class GroupIatiController(GroupController):
 
@@ -35,13 +21,13 @@
         c.licences = [('', '')] + model.Package.get_license_options()
 
         c.organization_types = ORGANIZATION_TYPES
-
+        c.publisher_source_types = PUBLISHER_SOURCE_TYPES
         c.countries = [(v, k) for k, v in COUNTRIES]
 
     def _form_to_db_schema(self):
         schema = group_form_schema()
         schema.update({
-            'type': [not_empty, publisher_source_type_validator, convert_to_extras],
+            'type': [not_empty, convert_to_extras],
             'license_id': [convert_to_extras],
             'publisher_iati_id': [convert_to_extras, ignore_missing],
             'publisher_country': [convert_to_extras, ignore_missing],
@@ -93,8 +79,3 @@
     def _check_data_dict(self, data_dict):
         return
 
-
-def publisher_source_type_validator(value,context):
-    if not value in PUBLISHER_SOURCE_TYPES:
-        raise Invalid('Unknown publisher source type, allowed values: [%s]' % ', '.join(PUBLISHER_SOURCE_TYPES))
-    return value


--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ckanext/iati/countries.py	Thu Sep 22 14:40:23 2011 +0100
@@ -0,0 +1,6 @@
+# -*- coding: UTF-8 -*-
+
+# This Python file uses the following encoding: utf-8
+# Country and regions names and codes sent by Bill Anderson on 2011-06-28
+
+COUNTRIES = (("", u"(No country assigned)"), ("AF",u"Afghanistan"),("AX",u"Åland Islands"),("AL",u"Albania"),("DZ",u"Algeria"),("AS",u"American Samoa"),("AD",u"Andorra"),("AO",u"Angola"),("AI",u"Anguilla"),("AQ",u"Antarctica"),("AG",u"Antigua And Barbuda"),("AR",u"Argentina"),("AM",u"Armenia"),("AW",u"Aruba"),("AU",u"Australia"),("AT",u"Austria"),("AZ",u"Azerbaijan"),("BS",u"Bahamas"),("BH",u"Bahrain"),("BD",u"Bangladesh"),("BB",u"Barbados"),("BY",u"Belarus"),("BE",u"Belgium"),("BZ",u"Belize"),("BJ",u"Benin"),("BM",u"Bermuda"),("BT",u"Bhutan"),("BO",u"Bolivia, Plurinational State Of"),("BQ",u"Bonaire, Sint Eustatius And Saba"),("BA",u"Bosnia And Herzegovina"),("BW",u"Botswana"),("BV",u"Bouvet Island"),("BR",u"Brazil"),("IO",u"British Indian Ocean Territory"),("BN",u"Brunei Darussalam"),("BG",u"Bulgaria"),("BF",u"Burkina Faso"),("BI",u"Burundi"),("KH",u"Cambodia"),("CM",u"Cameroon"),("CA",u"Canada"),("CV",u"Cape Verde"),("KY",u"Cayman Islands"),("CF",u"Central African Republic"),("TD",u"Chad"),("CL",u"Chile"),("CN",u"China"),("CX",u"Christmas Island"),("CC",u"Cocos (Keeling) Islands"),("CO",u"Colombia"),("KM",u"Comoros"),("CG",u"Congo"),("CD",u"Congo, The Democratic Republic Of The"),("CK",u"Cook Islands"),("CR",u"Costa Rica"),("CI",u"Côte D'Ivoire"),("HR",u"Croatia"),("CU",u"Cuba"),("CW",u"Curaçao"),("CY",u"Cyprus"),("CZ",u"Czech Republic"),("DK",u"Denmark"),("DJ",u"Djibouti"),("DM",u"Dominica"),("DO",u"Dominican Republic"),("EC",u"Ecuador"),("EG",u"Egypt"),("SV",u"El Salvador"),("GQ",u"Equatorial Guinea"),("ER",u"Eritrea"),("EE",u"Estonia"),("ET",u"Ethiopia"),("FK",u"Falkland Islands (Malvinas)"),("FO",u"Faroe Islands"),("FJ",u"Fiji"),("FI",u"Finland"),("FR",u"France"),("GF",u"French Guiana"),("PF",u"French Polynesia"),("TF",u"French Southern Territories"),("GA",u"Gabon"),("GM",u"Gambia"),("GE",u"Georgia"),("DE",u"Germany"),("GH",u"Ghana"),("GI",u"Gibraltar"),("GR",u"Greece"),("GL",u"Greenland"),("GD",u"Grenada"),("GP",u"Guadeloupe"),("GU",u"Guam"),("GT",u"Guatemala"),("GG",u"Guernsey"),("GN",u"Guinea"),("GW",u"Guinea-Bissau"),("GY",u"Guyana"),("HT",u"Haiti"),("HM",u"Heard Island And Mcdonald Islands"),("VA",u"Holy See (Vatican City State)"),("HN",u"Honduras"),("HK",u"Hong Kong"),("HU",u"Hungary"),("IS",u"Iceland"),("IN",u"India"),("ID",u"Indonesia"),("IR",u"Iran, Islamic Republic Of"),("IQ",u"Iraq"),("IE",u"Ireland"),("IM",u"Isle Of Man"),("IL",u"Israel"),("IT",u"Italy"),("JM",u"Jamaica"),("JP",u"Japan"),("JE",u"Jersey"),("JO",u"Jordan"),("KZ",u"Kazakhstan"),("KE",u"Kenya"),("KI",u"Kiribati"),("KP",u"Korea, Democratic People's Republic Of"),("KR",u"Korea, Republic Of"),("XK",u"Kosovo"),("KW",u"Kuwait"),("KG",u"Kyrgyzstan"),("LA",u"Lao People's Democratic Republic"),("LV",u"Latvia"),("LB",u"Lebanon"),("LS",u"Lesotho"),("LR",u"Liberia"),("LY",u"Libyan Arab Jamahiriya"),("LI",u"Liechtenstein"),("LT",u"Lithuania"),("LU",u"Luxembourg"),("MO",u"Macao"),("MK",u"Macedonia, The Former Yugoslav Republic Of"),("MG",u"Madagascar"),("MW",u"Malawi"),("MY",u"Malaysia"),("MV",u"Maldives"),("ML",u"Mali"),("MT",u"Malta"),("MH",u"Marshall Islands"),("MQ",u"Martinique"),("MR",u"Mauritania"),("MU",u"Mauritius"),("YT",u"Mayotte"),("MX",u"Mexico"),("FM",u"Micronesia, Federated States Of"),("MD",u"Moldova, Republic Of"),("MC",u"Monaco"),("MN",u"Mongolia"),("ME",u"Montenegro"),("MS",u"Montserrat"),("MA",u"Morocco"),("MZ",u"Mozambique"),("MM",u"Myanmar"),("NA",u"Namibia"),("NR",u"Nauru"),("NP",u"Nepal"),("NL",u"Netherlands"),("NC",u"New Caledonia"),("NZ",u"New Zealand"),("NI",u"Nicaragua"),("NE",u"Niger"),("NG",u"Nigeria"),("NU",u"Niue"),("NF",u"Norfolk Island"),("MP",u"Northern Mariana Islands"),("NO",u"Norway"),("OM",u"Oman"),("PK",u"Pakistan"),("PW",u"Palau"),("PS",u"Palestinian Territory, Occupied"),("PA",u"Panama"),("PG",u"Papua New Guinea"),("PY",u"Paraguay"),("PE",u"Peru"),("PH",u"Philippines"),("PN",u"Pitcairn"),("PL",u"Poland"),("PT",u"Portugal"),("PR",u"Puerto Rico"),("QA",u"Qatar"),("RE",u"Réunion"),("RO",u"Romania"),("RU",u"Russian Federation"),("RW",u"Rwanda"),("BL",u"Saint Barthélemy"),("SH",u"Saint Helena, Ascension And Tristan Da Cunha"),("KN",u"Saint Kitts And Nevis"),("LC",u"Saint Lucia"),("MF",u"Saint Martin (French Part)"),("PM",u"Saint Pierre And Miquelon"),("VC",u"Saint Vincent And The Grenadines"),("WS",u"Samoa"),("SM",u"San Marino"),("ST",u"Sao Tome And Principe"),("SA",u"Saudi Arabia"),("SN",u"Senegal"),("RS",u"Serbia"),("SC",u"Seychelles"),("SL",u"Sierra Leone"),("SG",u"Singapore"),("SX",u"Sint Maarten (Dutch Part)"),("SK",u"Slovakia"),("SI",u"Slovenia"),("SB",u"Solomon Islands"),("SO",u"Somalia"),("ZA",u"South Africa"),("GS",u"South Georgia And The South Sandwich Islands"),("ES",u"Spain"),("LK",u"Sri Lanka"),("SD",u"Sudan"),("SR",u"Suriname"),("SJ",u"Svalbard And Jan Mayen"),("SZ",u"Swaziland"),("SE",u"Sweden"),("CH",u"Switzerland"),("SY",u"Syrian Arab Republic"),("TW",u"Taiwan, Province Of China"),("TJ",u"Tajikistan"),("TZ",u"Tanzania, United Republic Of"),("TH",u"Thailand"),("TL",u"Timor-Leste"),("TG",u"Togo"),("TK",u"Tokelau"),("TO",u"Tonga"),("TT",u"Trinidad And Tobago"),("TN",u"Tunisia"),("TR",u"Turkey"),("TM",u"Turkmenistan"),("TC",u"Turks And Caicos Islands"),("TV",u"Tuvalu"),("UG",u"Uganda"),("UA",u"Ukraine"),("AE",u"United Arab Emirates"),("GB",u"United Kingdom"),("US",u"United States"),("UM",u"United States Minor Outlying Islands"),("UY",u"Uruguay"),("UZ",u"Uzbekistan"),("VU",u"Vanuatu"),("VE",u"Venezuela, Bolivarian Republic Of"),("VN",u"Viet Nam"),("VG",u"Virgin Islands, British"),("VI",u"Virgin Islands, U.S."),("WF",u"Wallis And Futuna"),("EH",u"Western Sahara"),("YE",u"Yemen"),("ZM",u"Zambia"),("ZW",u"Zimbabwe"),("298",u"Africa"),("189",u"Africa - North"),("289",u"Africa - Sub-Saharan"),("089",u"Europe"),("498",u"America"),("389",u"America - North & Central"),("489",u"America - South"),("380",u"West Indies"),("589",u"Middle East"),("798",u"Asia"),("619",u"Asia - Central"),("679",u"Asia - South"),("689",u"Asia - South & Central"),("789",u"Asia - Far East"),("889",u"Oceania"),("998",u"Unspecified"),)


--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ckanext/iati/lists.py	Thu Sep 22 14:40:23 2011 +0100
@@ -0,0 +1,26 @@
+from countries import COUNTRIES
+
+FILE_TYPES = [
+    ('activity', 'Activity'),
+    ('organisation', 'Organisation'),
+]
+
+
+PUBLISHER_SOURCE_TYPES = [
+    ('primary_source', 'Primary source'),
+    ('secondary_source', 'Secondary source'),
+]
+
+ORGANIZATION_TYPES = [
+    ('80', 'Academic, Training and Research'),
+    ('60', 'Foundation'),
+    ('10', 'Government'),
+    ('21', 'International NGO'),
+    ('40', 'Multilateral'),
+    ('22', 'National NGO'),
+    ('15', 'Other Public Sector'),
+    ('70', 'Private Sector'),
+    ('30', 'Public Private Partnership'),
+    ('23', 'Regional NGO'),
+]
+


--- a/ckanext/iati/patch.py	Thu Sep 22 14:00:45 2011 +0100
+++ b/ckanext/iati/patch.py	Thu Sep 22 14:40:23 2011 +0100
@@ -7,6 +7,7 @@
 from ckan.model import Package
 
 from ckanext.iati.controllers.group_schema import fields
+from ckanext.iati.lists import ORGANIZATION_TYPES, COUNTRIES, PUBLISHER_SOURCE_TYPES, FILE_TYPES
 
 log = logging.getLogger(__name__)
 
@@ -25,12 +26,6 @@
 Package.as_dict = as_dict_with_groups_types
 ######### 
 
-from ckanext.iati.controllers.group_iati import ORGANIZATION_TYPES
-
-FILE_TYPES = {
-    'activity':'Activity',
-    'organisation':'Organisation',
-}
 
 
 # TODO move this to helpers proper
@@ -44,17 +39,14 @@
         name = group.title
     return name
 
-def file_type_title(name):
-    if name in FILE_TYPES.keys():
-        return FILE_TYPES[name]
-    else:
-        return name
+def file_type_title(code):
+    return dict(FILE_TYPES).get(code, code)
+
+def publisher_type_title(code):
+    return dict(PUBLISHER_SOURCE_TYPES).get(code, code)
 
 def organization_type_title(code):
-    for k,v in ORGANIZATION_TYPES:
-        if k == code:
-            return v
-    return code
+    return dict(ORGANIZATION_TYPES).get(code, code)
 
 def am_authorized_with_publisher(c, action, domain_object=None):
     from ckan import model
@@ -86,6 +78,7 @@
 h.group_title = group_title
 h.file_type_title = file_type_title
 h.organization_type_title = organization_type_title
+h.publisher_type_title = publisher_type_title
 h.publisher_record_fields = fields
 h.my_group = my_group
 h.my_group_license = my_group_license


--- a/ckanext/iati/templates/group/form_iati.html	Thu Sep 22 14:00:45 2011 +0100
+++ b/ckanext/iati/templates/group/form_iati.html	Thu Sep 22 14:40:23 2011 +0100
@@ -32,8 +32,9 @@
             <dt><label class="field_req" for="type">Source</label></dt><dd><select id="type" name="type">
-                    <option value="Primary source" py:attrs="{'selected': 'selected' if data.get('type', '') == 'Primary source' else None}">Primary source</option>
-                    <option value="Secondary source" py:attrs="{'selected': 'selected' if data.get('type', '') == 'Secondary source' else None}">Secondary source</option>
+                    <py:for each="value, title in c.publisher_source_types">
+                        <option value="${value}" py:attrs="{'selected': 'selected' if data.get('type', '') == value else None}" >${title}</option>
+                    </py:for></select></dd> 
             


--- a/ckanext/iati/templates/package/read_core.html	Thu Sep 22 14:00:45 2011 +0100
+++ b/ckanext/iati/templates/package/read_core.html	Thu Sep 22 14:40:23 2011 +0100
@@ -120,7 +120,7 @@
         ${details_extras_item('Language','language','-')}
         ${details_extras_item('Recipient Country', 'country', '(Unknown)', h.country_name)}
 
-        ${details_extras_item('Publisher Type','publishertype','-')}
+        ${details_extras_item('Publisher Type','publishertype','-',h.publisher_type_title)}
         ${details_extras_item('Publisher Organization Type','publisher_organization_type','-',h.organization_type_title)}
         ${details_extras_item('Publisher Identifier','publisher_iati_id','-')}
         ${details_extras_item('Publisher Country','publisher_country','(Unknown)',h.country_name)}


--- a/ckanext/iati/templates/package/search_form.html	Thu Sep 22 14:00:45 2011 +0100
+++ b/ckanext/iati/templates/package/search_form.html	Thu Sep 22 14:40:23 2011 +0100
@@ -12,7 +12,7 @@
     any = ('', 'Any')
     country_options = [(o, h.country_name(o) + " (%s)" % n) for o, n in global_facets.get('extras_country', {}).items() if o != ""]
     groups_options = [(o, h.group_title(o) + " (%s)" % n) for o, n in global_facets.get('groups', {}).items() if o != ""]
-    types_options = [(o, o + " (%s)" % n) for o, n in global_facets.get('extras_publishertype', {}).items() if o != ""]
+    types_options = [(o, h.publisher_type_title(o) + " (%s)" % n) for o, n in global_facets.get('extras_publishertype', {}).items() if o != ""]
     file_types_options = [(o, h.file_type_title(o) + " (%s)" % n) for o, n in global_facets.get('extras_filetype', {}).items() if o != ""]
 
     country_options.sort(key=lambda name: name[1])

Repository URL: https://bitbucket.org/okfn/ckanextiati/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.




More information about the ckan-changes mailing list