Package: aa-freight
Freight for Alliance AuthFreight is anAlliance Auth(AA) app for running a freight service.ContentsOverviewKey FeaturesScreenshotsInstallationUpdatingSettingsOperation ModePermissionsPricingContract CheckChange LogOverviewThis app helps running a central freight service for an alliance or corporation. It allows different modes of operation that support the most common approaches a central freight service is setup. (e.g. for alliance members only or run by a corporation outside the alliance)Key FeaturesFreight offers the following main features:Reward calculator allowing members to easily calculate the correct reward for their a courier contractPage showing the list of currently outstanding courier contracts incl. an indicator if the contract is compliant with the pricing for the respective route ("contract check")Multiple routes can be defined, each with its own pricing.It's possible to have the same pricing for both directions, or to have different pricings for each direction of the same route.Automatic notifications to freight pilots on Discord informing them about new courier contractsAutomatic notifications to contract issuers on Discord informing them about the developing status of their contract or potentially issuesContract issuer can always check the current status of his courier contractsStatistics page showing key performance metrics for routes, pilots, customersLanguage support for English 🇺🇸 and German 🇩🇪ScreenshotsReward CalculatorContract ListDiscord NotificationInstallation1 - Install appInstall into your Alliance Auth virtual environment from PyPI:pipinstallaa-freight2 - Update Eve Online appUpdate the Eve Online app used for authentication in your AA installation to include the following scopes:esi-universe.read_structures.v1
esi-contracts.read_corporation_contracts.v13 - Configure AA settingsConfigure your AA settings (local.py) as follows:Add'freight'toINSTALLED_APPSAdd these lines add to bottom of your settings file:# settings for freightCELERYBEAT_SCHEDULE['freight_run_contracts_sync']={'task':'freight.tasks.run_contracts_sync','schedule':crontab(minute='*/10'),}If you want to setup notifications for Discord you can now also add the required settings. Check out sectionSettingsfor details.3a - Celery setupThis app uses celery for critical functions like refreshing data from ESI. We strongly recommend to enable the following additional settings for celery workers to enable proper logging and to protect against potential memory leaks:To enable logging of celery tasks up to info level:-l infoTo automatically restart workers that grow above 256 MB:--max-memory-per-child 262144Here is how an example config would look for workers in your supervisor conf:command=/home/allianceserver/venv/auth/bin/celery -A myauth worker -l info --max-memory-per-child 262144On Ubuntu you can runsystemctl status supervisorto see where your supervisor config file is located.Note that you need to restart the supervisor service itself to activate those changes.e.g. on Ubuntu:systemctlrestartsupervisor4 - Finalize installation into AARun migrations & copy static filespythonmanage.pymigrate
pythonmanage.pycollectstaticRestart your supervisor services for AA5 - Setup permissionsNow you can access Alliance Auth and setup permissions for your users. See sectionPermissionsbelow for details.6 - Setup contract handlerFinally you need to set the contract handler with the character that will be used for fetching the corporation or alliance contracts and related structures. Just click on "Set Contract Handler" and add the requested token. Note that only users with the appropriate permission will be able to see and use this function. However, the respective character does not need any special corporation roles. Any corp member will work.Once a contract handler is set the app will start fetching contracts. Wait a minute and then reload the contract list page to see the result.7 - Define pricingFinally go ahead and define the first pricing of a courier route. See sectionPricingfor details.That's it. The Freight app is fully installed and ready to be used.8 - Setup Discord Proxy (optional)If you want Freight to send contract updates as direct messages to your users you need to haveDiscord Proxyrunning. You also need to have Discord Proxy installed in the same Python venv like Freight.Once Discord Proxy is running just setFREIGHT_DISCORDPROXY_ENABLED = Truein your local settings to enable this feature.For details on how to setup Discord Proxy (if you don't have it running already) please see theinstallation documentation.UpdatingTo update your existing installation of Freight first enable your virtual environment.Then run the following commands from your AA project directory (the one that containsmanage.py).pipinstall-Uaa-freightpythonmanage.pymigratepythonmanage.pycollectstaticFinally restart your AA supervisor services.SettingsHere is a list of available settings for this app. They can be configured by adding them to your AA settings file (local.py). If they are not set the defaults are used.NameDescriptionDefaultFREIGHT_APP_NAMEName of this app as shown in the Auth sidebar, page titles and as default avatar name for notifications.'Freight'FREIGHT_CONTRACT_SYNC_GRACE_MINUTESSets the number minutes until a delayed sync will be recognized as error30FREIGHT_DISCORD_DISABLE_BRANDINGTurns off setting the name and avatar url for the webhook. Notifications will be posted by a bot called "Freight" with the logo of your organization as avatar imageFalseFREIGHT_DISCORDPROXY_ENABLEDWhether to use Discord Proxy for sending customer notifications as direct messages. Obviously requires Discord Proxy to be setup and running on your system and the Discord Services to be enabled.FalseFREIGHT_DISCORDPROXY_PORTTCP port on which Discord Proxy is running.50051FREIGHT_DISCORD_MENTIONSOptional mention string put in front of every notification to create pings: Typical values are:@hereor@everyone. You can also mention roles, however you will need to add the role ID for that. The format is:<@&role_id>and you can get the role ID by entering_<@role_name>in a channel on Discord. Seethis linkfor details.''FREIGHT_DISCORD_WEBHOOK_URLWebhook URL for the Discord channel where contract notifications for pilots should appear.NoneFREIGHT_DISCORD_CUSTOMERS_WEBHOOK_URLWebhook URL for the Discord channel where contract notifications for customers should appear.NoneFREIGHT_FULL_ROUTE_NAMESShow full name of locations in route, e.g on calculator drop downFalseFREIGHT_HOURS_UNTIL_STALE_STATUSDefines after how many hours the status of a contract is considered to be stale. Customer notifications will not be sent for a contract status that has become stale. This settings also prevents the app from sending out customer notifications for old contracts.24FREIGHT_OPERATION_MODESee sectionOperation Modefor details.Note that switching operation modes requires you to remove the existing contract handler with all its contracts and then setup a new contract handler'my_alliance'FREIGHT_STATISTICS_MAX_DAYSSets the number of days that are considered for creating the statistics90FREIGHT_NOTIFY_ALL_CONTRACTSSends all contracts notifications, even if they do not have corresponding pricingFalseOperation ModeThe operation mode defines which contracts are processed by the Freight. For example you can define that only contracts assigned to your alliance are processed. Any courier contract that is  not in scope of the configured operation mode will be ignored by the freight app and e.g. not show up in the contract list or generate notifications.The following operation modes are available:NameDescription'my_alliance'courier contracts assigned to configured alliance by an alliance member'my_corporation'courier contracts assigned to configured corporation by a corp member'corp_in_alliance'courier contracts assigned to configured corporation by an alliance member'corp_public'any courier contract assigned to the configured corporationPermissionsThis is an overview of all permissions used by this app:NamePurposeCodeCan add / update locationsUser can add and update Eve Online contract locations, e.g. stations and upwell structuresadd_locationCan access this appEnabling the app for a user. This permission should be enabled for everyone who is allowed to use the app (e.g. Member state)basic_accessCan setup contract handlerAdd or updates the character for syncing contracts. This should be limited to users with admins / leadership privileges. Note that characters need to retain that permission for the update process to continue to function.setup_contract_handlerCan use the calculatorEnables using the calculator page and the "My Contracts" page. This permission is usually enabled for every user with the member state.use_calculatorCan view the contracts listEnables viewing the page with all outstanding courier contractsview_contractsCan see statisticsUser with this permission can view the statistics pageview_statisticsPricingA pricing defines a route and the parameters for calculating the price for that route along with some additional information for the users. You can define multiple pricings if you want, but at least one pricing has to be defined for this app to work.Pricing routes are bidirectional by default. For bidirectional pricings courier contracts in both directions are matched against the same pricing. Alternatively pricings can also be defined individually for each direction.Pricings are defined in the admin section of AA, so you need staff permissions to access it.Most parameters of a pricing are optional, but you need to define at least one of the four pricing components to create a valid pricing. It's also possible to define a route that does not require a reward by setting "Price base" to 0 and not setting any other pricing components.All pricing parameters can be found on the admin panel under Pricing, with the exception of the "price per volume modifier", which is a global pricing parameter and therefore property of the ContractHandler.ParameterDescriptionPricing FunctionalityStart LocationStarting station or structure for courier route-End LocationDestination station or structure for courier route-Is ActiveNon active pricings will not be used or shown-Is BidirectionalWether this pricing shall apply to contracts for both directions of the route or only the specified direction-Price baseBase price in ISK. If this is the only defined pricing component it will be shown as "Fix price" in the calculator.Pricing componentPrice minMinimum total price in ISKPricing componentPrice per volumeAdd-on price per m3 volume in ISKPricing componentUse price per volume modifierSwitch defining if the global price per volume modifier should be used for pricingPricing flagPrice per volume modifierGlobal modifier for price per volume in percent.The purpose of this modifier is to be able to compensate for fuel price fluctuations, without having to adjust pricing for many individual routes. When used it will be added to the price per volume. It can be positive and negative, and the resulting price per volume will always be >= 0.e.g. if you have set a price of 200 ISK per m3 on a route, and set the global modifier to 10% then you get 220 ISK per m3 effectively.(defined for ContractHandler)Pricing modifierPrice per collateral_percentAdd-on price in % of collateralPricing componentCollateral minMinimum required collateral in ISKValidation checkCollateral maxMaximum allowed collateral in ISKValidation checkVolume minMinimum allowed volume in m3Validation checkVolume maxMaximum allowed volume in m3Validation checkDays to expireRecommended days for contracts to expireInfoDays to completeRecommended days for contract completionInfoDetailsText with additional instructions for using this pricingInfoHow to add new locations:If you are creating a pricing for a new route you may need to first add the locations (stations and/or structures).The easiest way is to create a courier contract between those locations in game and then run contract sync. Those locations will then be added automatically.Alternatively you can use the "Add Location" feature on the main page of the app. This will require you to provide the respective station or structure eve ID.Contract CheckThe app will automatically check if a newly issued contract complies with the pricing parameters for the respective route. If you want to be notified about all contracts, even without correct pricing, setFREIGHT_NOTIFY_ALL_CONTRACTSoption toTrueCompliant contracts will have a green checkmark (✓) in the "Contract Check" column on the contract list. Related notifications on Discord will be colored in green.Non-compliant contracts will have a red warning sign in the "Contract Check" column on the contract list. And related notifications on Discord will be colored in red. In addition the first customer notification will inform the customer about the issues and ask him to correct the issues.The following parameters will be checked (if they have been defined):reward in contract >= calculated rewardvolume min <= volume in contract <= volume maxcollateral min <= collateral in contract <= collateral maxDeviations on "Days to expire" and "Days to complete" are currently not part of the contract check and only used to show the recommended contract parameters in the calculator.