Base Views

globus_portal_framework.views.base.index_selection(request: HttpRequest) HttpResponse

This is usually the root / page for the portal for Globus Portal Framework. Users are first directed to this page to choose a Globus Search index. If the portal is configured with groups, they may also be prompted to check the groups page to ensure they have access to view the portal.

Parameters:

request – The Django request object

Returns:

A rendered Django Template View

Templates:

Chooses the following templates in order of precedence if they exist, determined by settings.BASE_TEMPLATES:

  • templates/globus-portal-framework/v2/index-selection.html

  • Default DGPF Template

Context:

This view creates the following context:

  • search_indexes - The entire block defined in settings.SEARCH_INDEXES

  • allowed_groups - The entire block defined in settings.SOCIAL_AUTH_GLOBUS_ALLOWED_GROUPS

Context Example:

{
    'allowed_groups': [
        {
            'name': 'My Group 1',
            'uuid': '08d8cd36-dd9d-11ee-8849-b93550bcf92a'
        }
    ],
    'search_indexes': {
        'perfdata': {
            'facets': [...],
            'fields': [...]
            'filter_match': 'match-all',
            'name': 'Performance Data',
            'template_override_dir': 'perfdata',
            'uuid': '5e83718e-add0-4f06-a00d-577dc78359bc'
        }
    }
}
globus_portal_framework.views.base.search_about(request: HttpRequest, index: str)

The Search About view is intended to show basic information about a Globus Search Index. It is by default accessible via the search tab located here:

templates/globus-portal-framework/v2/components/search-nav.html

Parameters:
  • request – The Django request object

  • index – The URL string identifying the Search Index

Returns:

A rendered Django Template View

Templates:

Chooses the following templates in order of precedence if they exist, determined by settings.BASE_TEMPLATES and settings.SEARCH_INDEXES.<index>.template_override_dir in Search Settings Reference:

  • templates/my-index/globus-portal-framework/v2/search-about.html

  • templates/globus-portal-framework/v2/search-about.html

  • Default DGPF Template

Context:

This view has not context.

globus_portal_framework.views.base.search(request: HttpRequest, index: str) HttpResponse

Search the ‘index’ with the queryparams ‘q’ for query, ‘filter.<filter>’ for facet-filtering, ‘page’ for pagination If the user visits this page again without a search query, we auto search for them again using their last query. If the user is logged in, they will automatically do a credentialed search for Globus Search to return confidential results (results where user is listed within visible_to). If more results than settings.SEARCH_RESULTS_PER_PAGE are returned, they are paginated.

Parameters:
  • request – The Django request object

  • index – The URL string identifying the Search Index

Returns:

A rendered Django Template View

Query Params:

q – key words for the users search. Ex: ‘q=foo*’ will search for ‘foo*’

filter. – Filter results on facets defined in settings.SEARCH_SCHEMA. The syntax for filters using query params is: ‘?filter.<filter_type>=<filter_value>, where ‘filter.<filter_type>’ is defined in settings.SEARCH_SCHEMA and <filter_value> is any value returned by Globus Search contained within search results. For example, we can define a filter ‘mdf.elements’ in our schema, and use it to filter all results containing H (Hydrogen).

page – Page of the search results. Number of results displayed per page is configured in settings.SEARCH_RESULTS_PER_PAGE, and number of pages can be controlled with settings.SEARCH_MAX_PAGES.

Templates:

Chooses the following templates in order of precedence if they exist, determined by settings.BASE_TEMPLATES and settings.SEARCH_INDEXES.<index>.template_override_dir in Search Settings Reference:

  • templates/my-index/globus-portal-framework/v2/search.html

  • templates/globus-portal-framework/v2/search.html

  • Default DGPF Template

Context - This view generates the following context:

  • count The number of search results shown

  • offset The offset of within the total search results, if the user has attempted to view the next page.

  • total The total results the search returned

  • pagination A dict containing pagination information about current and available pages of search results

  • facets Facets returned by get_search_facets in gsearch_reference DGPF does extra work to ensure facets are returned in the same order they are listed in SEARCH_RESULTS. SEARCH_INDEXES.facet_modifiers (see Facet Modifiers) can be used to modify data contained here.

  • search_results A list of results (controlled by settings.SEARCH_RESULTS_PER_PAGE) which contains two additional items for each search result:

    • subject: The Globus Search subject identifying the search result id

    • fields: An object containing DGPF fields (Passing result fields to templates). Raw results are always available via all.

{
    'search': {
        'count': 2,
        'offset': 0,
        'total': 2,
        'pagination': {'current_page': 1, 'pages': [{'number': 1}]},
        'facets': [
            {'buckets': [{'field_name': 'mdf.resource_type',
                        'value': 'record'}],
            'name': 'Resource Type'},
            <More Facets>...
        ],
        'search_results': [
        {
            'all': [<raw subject>],
            'subject': '<Globus Search Subject>',
            'fields': {
                'titles': {'field_name': 'titles',
                                                'value': '<Result Title>'},
                'version': {'field_name': 'version', 'value': '0.3.2'},
                '<field_name>': {'field_name': '<display_name>',
                                'value': '<field_value>'},
                'foo_field': {'field_name': 'foo', 'value': 'bar'}
            }
        }, <More Search Results>...]
    }
}

Example request: http://myhost/?q=foo*&page=2&filter.my.special.filter=goodresults

globus_portal_framework.views.base.detail(request: HttpRequest, index: str, subject: str) HttpResponse

Load a page for showing details for a single search result (subject). This view fetches the subject in the URL from Globus Search, and runs it through DGPF Fields (Passing result fields to templates). to produce context ready to render. The Detail page is intended to show all information about a Globus Search Subject, compared with the search view which is only intended to show minimum relavent information and hide unnecessary detail.

Parameters:
  • request – The Django request object

  • index – The URL string identifying the Search Index

  • subject – The Globus Search Subject to be displayed

Returns:

A rendered Django Template View

Templates:

Chooses the following templates in order of precedence if they exist, determined by settings.BASE_TEMPLATES and settings.SEARCH_INDEXES.<index>.template_override_dir in Search Settings Reference:

  • templates/my-index/globus-portal-framework/v2/detail-overview.html

  • templates/globus-portal-framework/v2/detail-overview.html

  • Default DGPF Template

Example Request: https://myhost/<myindex>/detail/<subject>/

Context

  • subject The quoted subject safe for being included in a URL

  • fields A dict of all configured fields (Passing result fields to templates).
    • Note: all is always included for the raw subject data.

Example context:

{
    'subject': '<Globus Search Subject>',
    'fields': {
        'all': [<list of raw entries>]
        'titles': {'field_name': 'titles', 'value': '<Result Title>'},
        'version': {'field_name': 'version', 'value': '0.3.2'},
        '<field_name>': {'field_name': '<display_name>', 'value': '<field_value>'}
    }
}
globus_portal_framework.views.base.detail_transfer(request, index, subject)

Deprecated. Will be removed in a future version.

globus_portal_framework.views.base.detail_preview(request, index, subject, endpoint=None, url_path=None)

Deprecated. Will be removed in a future version.

globus_portal_framework.views.base.logout(request: HttpRequest, next: str = '/') HttpResponseRedirect

Revoke the users tokens and pop their Django session, then redirect the user.

Parameters:
  • request – The Django Request

  • next – Location the user will be redirected after logout. Defaults to /. Can be specified by URL parameter or Query Parameter. Query Parameter takes precedence.

Returns:

django.http.HttpResponseRedirect

globus_portal_framework.views.base.allowed_groups(request: HttpRequest) HttpResponse

Show available Globus Groups configured in settings.SOCIAL_AUTH_GLOBUS_ALLOWED_GROUPS.

Note

This view is typically only used when groups are configured. If no groups are configured, all users will be allowed access and links to this view will not be listed by default (although it is still accessible in the URLs).

Warning

This view only controls access to the portal. Results on Globus Search records are controlled via visible_to per-search-result. Restricting who can login to your portal does not stop users from being able to access publicly listed search results via another Gloubs Application!

Parameters:

Parameters:

request – The Django Request object

Returns:

A rendered Django Template View

Templates:

Chooses the following templates in order of precedence if they exist, determined by settings.BASE_TEMPLATES and settings.SEARCH_INDEXES.<index>.template_override_dir in Search Settings Reference:

  • templates/my-index/globus-portal-framework/v2/allowed-groups.html

  • templates/globus-portal-framework/v2/allowed-groups.html

  • Default DGPF Template

Context

  • allowed_groups – A list of groups a user must have access to (at least one) to access
    the portal.
    • is_member – True if the user is a member of this group

    • name – The human readable name of this group

    • uuid – The Globus uuid if this group.

Example context:

{
    'allowed_groups': [
        {
            'is_member': True,
            'name': 'My Group 1',
            'uuid': '08d8cd36-dd9d-11ee-8849-b93550bcf92a'
        }
    ]
}