Skip to content

Commit

Permalink
[#626] Tweaks dashboard to have 3 new subpages
Browse files Browse the repository at this point in the history
A my datasets, my orgs and my groups pages. Each one showing ownership of the
relevant items within it.

Conflicts:

	ckan/templates/user/dashboard.html
  • Loading branch information
johnmartin authored and amercader committed Jul 1, 2013
1 parent 2676bb2 commit f7ec8a8
Show file tree
Hide file tree
Showing 8 changed files with 162 additions and 35 deletions.
8 changes: 7 additions & 1 deletion ckan/config/routing.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,9 +346,15 @@ def make_map():
m.connect('/user/activity/{id}/{offset}', action='activity')
m.connect('user_activity_stream', '/user/activity/{id}',
action='activity', ckan_icon='time')
m.connect('/dashboard/{offset}', action='dashboard')
m.connect('user_dashboard', '/dashboard', action='dashboard',
ckan_icon='list')
m.connect('user_dashboard_datasets', '/dashboard/datasets',
action='dashboard_datasets', ckan_icon='sitemap')
m.connect('user_dashboard_groups', '/dashboard/groups',
action='dashboard_groups', ckan_icon='group')
m.connect('user_dashboard_organizations', '/dashboard/organizations',
action='dashboard_organizations', ckan_icon='building')
m.connect('/dashboard/{offset}', action='dashboard')
m.connect('user_follow', '/user/follow/{id}', action='follow')
m.connect('/user/unfollow/{id}', action='unfollow')
m.connect('user_followers', '/user/followers/{id:.*}',
Expand Down
27 changes: 27 additions & 0 deletions ckan/controllers/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,33 @@ def dashboard(self, id=None, offset=0):

return render('user/dashboard.html')

def dashboard_datasets(self):
context = {'model': model, 'session': model.Session,
'user': c.user or c.author, 'for_view': True}
data_dict = {'user_obj': c.userobj}
self._setup_template_variables(context, data_dict)
return render('user/dashboard_datasets.html')

def dashboard_organizations(self):
context = {'model': model, 'session': model.Session,
'user': c.user or c.author, 'for_view': True}
data_dict = {'user_obj': c.userobj}
self._setup_template_variables(context, data_dict)
# TODO: Add organizations that user is a member of here. I tried
# h.organizations_available() but that errors in the template
c.organizations = []#h.organizations_available()
return render('user/dashboard_organizations.html')

def dashboard_groups(self):
context = {'model': model, 'session': model.Session,
'user': c.user or c.author, 'for_view': True}
data_dict = {'user_obj': c.userobj}
self._setup_template_variables(context, data_dict)
# TODO: Add groups that user is a member of here. I tried
# h.groups_available() but that errors in the template
c.groups = []#h.groups_available()
return render('user/dashboard_groups.html')

def follow(self, id):
'''Start following this user.'''
context = {'model': model,
Expand Down
17 changes: 16 additions & 1 deletion ckan/public/base/less/dashboard.less
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
.arrow {
position: absolute;
content: ' ';
top: 70px;
top: 30px;
right: -10px;
width: 10px;
height: 21px;
Expand Down Expand Up @@ -113,3 +113,18 @@
}
}
}

.dashboard-me {
.clearfix;
padding: 15px 15px 0 15px;
img {
float: left;
margin-right: 10px;
.border-radius(100px);
}
strong {
display: block;
font-size: 16px;
margin: 3px 0;
}
}
33 changes: 24 additions & 9 deletions ckan/public/base/less/nav.less
Original file line number Diff line number Diff line change
@@ -1,21 +1,31 @@
.nav-simple {
.nav-simple,
.nav-aside {
.simple-list; // Adds border and padding.
padding-bottom: 0;
}

.nav-item > a {
.nav-aside {
border-top: 1px dotted #DDD;
border-bottom: 1px dotted #DDD;
margin-bottom: 15px;
}

.nav-item > a,
.nav-aside li a {
color: @navLinkColor;
font-size: @baseFontSize;
line-height: @baseLineHeight;
margin: -7px -@gutterX;
padding: 7px @gutterX;
}

.nav-item.active {
.nav-item.active,
.nav-aside li.active {
background-color: @navActiveBackgroundColor;
}

.nav-item.active > a {
.nav-item.active > a,
.nav-aside li.active a {
position: relative;
color: @navItemActiveTextColor;
background-color: @navItemActiveBackgroundColor;
Expand All @@ -34,28 +44,33 @@
}
}

.nav-item.active > a span {
.nav-item.active > a span,
.nav-aside li.active a span {
white-space: nowrap;
overflow:hidden;
display:block;
}

.module-narrow .nav-item > a {
.module-narrow .nav-item > a,
.module-narrow .nav-aside li a {
padding-left: @gutterSmallX;
padding-right: @gutterSmallX;
position: relative;
}

.module-narrow .nav-item.image {
.module-narrow .nav-item.image,
.module-narrow .nav-aside li.image {
position: relative;
}

.module-narrow .nav-item.image > a {
.module-narrow .nav-item.image > a,
.module-narrow .nav-aside li.image a {
padding-left: @gutterSmallX + 27;
padding-right: @gutterSmallX + 27;
}

.module-narrow .nav-item.image > img {
.module-narrow .nav-item.image > img,
.module-narrow .nav-aside li.image img {
position: absolute;
top: 50%;
left: @gutterSmallX;
Expand Down
43 changes: 19 additions & 24 deletions ckan/templates/user/dashboard.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
{% extends "user/edit_base.html" %}

{% block page_primary_action %}
{% if h.check_access('package_create') %}
{% link_for _('Add Dataset'), controller='package', action='new', class_="btn btn-primary", icon="plus-sign-alt" %}
{% endif %}
{% block breadcrumb_content %}
<li class="active"><a href="{{ h.url_for(controller='user', action='dashboard') }}">{{ _('Dashboard') }}</a></li>
{% endblock %}

{% block primary_content_inner %}
Expand All @@ -30,26 +28,23 @@ <h2 class="page-heading">
</div>
{% endif %}
{% endblock %}
{% block dashboard_datasets %}
<div class="module module-narrow module-shallow">
<h2 class="module-heading">
<i class="icon-sitemap"></i>
{{ _('My Datasets') }}
</h2>
{% if c.user_dict['datasets'] %}
<ul class="nav nav-simple">
{% for package in c.user_dict['datasets'] %}
{% set title = package.title or package.name %}
<li class="nav-item">
{{ h.link_to(h.truncate(title, 80), h.url_for(controller='package', action='read', id=package.name)) }}
</li>
{% endfor %}
{% block dashboard_context %}
<div class="dashboard-me">
{{ h.gravatar(user.email_hash, 50) }}
<strong>{{ h.truncate(user.display_name, 25) }}</strong>
<a href="{{ h.url_for('user_edit', id=user.name) }}">{{ _('Edit settings') }}</a>
</div>
{% endblock %}
{% block dashboard_subnav %}
<div class="module module-narrow module-shallow">
<ul class="nav nav-aside">
{% block dashboard_subnav_content %}
{{ h.build_nav_icon('user_dashboard', _('News feed')) }}
{{ h.build_nav_icon('user_dashboard_datasets', _('My Datasets')) }}
{{ h.build_nav_icon('user_dashboard_organizations', _('My Organizations')) }}
{{ h.build_nav_icon('user_dashboard_groups', _('My Groups')) }}
{% endblock %}
</ul>
{% else %}
<div class="module-content">
<p class="empty">{{ _('You do not have any datasets') }}</p>
</div>
{% endif %}
</div>
</div>
{% endblock %}
{% endblock %}
23 changes: 23 additions & 0 deletions ckan/templates/user/dashboard_datasets.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{% extends "user/dashboard.html" %}

{% block dashboard_activity_stream_context %}{% endblock %}

{% block add_action_content %}
{% if h.check_access('package_create') %}
<li>{% link_for _('Add Dataset'), controller='package', action='new', class_="btn btn-primary", icon="plus-sign-alt" %}</li>
{% endif %}
{% endblock %}

{% block primary_content_inner %}
<h2 class="page-heading">{{ _('My Datasets') }}</h2>
{% if c.user_dict.datasets %}
{% snippet 'snippets/package_list.html', packages=c.user_dict.datasets %}
{% else %}
<p class="empty">
{{ _('You haven\'t created any datasets.') }}
{% if h.check_access('package_create') %}
{% link_for _('Create one now?'), controller='package', action='new' %}
{% endif %}
</p>
{% endif %}
{% endblock %}
23 changes: 23 additions & 0 deletions ckan/templates/user/dashboard_groups.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{% extends "user/dashboard.html" %}

{% block dashboard_activity_stream_context %}{% endblock %}

{% block add_action_content %}
{% if h.check_access('group_create') %}
<li>{% link_for _('Add Group'), controller='group', action='new', class_="btn btn-primary", icon="plus-sign-alt" %}</li>
{% endif %}
{% endblock %}

{% block primary_content_inner %}
<h2 class="page-heading">{{ _('My Groups') }}</h2>
{% if c.groups %}
{% snippet "group/snippets/group_list.html", groups=c.groups %}
{% else %}
<p class="empty">
{{ _('You are not a member of any groups.') }}
{% if h.check_access('group_create') %}
{% link_for _('Create one now?'), controller='group', action='new' %}
{% endif %}
</p>
{% endif %}
{% endblock %}
23 changes: 23 additions & 0 deletions ckan/templates/user/dashboard_organizations.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{% extends "user/dashboard.html" %}

{% block dashboard_activity_stream_context %}{% endblock %}

{% block add_action_content %}
{% if h.check_access('organization_create') %}
<li>{% link_for _('Add Organization'), controller='organization', action='new', class_="btn btn-primary", icon="plus-sign-alt" %}</li>
{% endif %}
{% endblock %}

{% block primary_content_inner %}
<h2 class="page-heading">{{ _('My Organizations') }}</h2>
{% if c.organizations %}
{% snippet "organization/snippets/organization_list.html", organizations=c.organizations %}
{% else %}
<p class="empty">
{{ _('You are not a member of any organizations.') }}
{% if h.check_access('organization_create') %}
{% link_for _('Create one now?'), controller='organization', action='new' %}
{% endif %}
</p>
{% endif %}
{% endblock %}

0 comments on commit f7ec8a8

Please sign in to comment.