mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-09-18 21:50:56 +00:00
Stubbing in broken recommended users.
This commit is contained in:
parent
dbcfaf4be5
commit
01e4827d80
4 changed files with 58 additions and 1 deletions
|
@ -3,6 +3,7 @@ import zlib
|
|||
import hashlib
|
||||
import redis
|
||||
import re
|
||||
import random
|
||||
import mongoengine as mongo
|
||||
from collections import defaultdict
|
||||
# from mongoengine.queryset import OperationError
|
||||
|
@ -113,6 +114,24 @@ class MSocialProfile(mongo.Document):
|
|||
self.follow_user(self.user_id)
|
||||
self.count()
|
||||
|
||||
@classmethod
|
||||
def recommended_users(cls, for_user_id):
|
||||
profile_count = cls.objects.filter(**{
|
||||
'shared_stories_count__gte': 1,
|
||||
'user_id__ne': for_user_id,
|
||||
}).count()
|
||||
profiles = []
|
||||
# for i in range(3):
|
||||
# skip = random.randint(0, max(profile_count-2, 0))
|
||||
# profile = cls.objects.filter(**{
|
||||
# 'shared_stories_count__gte': 1,
|
||||
# 'user_id__ne': for_user_id,
|
||||
# })
|
||||
# if profile:
|
||||
# profiles.append(profile[0])
|
||||
# profiles = sorted(profiles, key=lambda p: p.shared_stories_count)
|
||||
return profiles
|
||||
|
||||
def count_stories(self):
|
||||
# Popular Publishers
|
||||
self.save_popular_publishers()
|
||||
|
|
|
@ -42,6 +42,8 @@
|
|||
{% render_features_module %}
|
||||
{% endif %}
|
||||
|
||||
{% render_recommended_users %}
|
||||
|
||||
{% if recommended_feeds %}
|
||||
{% render_recommended_feed recommended_feeds %}
|
||||
{% endif %}
|
||||
|
|
26
templates/reader/recommended_users.xhtml
Normal file
26
templates/reader/recommended_users.xhtml
Normal file
|
@ -0,0 +1,26 @@
|
|||
{% if recommended_users %}
|
||||
|
||||
<div class="NB-module NB-module-recommended-users">
|
||||
|
||||
<h5 class="NB-module-header">
|
||||
Active Blurblogs
|
||||
</h5>
|
||||
|
||||
<ul class="NB-recommended-users">
|
||||
{% for recommended_user in recommended_users %}
|
||||
<li class="NB-recommended-user"
|
||||
{% if interaction.user_id %}data-user-id="{{ recommended_user.user_id }}"{% endif %}>
|
||||
<img class="NB-interaction-photo" src="{{ recommended_user.photo_url }}">
|
||||
<div class="NB-recommended-user-count NB-right">
|
||||
{{ recommended_user.shared_stories_count }} shared stor{{ recommended_user.shared_stories_count|pluralize:"y,ies" }}
|
||||
</div>
|
||||
<div class="NB-recommended-user-name">
|
||||
{{ recommended_user.username }}
|
||||
</div>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
{% endif %}
|
|
@ -3,7 +3,7 @@ from django.conf import settings
|
|||
from django import template
|
||||
from apps.reader.forms import FeatureForm
|
||||
from apps.reader.models import Feature
|
||||
from apps.social.models import MInteraction, MActivity
|
||||
from apps.social.models import MInteraction, MActivity, MSocialProfile
|
||||
from vendor.timezones.utilities import localtime_for_timezone
|
||||
from utils.user_functions import get_user
|
||||
|
||||
|
@ -32,6 +32,16 @@ def render_features_module(context):
|
|||
'feature_form': feature_form,
|
||||
}
|
||||
|
||||
@register.inclusion_tag('reader/recommended_users.xhtml', takes_context=True)
|
||||
def render_recommended_users(context):
|
||||
user = get_user(context['user'])
|
||||
recommended_users = MSocialProfile.recommended_users(user.pk)
|
||||
|
||||
return {
|
||||
'user': user,
|
||||
'recommended_users': recommended_users,
|
||||
}
|
||||
|
||||
@register.inclusion_tag('reader/interactions_module.xhtml', takes_context=True)
|
||||
def render_interactions_module(context, page=1):
|
||||
user = get_user(context['user'])
|
||||
|
|
Loading…
Add table
Reference in a new issue