コード例 #1
0
ファイル: userprofile.py プロジェクト: Conectivo/colab
def read(request, user, email_address=None, editable=False, form=None):
    
    if form is None:
        form = UserCreationForm()
    
    if user:
        email_addresses = user.emails.all()
        profile = user.profile
        last_modified_docs = solrutils.get_latest_collaborations(
            username=user.username
        )
        
        type_count = solrutils.count_types(
            filters={'collaborator': user.username}
        )
        
    else:
        email_addresses = [email_address]
        profile = None
        last_modified_docs = []
        type_count = {}
        
    if not email_address and email_addresses:
        email_address = email_addresses[0]

    email_addresses_ids = tuple([str(addr.id) for addr in email_addresses])
    
    query = """
    SELECT 
        * 
    FROM
        super_archives_message JOIN (
            SELECT id
            FROM super_archives_message
            WHERE from_address_id IN (%(ids)s)
            GROUP BY thread_id, id
        ) AS subquery 
        ON subquery.id = super_archives_message.id
    ORDER BY 
        received_time DESC
    LIMIT 10;
    
    """ % {'ids': ','.join(email_addresses_ids)}

    emails = Message.objects.raw(query)
    #n_sent = Message.objects.filter(from_address__in=email_addresses).count()

    template_data = {
        'user_profile': profile,
        'email_address': email_address,
        'emails': emails or [],
        'form': form,
        'editable': editable,
        'type_count': type_count,
        'docs': last_modified_docs,
    }
    
    return render_to_response('user-profile.html', template_data, 
                              RequestContext(request))
コード例 #2
0
ファイル: other.py プロジェクト: Conectivo/colab
def home(request):
    """Index page view"""

    latest_threads = queries.get_latest_threads()
    hottest_threads = queries.get_hottest_threads()

    template_data = {
        'hottest_threads': hottest_threads[:6],
        'latest_threads': latest_threads[:6],
        'type_count': solrutils.count_types(sample=1000),
        'latest_docs': solrutils.get_latest_collaborations(6),
    }
    return render_to_response('home.html', template_data,
                              context_instance=RequestContext(request))