예제 #1
0
def dashboard(request):
    """ 
  ID Issues and Crossref tables load for the first time w/o ajax
  All subsequent searches are done via ajax (ajax_dashboard_table method below)
  """
    d = {'menu_item': 'ui_admin.dashboard'}
    user = userauth.getUser(request)
    d['heading_user_display'] = user.displayName + "'s EZID " + _("Dashboard")
    d['display_adminlink'] = user.isSuperuser
    if request.method == "GET":
        REQUEST = request.GET
    elif request.method == "POST":
        REQUEST = request.POST
    else:
        return uic.methodNotAllowed(request)
    if not ('owner_selected' in REQUEST) or REQUEST['owner_selected'] == '':
        d['owner_selected'] = (
            None
            if user.isSuperuser
            else "realm_" + user.realm.name
            if user.isRealmAdministrator
            else "group_" + user.group.groupname
            if user.isGroupAdministrator
            else "user_" + user.username
        )
    else:
        d['owner_selected'] = REQUEST['owner_selected']
    d['owner_names'] = uic.owner_names(user, "dashboard")
    d = _getUsage(REQUEST, user, d)
    d['ajax'] = False

    # Search:    ID Issues
    d = ui_search.search(d, request, NO_CONSTRAINTS, "issues")
    # UI Tables need data named uniquely to distinguish them apart
    d['results_issues'] = d['results']
    d['total_pages_issues'] = d['total_pages']
    d['field_display_types_issues'] = d['field_display_types']
    d['fields_selected_issues'] = d['fields_selected']

    d['has_broken_links'] = ui_search.hasBrokenLinks(d, request)
    if d['has_broken_links']:
        d['accountEmail'] = user.accountEmail

    # Search:    Crossref Submission Status
    d = ui_search.search(d, request, NO_CONSTRAINTS, "crossref")
    d['order_by'] = 'c_crossref_date'
    d['sort'] = 'asc'
    d['results_crossref'] = d['results']
    d['total_pages_crossref'] = d['total_pages']
    d['field_display_types_crossref'] = d['field_display_types']
    d['fields_selected_crossref'] = d['fields_selected']
    return uic.render(request, 'dashboard/index', d)
예제 #2
0
def index(request):
    """ Manage Page, listing all Ids owned by user, or if groupadmin, all group users """
    d = {'menu_item': 'ui_manage.index'}
    d['collapse_advanced_search'] = "collapsed"
    if request.method != "GET":
        return uic.methodNotAllowed(request)
    noConstraintsReqd = True  # Empty 'manage' form means search everything
    d['q'] = ui_search.queryDict(request)
    user = userauth.getUser(request)
    d['owner_selected'] = (
        _defaultUser(user)
        if not ('owner_selected' in request.GET) or request.GET['owner_selected'] == ''
        else request.GET['owner_selected']
    )
    d['form'] = form_objects.ManageSearchIdForm(d['q'])
    # order_by and sort are initial sorting defaults. The request trumps these.
    d['order_by'] = 'c_update_time'
    d['sort'] = 'asc'
    d['owner_names'] = uic.owner_names(user, "manage")
    # Check if anything has actually been entered into search fields
    searchfields = {
        k: v
        for k, v in d['q'].items()
        if k not in [u'sort', u'ps', u'order_by', u'owner_selected']
    }
    searchfields = filter(None, searchfields.values())
    if searchfields:
        noConstraintsReqd = False
        d[
            'filtered'
        ] = True  # Flag for template to provide option of searching on all IDs
    d = ui_search.search(d, request, noConstraintsReqd, "manage")
    return uic.render(request, 'manage/index', d)
예제 #3
0
파일: ui_admin.py 프로젝트: rogerdahl/ezid
def ajax_dashboard_table(request):
    if request.is_ajax():
        user = userauth.getUser(request)
        G = request.GET
        d = {}
        d['owner_selected'] = G[
            'owner_selected'] if 'owner_selected' in G else user.username
        d['p'] = G.get('p')
        if 'name' in G and d['p'] is not None and d['p'].isdigit():
            d['ajax'] = True
            d['s_type'] = G['name']
            d = ui_search.search(d, request, NO_CONSTRAINTS, G['name'])
            return uic.render(request, "dashboard/_" + G['name'], d)