Skip to content

Commit

Permalink
Merged master
Browse files Browse the repository at this point in the history
  • Loading branch information
johnmartin committed Nov 5, 2012
2 parents beb1542 + c59b304 commit 61dc97b
Show file tree
Hide file tree
Showing 11 changed files with 675 additions and 765 deletions.
1 change: 1 addition & 0 deletions ckan/config/routing.py
Expand Up @@ -242,6 +242,7 @@ def make_map():
'follow',
'unfollow',
'admins',
'activity',
]))
)
m.connect('group_read', '/group/{id}', action='read')
Expand Down
74 changes: 14 additions & 60 deletions ckan/controllers/group.py
Expand Up @@ -231,12 +231,6 @@ def pager_url(q=None, page=None):
c.facets = {}
c.page = h.Page(collection=[])

# Add the group's activity stream (already rendered to HTML) to the
# template context for the group/read.html template to retrieve later.
c.group_activity_stream = \
get_action('group_activity_list_html')(context,
{'id': c.group_dict['id']})

return render(self._read_template(c.group_dict['type']))

def new(self, data=None, errors=None, error_summary=None):
Expand Down Expand Up @@ -496,70 +490,30 @@ def history(self, id):
return feed.writeString('utf-8')
return render(self._history_template(c.group_dict['type']))

def follow(self, id):
'''Start following this group.'''
context = {'model': model,
'session': model.Session,
'user': c.user or c.author}
data_dict = {'id': id}
try:
get_action('follow_group')(context, data_dict)
h.flash_success(_("You are now following {0}").format(id))
except ValidationError as e:
error_message = (e.extra_msg or e.message or e.error_summary
or e.error_dict)
h.flash_error(error_message)
except NotAuthorized as e:
h.flash_error(e.extra_msg)
h.redirect_to(controller='group', action='read', id=id)

def unfollow(self, id):
'''Stop following this group.'''
context = {'model': model,
'session': model.Session,
'user': c.user or c.author}
data_dict = {'id': id}
try:
get_action('unfollow_group')(context, data_dict)
h.flash_success(_("You are no longer following {0}").format(id))
except ValidationError as e:
error_message = (e.extra_msg or e.message or e.error_summary
or e.error_dict)
h.flash_error(error_message)
except (NotFound, NotAuthorized) as e:
error_message = e.extra_msg or e.message
h.flash_error(error_message)
h.redirect_to(controller='group', action='read', id=id)

def followers(self, id=None):
def activity(self, id):
'''Render this group's public activity stream page.'''

context = {'model': model, 'session': model.Session,
'user': c.user or c.author, 'for_view': True}
data_dict = {'id': id}
try:
c.group_dict = get_action('group_show')(context, data_dict)
c.followers = get_action('group_follower_list')(context,
{'id': c.group_dict['id']})
except NotFound:
abort(404, _('Group not found'))
except NotAuthorized:
abort(401, _('Unauthorized to read group %s') % id)

return render('group/followers.html')

def admins(self, id=None):
context = {'model': model, 'session': model.Session,
'user': c.user or c.author,
'for_view': True}
data_dict = {'id': id}
try:
c.group_dict = get_action('group_show')(context, data_dict)
c.admins = self.authorizer.get_admins(context['group'])
c.group = context['group']
except NotFound:
abort(404, _('Group not found'))
except NotAuthorized:
abort(401, _('Unauthorized to read group %s') % id)
abort(401,
_('Unauthorized to read group {group_id}').format(
group_id=id))

# Add the group's activity stream (already rendered to HTML) to the
# template context for the group/read.html template to retrieve later.
c.group_activity_stream = \
get_action('group_activity_list_html')(context,
{'id': c.group_dict['id']})

return render('group/admins.html')
return render('group/activity_stream.html')

def _render_edit_form(self, fs):
# errors arrive in c.error and fs.errors
Expand Down
38 changes: 36 additions & 2 deletions ckan/logic/action/get.py
Expand Up @@ -1717,12 +1717,17 @@ def vocabulary_show(context, data_dict):
def user_activity_list(context, data_dict):
'''Return a user's public activity stream.
You must be authorized to view the user's profile.
:param id: the id or name of the user
:type id: string
:rtype: list of dictionaries
'''
# FIXME: Filter out activities whose subject or object the user is not
# authorized to read.
_check_access('user_show', context, data_dict)
model = context['model']
user_id = _get_or_bust(data_dict, 'id')
query = model.Session.query(model.Activity)
Expand All @@ -1735,12 +1740,17 @@ def user_activity_list(context, data_dict):
def package_activity_list(context, data_dict):
'''Return a package's activity stream.
You must be authorized to view the package.
:param id: the id or name of the package
:type id: string
:rtype: list of dictionaries
'''
# FIXME: Filter out activities whose subject or object the user is not
# authorized to read.
_check_access('package_show', context, data_dict)
model = context['model']
package_id = _get_or_bust(data_dict, 'id')
query = model.Session.query(model.Activity)
Expand All @@ -1753,19 +1763,38 @@ def package_activity_list(context, data_dict):
def group_activity_list(context, data_dict):
'''Return a group's activity stream.
You must be authorized to view the group.
:param id: the id or name of the group
:type id: string
:rtype: list of dictionaries
'''
# FIXME: Filter out activities whose subject or object the user is not
# authorized to read.
_check_access('group_show', context, data_dict)

model = context['model']
group_id = _get_or_bust(data_dict, 'id')

# Convert group_id (could be id or name) into id.
group_show = logic.get_action('group_show')
group_id = group_show(context, {'id': group_id})['id']

# Get a list of the IDs of the group's datasets.
group_package_show = logic.get_action('group_package_show')
datasets = group_package_show(context, {'id': group_id})
dataset_ids = [dataset['id'] for dataset in datasets]

# Get the group's activities.
query = model.Session.query(model.Activity)
query = query.filter_by(object_id=group_id)
query = query.filter(_or_(model.Activity.object_id == group_id,
model.Activity.object_id.in_(dataset_ids)))
query = query.order_by(_desc(model.Activity.timestamp))
query = query.limit(15)
activity_objects = query.all()

return model_dictize.activity_list_dictize(activity_objects, context)

def recently_changed_packages_activity_list(context, data_dict):
Expand All @@ -1774,6 +1803,8 @@ def recently_changed_packages_activity_list(context, data_dict):
:rtype: list of dictionaries
'''
# FIXME: Filter out activities whose subject or object the user is not
# authorized to read.
model = context['model']
query = model.Session.query(model.Activity)
query = query.filter(model.Activity.activity_type.endswith('package'))
Expand All @@ -1790,14 +1821,15 @@ def activity_detail_list(context, data_dict):
:rtype: list of dictionaries.
'''
# FIXME: Filter out activities whose subject or object the user is not
# authorized to read.
model = context['model']
activity_id = _get_or_bust(data_dict, 'id')
activity_detail_objects = model.Session.query(
model.activity.ActivityDetail).filter_by(activity_id=activity_id).all()
return model_dictize.activity_detail_list_dictize(activity_detail_objects, context)



def user_activity_list_html(context, data_dict):
'''Return a user's public activity stream as HTML.
Expand Down Expand Up @@ -2171,6 +2203,8 @@ def dashboard_activity_list(context, data_dict):
:rtype: list of dictionaries
'''
# FIXME: Filter out activities whose subject or object the user is not
# authorized to read.
model = context['model']
user_id = _get_or_bust(data_dict, 'id')

Expand Down
26 changes: 6 additions & 20 deletions ckan/public/base/css/main.css
Expand Up @@ -4506,13 +4506,13 @@ ul.icons li .icon-large:before {
.simple-list:after {
clear: both;
}
.simple-list > li {
.simple-list > li {
font-size: 12px;
line-height: 1.1666666666666667em;
padding: 7px 25px;
border-bottom: 1px dotted #cccccc;
}
.simple-list > li:last-of-type {
.simple-list > li:last-of-type {
border-bottom: 0;
}
.simple-list .ckan-icon {
Expand Down Expand Up @@ -4669,8 +4669,6 @@ ul.icons li .icon-large:before {
padding-right: 15px;
}
.module-grid {
margin: 0;
list-style: none;
margin: 0;
list-style: none;
*zoom: 1;
Expand All @@ -4694,7 +4692,6 @@ ul.icons li .icon-large:before {
padding-left: 20px;
padding-bottom: 25px;
float: left;
float: left;
margin-left: 20px;
width: 460px;
padding-top: 10px;
Expand All @@ -4720,10 +4717,10 @@ ul.icons li .icon-large:before {
.ckanext-datapreview {
position: relative;
}
.ckanext-datapreview > iframe {
.ckanext-datapreview > iframe {
min-height: 400px;
}
.ckanext-datapreview > img {
.ckanext-datapreview > img {
max-height: 500px;
max-width: 100%;
overflow: hidden;
Expand Down Expand Up @@ -4887,13 +4884,13 @@ ol.media-grid:after {
.nav-simple:after {
clear: both;
}
.nav-simple > li {
.nav-simple > li {
font-size: 12px;
line-height: 1.1666666666666667em;
padding: 7px 25px;
border-bottom: 1px dotted #cccccc;
}
.nav-simple > li:last-of-type {
.nav-simple > li:last-of-type {
border-bottom: 0;
}
.nav-simple .ckan-icon {
Expand All @@ -4915,12 +4912,10 @@ ol.media-grid:after {
}
.nav-item.active > a {
background: url("../../../base/images/background-tag.png") no-repeat -13px center;
position: relative;
display: block;
font-size: 11px;
line-height: 27px;
color: #187794;
padding-left: 10px;
padding-right: 5px;
margin-right: 11px;
-webkit-box-sizing: border-box;
Expand Down Expand Up @@ -5209,8 +5204,6 @@ textarea {
background-image: url("../../../base/images/sprite-ckan-icons.png");
background-repeat: no-repeat;
background-position: 16px 16px;
width: 17px;
height: 17px;
background-position: -51px -16px;
position: absolute;
display: block;
Expand Down Expand Up @@ -5804,8 +5797,6 @@ textarea {
vertical-align: text-bottom;
position: relative;
top: 2px;
width: 16px;
height: 16px;
background-image: url("../../../base/images/sprite-ckan-icons.png");
background-repeat: no-repeat;
background-position: 16px 16px;
Expand Down Expand Up @@ -6661,7 +6652,6 @@ li .icon-large:before {
float: right;
}
[role=main] .secondary {
float: left;
margin-left: 20px;
width: 220px;
margin-left: 0;
Expand Down Expand Up @@ -6897,13 +6887,11 @@ li .icon-large:before {
bottom: NaN;
width: 1px;
background-color: #007094;
background-color: rgba(255, 255, 255, 0);
background-image: -webkit-gradient(radial, center center, 0, center center, 460, from(rgba(255, 255, 255, 0.1)), to(rgba(255, 255, 255, 0)));
background-image: -webkit-radial-gradient(circle, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0));
background-image: -moz-radial-gradient(circle, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0));
background-image: -ms-radial-gradient(circle, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0));
background-image: -o-radial-gradient(circle, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0));
background-repeat: no-repeat;
background-color: rgba(255, 255, 255, 0.08000000000000002);
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(rgba(255, 255, 255, 0)), color-stop(0.5, rgba(255, 255, 255, 0.1)), to(rgba(255, 255, 255, 0)));
background-image: -webkit-linear-gradient(rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.1) 0.5, rgba(255, 255, 255, 0));
Expand All @@ -6917,13 +6905,11 @@ li .icon-large:before {
.masthead .section:after {
left: -1px;
background-color: #004a61;
background-color: rgba(0, 0, 0, 0);
background-image: -webkit-gradient(radial, center center, 0, center center, 460, from(rgba(0, 0, 0, 0.2)), to(rgba(0, 0, 0, 0)));
background-image: -webkit-radial-gradient(circle, rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0));
background-image: -moz-radial-gradient(circle, rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0));
background-image: -ms-radial-gradient(circle, rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0));
background-image: -o-radial-gradient(circle, rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0));
background-repeat: no-repeat;
background-color: rgba(0, 0, 0, 0.16000000000000003);
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(rgba(0, 0, 0, 0)), color-stop(0.5, rgba(0, 0, 0, 0.2)), to(rgba(0, 0, 0, 0)));
background-image: -webkit-linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.2) 0.5, rgba(0, 0, 0, 0));
Expand Down
1 change: 0 additions & 1 deletion ckan/public/base/less/disqus.less

This file was deleted.

6 changes: 6 additions & 0 deletions ckan/templates/group/activity_stream.html
@@ -0,0 +1,6 @@
{% extends "page.html" %}

{% block primary_content %}
<h2 class="hide-heading">{{ _('Activity Stream') }}</h2>
{{ c.group_activity_stream | safe }}
{% endblock %}
2 changes: 1 addition & 1 deletion ckan/templates/package/snippets/resource_item.html
Expand Up @@ -15,6 +15,6 @@
</p>
<p class="btn-group">
<a class="btn btn-primary" href="{{ url }}">{{ _('Explore Data') }}</a>
<a class="btn" href="{{ res.url }}" target="_blank">{{ _('Raw Data') }}</a>
<a class="btn resource-url-analytics" href="{{ res.url }}" target="_blank">{{ _('Raw Data') }}</a>
</p>
</li>

0 comments on commit 61dc97b

Please sign in to comment.