diff --git a/ckanext/odsh/helpers.py b/ckanext/odsh/helpers.py index 0e85161bb30a7f90ca2e27050389614fbcf05876..302a5a32e75ef7247bab3bb6eeed860d635c969d 100644 --- a/ckanext/odsh/helpers.py +++ b/ckanext/odsh/helpers.py @@ -1,10 +1,13 @@ import logging import traceback import ast +import ckan.logic as logic +import ckan.model as model +from ckan.common import c +get_action = logic.get_action log = logging.getLogger(__name__) - def odsh_openness_score_dataset_html(dataset): score = 0 #dataset = json.loads(dataset) @@ -23,3 +26,12 @@ def odsh_openness_score_dataset_html(dataset): log.error('Error while calculating openness score %s: %s\nException: %s', e.__class__.__name__, unicode(e), traceback.format_exc()) return score + +def odsh_get_resource_views(pkg_dict, resource): + + context = {'model': model, 'session': model.Session, + 'user': c.user, 'for_view': True, + 'auth_user_obj': c.userobj} + return get_action('resource_view_list')( + context, {'id': resource['id']}) + diff --git a/ckanext/odsh/i18n/de/LC_MESSAGES/ckanext-odsh.mo b/ckanext/odsh/i18n/de/LC_MESSAGES/ckanext-odsh.mo index b5f7363d12c70bcf124ea3f4569043af2c10a2d0..4523fa3c101440a982b226ba25a1f43ef96a5e1e 100644 Binary files a/ckanext/odsh/i18n/de/LC_MESSAGES/ckanext-odsh.mo and b/ckanext/odsh/i18n/de/LC_MESSAGES/ckanext-odsh.mo differ diff --git a/ckanext/odsh/i18n/de/LC_MESSAGES/ckanext-odsh.po b/ckanext/odsh/i18n/de/LC_MESSAGES/ckanext-odsh.po index a92d3053d430d38fef8e85644eb117bfeb0f9643..1e3892410e3a17d18d7b8f9e791f1cc7f6c0d5ae 100644 --- a/ckanext/odsh/i18n/de/LC_MESSAGES/ckanext-odsh.po +++ b/ckanext/odsh/i18n/de/LC_MESSAGES/ckanext-odsh.po @@ -19,6 +19,33 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Generated-By: Babel 2.3.4\n" +msgid "Organizations" +msgstr "Herausgeber" + +#: ckan/templates/snippets/search_result_text.html:29 +msgid "{number} organization found" +msgid_plural "{number} organizations found" +msgstr[0] "{number} Herausgeber" +msgstr[1] "{number} Herausgeber" + +msgid "Login" +msgstr "Login" + +msgid "do Login" +msgstr "Einloggen" + +msgid "Forgotten your password?" +msgstr "Passwort vergessen" + +msgid "change password" +msgstr "Passwort ändern" + +msgid "Username" +msgstr "Name" + +msgid "enter password" +msgstr "Passwort eingeben" + msgid "odsh Create Dataset" msgstr "Datensatz-Upload" diff --git a/ckanext/odsh/plugin.py b/ckanext/odsh/plugin.py index aad1ae8c672d986108ae2687cfb0a64be58f54fb..501d67c960da6a6178f2f444bb9f71fd8dc650da 100644 --- a/ckanext/odsh/plugin.py +++ b/ckanext/odsh/plugin.py @@ -6,6 +6,7 @@ from ckan.lib.plugins import DefaultDatasetForm from ckan.common import OrderedDict import ckan.lib.helpers as helpers import helpers as odsh_helpers +from routes.mapper import SubMapper import logging @@ -85,6 +86,7 @@ class OdshPlugin(plugins.SingletonPlugin, DefaultTranslation, DefaultDatasetForm 'odsh_group_id_selected': odsh_group_id_selected, 'odsh_get_facet_items_dict': odsh_get_facet_items_dict, 'odsh_openness_score_dataset_html': odsh_helpers.odsh_openness_score_dataset_html, + 'odsh_get_resource_views': odsh_helpers.odsh_get_resource_views } def before_map(self, map): @@ -122,7 +124,8 @@ class OdshPlugin(plugins.SingletonPlugin, DefaultTranslation, DefaultDatasetForm # # toolkit.get_converter('not_empty'), # toolkit.get_converter('odsh_convert_groups_string')] }) schema['resources'].update({ - 'url' : [ toolkit.get_converter('not_empty') ] + 'url' : [ toolkit.get_converter('not_empty') ], + 'name' : [ toolkit.get_converter('not_empty') ] }) def create_package_schema(self): diff --git a/ckanext/odsh/public/odsh.css b/ckanext/odsh/public/odsh.css index 12ea178d960780d2538869daa37563ca147f8298..d03a801ae385739142deda7ba249928ae110edc2 100644 --- a/ckanext/odsh/public/odsh.css +++ b/ckanext/odsh/public/odsh.css @@ -51,7 +51,10 @@ input, button, select, textarea { } - +h1{ + color:#003064; + font-weight: normal ; +} /* css for searchresults */ @@ -88,6 +91,14 @@ input, button, select, textarea { padding: 0; } +.page-heading{ + font-size: 25px; + color: #003064; + font-weight: 300; + border-bottom: 4px solid #dbdbdb; + padding-bottom: 10px +} + input[type=radio], input[type=checkbox] { top: 0px; } @@ -189,10 +200,11 @@ input[type=radio], input[type=checkbox] { /* checkbox customize trick, see: https://stackoverflow.com/questions/24322599/css-why-cannot-change-checkbox-color-whatever-i-do */ -input[type=checkbox] { +.facet_label input[type=checkbox] { display:none; } +/* input[type=checkbox] + label.checkbox, */ input[type=checkbox] + label.mylabel { background: #fff; border: 1px solid white; @@ -200,8 +212,15 @@ input[type=checkbox] + label.mylabel { width: 8px; display: inline-block; padding: 0 0 0 0px; + margin-bottom: 0px; + min-height: 8px; } +/* input[type=checkbox] + label.checkbox{ + + border: 1px solid black; +} */ +/* input[type=checkbox]:checked + label.checkbox, */ input[type=checkbox]:checked + label.mylabel { background: url(/base/images/checked.png); background-color: #fff; @@ -209,10 +228,19 @@ input[type=checkbox]:checked + label.mylabel { border: 1px solid black; height: 8px; width: 8px; + min-height: 8px; display:inline-block; padding: 0 0px 0 0px; + margin-bottom: 0px; } +/* .checklabel .controls > .checkbox:first-child { + padding-top: 0px; +} */ +.checklabel input[type="checkbox"] +{ + float: inherit; +} label.mylabel { margin-right: 3px; @@ -473,6 +501,15 @@ label:after { background-color: #0089ca; } +.btn-forget-password{ + background-color: white; + font-size: 10pt; + padding:2px 10px; + margin-left: 2px; + margin-top: 4px; + display: inline-block; +} + /* remove icon in upload button */ .image-upload .fa-cloud-upload:before { content: unset; @@ -606,4 +643,9 @@ label:after { } .create-dataset-form{ - width: 50%;} \ No newline at end of file + width: 50%;} + +.organization-image{ + height:100px; + max-width: unset; +} \ No newline at end of file diff --git a/ckanext/odsh/templates/header.html b/ckanext/odsh/templates/header.html index 6970982b8c3074eb37c806b66eb577320978a485..a79412dd48bdd3e0325b44592abc661f75968660 100644 --- a/ckanext/odsh/templates/header.html +++ b/ckanext/odsh/templates/header.html @@ -1,73 +1,91 @@ {% block header_wrapper %} {% block header_account %} <header class="navbar navbar-static-top masthead"> - {% block header_debug %} - {% if g.debug and not g.debug_supress_header %} - <div class="debug">Controller : {{ c.controller }}<br />Action : {{ c.action }}</div> - {% endif %} - {% endblock %} - <div class="container"> - <button data-target=".nav-collapse" data-toggle="collapse" class="btn btn-navbar" type="button"> - <span class="fa fa-bars"></span> - </button> - {# The .header-image class hides the main text and uses image replacement for the title #} - <div class='row'> + {% block header_debug %} + {% if g.debug and not g.debug_supress_header %} + <div class="debug">Controller : {{ c.controller }}<br />Action : {{ c.action }}</div> + {% endif %} + {% endblock %} + <div class="container"> + <button data-target=".nav-collapse" data-toggle="collapse" class="btn btn-navbar" type="button"> + <span class="fa fa-bars"></span> + </button> + {# The .header-image class hides the main text and uses image replacement for the title #} + <div class='row'> - <div class='span3 span-navigation'> - <hgroup class="{{ g.header_class }} pull-left"> + <div class='span3 span-navigation'> + <hgroup class="{{ g.header_class }} pull-left"> - {% block header_logo %} - {% if g.site_logo %} - <a class="logo" href="{{ h.url_for('home') }}"><img src="{{ h.url_for_static_or_external(g.site_logo) }}" - alt="{{ g.site_title }}" title="{{ g.site_title }}" /></a> - {% else %} - <h1> - <a href="{{ h.url_for('home') }}">{{ g.site_title }}</a> - </h1> - {% if g.site_description %}<h2>{{ g.site_description }}</h2>{% endif %} - {% endif %} - {% endblock %} - </hgroup> - </div> + {% block header_logo %} + {% if g.site_logo %} + <a class="logo" href="{{ h.url_for('home') }}"><img src="{{ h.url_for_static_or_external(g.site_logo) }}" alt="{{ g.site_title }}" + title="{{ g.site_title }}" /></a> + {% else %} + <h1> + <a href="{{ h.url_for('home') }}">{{ g.site_title }}</a> + </h1> + {% if g.site_description %}<h2>{{ g.site_description }}</h2>{% endif %} + {% endif %} + {% endblock %} + </hgroup> + </div> - <div class='span9 span-navigation pull-right'> - {% snippet "snippets/language_selector.html" %} + <div class='span9 span-navigation pull-right'> + {% snippet "snippets/language_selector.html" %} - {% block header_site_search %} - <div class='top-search-form'> - <form class="section site-search simple-input" action="{% url_for controller='package', action='search' %}" - method="get"> - <div class="field"> - <input id="field-sitewide-search" type="text" name="q" placeholder="{{ _('Suchbegriff') }}" /> - <button class="btn-search" type="submit"> - </div> - </form> - </div> - {% endblock %} + {% block header_site_search %} + <div class='top-search-form'> + <form class="section site-search simple-input" action="{% url_for controller='package', action='search' %}" + method="get"> + <div class="field"> + <input id="field-sitewide-search" type="text" name="q" placeholder="{{ _('Suchbegriff') }}" /> + <button class="btn-search" type="submit"> + </div> + </form> </div> - + {% endblock %} </div> + </div> - - <div class="container navigation-container"> - <div class='row navigation-row'> - <div class="nav-collapse collapse"> - <nav class="section navigation"> - <ul class="nav nav-pills"> - {% block header_site_navigation_tabs %} - {{ h.build_nav_main( - ('home', _('Startseite')), - ('search', _('Daten')), - ('organizations_index', _('Herausgeber')), - ('info_page', _('Infos')) - ) }} - {% endblock %} - </ul> - </nav> - {% endblock %} - </div> + </div> + + <div class="container navigation-container"> + <div class='row navigation-row'> + <div class="nav-collapse collapse"> + <nav class="section navigation"> + <ul class="nav nav-pills"> + {% block header_site_navigation_tabs %} + {{ h.build_nav_main( + ('home', _('Startseite')), + ('search', _('Daten')), + ('organizations_index', _('Herausgeber')), + ('info_page', _('Infos')) + ) }} + {% endblock %} + </ul> + </nav> + {% endblock %} </div> + <nav class="navigation pull-right"> + <ul class="nav nav-pills "> + {% set clazz='active' if c.action=='login' else ''%} + {% if c.userobj %} + <li class='{{clazz}}'> + <a href="{{ h.url_for('/user/_logout') }}" title="logout"> + <span class="text">Logout</span> + </a> + </li> + {% else %} + <li class='{{clazz}}'> + <a href="{{ h.url_for('/user/login') }}" title="login"> + <span class="text">Login</span> + </a> + </li> + {% endif %} + </nav> + </ul> </div> -</div> + </div> + </div> </header> -{% endblock %} +{% endblock %} \ No newline at end of file diff --git a/ckanext/odsh/templates/organization/index.html b/ckanext/odsh/templates/organization/index.html new file mode 100644 index 0000000000000000000000000000000000000000..873dc798b8d9848cf4c03b29be0e148a82c32d4f --- /dev/null +++ b/ckanext/odsh/templates/organization/index.html @@ -0,0 +1,47 @@ +{% extends "page.html" %} + +{% block subtitle %}{{ _('Organizations') }}{% endblock %} + +{% block breadcrumb_content %} +<li class="active">{% link_for _('Organizations'), controller='organization', action='index' %}</li> +{% endblock %} + +{% block page_header %}{% endblock %} + +{% block page_primary_action %} +{% if h.check_access('organization_create') %} +{% link_for _('Add Organization'), controller='organization', action='new', class_='btn btn-primary', +icon='plus-square' %} +{% endif %} +{% endblock %} + +{% block primary_content_inner %} +<h1 class="hide-heading">{% block page_heading %}{{ _('Organizations') }}{% endblock %}</h1> +{% block organizations_search_form %} +<div class="row"> + {% snippet 'snippets/search_form.html', form_id='organization-search-form', type='organization', query=c.q, + sorting_selected=c.sort_by_selected, count=c.page.item_count, placeholder=_('Search organizations...'), + show_empty=request.params, no_bottom_border=true if c.page.items, hide_sorting=true %} +</div> +{% endblock %} +{% block organizations_list %} +{% if c.page.items or request.params %} +{% if c.page.items %} +{% snippet "organization/snippets/odsh_organization_list.html", organizations=c.page.items %} +{% endif %} +{% else %} +<p class="empty"> + {{ _('There are currently no organizations for this site') }}. + {% if h.check_access('organization_create') %} + {% link_for _('How about creating one?'), controller='organization', action='new' %}</a>. + {% endif %} +</p> +{% endif %} +{% endblock %} +{% block page_pagination %} +{{ c.page.pager(q=c.q or '', sort=c.sort_by_selected or '') }} +{% endblock %} +{% endblock %} + +{% block secondary%} +{% endblock %} \ No newline at end of file diff --git a/ckanext/odsh/templates/organization/snippets/odsh_organization_list.html b/ckanext/odsh/templates/organization/snippets/odsh_organization_list.html new file mode 100644 index 0000000000000000000000000000000000000000..02fd6618c38ee4566b7e6c6c3be7cc6d93117b8d --- /dev/null +++ b/ckanext/odsh/templates/organization/snippets/odsh_organization_list.html @@ -0,0 +1,18 @@ +{# +Display a grid of organization items. + +organizations - A list of organizations. + +Example: + +{% snippet "organization/snippets/organization_list.html" %} + +#} +{% block organization_list %} +{% block organization_list_inner %} +{% for organization in organizations %} +{% snippet "organization/snippets/organization_item.html", organization=organization, position=loop.index, +show_capacity=show_capacity %} +{% endfor %} +{% endblock %} +{% endblock %} \ No newline at end of file diff --git a/ckanext/odsh/templates/organization/snippets/organization_item.html b/ckanext/odsh/templates/organization/snippets/organization_item.html new file mode 100644 index 0000000000000000000000000000000000000000..ca7ea5c492d955caaedaf487ac394c0e89ee79dc --- /dev/null +++ b/ckanext/odsh/templates/organization/snippets/organization_item.html @@ -0,0 +1,28 @@ +{# +Renders a media item for a organization. This should be used in a list. + +organization - A organization dict. + +Example: + +<ul class="media-grid"> + {% for organization in organizations %} + {% snippet "organization/snippets/organization_item.html", organization=organization %} + {% endfor %} +</ul> +#} +{% set url = h.url_for(organization.type ~ '_read', action='read', id=organization.name) %} +<div class="row"> + <div class="span11"> + <p>{{ organization.display_name }}</p> + {% if organization.description %} + <p>{{ h.markdown_extract(organization.description, extract_length=300) }}</p> + {% endif %} + </div> + <div class="span1"> + <a href="{{ url }}" title="{{ _('View {organization_name}').format(organization_name=organization.display_name) }}"> + <img src="{{ organization.image_display_url or h.url_for_static('/base/images/placeholder-organization.png') }}" + alt="{{ organization.name }}" class="organization-image"> + </a> + </div> +</div> \ No newline at end of file diff --git a/ckanext/odsh/templates/snippets/search_result_text.html b/ckanext/odsh/templates/snippets/search_result_text.html new file mode 100644 index 0000000000000000000000000000000000000000..a764d458e0d529896f88161f3f0f08d5ea8f3ad6 --- /dev/null +++ b/ckanext/odsh/templates/snippets/search_result_text.html @@ -0,0 +1,47 @@ +{# + +Displays a test for results of a search. + +query - The text that was searched for +count - The number of results for the search +type - Search result type (dataset, group, organization) + +Example: + +{% snippet 'snippets/search_result_text.html', query=query, count=count, type='dataset' %} + +#} +{% if type == 'dataset' %} +{% set text_query = ungettext('{number} dataset found for "{query}"', '{number} datasets found for "{query}"', count) +%} +{% set text_query_none = _('No datasets found for "{query}"') %} +{% set text_no_query = ungettext('{number} dataset found', '{number} datasets found', count) %} +{% set text_no_query_none = _('No datasets found') %} + +{% elif type == 'group' %} +{% set text_query = ungettext('{number} group found for "{query}"', '{number} groups found for "{query}"', count) %} +{% set text_query_none = _('No groups found for "{query}"') %} +{% set text_no_query = ungettext('{number} group found', '{number} groups found', count) %} +{% set text_no_query_none = _('No groups found') %} + +{% elif type == 'organization' %} +{% set text_query = ungettext('{number} organization found for "{query}"', '{number} organizations found for +"{query}"', count) %} +{% set text_query_none = _('No organizations found for "{query}"') %} +{% set text_no_query = ungettext('{number} organization found', '{number} organizations found', count) %} +{% set text_no_query_none = _('No organizations found') %} +{%- endif -%} + +{% if query %} +{%- if count -%} +{{ text_query.format(number=h.localised_number(count), query=query) }} +{%- else -%} +{{ text_query_none.format(query=query) }} +{%- endif -%} +{%- else -%} +{%- if count -%} +{{ text_no_query.format(number=h.localised_number(count)) }} +{%- else -%} +{{ text_no_query_none }} +{%- endif -%} +{%- endif -%} \ No newline at end of file diff --git a/ckanext/odsh/templates/user/login.html b/ckanext/odsh/templates/user/login.html index cd389e28ec3ba4156b4658cc2898b70bbf7de3dc..874fd1bf692c79658d66e7946c0a69d8eb6f4e3e 100644 --- a/ckanext/odsh/templates/user/login.html +++ b/ckanext/odsh/templates/user/login.html @@ -1,6 +1,6 @@ {% extends "page.html" %} -{% block subtitle %}{{ _('Login') }}{% endblock %} +{% block subtitle %} {{ _('Login') }} {% endblock %} {% block breadcrumb_content %} <li class="active">{{ h.nav_link(_('Login'), controller='user', action='login') }}</li> @@ -9,7 +9,7 @@ {% block primary_content %} <section class="module"> <div class="module-content"> - <h1 class="page-heading">{% block page_heading %}{{ _('Login') }}{% endblock %}</h1> + <h2 class="page-heading">{% block page_heading %}{{ _('Login') }}{% endblock %}</h2> {% block form %} {% snippet "user/snippets/login_form.html", action=c.login_handler, error_summary=error_summary %} {% endblock %} @@ -18,37 +18,15 @@ {% endblock %} {% block secondary_content %} -{% if h.check_access('user_create') %} -{% block help_register %} -<section class="module module-narrow module-shallow"> - {% block help_register_inner %} - <h2 class="module-heading">{{ _('Need an Account?') }}</h2> - <div class="module-content"> - <p>{% trans %}Then sign right up, it only takes a minute.{% endtrans %}</p> - <p class="action"> - {% block help_register_button %} - <a class="btn" href="{{ h.url_for(controller='user', action='register') }}">{{ _('Create an Account') }}</a> - {% endblock %} - </p> - </div> - {% endblock %} -</section> -{% endblock %} -{% endif %} {% block help_forgotten %} <section class="module module-narrow module-shallow"> {% block help_forgotten_inner %} - <h2 class="module-heading">{{ _('Forgotten your password?') }}</h2> - <div class="module-content"> - <p>{% trans %}No problem, use our password recovery form to reset it.{% endtrans %}</p> - <p class="action"> - {% block help_forgotten_button %} - <a class="btn" href="{{ h.url_for(controller='user', action='request_reset') }}">{{ _('Forgot your - password?') }}</a> - {% endblock %} - </p> - </div> + <span>{{ _('Forgotten your password?') }}:</span> + {% block help_forgotten_button %} + <a class="btn-forget-password" href="{{ h.url_for(controller='user', action='request_reset') }}"> + {{ _('change password') }}</a> + {% endblock %} {% endblock %} </section> {% endblock %} diff --git a/ckanext/odsh/templates/user/snippets/login_form.html b/ckanext/odsh/templates/user/snippets/login_form.html new file mode 100644 index 0000000000000000000000000000000000000000..07e7d6f307eb7a6df001985f0b5d23cf633126e3 --- /dev/null +++ b/ckanext/odsh/templates/user/snippets/login_form.html @@ -0,0 +1,44 @@ +{# +Renders the login form. + +action - The url that the form should be submitted to. +error_summary - A tuple/list of form errors. + +Example: + +{% snippet "user/snippets/login_form.html", action=c.login_handler, error_summary=error_summary %} + +#} +{% import 'macros/form.html' as form %} + +{% set username_error = true if error_summary %} +{% set password_error = true if error_summary %} + +<form action="{{ action }}" method="post" class="form"> + {{ form.errors(errors=error_summary) }} + + <div class='row'> + <div class="span6"> + {{ form.input('login', label=_("Username"), id='field-login', value="", error=username_error, + classes=["control-full"], placeholder=_('enter name')) }} + </div> + </div> + + <div class='row'> + <div class="span6"> + {{ form.input('password', label=_("Password"), id='field-password', type="password", value="", + error=password_error, classes=["control-full"],placeholder=_('enter password')) }} + </div> + </div> + + {{ form.checkbox('remember', classes=["checklabel"], label=_("Remember me"), id='field-remember', checked=true, + value="63072000") }} + + <div class='row'> + <div class="form-actions span6"> + {% block login_button %} + <button class="btn btn-primary" type="submit">{{ _('do Login') }}</button> + {% endblock %} + </div> + </div> +</form> \ No newline at end of file