Skip to content

Commit

Permalink
Merge branch 'master' into dataviewer-iframe
Browse files Browse the repository at this point in the history
Conflicts:
	ckan/public/base/javascript/resource.config
	ckan/templates/package/resource_read.html
  • Loading branch information
amercader committed Sep 27, 2012
2 parents 0aa35ea + 0e9ff2d commit a50f999
Show file tree
Hide file tree
Showing 23 changed files with 457 additions and 315 deletions.
3 changes: 2 additions & 1 deletion ckan/controllers/group.py
Expand Up @@ -439,7 +439,8 @@ def history(self, id):

context = {'model': model, 'session': model.Session,
'user': c.user or c.author,
'schema': self._form_to_db_schema()}
'schema': self._form_to_db_schema(),
'extras_as_string': True}
data_dict = {'id': id}
try:
c.group_dict = get_action('group_show')(context, data_dict)
Expand Down
38 changes: 30 additions & 8 deletions ckan/lib/cli.py
Expand Up @@ -13,6 +13,35 @@
# i.e. do the imports in methods, after _load_config is called.
# Otherwise loggers get disabled.


def parse_db_config(config_key='sqlalchemy.url'):
''' Takes a config key for a database connection url and parses it into
a dictionary. Expects a url like:
'postgres://tester:pass@localhost/ckantest3'
'''
from pylons import config
url = config[config_key]
regex = [
'^\s*(?P<db_type>\w*)',
'://',
'(?P<db_user>[^:]*)',
':?',
'(?P<db_pass>[^@]*)',
'@',
'(?P<db_host>[^/:]*)',
':?',
'(?P<db_port>[^/]*)',
'/',
'(?P<db_name>[\w.-]*)'
]
db_details_match = re.match(''.join(regex), url)
if not db_details_match:
raise Exception('Could not extract db details from url: %r' % url)
db_details = db_details_match.groupdict()
return db_details


class MockTranslator(object):
def gettext(self, value):
return value
Expand Down Expand Up @@ -134,14 +163,7 @@ def command(self):
sys.exit(1)

def _get_db_config(self):
from pylons import config
url = config['sqlalchemy.url']
# e.g. 'postgres://tester:pass@localhost/ckantest3'
db_details_match = re.match('^\s*(?P<db_type>\w*)://(?P<db_user>[^:]*):?(?P<db_pass>[^@]*)@(?P<db_host>[^/:]*):?(?P<db_port>[^/]*)/(?P<db_name>[\w.-]*)', url)
if not db_details_match:
raise Exception('Could not extract db details from url: %r' % url)
db_details = db_details_match.groupdict()
return db_details
return parse_db_config()

def _get_postgres_cmd(self, command):
self.db_details = self._get_db_config()
Expand Down
2 changes: 2 additions & 0 deletions ckan/public/base/javascript/resource.config
Expand Up @@ -46,3 +46,5 @@ main =
modules/custom-fields.js
modules/related-item.js
modules/data-viewer.js
modules/resource-form.js
modules/resource-upload-field.js
38 changes: 38 additions & 0 deletions ckan/public/base/less/ckan.less
Expand Up @@ -94,4 +94,42 @@ iframe {
margin-bottom: 16px;
}

.m-top {
margin-top: @gutterSmallX;
}
.m-left {
margin-left: @gutterSmallX;
}
.m-right {
margin-right: @gutterSmallX;
}
.m-bottom {
margin-bottom: @gutterSmallX;
}
.no-margin {
margin: 0;
}
.reduced-margin {
margin: 3px 5px;
}

.p-top {
padding-top: @gutterSmallX;
}
.p-left {
padding-left: @gutterSmallX;
}
.p-right {
padding-right: @gutterSmallX;
}
.p-bottom {
padding-bottom: @gutterSmallX;
}
.no-padding {
padding: 0;
}
.reduced-padding {
padding: 3px 5px;
}

@import "iehacks.less";
3 changes: 3 additions & 0 deletions ckan/public/base/less/forms.less
Expand Up @@ -40,6 +40,9 @@ input[type=checkbox] {
top: 7px;
padding: 0;
margin: 0;
&.checkbox-onown {
top: 0;
}
}

select {
Expand Down
7 changes: 7 additions & 0 deletions ckan/public/base/vendor/resource.config
Expand Up @@ -23,6 +23,7 @@ block_html5_shim =
[depends]

vendor = jquery.js
fileupload = jquery.js

[groups]

Expand All @@ -38,3 +39,9 @@ vendor =
bootstrap/js/bootstrap-tab.js
bootstrap/js/bootstrap-button.js
font-awesome/css/font-awesome-ie7.css


fileupload =
jquery.ui.widget.js
jquery-fileupload/jquery.iframe-transport.js
jquery-fileupload/jquery.fileupload.js
83 changes: 49 additions & 34 deletions ckan/templates/admin/authz.html
Expand Up @@ -6,9 +6,15 @@
{% endblock %}

{% macro authz_form_table(id, roles, users, user_role_dict) %}
<table class="table table-bordered table-striped table-condensed">
<table class="table table-bordered table-striped">
<colgroup>
<col width="50%">
{% for role in roles %}
<col width="15%">
{% endfor %}
</colgroup>
<tr>
<th> User </th>
<th>{{ _('User') }}</th>
{% for role in roles %}
<th> {{ role }} </th>
{% endfor %}
Expand All @@ -20,15 +26,11 @@
</td>
{% for role in roles %}
<td>
<input type="hidden" name="{{ h.literal( '%s$%s' % (user,role)) }}" value="submitted"/>
<input type="hidden" name="{{ h.literal( '%s$%s' % (user, role)) }}" value="submitted"/>
{% if user_role_dict[(user,role)] %}
<input type="checkbox"
name="{{ h.literal( '%s$%s' % (user,role)) }}"
checked='checked'/>
<input type="checkbox" name="{{ h.literal( '%s$%s' % (user, role)) }}" checked='checked' class="checkbox-onown"/>
{% else %}
<input type="checkbox"
name="{{ h.literal( '%s$%s' % (user,role)) }}"
/>
<input type="checkbox" name="{{ h.literal( '%s$%s' % (user, role)) }}" class="checkbox-onown"/>
{% endif %}
</td>
{% endfor %}
Expand All @@ -39,31 +41,43 @@


{% macro authz_add_table(roles) %}
<table class="table table-bordered table-striped table-condensed">
<table class="table table-bordered table-striped">
<colgroup>
<col width="50%">
{% for role in roles %}
<col width="15%">
{% endfor %}
</colgroup>
<tr>
<th>User</th>
<th>{{ _('User') }}</th>
{% for role in roles %}
<th> {{ role }} </th>
{% endfor %}
</tr>
<tr>
<td>
<input type="textbox" name="new_user_name" class="autocomplete-user" />
<td class="control-full">
<input type="text" name="new_user_name" class="autocomplete-user no-margin reduced-padding" />
</td>
{% for role in roles %}
<td>
<input type="hidden" name="{{ h.literal( '%s' % role) }}" value="submitted"/>
<input type="checkbox" name="{{ h.literal( '%s' % role) }}"/>
<input type="checkbox" name="{{ h.literal( '%s' % role) }}" class="checkbox-onown"/>
</td>
{% endfor %}
</tr>
</table>
{% endmacro %}

{% macro authz_form_group_table(id, roles, users, user_role_dict) %}
<table class="table table-bordered table-striped table-condensed">
<table class="table table-bordered table-striped">
<colgroup>
<col width="50%">
{% for role in roles %}
<col width="15%">
{% endfor %}
</colgroup>
<tr>
<th>User Group</th>
<th>{{ _('User Group') }}</th>
{% for role in roles %}
<th> {{ role }} </th>
{% endfor %}
Expand All @@ -75,15 +89,11 @@
</td>
{% for role in roles %}
<td>
<input type="hidden" name="${ h.literal( '%s$%s' % (user,role)) }" value="submitted"/>
<input type="hidden" name="${ h.literal( '%s$%s' % (user, role)) }" value="submitted"/>
{% if user_role_dict[(user,role)] %}
<input type="checkbox"
name="{{ h.literal( '%s$%s' % (user,role)) }}"
checked='checked'/>
<input type="checkbox" name="{{ h.literal( '%s$%s' % (user, role)) }}" checked='checked' class="checkbox-onown"/>
{% else %}
<input type="checkbox"
name="{{ h.literal( '%s$%s' % (user,role)) }}"
/>
<input type="checkbox" name="{{ h.literal( '%s$%s' % (user, role)) }}" />
{% endif %}
</td>
{% endfor %}
Expand All @@ -94,21 +104,27 @@


{% macro authz_add_group_table(roles) %}
<table class="table table-bordered table-striped table-condensed">
<table class="table table-bordered table-striped">
<colgroup>
<col width="50%">
{% for role in roles %}
<col width="15%">
{% endfor %}
</colgroup>
<tr>
<th>User Group</th>
{% for role in roles %}
<th> {{ role }} </th>
{% endfor %}
</tr>
<tr>
<td>
<input type="textbox" name="new_user_name" class="autocomplete-authzgroup" />
<td class="control-full">
<input type="text" name="new_user_name" class="autocomplete-authzgroup no-margin reduced-padding" />
</td>
{% for role in roles %}
<td>
<input type="hidden" name="{{ h.literal( '%s' % role) }}" value="submitted"/>
<input type="checkbox" name="{{ h.literal( '%s' % role) }}"/>
<input type="checkbox" name="{{ h.literal( '%s' % role) }}" class="checkbox-onown"/>
</td>
{% endfor %}
</tr>
Expand All @@ -118,20 +134,19 @@
{% block primary %}
<article class="module">
<div class="module-content">
<h1 class="page-heading">{{ _('Administration - Authorization') }}</h1>
<h3>Update Existing Roles</h3>
{% snippet 'admin/snippets/header.html', action=c.action %}

<h3 class="m-bottom">{{ _('Update Existing Roles') }}</h3>
<form id="theform" method="POST">
{{ authz_form_table('theform', c.roles, c.users, c.user_role_dict) }}
<button type="submit" name="save" class="btn btn-primary">
Save Changes
</button>
<button type="submit" name="save" class="btn btn-primary">{{ _('Save Changes') }}</button>
<div class="clear"></div>
</form>

<h3>Add Roles for Any User</h3>
<h3 class="m-bottom">{{ _('Add Roles for Any User') }}</h3>
<form id="addform" method="POST">
{{ authz_add_table(c.roles) }}
<button type="submit" name="add" class="btn btn-primary">Add Role</button>
<button type="submit" name="add" class="btn btn-primary">{{ _('Add Role') }}</button>
<div class="clear"></div>
</form>

Expand Down
2 changes: 1 addition & 1 deletion ckan/templates/admin/config.html
Expand Up @@ -7,7 +7,7 @@
{% block primary %}
<article class="module">
<div class="module-content">
<h1 class="page-heading">{{ _('Configuration Settings') }}</h1>
{% snippet 'admin/snippets/header.html', action=c.action %}

<form method='post' action="" class="form-horizontal">
{{ autoform.generate(form_items, data, errors) }}
Expand Down
3 changes: 1 addition & 2 deletions ckan/templates/admin/index.html
Expand Up @@ -8,8 +8,7 @@
{% block primary %}
<article class="module">
<div class="module-content">
<h1 class="page-heading">{{ _('Current Sysadmins') }}</h1>
<p>{% set url=h.url_for(controller='admin', action='authz') %}{% trans %}You can change sysadmins on the <a href="{{ url }}">authorization page</a>.{% endtrans %}</p>
{% snippet 'admin/snippets/header.html', action=c.action %}
<ul>
{% for user in c.sysadmins %}
<li py:for="user in c.sysadmins">
Expand Down
13 changes: 13 additions & 0 deletions ckan/templates/admin/snippets/header.html
@@ -0,0 +1,13 @@
<h1 class="page-heading">{{ _('Administration') }}</h1>

<ul class="nav nav-tabs">
<li{% if action == 'index' %} class="active"{% endif %}>
<a href="{{ h.url_for(controller='admin', action='index') }}">{{ _('Sysadmins') }}</a>
</li>
<li{% if action == 'authz' %} class="active"{% endif %}>
<a href="{{ h.url_for(controller='admin', action='authz') }}">{{ _('User Roles') }}</a>
</li>
<li{% if action == 'config' %} class="active"{% endif %}>
<a href="{{ h.url_for(controller='admin', action='config') }}">{{ _('Config settings') }}</a>
</li>
</ul>
2 changes: 2 additions & 0 deletions ckan/templates/base.html
Expand Up @@ -106,6 +106,8 @@
{#
The scripts block allows you to add additonal scripts to the page. Use the
super() function to load the default scripts before/after your own.
NOTE: Scripts should be loaded by the {% resource %} tag except
in very special circumstances DO NOT USE THIS METHOD FOR ADDING SCRIPTS.

Example:

Expand Down
6 changes: 1 addition & 5 deletions ckan/templates/package/new_resource.html
Expand Up @@ -23,11 +23,7 @@ <h2 class="module-heading"><i class="icon-large icon-info-sign"></i> {{ _('What

{% block scripts %}
{{ super() }}
<script src="{% url_for_static "/base/vendor/jquery.ui.widget.js" %}"></script>
<script src="{% url_for_static "/base/vendor/jquery-fileupload/jquery.iframe-transport.js" %}"></script>
<script src="{% url_for_static "/base/vendor/jquery-fileupload/jquery.fileupload.js" %}"></script>
<script src="{% url_for_static "/base/javascript/modules/resource-form.js" %}"></script>
<script src="{% url_for_static "/base/javascript/modules/resource-upload-field.js" %}"></script>
{% resource 'vendor/fileupload' %}
{% endblock %}

{% block breadcrumb_content %}
Expand Down
1 change: 1 addition & 0 deletions ckan/templates/package/resource_read.html
Expand Up @@ -115,3 +115,4 @@ <h2 class="module-heading"><i class="icon-medium icon-info-sign"></i> Resource I
{% snippet "snippets/social.html" %}
{% endblock %}
{% endblock %}

19 changes: 0 additions & 19 deletions ckan/templates/snippets/recline-extra-footer.html

This file was deleted.

0 comments on commit a50f999

Please sign in to comment.