Models¶
models
Module¶
-
class
spreedly.models.
Fee
(*args, **kwargs)[source]¶ A Fee for a given Plan.
Attr plan: ForeignKey(Plan) Attr name: CharField(max_length=100) Attr group: ForeignKey(FeeGroup) Attr default_amount: DecimalField(default=0) -
add_fee
(user, description, amount=None)[source]¶ add a fee to the given user, with description and amount. if amount is not passed, then it will use default_amount if it is greater than 0.
if 404 or 422 are returned, the default action is not to save the line item to the db, this can be overriden with the setting SPREEDLY_SAVE_ON_FAIL, but it is not recomended as who knows what will happen.
Parameters: - user – the user to bill for the fee. they must be subscribed to self.plan
- description – The description of the fee to appear on the invoice
- amount – The amount to bill or None
Raises: ValueError
if the user is not subscribed to the plan or is subscribed to a different plan.Raises: Http404
if spreedly can’t find the plan, user, etc.Raises: HttpUnprocessableEntity
if spreedly raised 422 for some reason.
-
-
class
spreedly.models.
Plan
(*args, **kwargs)[source]¶ Subscription plan
-
class
spreedly.models.
PlanManager
[source]¶ Manager that handles syncing plans and finding enabled plans
-
class
spreedly.models.
Subscription
(*args, **kwargs)[source]¶ Class that manages the details for a specific
auth.User
‘s subscription to a plan. Since a user can only have one subscription, this is sometimes treated as a user profile class.-
add_fee
(fee, units, description)[source]¶ Add a fee to the subscription
Parameters: - fee –
Fee
to add to the linked user - units – the number of units the charge is for (100kb, 4 nights, etc.)
- description – a description of the charge
Returns: None
Raises: Http404 if incorrect subscriber, HttpUnprocessableEntity for any other 422 error
- fee –
-
allow_free_trial
()[source]¶ Allow a free Trial
Returns: Subscription
Raises: Exception
(of some kind) if bad juju
-
create_complimentary_subscription
(time, unit, feature_level)[source]¶ Raises: NotImplementedError
cause it isn’t implemented
-
ending_this_month
¶ Will this plan end within the next 30 days
-
subscription_active
¶ gets the status based on current active status and active_until
-