Exemple #1
0
def images(request):

    context = setConstants({}, prmz, request)

    if request.method == 'GET' and request.GET != {}:
        context['searchValues'] = request.GET
        prmz.MAXFACETS = 0

        if 'keyword' in request.GET:
            context['keyword'] = request.GET['keyword']
        if 'accession' in request.GET:
            context['accession'] = request.GET['accession']
            context['maxresults'] = 1

        context['maxresults'] = prmz.MAXRESULTS
        # use the grid display fields (we only show two of the required ones)
        context['displayType'] = 'grid'
        # it's an image browser, so only return items with images...
        context['pixonly'] = 'true'

        # do search
        loginfo('imagebrowser', 'start imagebrowser search', context, request)
        context = doSearch(context, prmz, request)
        context['additionalInfo'] = AdditionalInfo.objects.filter(live=True)

        return render(request, 'showImages.html', context)

    else:

        context = setConstants({}, prmz, request)
        context['pgNum'] = 10
        context['maxresults'] = 20
        return render(request, 'showImages.html', context)
Exemple #2
0
def locations(request):
    if request.method == 'GET' and request.GET != {}:
        context = {'searchValues': request.GET}

        context = setConstants(context)

        #context['currentlocation_s'] = '*'
        #context['pgNum'] = pgNum if 'pgNum' in context else '1'
        #context['url'] = url
        #context['displayType'] = 'list'
        #context['pixonly'] = 'true'
        #context['title'] = TITLE

        # do search
        loginfo('start search', context, request)
        #context = doSearch(context)

        locations = getlocations(connect_string)
        context['locations'] = locations
        context['loginBtnNext'] = 'locviewer/'

        return render(request, 'viewLocations.html', context)

    else:
        return render(request, 'viewLocations.html',
                      {'title': TITLE, 'pgNum': 10, 'maxresults': 20,
                       'imageserver': IMAGESERVER, 'loginBtnNext': 'locviewer/'})
def skeleton(request):
    if request.method == 'GET' and request.GET != {}:
        context = {'searchValues': dict(request.GET.iteritems())}
        context = doSearch(context, prmz, request)
    else:
        context = setConstants({}, prmz, request)

    loginfo(logger, 'start search', context, request)
    context['additionalInfo'] = AdditionalInfo.objects.filter(live=True)
    return render(request, 'osteo.html', context)
Exemple #4
0
def images(request):

    context = setConstants({}, prmz, request)

    # http://blog.mobileesp.com/
    # the middleware must be installed for the following to work...
    if request.is_phone:
        context['device'] = 'phone'
    elif request.is_tablet:
        context['device'] = 'tablet'
    else:
        context['device'] = 'other'

    if request.method == 'GET' and request.GET != {}:
        context['searchValues'] = request.GET
        prmz.MAXFACETS = 0

        if 'keyword' in request.GET:
            context['keyword'] = request.GET['keyword']
        if 'accession' in request.GET:
            context['accession'] = request.GET['accession']
            context['maxresults'] = 1

        context['maxresults'] = prmz.MAXRESULTS
        # use the grid display fields (we only show two of the required ones)
        context['displayType'] = 'grid'
        # it's an image browser, so only return items with images...
        context['pixonly'] = 'true'

        # do search
        loginfo(logger, 'start imagebrowser search', context, request)
        context = doSearch(context, prmz, request)
        context['additionalInfo'] = AdditionalInfo.objects.filter(live=True)

        return render(request, 'showImages.html', context)

    else:

        context = setConstants({}, prmz, request)
        context['pgNum'] = 10
        context['maxresults'] = 20
        return render(request, 'showImages.html', context)
def images(request):

    context = setConstants({}, prmz, request)

    # http://blog.mobileesp.com/
    # the middleware must be installed for the following to work...
    if request.is_phone:
        context['device'] = 'phone'
    elif request.is_tablet:
        context['device'] = 'tablet'
    else:
        context['device'] = 'other'

    if request.method == 'GET' and request.GET != {}:
        context['searchValues'] = request.GET
        prmz.MAXFACETS = 0

        if 'keyword' in request.GET:
            context['keyword'] = request.GET['keyword']
        if 'accession' in request.GET:
            context['accession'] = request.GET['accession']
            context['maxresults'] = 1

        context['maxresults'] = prmz.MAXRESULTS
        # use the grid display fields (we only show two of the required ones)
        context['displayType'] = 'grid'
        # it's an image browser, so only return items with images...
        context['pixonly'] = 'true'

        # do search
        loginfo(logger, 'start imagebrowser search', context, request)
        context = doSearch(context, prmz, request)
        context['additionalInfo'] = AdditionalInfo.objects.filter(live=True)

        return render(request, 'showImages.html', context)

    else:

        context = setConstants({}, prmz, request)
        context['pgNum'] = 10
        context['maxresults'] = 20
        return render(request, 'showImages.html', context)
Exemple #6
0
def search(request):
    if request.method == 'GET' and request.GET != {}:
        context = {'searchValues': dict(request.GET.iteritems())}
        context = doSearch(context, adhocprmz, request)

    else:
        context = setConstants({}, adhocprmz, request)

    loginfo('adhocreports', 'start adhocreport', context, request)
    context['additionalInfo'] = AdditionalInfo.objects.filter(live=True)
    return render(request, 'adhocreports.html', context)
def search(request):
    if request.method == 'GET' and request.GET != {}:
        context = {'searchValues': dict(request.GET.iteritems())}
        context = doSearch(context, prmz, request)
    else:
        context = setConstants({}, prmz, request)

    loginfo(logger, 'start search', context, request)
    context['additionalInfo'] = AdditionalInfo.objects.filter(live=True)
    context['extra_nav'] = {'href': '../skeleton', 'id': 'skeleton', 'name': 'Skeleton'}
    return render(request, 'search.html', context)
def search(request):
    if request.method == "GET" and request.GET != {}:
        context = {"searchValues": dict(request.GET.iteritems())}
        context = doSearch(context, prmz, request)

    else:
        context = setConstants({}, prmz, request)

    loginfo(logger, "start search", context, request)
    context["additionalInfo"] = AdditionalInfo.objects.filter(live=True)
    return render(request, "search.html", context)
Exemple #9
0
def search(request):
    if request.method == 'GET' and request.GET != {}:
        context = {'searchValues': request.GET}
        context = doSearch(context, prmz, request)

    else:
        context = setConstants({}, prmz, request)

    loginfo('internal', 'start search', context, request)
    context['additionalInfo'] = AdditionalInfo.objects.filter(live=True)
    return render(request, 'search.html', context)
Exemple #10
0
def search(request):
    if request.method == 'GET' and request.GET != {}:
        context = {'searchValues': dict(request.GET.iteritems())}
        context = doSearch(context, prmz)

    else:
        context = setConstants({}, prmz)

    loginfo(logger, 'start search', context, request)
    context['additionalInfo'] = AdditionalInfo.objects.filter(live=True)
    return render(request, 'ucjeps_searchmedia.html', context)
Exemple #11
0
def skeleton(request):
    if request.method == 'GET' and request.GET != {}:
        # context = {'searchValues': dict(request.GET.iteritems())}
        aggregate, search_keys = gatherosteoparms(dict(request.GET.iteritems()))
        requestObject = {'querystring': (' OR '.join(aggregate)), 'url': 'url', 'special': 'true'}
        context = {'searchValues': requestObject}
        context['aggregate'] = search_keys
        context = doSearch(context, prmz, request)
    else:
        context = setConstants({}, prmz, request)

    loginfo(logger, 'start skeleton search', context, request)
    context['additionalInfo'] = AdditionalInfo.objects.filter(live=True)
    context['extra_nav'] = {'href': '../search', 'id': 'search', 'name': 'Metadata Search'}
    return render(request, 'osteo.html', context)
def index(request):

    context = setConstants({}, prmz)

    # http://blog.mobileesp.com/
    # the middleware must be installed for the following to work...
    if request.is_phone:
        context['device'] = 'phone'
    elif request.is_tablet:
        context['device'] = 'tablet'
    else:
        context['device'] = 'other'

    if request.method == 'GET':
        context['searchValues'] = request.GET
        prmz.MAXFACETS = 0

        if 'keyword' in request.GET:
            context['keyword'] = request.GET['keyword']
        if 'accession' in request.GET:
            context['accession'] = request.GET['accession']
            context['maxresults'] = 1
        if 'submit' in request.GET:
            context['maxresults'] = prmz.MAXRESULTS
            if "Metadata" in request.GET['submit']:
                context['resultType'] = 'metadata'
                context['displayType'] = 'full'
            elif "Images" in request.GET['submit']:
                context['resultType'] = 'images'
                context['pixonly'] = 'true'
                context['displayType'] = 'grid'
            elif "Lucky" in request.GET['submit']:
                context['resultType'] = 'metadata'
                context['maxresults'] = 1
        else:
            context['resultType'] = 'metadata'

        # do search
        loginfo(logger, 'start imaginator search', context, request)
        context = doSearch(context, prmz)
        context['additionalInfo'] = AdditionalInfo.objects.filter(live=True)

        return render(request, 'imagineImages.html', context)

    else:

        return render(request, 'imagineImages.html', context)
def index(request):

    context = setConstants({}, prmz)

    # http://blog.mobileesp.com/
    # the middleware must be installed for the following to work...
    if request.is_phone:
        context['device'] = 'phone'
    elif request.is_tablet:
        context['device'] = 'tablet'
    else:
        context['device'] = 'other'

    if request.method == 'GET':
        context['searchValues'] = request.GET
        prmz.MAXFACETS = 0

        if 'keyword' in request.GET:
            context['keyword'] = request.GET['keyword']
        if 'accession' in request.GET:
            context['accession'] = request.GET['accession']
            context['maxresults'] = 1
        if 'submit' in request.GET:
            context['maxresults'] = prmz.MAXRESULTS
            if "Metadata" in request.GET['submit']:
                context['resultType'] = 'metadata'
                context['displayType'] = 'full'
            elif "Images" in request.GET['submit']:
                context['resultType'] = 'images'
                context['pixonly'] = 'true'
                context['displayType'] = 'grid'
            elif "Lucky" in request.GET['submit']:
                context['resultType'] = 'metadata'
                context['maxresults'] = 1
        else:
            context['resultType'] = 'metadata'

        # do search
        loginfo(logger, 'start imaginator search', context, request)
        context = doSearch(context, prmz)
        context['additionalInfo'] = AdditionalInfo.objects.filter(live=True)

        return render(request, 'imagineImages.html', context)

    else:
        
        return render(request, 'imagineImages.html', context)
def index(request):

    context = setConstants({}, prmz, request)

    if request.method == 'GET':
        context['searchValues'] = request.GET
        prmz.MAXFACETS = 0
        # default display type is Full
        context['displayType'] = 'full'

        if 'keyword' in request.GET:
            context['keyword'] = request.GET['keyword']
        if 'accession' in request.GET:
            context['accession'] = request.GET['accession']
            context['maxresults'] = 1
        if 'submit' in request.GET:
            context['maxresults'] = prmz.MAXRESULTS
            if "Metadata" in request.GET['submit']:
                context['resultType'] = 'metadata'
            elif "Images" in request.GET['submit']:
                context['resultType'] = 'images'
                context['pixonly'] = 'true'
            elif "Lucky" in request.GET['submit']:
                context['resultType'] = 'metadata'
                context['maxresults'] = 1
        else:
            context['resultType'] = 'metadata'

        # do search
        loginfo('imaginator', 'start imaginator search', context, request)
        context = doSearch(context, prmz, request)
        context['additionalInfo'] = AdditionalInfo.objects.filter(live=True)

        return render(request, 'imagineImages.html', context)

    else:

        return render(request, 'imagineImages.html', context)
def index(request):

    context = setConstants({}, prmz, request)

    if request.method == 'GET':
        context['searchValues'] = request.GET
        prmz.MAXFACETS = 0

        if 'keyword' in request.GET:
            context['keyword'] = request.GET['keyword']
        if 'accession' in request.GET:
            context['accession'] = request.GET['accession']
            context['maxresults'] = 1
        if 'submit' in request.GET:
            context['maxresults'] = prmz.MAXRESULTS
            if "Metadata" in request.GET['submit']:
                context['resultType'] = 'metadata'
                context['displayType'] = 'full'
            elif "Images" in request.GET['submit']:
                context['resultType'] = 'images'
                context['pixonly'] = 'true'
                context['displayType'] = 'grid'
            elif "Lucky" in request.GET['submit']:
                context['resultType'] = 'metadata'
                context['maxresults'] = 1
        else:
            context['resultType'] = 'metadata'

        # do search
        loginfo(logger, 'start imaginator search', context, request)
        context = doSearch(context, prmz, request)
        context['additionalInfo'] = AdditionalInfo.objects.filter(live=True)

        return render(request, 'imagineImages.html', context)

    else:
        
        return render(request, 'imagineImages.html', context)
Exemple #16
0
def loadNewFields(request, fieldfile, prmx):
    loadFields(fieldfile + '.csv', prmx)

    context = setConstants({}, prmx, request)
    loginfo('internal', 'loaded fields', context, request)
    return render(request, 'search.html', context)
def loadNewFields(request, fieldfile, prmz):
    loadFields(fieldfile + '.csv', prmz)

    context = setConstants({}, prmz)
    loginfo(logger, 'loaded fields', context, request)
    return render(request, 'search.html', context)
def index(request):

    context = setConstants({}, prmz, request)
    context['additionalInfo'] = AdditionalInfo.objects.filter(live=True)

    if request.method == 'POST':
        prmz.MAXFACETS = 0
        context['searchValues'] = {'map-bmapper': '', 'querystring': ''}
        context['maxresults'] = prmz.MAXRESULTS
        context['displayType'] = 'list'

        context['objects'] = request.POST['objects']
        context['group'] = request.POST['gr.group']

        messages = []
        groupcsid = None
        queryterms = []

        if 'submit' in request.POST:
            # we piggyback on the "bmapper search handling" here: we don't want
            # doSearch to construct the query string for us 'cause it won't
            # do it right: we make our own below that merges the group results (if any)
            # with the list of object numbers (if any)
            if 'gr.group' in request.POST:
                group = request.POST['gr.group']
                if group == '':
                    messages = ['A value for group title (either an existing group or a potential new one) is required.']
                else:
                    grouptitle, groupcsid, totalItems, list_of_objects, errormsg = find_group(request, urllib.quote_plus(group), prmz.MAXRESULTS)

                    if groupcsid is not None:
                        if len(list_of_objects) > 0:
                            queryterms.append(prmz.CSIDFIELD + ':(' + " OR ".join(list_of_objects) + ')')
                        context['groupaction'] = 'Update Group'
                    else:
                        context['groupaction'] = 'Create Group'

                    if totalItems > prmz.MAXRESULTS:
                        messages += ['This group has %s members and so is too big for Grouper. Maximum number of members Grouper can handle is %s' % (totalItems, prmz.MAXRESULTS)]
                        remove_items(context)
                    if errormsg is not None:
                        messages.append(errormsg)
                        remove_items(context)

            if 'objects' in request.POST:
                objectnumbers = request.POST['objects'].strip()
                objectnumbers = re.sub(r"[\r\n ]+", ' ', objectnumbers)
                if objectnumbers == '':
                    pass
                else:
                    objectnumbers_escaped = objectnumbers.replace(')','\)').replace('(','\(').replace('+','\+')
                    objectnumbers_escaped = objectnumbers_escaped.split(' ')
                    objectnumbers = objectnumbers.split(' ')
                    if len(objectnumbers) > 0:
                        queryterms.append('%s: (' % prmz.NUMBERFIELD + " OR ".join(objectnumbers_escaped) + ')')

            if 'groupaction' in context:
                context = setup_solr_search(queryterms, context, prmz, request)
                if 'count' in context and context['count'] > prmz.MAXRESULTS:
                    messages += ['This group is too big for Grouper. Maximum number of members is %s' % prmz.MAXRESULTS]
                    remove_items(context)
                elif 'items' in context:
                    object_numbers_found = [item['accession'] for item in context['items']]
                    obj2csid = [[item['csid'], item['accession']] for item in context['items'] if item['accession'] in objectnumbers]
                    # if we are dealing with a group that already exists, we need to avoid inserting duplicates
                    messages += ['"%s" not found and so not included.' % accession for accession in objectnumbers if accession not in object_numbers_found ]
                    if groupcsid is not None:
                        messages += ['"%s" already in member list and so not duplicated.' % item[1] for item in obj2csid if item[0] in list_of_objects]
                    if prmz.MAXRESULTS < context['count']:
                        messages += ['Only %s items of %s are displayed below and can be managed.' % (prmz.MAXRESULTS, context['count'])]
                else:
                    messages += ['problem with Solr query: %s' % context['searchValues']['querystring'] ]

        elif 'updategroup' in request.POST:
            group = request.POST['gr.group']
            # it's complicated: we can't search in Solr for the group, as we may have just created or updated it.
            # so we have to do REST calls to find the group and its CSIDs, then we can search Solr
            # though we might still miss some... :-(
            grouptitle, groupcsid, totalItems, list_of_objects, errormsg = find_group(request, urllib.quote_plus(group), prmz.MAXRESULTS)
            if groupcsid is None:
                groupcsid = create_group(group, request)
                context['items'] = []
            else:
                if len(list_of_objects) > 0:
                    queryterms = ['%s: (' % prmz.CSIDFIELD + " OR ".join(list_of_objects) + ')']
                context = setup_solr_search(queryterms, context, prmz, request)
                if prmz.MAXRESULTS < len(context['items']):
                    messages += ['Only %s items of %s are displayed below.' % (prmz.MAXRESULTS, context['items'])]
            items2add = []
            items2delete = []
            items_ignored = []
            items_included = []
            for item in request.POST:
                if "item-" in item:
                    items_included.append(request.POST[item])
                    # add this item to the group if it's not a member already
                    if request.POST[item] in list_of_objects:
                        pass
                    else:
                        items2add.append(request.POST[item])
            object_numbers_found = [item['csid'] for item in context['items']]
            for i, item in enumerate(object_numbers_found):
                if item in items_included:
                    pass
                else:
                    items2delete.append(item)

            messages += add2group(groupcsid, items2add, request)
            messages += delete_from_group(groupcsid, items2delete, request)
            grouptitle, groupcsid, totalItems, list_of_objects, errormsg = find_group(request, urllib.quote_plus(group), prmz.MAXRESULTS)
            if len(items_ignored) > 0 : messages += ['%s items in group untouched.' % len(items_ignored)]
            queryterms = [ '%s: (' % prmz.CSIDFIELD + " OR ".join(list_of_objects) + ')' ]
            context = setup_solr_search(queryterms, context, prmz, request)

        if len(messages) > 0:
            context['messages'] = messages
        return render(request, 'grouper.html', context)

    else:
        
        return render(request, 'grouper.html', context)
Exemple #19
0
def loadNewFields(request, fieldfile, prmz):
    loadFields(fieldfile + '.csv', prmz)

    context = setConstants({}, prmz)
    loginfo(logger, 'loaded fields', context, request)
    return render(request, 'ucjeps_searchmedia.html', context)
Exemple #20
0
def index(request):

    context = setConstants({}, prmz, request)
    context['additionalInfo'] = AdditionalInfo.objects.filter(live=True)

    return render(request, 'locationhistory.html', context)
def loadNewFields(request, fieldfile, prmx):
    loadFields(fieldfile + ".csv", prmx)

    context = setConstants({}, prmx, request)
    loginfo(logger, "loaded fields", context, request)
    return render(request, "search.html", context)
def JSONentry(request): 
    context = setConstants({}, prmz, request)
    
    return render(request, 'json_searchentry.html', context)
Exemple #23
0
def loadNewFields(request, fieldfile, prmz):
    loadFields(fieldfile + '.csv', prmz)

    context = setConstants({}, prmz, request)
    loginfo(logger, 'loaded fields', context, request)
    return render(request, 'adhocreports.html', context)
Exemple #24
0
def JSONentry(request): 
    context = setConstants({}, prmz, request)
    
    return render(request, 'json_searchentry.html', context)
Exemple #25
0
def results(request):

    context = setConstants({}, prmz, request)
    context['additionalInfo'] = AdditionalInfo.objects.filter(live=True)

    if request.method == 'POST':
        prmz.MAXFACETS = 0
        context['searchValues'] = {'map-bmapper': '', 'querystring': ''}
        context['maxresults'] = prmz.MAXRESULTS
        context['displayType'] = 'list'

        # copy input form fields into context so they are preserved...
        #for i in 'gr.group lo.location ob.objects'.split(' '):
        #    if i in request.POST:
        #        context[i] = request.POST[i]

        messages = []

        #if 'group' in request.POST or 'location' in request.POST or 'objects' in request.POST:
        if request.POST['searchtype'] == 'search-group':
            context['clicked'] = 'group'
            group = request.POST['gr.group']
            if group == '':
                messages = ['A value for group title is required.']
            else:
                grouptitle, groupcsid, totalItems, list_of_objects, errormsg = find_items_in_cspace(
                    request, 'group', urllib.quote_plus(group),
                    prmz.MAXRESULTS)

                if groupcsid is not None and len(list_of_objects) > 0:
                    queryterms = [
                        prmz.CSIDFIELD + ':(' + " OR ".join(list_of_objects) +
                        ')'
                    ]
                    context['searchterm'] = group
                    context = setup_solr_search(queryterms, context, prmz,
                                                request, group)
                    context['count'] = totalItems

        elif request.POST['searchtype'] == 'search-location':
            context['clicked'] = 'location'
            location = request.POST['lo.location'].strip()
            if location == '':
                messages = ['A value for storage location is required.']
            else:
                # first we find all the movement records that use this location
                queryterms = ['location_txt: "%s"' % location]
                context['searchterm'] = location
                context = setup_solr_search(queryterms, context, prmz, request,
                                            location)

                # then we find the CSIDs of the objects that have been in that location
                csids = [item['csid'] for item in context['items']]
                csids = list(set(csids))
                totalItems = len(csids)

                if totalItems > prmz.MAXRESULTS:
                    messages += [
                        'This location housed %s objects and so is too big for location history. Maximum number of members locationhistory can handle is %s'
                        % (totalItems, prmz.MAXRESULTS)
                    ]
                else:
                    # then we search for those objects
                    queryterms = [
                        prmz.CSIDFIELD + ':(' + " OR ".join(csids) + ')'
                    ]
                    context = setup_solr_search(queryterms, context, prmz,
                                                request, location)
                    context['count'] = totalItems

                    if totalItems > prmz.MAXRESULTS:
                        messages += [
                            '%s objects passed through this location and so it is too big for location history. Maximum number of members locationhistory can handle is %s'
                            % (totalItems, prmz.MAXRESULTS)
                        ]

                if 'errormsg' in context:
                    messages.append(context['errormsg'])

        elif request.POST['searchtype'] == 'search-objects':
            context['clicked'] = 'objects'
            objectnumbers = request.POST['ob.objects']
            objectnumbers = re.sub(r"[\r\n\t ]+", ' ', objectnumbers)
            objectnumbers = objectnumbers.strip()
            if objectnumbers == '':
                messages = ['One or more museum numbers is required.']
            else:
                objectnumbers_escaped = objectnumbers.replace(
                    ')', '\)').replace('(', '\(').replace('+', '\+')
                objectnumbers_escaped = objectnumbers_escaped.split(' ')
                context['searchterm'] = objectnumbers
                objectnumbers = objectnumbers.split(' ')
                if len(objectnumbers) > 0:
                    queryterms = [
                        'objectnumber_s' + ':(' +
                        " OR ".join(objectnumbers_escaped) + ')'
                    ]
                context = setup_solr_search(queryterms, context, prmz, request,
                                            '')
                totalItems = len(context['items'])
                context['count'] = totalItems

                if totalItems > prmz.MAXRESULTS:
                    messages += [
                        'This list of objects too big (%s) for location history. Maximum number of members locationhistory can handle is %s'
                        % (totalItems, prmz.MAXRESULTS)
                    ]
                if 'errormsg' in context:
                    messages.append(context['errormsg'])

        if len(messages) > 0:
            context['messages'] = messages

    return render(request, 'location_results_panel.html', context)
Exemple #26
0
def index(request):

    context = setConstants({}, prmz, request)
    context['additionalInfo'] = AdditionalInfo.objects.filter(live=True)

    if request.method == 'POST':
        prmz.MAXFACETS = 0
        context['searchValues'] = {'map-bmapper': '', 'querystring': ''}
        context['maxresults'] = prmz.MAXRESULTS
        context['displayType'] = 'list'

        context['objects'] = request.POST['objects']
        context['group'] = request.POST['gr.group']

        messages = []
        groupcsid = None
        queryterms = []

        if 'submit' in request.POST:
            # we piggyback on the "bmapper search handling" here: we don't want
            # doSearch to construct the query string for us 'cause it won't
            # do it right: we make our own below that merges the group results (if any)
            # with the list of object numbers (if any)
            if 'gr.group' in request.POST:
                group = request.POST['gr.group']
                if group == '':
                    messages = [
                        'A value for group title (either an existing group or a potential new one) is required.'
                    ]
                else:
                    grouptitle, groupcsid, totalItems, list_of_objects, errormsg = find_group(
                        request, urllib.quote_plus(group), prmz.MAXRESULTS)

                    if groupcsid is not None:
                        if len(list_of_objects) > 0:
                            queryterms.append(prmz.CSIDFIELD + ':(' +
                                              " OR ".join(list_of_objects) +
                                              ')')
                        context['groupaction'] = 'Update Group'
                    else:
                        context['groupaction'] = 'Create Group'

                    if totalItems > prmz.MAXRESULTS:
                        messages += [
                            'This group has %s members and so is too big for Grouper. Maximum number of members Grouper can handle is %s'
                            % (totalItems, prmz.MAXRESULTS)
                        ]
                        remove_items(context)
                    if errormsg is not None:
                        messages.append(errormsg)
                        remove_items(context)

            if 'objects' in request.POST:
                objectnumbers = request.POST['objects'].strip()
                objectnumbers = re.sub(r"[\r\n ]+", ' ', objectnumbers)
                if objectnumbers == '':
                    pass
                else:
                    objectnumbers_escaped = objectnumbers.replace(
                        ')', '\)').replace('(', '\(').replace('+', '\+')
                    objectnumbers_escaped = objectnumbers_escaped.split(' ')
                    objectnumbers = objectnumbers.split(' ')
                    if len(objectnumbers) > 0:
                        queryterms.append('%s: (' % prmz.NUMBERFIELD +
                                          " OR ".join(objectnumbers_escaped) +
                                          ')')

            if 'groupaction' in context:
                context = setup_solr_search(queryterms, context, prmz, request)
                if 'count' in context and context['count'] > prmz.MAXRESULTS:
                    messages += [
                        'This group is too big for Grouper. Maximum number of members is %s'
                        % prmz.MAXRESULTS
                    ]
                    remove_items(context)
                elif 'items' in context:
                    object_numbers_found = [
                        item['accession'] for item in context['items']
                    ]
                    obj2csid = [[item['csid'], item['accession']]
                                for item in context['items']
                                if item['accession'] in objectnumbers]
                    # if we are dealing with a group that already exists, we need to avoid inserting duplicates
                    messages += [
                        '"%s" not found and so not included.' % accession
                        for accession in objectnumbers
                        if accession not in object_numbers_found
                    ]
                    if groupcsid is not None:
                        messages += [
                            '"%s" already in member list and so not duplicated.'
                            % item[1] for item in obj2csid
                            if item[0] in list_of_objects
                        ]
                    if prmz.MAXRESULTS < context['count']:
                        messages += [
                            'Only %s items of %s are displayed below and can be managed.'
                            % (prmz.MAXRESULTS, context['count'])
                        ]
                else:
                    messages += [
                        'problem with Solr query: %s' %
                        context['searchValues']['querystring']
                    ]

        elif 'updategroup' in request.POST:
            group = request.POST['gr.group']
            # it's complicated: we can't search in Solr for the group, as we may have just created or updated it.
            # so we have to do REST calls to find the group and its CSIDs, then we can search Solr
            # though we might still miss some... :-(
            grouptitle, groupcsid, totalItems, list_of_objects, errormsg = find_group(
                request, urllib.quote_plus(group), prmz.MAXRESULTS)
            if groupcsid is None:
                groupcsid = create_group(group, request)
                context['items'] = []
            else:
                if len(list_of_objects) > 0:
                    queryterms = [
                        '%s: (' % prmz.CSIDFIELD +
                        " OR ".join(list_of_objects) + ')'
                    ]
                context = setup_solr_search(queryterms, context, prmz, request)
                if prmz.MAXRESULTS < len(context['items']):
                    messages += [
                        'Only %s items of %s are displayed below.' %
                        (prmz.MAXRESULTS, context['items'])
                    ]
            items2add = []
            items2delete = []
            items_ignored = []
            items_included = []
            for item in request.POST:
                if "item-" in item:
                    items_included.append(request.POST[item])
                    # add this item to the group if it's not a member already
                    if request.POST[item] in list_of_objects:
                        pass
                    else:
                        items2add.append(request.POST[item])
            object_numbers_found = [item['csid'] for item in context['items']]
            for i, item in enumerate(object_numbers_found):
                if item in items_included:
                    pass
                else:
                    items2delete.append(item)

            messages += add2group(groupcsid, items2add, request)
            messages += delete_from_group(groupcsid, items2delete, request)
            grouptitle, groupcsid, totalItems, list_of_objects, errormsg = find_group(
                request, urllib.quote_plus(group), prmz.MAXRESULTS)
            if len(items_ignored) > 0:
                messages += [
                    '%s items in group untouched.' % len(items_ignored)
                ]
            queryterms = [
                '%s: (' % prmz.CSIDFIELD + " OR ".join(list_of_objects) + ')'
            ]
            context = setup_solr_search(queryterms, context, prmz, request)

        if len(messages) > 0:
            context['messages'] = messages
        return render(request, 'grouper.html', context)

    else:

        return render(request, 'grouper.html', context)