[ckan-changes] [okfn/ckan] b8d754: Merge branch 'master' of https://github.com/okfn/c...

GitHub noreply at github.com
Tue Apr 17 08:52:51 UTC 2012


  Branch: refs/heads/master
  Home:   https://github.com/okfn/ckan
  Commit: b8d7548fabda43e3da887606e9a4d30148b219d7
      https://github.com/okfn/ckan/commit/b8d7548fabda43e3da887606e9a4d30148b219d7
  Author: Ross Jones <rossdjones at gmail.com>
  Date:   2012-04-16 (Mon, 16 Apr 2012)

  Changed paths:
    M ckan/logic/schema.py
    A ckan/migration/versions/053_add_group_logo.py
    M ckan/model/group.py
    M ckan/public/css/style.css
    M ckan/templates/group/new_group_form.html
    M ckan/templates/group/read.html
    M ckan/templates/layout_base.html
    M ckan/tests/functional/test_group.py
    M ckan/tests/lib/test_dictization.py
    M ckan/tests/lib/test_dictization_schema.py

  Log Message:
  -----------
  Merge branch 'master' of https://github.com/okfn/ckan


diff --git a/ckan/logic/schema.py b/ckan/logic/schema.py
index e77b894..b07d2bb 100644
--- a/ckan/logic/schema.py
+++ b/ckan/logic/schema.py
@@ -179,6 +179,7 @@ def default_group_schema():
         'name': [not_empty, unicode, name_validator, group_name_validator],
         'title': [ignore_missing, unicode],
         'description': [ignore_missing, unicode],
+        'image_url': [ignore_missing, unicode],
         'type': [ignore_missing, unicode],
         'state': [ignore_not_group_admin, ignore_missing],
         'created': [ignore],
diff --git a/ckan/migration/versions/053_add_group_logo.py b/ckan/migration/versions/053_add_group_logo.py
new file mode 100644
index 0000000..7a31fb6
--- /dev/null
+++ b/ckan/migration/versions/053_add_group_logo.py
@@ -0,0 +1,12 @@
+from sqlalchemy import *
+from migrate import *
+
+def upgrade(migrate_engine):
+    migrate_engine.execute('''
+        ALTER TABLE "group"
+            ADD COLUMN image_url text;
+
+        ALTER TABLE group_revision
+            ADD COLUMN image_url text;
+    '''
+    )
diff --git a/ckan/model/group.py b/ckan/model/group.py
index b43ee10..f622a7a 100644
--- a/ckan/model/group.py
+++ b/ckan/model/group.py
@@ -31,6 +31,7 @@
     Column('title', UnicodeText),
     Column('type', UnicodeText, nullable=False),
     Column('description', UnicodeText),
+    Column('image_url', UnicodeText),
     Column('created', DateTime, default=datetime.datetime.now),
     Column('approval_status', UnicodeText, default=u"approved"),
     )
@@ -78,11 +79,12 @@ class Group(vdm.sqlalchemy.RevisionedObjectMixin,
             vdm.sqlalchemy.StatefulObjectMixin,
             DomainObject):
 
-    def __init__(self, name=u'', title=u'', description=u'',
-                 type=u'group', approval_status=u'approved' ):
+    def __init__(self, name=u'', title=u'', description=u'', image_url=u'',
+                 type=u'group', approval_status=u'approved'):
         self.name = name
         self.title = title
         self.description = description
+        self.image_url = image_url
         self.type = type
         self.approval_status= approval_status
 
diff --git a/ckan/public/css/style.css b/ckan/public/css/style.css
index 354734e..981156e 100644
--- a/ckan/public/css/style.css
+++ b/ckan/public/css/style.css
@@ -196,6 +196,11 @@ tbody tr:nth-child(odd) td, tbody tr.odd td {
   font-size: 2.2em;
   font-weight: normal;
 }
+#page-logo {
+  max-width: 36px;
+  max-height: 36px;
+  margin-right: 5px;
+}
 .hover-for-help {
   position: relative;
 }
diff --git a/ckan/templates/group/new_group_form.html b/ckan/templates/group/new_group_form.html
index ad24ea3..99d5388 100644
--- a/ckan/templates/group/new_group_form.html
+++ b/ckan/templates/group/new_group_form.html
@@ -43,6 +43,13 @@
       ${markdown_editor('description', data.get('description'), 'notes', _('Start with a summary sentence ...'))}
     </div>
   </div>
+  <div class="control-group">
+    <label for="name" class="control-label">Image URL:</label>
+    <div class="controls">
+      <input id="image_url" name="image_url" type="text" value="${data.get('image_url', '')}"/>
+      <p>The URL for the image that is associated with this group.</p>
+    </div>
+  </div>
   <div class="state-field control-group" py:if="c.is_sysadmin or c.auth_for_change_state">
     <label for="" class="control-label">State</label>
     <div class="controls">
diff --git a/ckan/templates/group/read.html b/ckan/templates/group/read.html
index 69314b4..7b01fe5 100644
--- a/ckan/templates/group/read.html
+++ b/ckan/templates/group/read.html
@@ -6,6 +6,9 @@
   <xi:include href="../facets.html" />
   <py:def function="page_title">${c.group.display_name}</py:def>
   <py:def function="page_heading">${c.group.display_name}</py:def>
+  <py:if test="c.group.image_url">
+    <py:def function="page_logo">${c.group.image_url}</py:def>
+  </py:if>
 
   <py:match path="primarysidebar">
   
diff --git a/ckan/templates/layout_base.html b/ckan/templates/layout_base.html
index 3b090f1..1518d72 100644
--- a/ckan/templates/layout_base.html
+++ b/ckan/templates/layout_base.html
@@ -90,7 +90,10 @@
     </py:with>
 
     <div id="main" class="container" role="main">
-      <h1 py:if="defined('page_heading')" class="page_heading">${page_heading()}</h1>
+      <h1 py:if="defined('page_heading')" class="page_heading">
+        <img py:if="defined('page_logo')" id="page-logo" src="${page_logo()}" alt="Page Logo" />
+        ${page_heading()}
+      </h1>
       <div class="row">
         <div class="span12">
           <div id="minornavigation">
diff --git a/ckan/tests/functional/test_group.py b/ckan/tests/functional/test_group.py
index 8b452a6..e71cd28 100644
--- a/ckan/tests/functional/test_group.py
+++ b/ckan/tests/functional/test_group.py
@@ -72,7 +72,7 @@ def test_mainmenu(self):
     def test_index(self):
         offset = url_for(controller='group', action='index')
         res = self.app.get(offset)
-        assert '<h1 class="page_heading">Groups' in res, res
+        assert re.search('<h1(.*)>\s*Groups', res.body)
         groupname = 'david'
         group = model.Group.by_name(unicode(groupname))
         group_title = group.title
@@ -259,6 +259,20 @@ def test_edit_plugin_hook(self):
         assert plugin.calls['edit'] == 1, plugin.calls
         plugins.unload(plugin)
 
+    def test_edit_image_url(self):
+        group = model.Group.by_name(self.groupname)
+        offset = url_for(controller='group', action='edit', id=self.groupname)
+        res = self.app.get(offset, status=200, extra_environ={'REMOTE_USER': 'russianfan'})
+
+        form = res.forms['group-edit']
+        image_url = u'http://url.to/image_url'
+        form['image_url'] = image_url
+        res = form.submit('save', status=302, extra_environ={'REMOTE_USER': 'russianfan'})
+
+        model.Session.remove()
+        group = model.Group.by_name(self.groupname)
+        assert group.image_url == image_url, group
+
     def test_edit_non_existent(self):
         name = u'group_does_not_exist'
         offset = url_for(controller='group', action='edit', id=name)
diff --git a/ckan/tests/lib/test_dictization.py b/ckan/tests/lib/test_dictization.py
index ba8ec69..c6ceb0b 100644
--- a/ckan/tests/lib/test_dictization.py
+++ b/ckan/tests/lib/test_dictization.py
@@ -42,19 +42,19 @@ def setup_class(cls):
             'groups': [{'description': u'These are books that David likes.',
                         'name': u'david',
                         'capacity': 'public',
+                        'image_url': u'',
                         'type': u'group',
                         'state': u'active',
                         'title': u"Dave's books",
-                        "approval_status": u"approved",
-                        'capacity': u'public'},
+                        "approval_status": u"approved"},
                        {'description': u'Roger likes these books.',
                         'name': u'roger',
                         'capacity': 'public',
+                        'image_url': u'',
                         'type': u'group',
                         'state': u'active',
                         'title': u"Roger's books",
-                        "approval_status": u"approved",
-                        'capacity': u'public'}],
+                        "approval_status": u"approved"}],
             'isopen': True,
             'license_id': u'other-open',
             'license_title': u'Other (Open)',
@@ -212,7 +212,7 @@ def test_01_dictize_main_objects_simple(self):
     def test_02_package_dictize(self):
 
         context = {"model": model,
-                 "session": model.Session}
+                   "session": model.Session}
 
         model.Session.remove()
         pkg = model.Session.query(model.Package).filter_by(name='annakarenina').first()
@@ -864,13 +864,14 @@ def test_16_group_dictized(self):
 
         group_dictized = group_dictize(group, context)
 
-        expected =  {'description': u'',
+        expected = {'description': u'',
                     'extras': [{'key': u'genre', 'state': u'active', 'value': u'"horror"'},
                                {'key': u'media', 'state': u'active', 'value': u'"dvd"'}],
                     'tags': [{'capacity': 'public', 'name': u'russian'}],
                     'groups': [{'description': u'',
                                'capacity' : 'public',
                                'display_name': u'simple',
+                               'image_url': u'',
                                'name': u'simple',
                                'packages': 0,
                                'state': u'active',
@@ -889,6 +890,7 @@ def test_16_group_dictized(self):
                               'reset_key': None}],
                     'name': u'help',
                     'display_name': u'help',
+                    'image_url': u'',
                     'packages': [{'author': None,
                                   'author_email': None,
                                   'license_id': u'other-open',
diff --git a/ckan/tests/lib/test_dictization_schema.py b/ckan/tests/lib/test_dictization_schema.py
index 13f14e1..a004b1e 100644
--- a/ckan/tests/lib/test_dictization_schema.py
+++ b/ckan/tests/lib/test_dictization_schema.py
@@ -149,6 +149,7 @@ def test_2_group_schema(self):
                                  'id': group.id,
                                  'name': u'david',
                                  'type': u'group',
+                                 'image_url': u'',
                                  'packages': sorted([{'id': group_pack[0].id,
                                                     'name': group_pack[0].name,
                                                     'title': group_pack[0].title},


================================================================
  Commit: 06d606bfdbd1e3b499cff9568dffed6e842d5e4f
      https://github.com/okfn/ckan/commit/06d606bfdbd1e3b499cff9568dffed6e842d5e4f
  Author: Ross Jones <rossdjones at gmail.com>
  Date:   2012-04-17 (Tue, 17 Apr 2012)

  Changed paths:
    M ckan/templates/group/new_group_form.html
    M ckanext/organizations/templates/organization_form.html
    M ckanext/organizations/templates/organization_read.html

  Log Message:
  -----------
  [xs,noticket] Adding image_url from groups into organization templates


diff --git a/ckan/templates/group/new_group_form.html b/ckan/templates/group/new_group_form.html
index 99d5388..9abc6c1 100644
--- a/ckan/templates/group/new_group_form.html
+++ b/ckan/templates/group/new_group_form.html
@@ -1,8 +1,8 @@
-<form 
-  class="form-horizontal ${'has-errors' if errors else ''}" 
-  id="group-edit" 
-  action="" 
-  method="post" 
+<form
+  class="form-horizontal ${'has-errors' if errors else ''}"
+  id="group-edit"
+  action=""
+  method="post"
   xmlns:i18n="http://genshi.edgewall.org/i18n"
   xmlns:py="http://genshi.edgewall.org/"
   xmlns:xi="http://www.w3.org/2001/XInclude">
@@ -60,7 +60,7 @@
     </div>
   </div>
 </fieldset>
-  
+
 <fieldset id="extras">
   <h3>Extras</h3>
   <dl>
diff --git a/ckanext/organizations/templates/organization_form.html b/ckanext/organizations/templates/organization_form.html
index 76b28c7..df0b9d7 100644
--- a/ckanext/organizations/templates/organization_form.html
+++ b/ckanext/organizations/templates/organization_form.html
@@ -42,6 +42,15 @@
       <span class="hints">You can use <a href="http://daringfireball.net/projects/markdown/syntax" target="_blank">Markdown formatting</a> here.</span>
     </div></dd>
 
+  <div class="control-group">
+    <label for="name" class="control-label">Image URL:</label>
+    <div class="controls">
+      <input id="image_url" name="image_url" type="text" value="${data.get('image_url', '')}"/>
+      <p>The URL for the image that is associated with this group.</p>
+    </div>
+  </div>
+
+
     <dt class="parent-label" py:if="c.is_superuser_or_groupadmin">
 		<label class="field_opt" for="parent">Parent Organization</label>
 	</dt>
diff --git a/ckanext/organizations/templates/organization_read.html b/ckanext/organizations/templates/organization_read.html
index 0176952..944192e 100644
--- a/ckanext/organizations/templates/organization_read.html
+++ b/ckanext/organizations/templates/organization_read.html
@@ -6,6 +6,9 @@
   <xi:include href="facets.html" />
   <py:def function="page_title">${c.group.display_name}</py:def>
   <py:def function="page_heading">${c.group.display_name}</py:def>
+  <py:if test="c.group.image_url">
+    <py:def function="page_logo">${c.group.image_url}</py:def>
+  </py:if>
 
   <?python
     from pylons import config


================================================================
Compare: https://github.com/okfn/ckan/compare/114ecac...06d606b


More information about the ckan-changes mailing list