[ckan-changes] [okfn/ckan] c42ab5: [xs, noticket] Changes to get organization_form.htm...
GitHub
noreply at github.com
Tue Apr 17 15:10:50 UTC 2012
Branch: refs/heads/master
Home: https://github.com/okfn/ckan
Commit: c42ab5a6a925ab596f376dcc5a3eb781dd10bbb9
https://github.com/okfn/ckan/commit/c42ab5a6a925ab596f376dcc5a3eb781dd10bbb9
Author: Ross Jones <rossdjones at gmail.com>
Date: 2012-04-17 (Tue, 17 Apr 2012)
Changed paths:
M ckanext/organizations/templates/organization_form.html
Log Message:
-----------
[xs,noticket] Changes to get organization_form.html to match the group template
diff --git a/ckanext/organizations/templates/organization_form.html b/ckanext/organizations/templates/organization_form.html
index f774043..5a1dc6a 100644
--- a/ckanext/organizations/templates/organization_form.html
+++ b/ckanext/organizations/templates/organization_form.html
@@ -1,108 +1,118 @@
+<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">
-<form id="organization-edit" action="" method="post"
- py:attrs="{'class':'has-errors'} if errors else {}"
- xmlns:i18n="http://genshi.edgewall.org/i18n"
- xmlns:py="http://genshi.edgewall.org/"
- xmlns:xi="http://www.w3.org/2001/XInclude">
+<xi:include href="_util.html" />
<div class="error-explanation" py:if="error_summary">
<h2>Errors in form</h2>
<p>The form contains invalid entries:</p>
<ul>
- <li py:for="key, error in error_summary.items()">${"%s: %s" % (key, error)}</li>
+ <li py:for="key, error in error_summary.items()">${"%s: %s" % (key if not key=='Name' else 'URL', error)}</li>
</ul>
</div>
-<input type="hidden" id="type" name="type" value="organization" />
-<input type="hidden" id="approval_status" name="approval_status" value="pending" />
-
<fieldset id="basic-information">
- <dl>
- <dt><label class="field_opt" for="name">Organization name</label></dt>
- <dd><input class="js-title" id="title" name="title" type="text" value="${data.get('title', '')}"/></dd>
-
-
- <dt><label class="field_opt" for="title">Url</label></dt>
- <dd class="name-field">
- <span class="js-url-text url-text">${g.site_url+h.url_for('organization_index')+'/'}<span class="js-url-viewmode js-url-suffix"> </span><a style="display: none;" href="#" class="url-edit js-url-editlink js-url-viewmode">(edit)</a></span>
- <input style="display: none;" id="name" maxlength="100" name="name" type="text" class="url-input js-url-editmode js-url-input" value="${data.get('name', '')}" />
+ <div class="control-group">
+ <label for="name" class="control-label">Title</label>
+ <div class="controls">
+ <input class="js-title" id="title" name="title" type="text" value="${data.get('title', '')}"/>
+ </div>
+ </div>
+ <div class="control-group">
+ <label for="title" class="control-label">Url</label>
+ <div class="controls">
+ <div class="input-prepend">
+ <span class="add-on">${h.url(controller='group', action='index')+'/'}</span>
+ <input maxlength="100" name="name" type="text" class="js-url-input" value="${data.get('name', '')}" />
+ </div>
<p class="js-url-is-valid"> </p>
- </dd>
- <dd style="display: none;" class="js-url-editmode instructions basic">2+ chars, lowercase, using only 'a-z0-9' and '-_'</dd>
- <dd class="field_error" py:if="errors.get('name', '')">${errors.get('name', '')}</dd>
-
- <dt class="description-label"><label class="field_opt" for="title">Organization Description</label></dt>
- <dd class="description-field"><div class="markdown-editor">
- <ul class="button-row">
- <li><button class="pretty-button js-markdown-edit depressed">Edit</button></li>
- <li><button class="pretty-button js-markdown-preview">Preview</button></li>
- </ul>
- <textarea class="markdown-input" name="description" id="notes" placeholder="${_('Start with a summary sentence ...')}">${data.get('description','')}</textarea>
- <div class="markdown-preview" style="display: none;"></div>
- <span class="hints">You can use <a href="http://daringfireball.net/projects/markdown/syntax" target="_blank">Markdown formatting</a> here.</span>
- </div></dd>
-
+ <p class="url-is-long">Warning: URL is very long. Consider changing it to something shorter.</p>
+ <p>2+ characters, lowercase, using only 'a-z0-9' and '-_'</p>
+ <p class="field_error" py:if="errors.get('name', '')">${errors.get('name', '')}</p>
+ </div>
+ </div>
+ <div class="control-group">
+ <label for="" class="control-label">Description</label>
+ <div class="controls">
+ ${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>
+ <p>The URL for the image that is associated with this organization.</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">
+ <select id="state" name="state" >
+ <option py:attrs="{'selected': 'selected' if data.get('state') == 'active' else None}" value="active">active</option>
+ <option py:attrs="{'selected': 'selected' if data.get('state') == 'deleted' else None}" value="deleted">deleted</option>
+ </select>
+ </div>
+ </div>
+</fieldset>
- <dt class="parent-label" py:if="c.is_superuser_or_groupadmin">
- <label class="field_opt" for="parent">Parent Organization</label>
- </dt>
-
- <dd py:if="c.group and not c.is_superuser_or_groupadmin">
+ <div class="control-group" py:if="c.is_superuser_or_groupadmin">
+ <label class="control-label" for="parent">Parent Organization</label>
+ <div class="controls" py:if="c.group and not c.is_superuser_or_groupadmin">
<span py:if="c.parent is not None" class="js-title">
${ c.parent.title }
</span>
<span py:if="c.parent is None" class="js-title">
No parent organization
</span>
- </dd>
-
- <dd py:if="c.is_superuser_or_groupadmin" class="parent-field">
+ </div>
+ <div class="controls" py:if="c.is_superuser_or_groupadmin">
<select id="parent" name="parent" class="chzn-select" data-placeholder="Please choose a organization">
<option value=""></option>
<py:for each="pg in c.possible_parents">
<option py:attrs="{'selected': 'selected' if c.parent and pg.id == c.parent.id else None}" value="${pg.id}">${pg.title}</option>
</py:for>
</select>
- </dd>
+ </div>
+ </div>
- <dt class="state-label" py:if="c.is_sysadmin or c.auth_for_change_state"><label class="field_opt" for="state">State</label></dt>
- <dd class="state-field" py:if="c.is_sysadmin or c.auth_for_change_state">
- <select id="state" name="state" >
- <option py:attrs="{'selected': 'selected' if data.get('state') == 'active' else None}" value="active">active</option>
- <option py:attrs="{'selected': 'selected' if data.get('state') == 'deleted' else None}" value="deleted">deleted</option>
- </select>
- </dd>
- </dl>
-</fieldset>
-
<fieldset id="extras">
<h3>Extras</h3>
<dl>
<py:with vars="extras = data.get('extras', [])">
<py:for each="num, extra in enumerate(data.get('extras', []))">
- <dt><label for="extras__${num}__value">${extra.get('key')}</label></dt>
- <dd>
- <input id="extras__${num}__key" name="extras__${num}__key" type="hidden" value="${extra.get('key')}" />
- <input id="extras__${num}__value" name="extras__${num}__value" type="text" value="${extra.get('value')}" />
- <input type="checkbox" name="extras__${num}__deleted" checked="${extra.get('deleted')}">Delete</input>
- </dd>
+ <div class="control-group">
+ <label class="control-label" for="extras__${num}__value">${extra.get('key')}</label>
+ <div class="controls">
+ <input id="extras__${num}__key" name="extras__${num}__key" type="hidden" value="${extra.get('key')}" />
+ <input id="extras__${num}__value" name="extras__${num}__value" type="text" value="${extra.get('value')}" />
+ <label class="checkbox" style="display: inline-block;">
+ <input type="checkbox" name="extras__${num}__deleted" checked="${extra.get('deleted')}" />Delete
+ </label>
+ </div>
+ </div>
</py:for>
-
+ <hr py:if="len(extras)" class="extras-divider" />
<py:for each="num in range(len(extras), len(extras) + 4)">
- <dt><label for="extras__${num}__key">New key</label></dt>
- <dd>
- <input class="medium-width" id="extras__${num}__key" name="extras__${num}__key" type="text" />
- with value
- <input class="medium-width" id="extras__${num}__value" name="extras__${num}__value" type="text" />
- </dd>
+ <div class="control-group">
+ <label class="control-label" for="extras__${num}__key">Add...</label>
+ <div class="controls">
+ <label>
+ <span class="extras-label">Key =</span>
+ <input class="medium-width" id="extras__${num}__key" name="extras__${num}__key" type="text" />
+ </label>
+ <label>
+ <span class="extras-label">Value =</span>
+ <input class="medium-width" id="extras__${num}__value" name="extras__${num}__value" type="text" />
+ </label>
+ </div>
+ </div>
</py:for>
</py:with>
</dl>
@@ -111,12 +121,13 @@
<?python
import ckan.model as model
users = []
- users.extend( { "name": user.name,
- "capacity": "admin" }
- for user in c.group.members_of_type( model.User, "admin" ).all() )
- users.extend( { "name": user.name,
- "capacity": "editor" }
- for user in c.group.members_of_type( model.User, 'editor' ).all() )
+ if c.group:
+ users.extend( { "name": user.name,
+ "capacity": "admin" }
+ for user in c.group.members_of_type( model.User, "admin" ).all() )
+ users.extend( { "name": user.name,
+ "capacity": "editor" }
+ for user in c.group.members_of_type( model.User, 'editor' ).all() )
?>
<fieldset id="users">
<h3>Users <span py:if="c.users">(${len(c.users.all())})</span></h3>
@@ -136,10 +147,10 @@
</fieldset>
-<div class="form-submit">
- <input id="save" class="pretty-button primary" name="save" type="submit" value="${_('Save Changes')}" />
+<div class="form-actions">
+ <input id="save" class="btn btn-primary" name="save" type="submit" value="${_('Save Changes')}" />
<py:if test="c.group">
- <input id="cancel" class="pretty-button href-action" name="cancel" type="reset" value="${_('Cancel')}" action="${h.url_for(controller='group', action='read', id=c.group.name)}" />
+ <input id="cancel" class="btn href-action" name="cancel" type="reset" value="${_('Cancel')}" action="${h.url_for(controller='group', action='read', id=c.group.name)}" />
</py:if>
</div>
</form>
================================================================
Commit: bad42b82985a5f7a3d3dfababd6dbeff1a2b4405
https://github.com/okfn/ckan/commit/bad42b82985a5f7a3d3dfababd6dbeff1a2b4405
Author: Ross Jones <rossdjones at gmail.com>
Date: 2012-04-17 (Tue, 17 Apr 2012)
Changed paths:
M ckanext/organizations/templates/organization_read.html
Log Message:
-----------
Adding missing group type in template
diff --git a/ckanext/organizations/templates/organization_read.html b/ckanext/organizations/templates/organization_read.html
index 944192e..d946d31 100644
--- a/ckanext/organizations/templates/organization_read.html
+++ b/ckanext/organizations/templates/organization_read.html
@@ -10,6 +10,8 @@
<py:def function="page_logo">${c.group.image_url}</py:def>
</py:if>
+<input type="hidden" id="type" name="type" value="organization" />
+
<?python
from pylons import config
from ckan import model
================================================================
Commit: dbf246234d27d3ff7615219bb88570cd550d6c7f
https://github.com/okfn/ckan/commit/dbf246234d27d3ff7615219bb88570cd550d6c7f
Author: Ross Jones <rossdjones at gmail.com>
Date: 2012-04-17 (Tue, 17 Apr 2012)
Changed paths:
M ckan/config/environment.py
M ckan/lib/helpers.py
M ckan/plugins/interfaces.py
Log Message:
-----------
Merge branch 'master' of https://github.com/okfn/ckan
diff --git a/ckan/config/environment.py b/ckan/config/environment.py
index a792b6e..fa91541 100644
--- a/ckan/config/environment.py
+++ b/ckan/config/environment.py
@@ -104,6 +104,20 @@ def find_controller(self, controller):
else:
config['pylons.h'] = h
+ # extend helper functions with ones supplied by plugins
+ from ckan.plugins import PluginImplementations
+ from ckan.plugins.interfaces import ITemplateHelpers
+
+ extra_helpers = []
+ for plugin in PluginImplementations(ITemplateHelpers):
+ helpers = plugin.get_helpers()
+ for helper in helpers:
+ if helper in extra_helpers:
+ raise Exception('overwritting extra helper %s' % helper)
+ extra_helpers.append(helper)
+ setattr(config['pylons.h'], helper, helpers[helper])
+
+
## redo template setup to use genshi.search_path (so remove std template setup)
template_paths = [paths['templates'][0]]
extra_template_paths = config.get('extra_template_paths', '')
diff --git a/ckan/lib/helpers.py b/ckan/lib/helpers.py
index 7996e7f..0824c15 100644
--- a/ckan/lib/helpers.py
+++ b/ckan/lib/helpers.py
@@ -659,6 +659,7 @@ def snippet(template_name, **kw):
globs = kw
globs['h'] = pylons_globs['h']
globs['c'] = pylons_globs['c']
+ globs['config'] = pylons_globs['config']
stream = template.generate(**globs)
for item in PluginImplementations(IGenshiStreamFilter):
stream = item.filter(stream)
diff --git a/ckan/plugins/interfaces.py b/ckan/plugins/interfaces.py
index a04d8fd..826e41d 100644
--- a/ckan/plugins/interfaces.py
+++ b/ckan/plugins/interfaces.py
@@ -13,7 +13,7 @@
'IPackageController', 'IPluginObserver',
'IConfigurable', 'IConfigurer', 'IAuthorizer',
'IActions', 'IResourceUrlChange', 'IDatasetForm',
- 'IGroupForm',
+ 'IGroupForm', 'ITemplateHelpers',
]
from inspect import isclass
@@ -385,6 +385,16 @@ def get_auth_functions(self):
implementation overrides
"""
+class ITemplateHelpers(Interface):
+ """
+ Allow adding extra template functions available via h variable
+ """
+ def get_helpers(self):
+ """
+ Should return a dict, the keys being the name of the helper
+ function and the values being the functions themselves.
+ """
+
class IDatasetForm(Interface):
"""
Allows customisation of the package controller as a plugin.
================================================================
Compare: https://github.com/okfn/ckan/compare/94180bd...dbf2462
More information about the ckan-changes
mailing list