Exemple #1
0
def get_or_create_default_search_group(project):
    
    profile = project.searchprofile
    try:
        group = SearchGroup.objects.filter(profile=profile).filter(name=SearchGroup.DEFAULT_NAME)[0]
    except IndexError:
        print 'Creating default search group for project=%s' % project.short_name
        group = SearchGroup(profile=profile, name=SearchGroup.DEFAULT_NAME, order=len(list(profile.groups.all())))
        group.save()
    return group    
Exemple #2
0
def get_or_create_default_search_group(project):

    profile = project.searchprofile
    try:
        group = SearchGroup.objects.filter(profile=profile).filter(
            name=SearchGroup.DEFAULT_NAME)[0]
    except IndexError:
        print 'Creating default search group for project=%s' % project.short_name
        group = SearchGroup(profile=profile,
                            name=SearchGroup.DEFAULT_NAME,
                            order=len(list(profile.groups.all())))
        group.save()
    return group
Exemple #3
0
def create_project_search_profile(project):
    
    # don't do anything if profile already exists
    try:
        profile = project.searchprofile
    except SearchProfile.DoesNotExist:
        print 'Configuring the project search profile'
        # assign default URL, if available
        url = getattr(settings, "DEFAULT_SEARCH_URL", "")
        profile = SearchProfile(project=project, url=url)
        profile.save()
        # create default search group, assign facets to it
        group = SearchGroup(profile=profile, name=SearchGroup.DEFAULT_NAME, order=0)
        group.save()
        # assign default facets
        facets = DEFAULT_SEARCH_FACETS
        for key, label in facets.items():
            facet = SearchFacet(key=key, label=label, group=group)
            facet.save()
        project.searchprofile = profile
        project.save()
        return profile
Exemple #4
0
def create_project_search_profile(project):

    # don't do anything if profile already exists
    try:
        profile = project.searchprofile
    except SearchProfile.DoesNotExist:
        print 'Configuring the project search profile'
        # assign default URL, if available
        url = getattr(settings, "DEFAULT_SEARCH_URL", "")
        profile = SearchProfile(project=project, url=url)
        profile.save()
        # create default search group, assign facets to it
        group = SearchGroup(profile=profile,
                            name=SearchGroup.DEFAULT_NAME,
                            order=0)
        group.save()
        # assign default facets
        facets = DEFAULT_SEARCH_FACETS
        for key, label in facets.items():
            facet = SearchFacet(key=key, label=label, group=group)
            facet.save()
        project.searchprofile = profile
        project.save()
        return profile