arxiv.users.legacy.endorsements module

Provide endorsement authorizations for users.

Endorsements are authorization scopes tied to specific classificatory categories, and are used primarily to determine whether or not a user may submit a paper with a particular primary or secondary classification.

This module preserves the behavior of the legacy system with respect to interpreting endorsements and evaluating potential autoendorsement. The relevant policies can be found on the arXiv help pages.

arxiv.users.legacy.endorsements.category_policies()[source]

Load auto-endorsement policies for each category from the database.

Each category belongs to an endorsement domain, which defines the auto-endorsement policies. We retrieve those policies from the perspective of the individueal category for ease of lookup.

Returns:Keys are domain.Category instances. Values are dicts with policiy details.
Return type:dict
Return type:Dict[Category, Dict[~KT, ~VT]]
arxiv.users.legacy.endorsements.domain_papers(user, start_date=None)[source]

Calculate the number of papers that a user owns in each endorsement domain.

This includes both submitted and claimed papers.

Parameters:
  • user (domain.User) –
  • start_date (datetime or None) – If provided, will only count papers published after this date.
Returns:

Keys are classification domains (str), values are the number of papers in each respective domain (int).

Return type:

dict

Return type:

Dict[str, int]

arxiv.users.legacy.endorsements.explicit_endorsements(user)[source]

Load endorsed categories for a user.

These are endorsements (including auto-endorsements) that have been explicitly commemorated.

Parameters:user (domain.User) –
Returns:Each item is a domain.Category for which the user is explicitly endorsed.
Return type:list
Return type:List[Category]
arxiv.users.legacy.endorsements.get_endorsements(user)[source]

Get all endorsements (explicit and implicit) for a user.

Parameters:user (domain.User) –
Returns:Each item is a domain.Category for which the user is either explicitly or implicitly endorsed.
Return type:list
Return type:List[Category]
arxiv.users.legacy.endorsements.implicit_endorsements(user)[source]

Determine categories for which a user may be autoendorsed.

In the classic system, this was determined upon request, when the user attempted to submit to a particular category. Because we are separating authorization concerns (which includes endorsement) from the submission system itself, we want to calculate possible autoendorsement categories ahead of time.

New development of autoendorsement-related functionality should not happen here. This function and related code are intended only to preserve the business logic already implemented in the classic system.

:param User:

Returns:Each item is a domain.Category for which the user may be auto-endorsed.
Return type:list
Return type:List[Category]
arxiv.users.legacy.endorsements.invalidated_autoendorsements(user)[source]

Load any invalidated (revoked) auto-endorsements for a user.

Parameters:user (domain.User) –
Returns:Items are domain.Category for which the user has had past auto-endorsements revoked.
Return type:list
Return type:List[Category]
arxiv.users.legacy.endorsements.is_academic(user)[source]

Determine whether a user is academic, based on their email address.

Uses whitelist and blacklist patterns in the database.

Parameters:user (domain.User) –
Returns:
Return type:bool
Return type:bool