コード例 #1
0
ファイル: views.py プロジェクト: DevangS/CoralNet
def source_list(request):
    """
    Page with a list of the user's Sources.
    Redirect to the About page if the user isn't logged in or doesn't have any Sources.
    """

    if request.user.is_authenticated():
        your_sources = Source.get_sources_of_user(request.user)
        your_sources_dicts = [dict(id=s.id,
                                   name=s.name,
                                   your_role=s.get_member_role(request.user),)
                              for s in your_sources]
        other_public_sources = Source.get_other_public_sources(request.user)

        # Here we get the map sources
        map_sources = get_map_sources()

        list_thumbnails = []
        # Here we get a list of a list of images, these will be displayed
        # within each of the description windows.
        # the latest images source will not be passed into the javascript functions
        for source in map_sources:
            list_thumbnails.append((source["latest_images"],source["id"]))
            del source["latest_images"]
        
        if your_sources:
            return render_to_response('images/source_list.html', {
                'your_sources': your_sources_dicts,
                'map_sources': map_sources,
                'google_maps_api_key': settings.GOOGLE_MAPS_API_KEY,
                'other_public_sources': other_public_sources,
                'list_thumbnails': list_thumbnails,
                },
                context_instance=RequestContext(request)
            )

    # not used
    return HttpResponseRedirect(reverse('source_about'))
コード例 #2
0
ファイル: views.py プロジェクト: koudev/CoralNet
def source_list(request):
    """
    Page with a list of the user's Sources.
    Redirect to the About page if the user isn't logged in or doesn't have any Sources.
    """

    if request.user.is_authenticated():
        your_sources = Source.get_sources_of_user(request.user)
        your_sources_dicts = [dict(id=s.id,
                                   name=s.name,
                                   your_role=s.get_member_role(request.user),)
                              for s in your_sources]
        other_public_sources = Source.get_other_public_sources(request.user)
        
        if your_sources:
            return render_to_response('images/source_list.html', {
                'your_sources': your_sources_dicts,
                'other_public_sources': other_public_sources,
                },
                context_instance=RequestContext(request)
            )

    return HttpResponseRedirect(reverse('source_about'))