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:
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.

  • 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.FeeGroup(*args, **kwargs)[source]


class spreedly.models.LineItem(*args, **kwargs)[source]

This is an instance of a fee

class spreedly.models.Plan(*args, **kwargs)[source]

Subscription plan


Check if a user is eligibile for a trial on this plan, and if so, start a plan.

Parameters:user – user object to check
Raises :py:exc:Plan.NotEligibile if the user is not eligibile

Is a customer/user eligibile for a trial? :param user: auth.User

class spreedly.models.PlanManager[source]

Manager that handles syncing plans and finding enabled plans

Returns:Returns all enabled Plans

Gets a full list of plans from spreedly, and updates the local db to match it

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

  • feeFee 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


Raises :

Http404 if incorrect subscriber, HttpUnprocessableEntity for any other 422 error


Allow a free Trial

Raises :Exception (of some kind) if bad juju
create_complimentary_subscription(time, unit, feature_level)[source]
Raises :NotImplementedError cause it isn’t implemented

Will this plan end within the next 30 days


gets the status based on current active status and active_until


update a subscription with supplied data

Project Versions

Table Of Contents

Previous topic


Next topic


This Page