Skip to content

Commit

Permalink
Merge branch '2375-demo-theme-development' of github.com:okfn/ckan in…
Browse files Browse the repository at this point in the history
…to 2375-demo-theme-development
  • Loading branch information
tobes committed Aug 30, 2012
2 parents e947a25 + db28796 commit f183ff3
Show file tree
Hide file tree
Showing 20 changed files with 169 additions and 19 deletions.
13 changes: 7 additions & 6 deletions ckanext/organizations/controllers.py
Expand Up @@ -51,8 +51,9 @@ def _send_application( self, group, reason ):
'requester': c.userobj,
'reason' : reason
}
email_msg = render("email/join_publisher_request.txt", extra_vars=extra_vars,
loader_class=NewTextTemplate)
email_msg = render("organizations/email/join_publisher_request.txt",
extra_vars=extra_vars,
loader_class=NewTextTemplate)

try:
for (name,recipient) in recipients:
Expand Down Expand Up @@ -90,8 +91,8 @@ def apply(self, id=None, data=None, errors=None, error_summary=None):
data.update(request.params)

vars = {'data': data, 'errors': errors, 'error_summary': error_summary}
c.form = render('organization_apply_form.html', extra_vars=vars)
return render('organization_apply.html')
c.form = render('organizations/apply_form.html', extra_vars=vars)
return render('organizations/apply.html')

def _add_users( self, group, parameters ):
if not group:
Expand Down Expand Up @@ -161,9 +162,9 @@ def users(self, id, data=None, errors=None, error_summary=None):
for user in c.group.members_of_type( model.User, 'editor' ).all() )

vars = {'data': data, 'errors': errors, 'error_summary': error_summary}
c.form = render('organization_users_form.html', extra_vars=vars)
c.form = render('organizations/users_form.html', extra_vars=vars)

return render('organization_users.html')
return render('organizations/users.html')

def _add_publisher_list(self):
c.possible_parents = model.Session.query(model.Group).\
Expand Down
12 changes: 6 additions & 6 deletions ckanext/organizations/forms.py
Expand Up @@ -80,28 +80,28 @@ def new_template(self):
Returns a string representing the location of the template to be
rendered for the new page
"""
return 'organization_new.html'
return 'organizations/new.html'

def index_template(self):
"""
Returns a string representing the location of the template to be
rendered for the index page
"""
return 'organization_index.html'
return 'organizations/index.html'

def read_template(self):
"""
Returns a string representing the location of the template to be
rendered for the read page
"""
return 'organization_read.html'
return 'organizations/read.html'

def history_template(self):
"""
Returns a string representing the location of the template to be
rendered for the read page
"""
return 'organization_history.html'
return 'organizations/history.html'

def edit_template(self):
"""
Expand All @@ -115,7 +115,7 @@ def group_form(self):
Returns a string representing the location of the template to be
rendered. e.g. "forms/group_form.html".
"""
return 'organization_form.html'
return 'organizations/form.html'

def group_types(self):
"""
Expand Down Expand Up @@ -235,7 +235,7 @@ def history_template(self):
return 'package/history.html'

def package_form(self):
return 'organization_package_form.html'
return 'organizations/package_form.html'

def db_to_form_schema(self):
'''This is an interface to manipulate data from the database
Expand Down
42 changes: 42 additions & 0 deletions ckanext/organizations/templates/organizations/form.html
@@ -0,0 +1,42 @@
{% extends "group/snippets/group_form.html" %}

{#
As the form is rendered as a seperate page we take advantage of this by
overriding the form blocks depending on the current context
#}
{% block dataset_fields %}
{% if action == "edit" %}{{ super() }}{% endif %}
{% endblock %}

{% block custom_fields %}
{% if action == "edit" %}{{ super() }}{% endif %}
{% endblock %}

{% block save_text %}
{%- if action == "edit" -%}
{{ _('Update Organization') }}
{%- else -%}
{{ _('Create Organization') }}
{%- endif -%}
{% endblock %}

{% block delete_button %}
{% if action == "edit" %}{{ super() }}{% endif %}
{% endblock %}

{% block basic_fields %}
{% set attrs = {'data-module': 'slug-preview-target'} %}
{{ form.input('title', label=_('Title'), id='field-title', placeholder=_('My Organization'), value=data.title, error=errors.title, classes=['control-full'], attrs=attrs) }}

{% set prefix = h.url_for(controller='group', action='read', id='') %}
{% set domain = h.url_for(controller='group', action='read', id='', qualified=true) %}
{% set domain = domain|replace("http://", "")|replace("https://", "") %}
{% set attrs = {'data-module': 'slug-preview-slug', 'data-module-prefix': domain, 'data-module-placeholder': '<organization>'} %}

{{ form.prepend('name', label=_('URL'), prepend=prefix, id='field-url', placeholder=_('my-organization'), value=data.name, error=errors.name, attrs=attrs) }}

{{ form.markdown('description', label=_('Description'), id='field-description', placeholder=_('A little information about my organization...'), value=data.description, error=errors.description) }}

{{ form.input('image_url', label=_('Image URL'), id='field-image-url', type='url', placeholder=_('http://example.com/my-image.jpg'), value=data.image_url, error=errors.image_url, classes=['control-full']) }}

{% endblock %}
41 changes: 41 additions & 0 deletions ckanext/organizations/templates/organizations/index.html
@@ -0,0 +1,41 @@
{% extends "page.html" %}

{% block subtitle %}{{ _('Organization') }}{% endblock %}

{% block breadcrumb_content %}
<li class="active">{% link_for _('Organizations'), controller='group', action='index' %}</li>
{% endblock %}

{% block actions_content %}
<li>{% link_for _('Add Organization'), controller='group', action='new', class_='btn', icon='plus' %}</li>
{% endblock %}

{% block primary_content %}
<div class="module">
<div class="module-content">
<h1 class="page-heading">{{ _('Organizations') }}</h1>
{% if c.page.items %}
{% snippet "group/snippets/group_list.html", groups=c.page.items %}
{% else %}
<p class="empty">
{{ _('There are currently no organizations for this site') }}.
{% if h.check_access('package_create') %}
{% link_for _('How about creating one?'), controller='group', action='new' %}</a>.
{% endif %}
</p>
{% endif %}
</div>
{{ c.page.pager() }}
</div>
{% endblock %}

{% block secondary_content %}
<div class="module module-narrow module-shallow">
<h2 class="module-heading"><i class="icon-large icon-info-sign"></i> {{ _('What are Organizations?') }}</h2>
<div class="module-content">
{% trans %}
<p>Organizations allow you to add both users and datasets to it in order to control who can access and manage your datasets</p>
{% endtrans %}
</div>
</div>
{% endblock %}
19 changes: 19 additions & 0 deletions ckanext/organizations/templates/organizations/new.html
@@ -0,0 +1,19 @@
{% extends "group/base_form_page.html" %}

{% block subtitle %}{{ _('Create an organization') }}{% endblock %}

{% block breadcrumb_link %}{{ h.nav_link(_('Create Organization'), controller='group', action='edit', id=c.group.name) }}{% endblock %}

{% block page_heading %}{{ _('Create an organization') }}{% endblock %}

{% block secondary_content %}
<div class="module module-narrow module-shallow">
<h2 class="module-heading"><i class="icon-large icon-info-sign"></i> {{ _('What are Organizations?') }}</h2>
<div class="module-content">
{% trans %}
<p>An organization can be set-up to specify which users have permission to add or
remove datasets from it.</p>
{% endtrans %}
</div>
</div>
{% endblock %}
47 changes: 47 additions & 0 deletions ckanext/organizations/templates/organizations/read.html
@@ -0,0 +1,47 @@
{% extends "page.html" %}

{% block subtitle %}{{ c.group_dict.display_name }}{% endblock %}

{% block breadcrumb_content %}
<li>{% link_for _('Organizations'), controller='group', action='index' %}</li>
<li class="active">{% link_for c.group_dict.display_name|truncate(35), controller='group', action='read', id=c.group_dict.name %}</li>
{% endblock %}

{% block actions_content %}
{% if h.check_access('group_update', {'id': c.group.id}) %}
<li>{% link_for _('Add Dataset to Organization'), controller='package', action='new', group=c.group_dict.id, class_='btn', icon='plus' %}</li>
<li>{% link_for _('Edit'), controller='group', action='edit', id=c.group_dict.name, class_='btn', icon='cog' %}</li>
<li>{% link_for _('Manage Users'), controller='ckanext.organizations.controllers:OrganizationController', action='users', id=c.group_dict.name, class_='btn', icon='cog' %}</li>
{% endif %}
{# <li>{% link_for _('History'), controller='group', action='history', id=c.group_dict.name, class_='btn', icon='undo' %}</li> #}
{% endblock %}

{% block primary_content %}
<section class="module">
<div class="module-content">
{% include "package/snippets/search_form.html" %}
</div>
{{ c.page.pager(q=c.q) }}
</section>
{% endblock %}

{% block secondary_content %}
{% snippet 'snippets/group.html', group=c.group_dict %}

<section class="module module-narrow module-shallow">
<h2 class="module-heading"><i class="icon-large icon-user"></i> {{ _('Administrators') }}</h2>
<ul class="nav nav-simple">
{% for admin in c.group_admins %}
<li class="nav-item image">{{ h.linked_user(admin, 30) }}</li>
{% endfor %}
</ul>
</section>

{{ h.snippet('snippets/facet_list.html', title='Tags', name='tags', extras={'id':c.group_dict.id}) }}
{{ h.snippet('snippets/facet_list.html', title='Formats', name='res_format', extras={'id':c.group_dict.id}) }}
{% endblock %}

{% block links %}
{{ super() }}
{% include "group/snippets/feeds.html" %}
{% endblock %}
Empty file.
Empty file.
Expand Up @@ -10,6 +10,6 @@
${Markup(c.form)}
</div>

<xi:include href="organization_layout.html" />
<xi:include href="layout.html" />
</html>

Expand Up @@ -55,5 +55,5 @@ <h3 py:if="c.error" class="form-errors">
href="${h.url(controller='group', action='history', id=c.group_dict['name'], format='atom', days=7)}" />
</py:def>

<xi:include href="organization_layout.html" />
<xi:include href="layout.html" />
</html>
Expand Up @@ -20,5 +20,5 @@ <h3>What Are Organizations?</h3>
${c.page.pager()}
</div>

<xi:include href="organization_layout.html" />
<xi:include href="layout.html" />
</html>
Expand Up @@ -40,5 +40,5 @@
</ul>
</py:match>

<xi:include href="layout.html" />
<xi:include href="../layout.html" />
</html>
Expand Up @@ -9,6 +9,6 @@
${Markup(c.form)}
</div>

<xi:include href="organization_layout.html" />
<xi:include href="organizations/layout.html" />
</html>

Expand Up @@ -77,5 +77,5 @@ <h3>Datasets</h3>
</div>
</py:match>

<xi:include href="organization_layout.html" />
<xi:include href="organizations/layout.html" />
</html>
Expand Up @@ -10,7 +10,7 @@
${Markup(c.form)}
</div>

<xi:include href="organization_layout.html" />
<xi:include href="organizations/layout.html" />

</html>

0 comments on commit f183ff3

Please sign in to comment.