Models

class evesrp.models.ActionType[source]

An Enum for representing the types of Actions performed on a Request in addition to the status of a Request.

statuses[source]

A frozenset of all of the single ActionType members that also double as statuses for Requests.

finalized[source]

A frozenset of the ActionTypes that are terminal states for a Request (paid and rejected).

pending[source]

A frozenset of ActionTypes for Requests that require further action to be put in a finalized state.

approved = <approved>

Status for a request that has been evaluated and is awaitng payment.

comment = <comment>

A special type of Action representing a comment made on the request.

evaluating = <evaluating>

Status for a request being evaluated.

incomplete = <incomplete>

Status for a request that is missing details and needs further action.

paid = <paid>

Status for a request that has been paid. This is a terminatint state.

rejected = <rejected>

Status for a requests that has been rejected. This is a terminating state.

exception evesrp.models.ActionError[source]

Error raised for invalid state changes for a Request.

class evesrp.models.Action(request, user, note=None, type_=None)[source]

Bases: flask_sqlalchemy.Model, evesrp.util.models.AutoID, evesrp.util.models.Timestamped, evesrp.util.models.AutoName

Actions change the state of a Request.

Requests enforce permissions when actions are added to them. If the user adding the action does not have the appropriate Permissions in the request’s Division, an ActionError will be raised.

With the exception of the comment action (which just adds text to a request), actions change the status of a Request.

note

Any additional notes for this action.

request

The Request this action applies to.

type_

The action be taken. See ActionType for possible values.

user

The User who made this action.

class evesrp.models.ModifierError[source]

Error raised when a modification is attempted to a Request when it’s in an invalid state.

class evesrp.models.Modifier(request, user, note, value)[source]

Bases: flask_sqlalchemy.Model, evesrp.util.models.AutoID, evesrp.util.models.Timestamped, evesrp.util.models.AutoName

Modifiers apply bonuses or penalties to Requests.

This is an abstract base class for the pair of concrete implementations. Modifiers can be voided at a later date. The user who voided a modifier and when it was voided are recorded.

Requests enforce permissions when modifiers are added. If the user adding a modifier does not have the appropriate Permissions in the request’s Division, a ModifierError will be raised.

voided[source]

Boolean of whether this modifier has been voided or not.

This property is available as a hybrid_property, so it can be used natively in SQLAlchemy queries.

note

Any notes explaining this modification.

request

The Request this modifier applies to.

user

The User who added this modifier.

void(user)[source]

Mark this modifier as void.

Parameters:user (User) – The user voiding this modifier
voided_timestamp

If this modifier has been voided, this will be the timestamp of when it was voided.

voided_user

The User who voided this modifier if it has been voided.

class evesrp.models.AbsoluteModifier(request, user, note, value)[source]

Subclass of Modifier for representing absolute modifications.

Absolute modifications are those that are not dependent on the value of Request.base_payout.

value

How much ISK to add or remove from the payout

class evesrp.models.RelativeModifier(request, user, note, value)[source]

Subclass of Modifier for representing relative modifiers.

Relative modifiers depend on the value of Modifier.base_payout to calculate their effect.

value

What percentage of the payout to add or remove

class evesrp.models.Request(submitter, details, division, killmail, **kwargs)[source]

Bases: flask_sqlalchemy.Model, evesrp.util.models.AutoID, evesrp.util.models.Timestamped, evesrp.util.models.AutoName

Requests represent SRP requests.

payout

The total payout of this request taking all active modifiers into account.

In calculating the total payout, all absolute modifiers along with the base_payout are summed. This is then multipled by the sum of all of the relative modifiers plus 1. This property is a read-only hybrid_property, so it can be used natively in SQLAlchemy queries.

finalized[source]

Boolean of if this request is in a finalized state. Also a read-only hybrid_property so it can be used natively in SQLAlchemy queries.

__init__(submitter, details, division, killmail, **kwargs)[source]

Create a Request.

Parameters:
  • submitter (User) – The user submitting this request
  • details (str) – Supporting details for this request
  • division (Division) – The division this request is being submitted to
  • killmail (Killmail) – The killmail this request pertains to
actions

A list of Actions that have been applied to this request, sorted in the order they were applied.

alliance

The alliance of the pilot at the time of the killmail.

base_payout

The base payout for this request.

This value is clamped to a lower limit of 0. It can only be changed when this request is in an evaluating state, or else a ModifierError will be raised.

constellation

The constellation this loss occured in.

corporation

The corporation of the pilot at the time of the killmail.

details

Supporting information for the request.

division

The Division this request was submitted to.

kill_timestamp

The date and time of when the ship was destroyed.

killmail_url

The URL of the source killmail.

modifiers

A list of all Modifiers that have been applied to this request, regardless of wether they have been voided or not. They’re sorted in the order they were added.

payout

The payout for this requests taking into account all active modifiers.

pilot

The Pilot who was the victim in the killmail.

region

The region this loss occured in.

ship_type

The type of ship that was destroyed.

status

This attribute is automatically kept in sync as Actions are added to the request. It should not be set otherwise.

At the time an Action is added to this request, the type of action is checked and the state diagram below is enforced. If the action is invalid, an ActionError is raised.

digraph request_workflow {
rankdir="LR";

sub [label="submitted", shape=plaintext];

node [style="dashed, filled"];

eval [label="evaluating", fillcolor="#fcf8e3"];
rej [label="rejected", style="solid, filled", fillcolor="#f2dede"];
app [label="approved", fillcolor="#d9edf7"];
inc [label="incomplete", fillcolor="#f2dede"];
paid [label="paid", style="solid, filled", fillcolor="#dff0d8"];

sub -> eval;
eval -> rej [label="R"];
eval -> app [label="R"];
eval -> inc [label="R"];
rej -> eval [label="R"];
inc -> eval [label="R, S"];
inc -> rej [label="R"];
app -> paid [label="P"];
app -> eval [label="R"];
paid -> eval [label="P"];
paid -> app [label="P"];
}

R means a reviewer can make that change, S means the submitter can make that change, and P means payers can make that change. Solid borders are terminal states.

submitter

The User who submitted this request.

system

The solar system this loss occured in.

transformed[source]

Get a special HTML representation of an attribute.

Divisions can have a transformer defined on various attributes that output a URL associated with that attribute. This property provides easy access to the output of any transformed attributes on this request.

valid_actions(user)[source]

Get valid actions (besides comment) the given user can perform.