예제 #1
0
def rss_newsfeed_private(request, enc, rss_key):
    userprofile = models.UserProfile.objects.get(rss_key=rss_key)
    user = userprofile.user
    return HttpResponse(
        newsfeed.get_rendered_news_feed(request.user,
                                        user,
                                        'R', None, rss_key),
        mimetype='application/rss+xml')
예제 #2
0
def show_user(request, enc, user):
    user_properties = webhelpers.get_user_properties(user, True)
    
    profile = user_properties['profile']
    profile.views += 1
    profile.save()
    profile_views = profile.views

    newsfeed_display = newsfeed.render(request.user, user, True)

    context = {
        'u': user,
        'subs_active': localsettings.FEATURE['subscriptions_fw'],
        'send_to_details': localsettings.FEATURE['send_to_details'],
        'activesecondary': 'profile',
        'mostviewed': cached_sets.most_viewed()[:6],
        'profile_views': profile_views,
        'newsfeed_display': newsfeed_display,
        'posts': webhelpers.get_latest_fg_blog_posts(),
    }
    context.update(webhelpers.translate_user_properties(user_properties))

    if user == request.user:
        return helpers.req_render_to_response(request, 'user/show_profile_owner.html', context)
    else:
        favs = models.Favorite.objects.filter(owner=user)
        fav_fgs = [favorite.flowgram for favorite in favs if favorite.flowgram.public][:4]
                
        fgs = models.Flowgram.from_published.filter(owner=user,
                                                    public=True).order_by('-published_at')[:6]
        
        # Checking if user is sub'd to this user.
        is_subscribed = models.Subscription.objects.filter(user=user, subscriber=request.user)
        
        context.update({
            'is_subscribed': is_subscribed,
            'fgs': fgs,
            'active': 'browse',
            'pageowner' : False,
            'display_filters_suppress': True,
            'fg_timestamp': False,
            'fav_fgs': fav_fgs,
            'news_list': newsfeed.get_rendered_news_feed(request.user, user, 'S')
        })
        
        return helpers.req_render_to_response(request, 'user/show_profile.html', context)
예제 #3
0
    def fetch(self):
        user_profiles = UserProfile.objects.filter(notify_by_email=True).exclude(notification_freq='')
        print("got %d user profiles" % len(user_profiles))
            
        for user_profile in user_profiles:
            user = user_profile.user
            email_digest_record = None
            now = datetime.datetime.now()
            timestamp = None
            try:
                email_digest_record = EmailDigestRecord.objects.get(user=user)

                timestamp = now
                if user_profile.notification_freq == 'I':
                    timestamp -= datetime.timedelta(seconds=600)
                elif user_profile.notification_freq == 'D':
                    timestamp -= datetime.timedelta(seconds=86400)
                elif user_profile.notification_freq == 'W':
                    timestamp -= datetime.timedelta(seconds=604800)

                if email_digest_record.timestamp > timestamp:
                    continue

                timestamp = email_digest_record.timestamp

                email_digest_record.timestamp = now
                email_digest_record.save()
                
                print("user=%s has timestamp=%s" % (user.id, str(now)))
            except:
                EmailDigestRecord.objects.create(user=user, timestamp=now)
                print("user=%s had no EmailDigestRecord so made one with timetsamp=%s" % (user.id, str(now)))

            content = newsfeed.get_rendered_news_feed(user, user, 'E', timestamp)
            if content:
                print("sending email to %s" % user.id)
                
                add_to_mail_queue(
                    '*****@*****.**',
                    user.email,
                    '[Flowgram] Your subscription updates',
                    '',
                    content,
                    'text/html')
        
        time.sleep(600)
예제 #4
0
def rss_newsfeed(request, enc, username):
    return HttpResponse(
        newsfeed.get_rendered_news_feed(request.user,
                                        get_object_or_404(auth_models.User, username=username),
                                        'R'),
        mimetype='application/rss+xml')