Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: samuelclay/NewsBlur
base: 3f7810287b
...
head fork: samuelclay/NewsBlur
compare: 451485d32e
Checking mergeability… Don't worry, you can still create the pull request.
  • 6 commits
  • 15 files changed
  • 0 commit comments
  • 1 contributor
Commits on Apr 10, 2012
@samuelclay Merge branch 'master' of github.com:samuelclay/NewsBlur
* 'master' of github.com:samuelclay/NewsBlur:
  Adding logging to PuSH subscription.
  Showing feed pushes in statistics.
  Instrumentation to count feed pushes.
  Migration to fix starred stories with incorrectly double-encoded url strings.
  Adding MongoDB logging for debug.
1e45b3f
@samuelclay Reducing logging in unread counts node server. 7e7d021
@samuelclay Fixing username logging for unread counts. ed49f6c
@samuelclay Merge branch 'master' of github.com:samuelclay/NewsBlur into social
* 'master' of github.com:samuelclay/NewsBlur:
  Fixing username logging for unread counts.
  Reducing logging in unread counts node server.
6916aa1
Commits on Apr 11, 2012
@samuelclay Showing interactions in module. Adding interactivity. b9d8b91
@samuelclay Splitting interactions into public/private interactions and activities. 451485d
View
83 apps/profile/models.py
@@ -178,43 +178,90 @@ def autologin_url(self, next=None):
class MInteraction(mongo.Document):
- user_id = mongo.IntField()
- activity_date = mongo.DateTimeField(default=datetime.datetime.now)
- activity_type = mongo.StringField()
- activity_content = mongo.StringField()
- activity_user_id = mongo.IntField()
+ user_id = mongo.IntField()
+ date = mongo.DateTimeField(default=datetime.datetime.now)
+ category = mongo.StringField()
+ title = mongo.StringField()
+ content = mongo.StringField()
+ with_user_id = mongo.IntField()
+ feed_id = mongo.IntField()
+ content_id = mongo.StringField()
meta = {
'collection': 'interactions',
- 'indexes': [('user_id', 'activity_date')],
+ 'indexes': [('user_id', 'date'), 'category'],
'allow_inheritance': False,
'index_drop_dups': True,
+ 'ordering': ['-date'],
}
def __unicode__(self):
user = User.objects.get(pk=self.user_id)
- return "%s on %s: %s - %s" % (user.username, self.activity_date,
- self.activity_type, self.activity_content[:20])
+ with_user = self.with_user_id and User.objects.get(pk=self.with_user_id)
+ return "<%s> %s on %s: %s - %s" % (user.username, with_user and with_user.username, self.date,
+ self.category, self.content and self.content[:20])
@classmethod
def new_follow(cls, follower_user_id, followee_user_id):
cls.objects.create(user_id=followee_user_id,
- activity_user_id=follower_user_id,
- activity_type='follow')
+ with_user_id=follower_user_id,
+ category='follow')
@classmethod
- def new_reply(cls, user_id, reply_user_id, reply_content):
+ def new_comment_reply(cls, user_id, reply_user_id, reply_content, social_feed_id, story_id):
cls.objects.create(user_id=user_id,
- activity_user_id=reply_user_id,
- activity_type='reply',
- activity_content=reply_content)
+ with_user_id=reply_user_id,
+ category='comment_reply',
+ content=reply_content,
+ feed_id=social_feed_id,
+ content_id=story_id)
+
@classmethod
- def new_starred_story(cls, user_id, story_title, story_feed_id):
- feed = Feed.objects.get(pk=story_feed_id)
+ def new_reply_reply(cls, user_id, reply_user_id, reply_content, social_feed_id, story_id):
cls.objects.create(user_id=user_id,
- activity_type='star',
- activity_content=story_title)
+ with_user_id=reply_user_id,
+ category='reply_reply',
+ content=reply_content,
+ feed_id=social_feed_id,
+ content_id=story_id)
+
+class MActivity(mongo.Document):
+ user_id = mongo.IntField()
+ date = mongo.DateTimeField(default=datetime.datetime.now)
+ category = mongo.StringField()
+ title = mongo.StringField()
+ content = mongo.StringField()
+ feed_id = mongo.IntField()
+ content_id = mongo.StringField()
+
+ meta = {
+ 'collection': 'activities',
+ 'indexes': [('user_id', 'date'), 'category'],
+ 'allow_inheritance': False,
+ 'index_drop_dups': True,
+ 'ordering': ['-date'],
+ }
+
+ def __unicode__(self):
+ user = User.objects.get(pk=self.user_id)
+ return "<%s> %s - %s" % (user.username, self.category, self.content and self.content[:20])
+
+ @classmethod
+ def new_starred_story(cls, user_id, story_title, story_feed_id, story_id):
+ cls.objects.create(user_id=user_id,
+ category='star',
+ content=story_title,
+ feed_id=story_feed_id,
+ content_id=story_id)
+
+ @classmethod
+ def new_feed_subscription(cls, user_id, feed_id, feed_title):
+ cls.objects.create(user_id=user_id,
+ category='feed_sub',
+ content=feed_title,
+ feed_id=feed_id)
+
def create_profile(sender, instance, created, **kwargs):
if created:
View
14 apps/reader/models.py
@@ -118,16 +118,20 @@ def add_subscription(cls, user, feed_address, folder=None, bookmarklet=False, au
user_sub_folders_object.folders = json.encode(user_sub_folders)
user_sub_folders_object.save()
- if not auto_active:
+ if auto_active:
+ us.active = True
+ else:
feed_count = cls.objects.filter(user=user).count()
if feed_count < 64 or user.profile.is_premium:
us.active = True
- us.save()
-
- feed.setup_feed_for_premium_subscribers()
+ us.save()
if feed.last_update < datetime.datetime.utcnow() - datetime.timedelta(days=1):
- feed.update()
+ feed = feed.update()
+
+ from apps.profile.models import MActivity
+ MActivity.new_feed_subscription(cls, user_id=user.pk, feed_id=feed.pk, feed_title=feed.title)
+ feed.setup_feed_for_premium_subscribers()
return code, message, us
View
9 apps/reader/views.py
@@ -22,9 +22,10 @@
from operator import itemgetter
from apps.recommendations.models import RecommendedFeed
from apps.analyzer.models import MClassifierTitle, MClassifierAuthor, MClassifierFeed, MClassifierTag
-from apps.analyzer.models import apply_classifier_titles, apply_classifier_feeds, apply_classifier_authors, apply_classifier_tags
+from apps.analyzer.models import apply_classifier_titles, apply_classifier_feeds
+from apps.analyzer.models import apply_classifier_authors, apply_classifier_tags
from apps.analyzer.models import get_classifiers_for_user
-from apps.profile.models import Profile
+from apps.profile.models import Profile, MActivity
from apps.reader.models import UserSubscription, UserSubscriptionFolders, MUserStory, Feature
from apps.reader.forms import SignupForm, LoginForm, FeatureForm
from apps.rss_feeds.models import MFeedIcon
@@ -1199,6 +1200,10 @@ def mark_story_as_starred(request):
defaults=story_values)
if created:
logging.user(request, "~FCStarring: ~SB%s" % (story[0].story_title[:50]))
+ MActivity.new_starred_story(user_id=request.user.pk,
+ story_title=story[0].story_title,
+ story_feed_id=feed_id,
+ story_id=starred_story.story_guid)
else:
logging.user(request, "~FC~BRAlready stared:~SN~FC ~SB%s" % (story[0].story_title[:50]))
else:
View
20 apps/social/views.py
@@ -12,6 +12,7 @@
from apps.analyzer.models import apply_classifier_titles, apply_classifier_feeds, apply_classifier_authors, apply_classifier_tags
from apps.analyzer.models import get_classifiers_for_user
from apps.reader.models import MUserStory, UserSubscription
+from apps.profile.models import MInteraction
from utils import json_functions as json
from utils import log as logging
from utils import PyRSS2Gen as RSS
@@ -252,14 +253,29 @@ def save_comment_reply(request):
reply.comments = reply_comments
shared_story.replies.append(reply)
shared_story.save()
+
logging.user(request, "~FCReplying to comment in: ~SB~FM%s (~FB%s~FM)" % (story.story_title[:50], reply_comments[:100]))
comment = shared_story.comments_with_author()
profile_user_ids = set([comment['user_id']])
- profile_user_ids = profile_user_ids.union([reply['user_id'] for reply in comment['replies']])
+ reply_user_ids = [reply['user_id'] for reply in comment['replies']]
+ profile_user_ids = profile_user_ids.union(reply_user_ids)
profiles = MSocialProfile.objects.filter(user_id__in=list(profile_user_ids))
profiles = [profile.to_json(compact=True) for profile in profiles]
+ # Interaction for every other replier and original commenter
+ MInteraction.new_comment_reply(user_id=comment['user_id'],
+ reply_user_id=request.user.pk,
+ reply_content=reply_comments,
+ social_feed_id=comment_user_id,
+ story_id=story_id)
+ for user_id in set(reply_user_ids).difference([comment['user_id']]):
+ MInteraction.new_reply_reply(user_id=user_id,
+ reply_user_id=request.user.pk,
+ reply_content=reply_comments,
+ social_feed_id=comment_user_id,
+ story_id=story_id)
+
return {'code': code, 'comment': comment, 'user_profiles': profiles}
def shared_stories_public(request, username):
@@ -299,7 +315,7 @@ def profile(request):
def load_user_profile(request):
social_profile, _ = MSocialProfile.objects.get_or_create(user_id=request.user.pk)
social_services, _ = MSocialServices.objects.get_or_create(user_id=request.user.pk)
-
+
return {
'services': social_services,
'user_profile': social_profile.to_json(full=True),
View
2  apps/statistics/models.py
@@ -176,6 +176,6 @@ def collect_feedback(cls):
@classmethod
def all(cls):
- feedbacks = cls.objects.all()[:5]
+ feedbacks = cls.objects.all()[:3]
return feedbacks
View
73 media/css/reader.css
@@ -3961,7 +3961,7 @@ background: transparent;
.NB-module.NB-loading .NB-spinner {
display: block;
}
-.NB-module h3.NB-module-content-header {
+.NB-module .NB-module-content-header {
border-bottom: 1px solid #F0F0F0;
padding: 4px 0 0px;
margin: 12px 0 4px 12px;
@@ -3972,7 +3972,7 @@ background: transparent;
clear: both;
}
-.NB-modules-center .NB-module h3.NB-module-content-header {
+.NB-modules-center .NB-module-content-header {
margin-right: 12px;
}
.NB-module .NB-module-content-subtitle {
@@ -4022,10 +4022,10 @@ background: transparent;
.NB-module .NB-module-item.NB-done .NB-done-label {
display: block;
}
-.NB-module .NB-module-item .NB-module-content-header {
+.NB-module.NB-module-account .NB-module-content-header {
margin-left: 128px;
}
-.NB-module .NB-module-item .NB-module-item-image {
+.NB-module .NB-module-item-image {
position: absolute;
left: 0;
top: 0;
@@ -4089,6 +4089,14 @@ background: transparent;
margin: 0 0 0 72px;
clear: none;
}
+.NB-account .NB-module-account-stats {
+ margin-top: 0;
+ overflow: hidden;
+}
+.NB-module .NB-module-activity .NB-module-content-header {
+ margin-left: 12px;
+ padding-right: 12px;
+}
/* ======================= */
/* = How it Works Module = */
@@ -7707,3 +7715,60 @@ background: transparent;
color: #909090;
text-transform: uppercase;
}
+
+/* ======================= */
+/* = Interactions Module = */
+/* ======================= */
+
+.NB-interactions {
+ list-style: none;
+ padding: 0;
+ margin: 12px 0;
+}
+.NB-interaction {
+ list-style: none;
+ position: relative;
+ margin: 0 12px;
+ padding: 6px 0 6px 24px;
+ border-bottom: 1px solid #F0F0F0;
+ overflow: hidden;
+}
+.NB-interaction:last-child {
+ border-bottom: none;
+ padding-bottom: 0;
+ margin-bottom: 0;
+}
+.NB-interaction-photo {
+ position: absolute;
+ width: 16px;
+ height: 16px;
+ border-radius: 3px;
+ left: 0;
+ top: 10px;
+ cursor: pointer;
+}
+.NB-interaction-date {
+ color: #B0B0B0;
+ font-size: 11px;
+ float: right;
+ text-transform: uppercase;
+ padding: 4px 0 4px 4px;
+}
+.NB-interaction-title {
+ font-size: 13px;
+ line-height: 18px;
+ color: #404040;
+ padding: 2px 0 0 0;
+}
+.NB-interaction-content {
+ font-size: 11px;
+ padding-top: 2px;
+ line-height: 14px;
+ color: #808080;
+}
+.NB-interaction-username {
+ cursor: pointer;
+}
+.NB-interaction-starred-story-title {
+ cursor: pointer;
+}
View
5 media/js/newsblur/common/assetmodel.js
@@ -1123,7 +1123,10 @@ NEWSBLUR.AssetModel.Reader.prototype = {
},
fetch_user_profile: function(user_id, callback) {
- this.make_request('/social/profile', {'user_id': user_id}, callback, callback, {
+ this.make_request('/social/profile', {'user_id': user_id}, _.bind(function(data) {
+ this.add_user_profiles(data.profiles);
+ callback(data);
+ }, this), callback, {
request_type: 'GET'
});
},
View
24 media/js/newsblur/reader/reader.js
@@ -2067,7 +2067,7 @@
}
},
- open_starred_stories: function() {
+ open_starred_stories: function(story_guid) {
var $story_titles = this.$s.$story_titles;
$story_titles.empty().scrollTop('0px');
@@ -7567,6 +7567,28 @@
self.save_social_comment_reply($comment);
});
+ // = Interactions Module ==========================================
+
+ $.targetIs(e, { tagSelector: '.NB-interaction-username' }, function($t, $p){
+ e.preventDefault();
+ var user_id = $t.data('userId');
+ var username = $t.text();
+ self.model.add_user_profiles([{user_id: user_id, username: username}]);
+ self.open_social_profile_modal(user_id);
+ });
+ $.targetIs(e, { tagSelector: '.NB-interaction-profile-photo' }, function($t, $p){
+ e.preventDefault();
+ var user_id = $t.data('userId');
+ var username = $t.closest('.NB-interaction').find('.NB-interaction-username').text();
+ self.model.add_user_profiles([{user_id: user_id, username: username}]);
+ self.open_social_profile_modal(user_id);
+ });
+ $.targetIs(e, { tagSelector: '.NB-interaction-starred-story-title' }, function($t, $p){
+ e.preventDefault();
+ var story_guid = $t.closest('.NB-interaction').data('contentId');
+ self.open_starred_stories(story_guid);
+ });
+
// = One-offs =====================================================
var clicked = false;
View
5 media/js/newsblur/reader/reader_social_profile.js
@@ -6,7 +6,8 @@ NEWSBLUR.ReaderSocialProfile = function(user_id, options) {
this.options = $.extend({}, defaults, options);
this.model = NEWSBLUR.AssetModel.reader();
this.profiles = new NEWSBLUR.Collections.Users();
- user_id = _.string.ltrim(user_id, 'social:');
+ user_id = parseInt(_.string.ltrim(user_id, 'social:'), 10);
+ console.log(["user_id", user_id]);
this.runner(user_id);
};
@@ -19,7 +20,7 @@ _.extend(NEWSBLUR.ReaderSocialProfile.prototype, {
this.make_modal();
this.open_modal();
_.defer(_.bind(this.fetch_profile, this, user_id));
-
+
this.$modal.bind('click', $.rescope(this.handle_click, this));
},
View
8 node/unread_counts.coffee
@@ -2,9 +2,15 @@ fs = require 'fs'
io = require('socket.io').listen 8888
redis = require 'redis'
-REDIS_SERVER = if process.env.NODE_ENV == 'dev' then 'localhost' else 'db01'
+REDIS_SERVER = if process.env.NODE_ENV == 'development' then 'localhost' else 'db01'
client = redis.createClient 6379, REDIS_SERVER
+io.configure 'production', ->
+ io.set 'log level', 1
+
+io.configure 'development', ->
+ io.set 'log level', 2
+
io.sockets.on 'connection', (socket) ->
socket.on 'subscribe:feeds', (@feeds, @username) ->
console.log " ---> [#{@username}] Subscribing to #{feeds.length} feeds " +
View
10 node/unread_counts.js
@@ -7,10 +7,18 @@
redis = require('redis');
- REDIS_SERVER = process.env.NODE_ENV === 'dev' ? 'localhost' : 'db01';
+ REDIS_SERVER = process.env.NODE_ENV === 'development' ? 'localhost' : 'db01';
client = redis.createClient(6379, REDIS_SERVER);
+ io.configure('production', function() {
+ return io.set('log level', 1);
+ });
+
+ io.configure('development', function() {
+ return io.set('log level', 2);
+ });
+
io.sockets.on('connection', function(socket) {
socket.on('subscribe:feeds', function(feeds, username) {
var _ref,
View
46 templates/reader/activities_module.xhtml
@@ -0,0 +1,46 @@
+{% load utils_tags typogrify_tags statistics_tags %}
+
+{% if activities %}
+
+<div class="NB-module-item NB-module-activity">
+ <h3 class="NB-module-content-header">
+ <div class="NB-module-header-right">
+ <div class="NB-spinner NB-left"></div>
+ <a href="#" class="NB-module-direction NB-module-next-page NB-javascript {% if activities|length <= 5 %}NB-disabled{% endif %}"></a>
+ <a href="#" class="NB-module-direction NB-module-previous-page NB-disabled"></a>
+ </div>
+
+ Your Activity
+ </h3>
+
+ <ul class="NB-interactions">
+ {% for activity in activities|slice:":5" %}
+ <li class="NB-interaction NB-interaction-{{ activity.category }}"
+ {% if activity.content_id %}data-content-id="{{ activity.content_id }}"{% endif %}>
+
+ {% if activity.category == 'star' %}
+ <img class="NB-interaction-photo" src="/rss_feeds/icon/{{ activity.feed_id }}">
+ <div class="NB-interaction-date">
+ {{ activity.date }} ago
+ </div>
+ <div class="NB-interaction-title">
+ You starred "<span class="NB-interaction-starred-story-title NB-splash-link">{{ activity.content|truncatewords:8 }}</span>".
+ </div>
+ {% endif %}
+
+ {% if activity.category == 'feed_sub' %}
+ <img class="NB-interaction-photo" src="/rss_feeds/icon/{{ activity.feed_id }}">
+ <div class="NB-interaction-date">
+ {{ activity.date }} ago
+ </div>
+ <div class="NB-interaction-title">
+ You subscribed to "<span class="NB-interaction-feed-title NB-splash-link">{{ activity.content|truncatewords:8 }}</span>".
+ </div>
+ {% endif %}
+
+ </li>
+ {% endfor %}
+ </ul>
+
+</div>
+{% endif %}
View
24 templates/reader/feeds.xhtml
@@ -256,26 +256,6 @@
{% endif %}
</h3>
<div class="NB-module-item-title">
- {% if user.profile.is_premium %}
-
- {% else %}
-
- <div class="NB-modal-submit">
- {% if feed_count == 0 %}
- {# <div class="NB-modal-submit-green NB-modal-submit-button NB-task-add NB-javascript">Add Sites</div> #}
- {% else %}
- <div class="{% if active_count == 0 %}NB-modal-submit-green{% else %}NB-modal-submit-close{% endif %} NB-modal-submit-button NB-module-account-upgrade NB-javascript">Choose Your 64 Sites</div>
- {% endif %}
- </div>
- {% endif %}
- </div>
- </div>
-
- <div class="NB-module-user-statistics {% if not user_statistics.shared_stories or not user_statistics %}NB-hidden{% endif %}">
- <h3 class="NB-module-content-header">
- Your statistics
- </h3>
-
<div class="NB-module-item NB-module-stats NB-module-account-stats">
<div class="NB-module-stats-count">
<div class="NB-module-stats-count-number">{{ user_statistics.shared_stories|commify }}</div>
@@ -290,6 +270,10 @@
<div class="NB-module-stats-count-description">Follower{{ user_statistics.followers|pluralize }}</div>
</div>
</div>
+ </div>
+
+ {% render_activities_module %}
+
</div>
</div>
View
58 templates/reader/interactions_module.xhtml
@@ -1,18 +1,50 @@
{% load utils_tags typogrify_tags statistics_tags %}
+{% if interactions %}
<div class="NB-module NB-module-features">
- <h5 class="NB-module-header">
- <div class="NB-module-header-right">
- <div class="NB-spinner NB-left"></div>
- <a href="#" class="NB-module-direction NB-module-next-page NB-javascript"></a>
- <a href="#" class="NB-module-direction NB-module-previous-page NB-disabled"></a>
- </div>
- Interactions
- </h5>
-
- <div class="NB-interactions">
- Follow, comments, replies, starred stories.
- </div>
+ <h5 class="NB-module-header">
+ <div class="NB-module-header-right">
+ <div class="NB-spinner NB-left"></div>
+ <a href="#" class="NB-module-direction NB-module-next-page NB-javascript {% if interactions|length <= 5 %}NB-disabled{% endif %}"></a>
+ <a href="#" class="NB-module-direction NB-module-previous-page NB-disabled"></a>
+ </div>
+ Interactions
+ </h5>
-</div>
+ <ul class="NB-interactions">
+ {% for interaction in interactions|slice:":5" %}
+ <li class="NB-interaction NB-interaction-{{ interaction.category }}"
+ {% if interaction.content_id %}data-content-id="{{ interaction.content_id }}"{% endif %}>
+ {% if interaction.category == 'follow' %}
+ <img class="NB-interaction-photo NB-interaction-profile-photo" src="{{ interaction.photo_url }}" data-user-id="{{ interaction.with_user_id }}">
+ <div class="NB-interaction-date">
+ {{ interaction.date }} ago
+ </div>
+ <div class="NB-interaction-title">
+ <span class="NB-interaction-username NB-splash-link" data-user-id="{{ interaction.with_user_id }}">
+ {{ interaction.with_user.username }}
+ </span> started following you.
+ </div>
+ {% endif %}
+
+ {% if interaction.category == 'comment_reply' or interaction.category == 'reply_reply' %}
+ <img class="NB-interaction-photo NB-interaction-profile-photo" src="{{ interaction.photo_url }}" data-user-id="{{ interaction.with_user_id }}">
+ <div class="NB-interaction-date">
+ {{ interaction.date }} ago
+ </div>
+ <div class="NB-interaction-title">
+ <span class="NB-interaction-username NB-splash-link" data-user-id="{{ interaction.with_user_id }}">
+ {{ interaction.with_user.username }}
+ </span> replied to your {% if interaction.category == 'comment_reply' %}comment{% else %}reply{% endif %}:
+ </div>
+ <div class="NB-interaction-content">
+ "<span class="NB-interaction-starred-story-title NB-splash-link" data-social-user-id="{{ interaction.feed_id }}">{{ interaction.content|truncatewords:16 }}</span>"
+ </div>
+ {% endif %}
+ </li>
+ {% endfor %}
+ </ul>
+
+</div>
+{% endif %}
View
47 utils/templatetags/utils_tags.py
@@ -1,11 +1,13 @@
from django.contrib.sites.models import Site
-from django import template
from django.conf import settings
-from utils.user_functions import get_user
-from vendor.timezones.utilities import localtime_for_timezone
+from django import template
from apps.reader.forms import FeatureForm
from apps.reader.models import Feature
-from apps.profile.models import MInteraction
+from apps.profile.models import MInteraction, MActivity
+from apps.social.models import MSocialProfile
+from vendor.timezones.utilities import localtime_for_timezone
+from utils.feed_functions import relative_timesince
+from utils.user_functions import get_user
register = template.Library()
@@ -34,14 +36,47 @@ def render_features_module(context):
@register.inclusion_tag('reader/interactions_module.xhtml', takes_context=True)
def render_interactions_module(context):
- user = get_user(context['user'])
- interactions = MInteraction.objects.filter(user_id=user.pk)[0:5]
+ user = get_user(context['user'])
+ interactions_db = MInteraction.objects.filter(user_id=user.pk)[0:5]
+ with_user_ids = [i.with_user_id for i in interactions_db if i.with_user_id]
+ social_profiles = dict((p.user_id, p) for p in MSocialProfile.objects.filter(user_id__in=with_user_ids))
+ interactions = []
+ for interaction_db in interactions_db:
+ interaction = interaction_db.to_mongo()
+ interaction['photo_url'] = getattr(social_profiles.get(interaction_db.with_user_id), 'photo_url', None)
+ interaction['with_user'] = social_profiles.get(interaction_db.with_user_id)
+ interaction['date'] = relative_timesince(interaction_db.date)
+ interactions.append(interaction)
+
return {
'user': user,
'interactions': interactions,
}
+
+@register.inclusion_tag('reader/activities_module.xhtml', takes_context=True)
+def render_activities_module(context):
+ user = get_user(context['user'])
+ activities_db = MActivity.objects.filter(user_id=user.pk)[:6]
+
+ activities = []
+ for activity_db in activities_db[:5]:
+ activity = activity_db.to_mongo()
+ activity['date'] = relative_timesince(activity_db.date)
+ activities.append(activity)
+ if len(activities_db) > 5:
+ activities.append(activities_db[5].to_mongo())
+ return {
+ 'user': user,
+ 'activities': activities,
+ }
+
+@register.filter
+def get(h, key):
+ print h, key
+ return h[key]
+
@register.filter
def get_range( value ):
"""

No commit comments for this range

Something went wrong with that request. Please try again.