Exemplo n.º 1
0
def resources(request, site, tag_string='', type='other', template_name='plus_explore/explore_filtered.html', current_app='plus_groups'):
    form = SearchForm(request.GET)
    if form.is_valid():
        search, order = set_search_order(request, form)
    else:
        search = ''
        search_type = ''
 

    head_title = _('Resources')
    type_name = "Resource"

    # hmm shouldn't we just use current app to determine search_types?        
    search_types = narrow_search_types(type_name) 
    side_search = side_search_args('resources', search_types[0][1][2])

    listing_args_dict = listing_args('resources', 'resources_tag', tag_string=tag_string, search_terms=search, multitabbed=False, order=order, template_base="site_base.html", search_type_label=head_title)
    search_dict = plus_search(listing_args_dict['tag_filter'], search, search_types, order)
    
    return render_to_response(template_name, 
                              {'head_title':head_title,
                               'search':search_dict,
                               'listing_args':listing_args_dict,
                               'search_args':side_search,
                               "obj_type": type_name,
                               'intro_box_override':True}, 
                              context_instance=RequestContext(request,
                                                              current_app=current_app))
Exemplo n.º 2
0
def group_resources(request, group, tag_string, search, order, current_app, **kwargs):
    resource_listings_args = listing_args(current_app + ':group_resources', current_app + ':group_resources_tag', 
                                          tag_string=tag_string, search_terms=search, multitabbed=False, 
                                          order=order, template_base='plus_lib/listing_frag.html', 
                                          template_base_div_id='resources', group_id=group.id)
    search_types = narrow_search_types('Resource')
    results = plus_search(resource_listings_args['tag_filter'], search, search_types, order, in_group=group.get_ref())
    return {'search':results, 'listing_args':resource_listings_args}
Exemplo n.º 3
0
    def group_members(request, group, tag_string, search, order, current_app, **kwargs):
        member_listings_args = listing_args(current_app + ':group_%s'%member_or_host, 
                                            current_app + ':group_%s_tag'%member_or_host, 
                                            tag_string=tag_string, search_terms=search, multitabbed=False, 
                                            order=order, template_base='plus_lib/listing_frag.html', 
                                            template_base_div_id=member_or_host, group_id=group.id)

        search_types = narrow_search_types('Profile')
        member_profile_ids=make_profile_id_list(group)
        results = plus_search(member_listings_args['tag_filter'], search, search_types, order, 
                              extra_filter={'id__in':member_profile_ids})

        return {'search':results, 'listing_args':member_listings_args}
Exemplo n.º 4
0
def resources(request,
              site,
              tag_string='',
              type='other',
              template_name='plus_explore/explore_filtered.html',
              current_app='plus_groups'):
    form = SearchForm(request.GET)
    if form.is_valid():
        search, order = set_search_order(request, form)
    else:
        search = ''
        search_type = ''

    head_title = _('Resources')
    type_name = "Resource"

    # hmm shouldn't we just use current app to determine search_types?
    search_types = narrow_search_types(type_name)
    side_search = side_search_args('resources', search_types[0][1][2])

    listing_args_dict = listing_args('resources',
                                     'resources_tag',
                                     tag_string=tag_string,
                                     search_terms=search,
                                     multitabbed=False,
                                     order=order,
                                     template_base="site_base.html",
                                     search_type_label=head_title)
    search_dict = plus_search(listing_args_dict['tag_filter'], search,
                              search_types, order)

    return render_to_response(template_name, {
        'head_title': head_title,
        'search': search_dict,
        'listing_args': listing_args_dict,
        'search_args': side_search,
        "obj_type": type_name,
        'intro_box_override': True
    },
                              context_instance=RequestContext(
                                  request, current_app=current_app))
Exemplo n.º 5
0
def profiles(request, tag_string='', template_name="plus_explore/explore_filtered.html"):
    form = SearchForm(request.GET)
    if form.is_valid():
        search, order = set_search_order(request, form)
    else:
        search = ''
        order = ''

    search_types = narrow_search_types()
    side_search = side_search_args('profile_list', search_types[0][1][2])

    head_title = _('Members')
    listing_args_dict = listing_args('profile_list', 'profile_list_tag', tag_string=tag_string, search_terms=search, multitabbed=False, order=order, template_base="site_base.html", search_type_label=head_title)
    search_dict = plus_search(listing_args_dict['tag_filter'], search, search_types, order)

    #users = users.filter(~Q(username='******')).filter(~Q(username='******')).filter(~Q(username='******'))
    return render_to_response(template_name, {'head_title':head_title, 
                                              'listing_args':listing_args_dict,
                                              'search_args':side_search,
                                              'search':search_dict,
                                              'intro_box_override':True}, context_instance=RequestContext(request))
Exemplo n.º 6
0
def get_tags(tagged=None, tag_type=None, tag_value=None, tagged_for=None, tagged_by=None, partial_tag_value=None):
    """XXX Should only get viewable tags here, further should only get viewable items within those tags, and only viewable items within a tag which count towards its weight
    """

    tag_filter = {}

    if tag_type != None:
        tag_filter['tag_type'] = tag_type
    if tag_value != None:
        tag_filter['keyword'] = tag_value
    elif partial_tag_value != None:
        Qobj = Q(keyword__startswith=partial_tag_value) | Q(keyword__contains=' '+partial_tag_value)
    if tagged_for != None:
        if not isinstance(tagged_for, GenericReference):
            tagged_for = tagged_for.get_ref()
        tag_filter['tagged_for'] = tagged_for
    require_distinct = False

    if tagged != None:
        require_distinct = True
        if isinstance(tagged, tuple):
            from apps.plus_explore.views import plus_search
            tagged = plus_search([], '', tagged)['All'] #GenericReference.objects.filter(**tagged)
        else:
            tagged = [tagged.get_ref().id]
        tag_filter['items__in'] = tagged
        
    if tagged_by != None:
        require_distinct = True
        tag_filter['items__tagged_by'] = tagged_by.id
    if 'Qobj' in locals():
        tags = Tag.objects.filter(Qobj, **tag_filter)
    else:
        tags = Tag.objects.filter(**tag_filter)
    if require_distinct:
        tags.distinct()
    return tags
Exemplo n.º 7
0
def profiles(request, tag_string='', template_name="plus_explore/explore_filtered.html"):
    tags = tag_string.split('+')
    search = request.GET.get('search', '')
    order = request.GET.get('order', '')
    explicit_order = ''
    if order:
        explicit_order = order
    try:
        tags.remove('')
    except ValueError:
        pass
    search_type = 'profile_list'
    tag_search_type = 'profile_list_tag'
    search_types = narrow_search_types()
    search_types_len = len(search_types)
    search_type_label = search_types[0][1][2]
    all_results, search_types, tag_intersection  = plus_search(tags, search, search_types, order)
    head_title = _('Members')
    #users = users.filter(~Q(username='******')).filter(~Q(username='******')).filter(~Q(username='******'))
    return render_to_response(template_name, {'head_title':head_title, 
                                              'order':order,
                                              'explicit_order':order,
                                              'search_terms':search,
                                              'items': all_results,
                                              'items_len': len(all_results),
                                              'tag_filter':tags,
                                              'tag_string':tag_string,
                                              'multiple_tags':len(tags)>1,
                                              'tag_intersection':tag_intersection,
                                              'search_types':search_types,
                                              "search_types_len":search_types_len,
                                              'search_type_label':search_type_label,
                                              'search_type':search_type,
                                              'tag_search_type':tag_search_type,
                                              'multitabbed':False,
                                              'base':"site_base.html"}, context_instance=RequestContext(request))
Exemplo n.º 8
0
    search_type = current_app + ':groups'
    search_url = reverse(search_type)
    tag_search_type = current_app + ':groups_tag'
    search_types = narrow_search_types('Group')
    search_types_len = len(search_types)
    search_type_label = search_types[0][1][2]
    # XXX replace when we slot permissions in
    # XXX replace when we have more sophisticated listings search
    #pages = get_pages_for(group.get_inner())
    #resources = get_resources_for(group.get_inner())
    #objects = get_resources_and_pages_for(group)
    #objects = get_resources_and_pages_for(user, group)

    context = RequestContext(request, current_app=current_app)
    all_results, search_types, tag_intersection = plus_search(tags, search,  narrow_search_types('Resource'), order) #, extra_filter={'context':'TgGroup'})
    return render_to_response(template_name, {
            "head_title" : "%s" % group.get_display_name(),
            "head_title_status" : dummy_status,
            "group" : TemplateSecureWrapper(group),
            "target_class" : ContentType.objects.get_for_model(group.get_inner()).id,
            "target_id" : group.get_inner().id,
            "members" : members,
            "member_count" : member_count,
            "leave": leave,
            "can_join" : can_join, 
            "apply" : apply, 
            "invite" : invite, 
            "can_comment" : can_comment, 
            "message" : message,
            "add_link" : add_link,
Exemplo n.º 9
0
def a_member_search(group, tags=[], order=None, search='', member_profile_ids=[]):
    search_types = narrow_search_types('Profile')
    return plus_search(tags, search, search_types, order, extra_filter={'id__in':member_profile_ids})
Exemplo n.º 10
0
def resources(group, tags=[], order=None, search=''):
    search_types = narrow_search_types('Resource')
    return plus_search(tags, search, search_types, order, in_group=group.get_ref())
Exemplo n.º 11
0
        except Exception, e:
            print "User can't create a group",e
 
    if type == 'hub':
        head_title = _(hub_name_plural())
        type_name = hub_name()
    else:
        head_title = _('Groups')
        type_name = "Group"

    # hmm shouldn't we just use current app to determine search_types?        
    search_types = narrow_search_types(type_name) 
    side_search = side_search_args(current_app + ':groups', search_types[0][1][2])

    listing_args_dict = listing_args(current_app + ':groups', current_app + ':groups_tag', tag_string=tag_string, search_terms=search, multitabbed=False, order=order, template_base="site_base.html", search_type_label=head_title)
    search_dict = plus_search(listing_args_dict['tag_filter'], search, search_types, order)

    return render_to_response(template_name, 
                              {'head_title':head_title,
                               'search':search_dict,
                               'listing_args':listing_args_dict,
                               'search_args':side_search,
                               "create_group":create_group,
                               "obj_type": type_name,
                               'intro_box_override':True}, 
                             context_instance=RequestContext(request,
                                                             current_app=current_app,
                                                             ))