Workout With Friends
Stay fit with a little motivation
 All Classes Namespaces Files Functions Variables Properties
Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
wowf.models.user.User Class Reference
Inheritance diagram for wowf.models.user.User:
Inheritance graph
Collaboration diagram for wowf.models.user.User:
Collaboration graph

Public Member Functions

def age
 Calculate this users age.
def bmi
 Calculate this users Body Mass Index, which is a useful indicator of health.
def bmi_category
 Return the category this user belongs to based on BMI.
def total_points
 Calculate how many points this user has in total.
def __init__
def __unicode__
def get_by_username
 Search by username.
def get_by_email
 Search by email.
def create
def search
 Perform a fulltext search, matching the given terms.
def count_search_results
def is_user
 Quick and easy test to check if the given user is this user.
def update_profile
 Update this users profile, with both required and optional data.
def update_password
 Update this users password.
def update_avatar
 Update this users avatar (profile pic)
def get_average_speed
 Calculate the average speed (speed challenge) for a given distance.
def get_average_heart_rate
 Calculate the average heart rate (endurance challenge) for a given duration.
def get_average_calories_burned
 Calculate the average calories burned (endurance challenge) for a given duration.
def get_average_bench_press_repetitions
 Calculate the average bench press repetitions (bench press challenge) for a given percentage.
def get_average_squat_repetitions
 Calculate the average squat repetitions (squat challenge) for a given percentage.
def group_average_speed
 Calculate the average speed by day for a given distance.
def group_average_heart_rate
 Calculate the average heart rate by day for a given duration.
def group_average_calories_burned
 Calculate the average calories burned by day for a given duration.
def group_average_bench_press_repetitions
 Calculate the average bench press by day for a given percentage.
def group_average_squat_repetitions
 Calculate the average squat repetitions by day for a given percentage.
def get_buddies
 Return all of this users workout buddies.
def count_buddies
 Count how many workout buddies this user has.
def is_buddy
 Check whether the given user is a workout buddy.
def add_buddy
 Add the user to the list of workout buddies.
def remove_buddy
 Remove the user from the list of workout buddies.
def get_challenges
 Return all challenges this user is apart of (paginated).
def get_workout_for_challenge
 Return this users workout for the given challenge.
def count_challenges
 Count all challenges this user is a competitor in.
def create_speed_challenge
def create_endurance_challenge
def create_bench_press_challenge
def create_squat_challenge
def create_speed_workout
def create_endurance_workout
def create_bench_press_workout
def create_squat_workout
def in_challenge
 Check whether this user is a competitor in the given challenge.
def owns_challenge
 Check whether this user is the creator of the given challenge.
def accepted_challenge
 Check whether this user has accepted the given challenge.
def denied_challenge
 Check whether this user has denied the given challenge.
def accept_challenge
 Change the status between this user and the given challenge to accepted, and send all other competitors a notification.
def deny_challenge
 Change the status between this user and the given challenge to denied, and send all other competitors a notification.
def get_all_notifications
 Return all notifications, regardless of status (paginated).
def count_all_notifications
 Count all notifications, regardless of status.
def get_unconfirmed_notifications
 Return all notifications which have not been confirmed.
def count_unconfirmed_notifications
 Count all notifications which have not been confirmed.
def confirm_all_notifications
 Mark all notifications as confirmed (read).
def has_unconfirmed_notifications
 Check whether this user has any unconfirmed (unread) notifications.
- Public Member Functions inherited from wowf.models.meta.Base
def __str__
def __repr__
def get_by_id
def create
def delete
- Public Member Functions inherited from wowf.lib.fulltext.FulltextBase
def index_type
def index_id
def index_data
def add_index
 Add a fulltext index for this instance.
def delete_index
 Delete the fulltext index for this instance.
def update_index
 Update the fulltext index for this instance.

Public Attributes

 username
 email
 password
 gender
 dob
 weight
 height
 timezone
 avatar

Static Public Attributes

list index_fields = ['username']
tuple id = Column(Integer(unsigned=True), primary_key=True)
tuple username = Column(Unicode(10), nullable=False, unique=True)
tuple email = Column(Unicode(254), nullable=False, unique=True)
tuple gender = Column(Enum('F', 'M', name='user_genders'), nullable=False)
tuple dob = Column(Date, nullable=False)
tuple weight = Column(Numeric(7, 4), nullable=False, doc='weight in kilograms')
tuple height = Column(Numeric(5, 4), nullable=False, doc='height in meters')
tuple timezone = Column(Unicode(50))
tuple is_active = Column(Boolean, nullable=False, default=True)
tuple created_at = Column(DateTime, nullable=False, default=current_timestamp)
tuple last_active_at = Column(DateTime, nullable=False, default=current_timestamp)
tuple password = synonym('_password', descriptor=property(_get_password, _set_password))
tuple avatar = synonym('_avatar', descriptor=property(_get_avatar, _set_avatar))
- Static Public Attributes inherited from wowf.models.meta.Base
tuple query = DBSession.query_property()
- Static Public Attributes inherited from wowf.lib.fulltext.FulltextBase
list index_fields = []

Private Member Functions

def _get_password
def _set_password
 Hash the given password.
def _get_avatar
 Return a stored image, to allow different versions of the avatar to be served.
def _set_avatar
 Upload the avatar and set the necessary reference to it.
def _get_search_query
def _create_challenge
 Add the competitor to the challenge and send them a notification.
def _create_workout
 Send the other competitor(s) a notification.
def _get_buddies_query
 Query for all of this users buddies.
def _get_buddy
 Return the buddy link between this user and the given user.
def _get_challenge_link
 Return the link between this user and the given challenge.
def _get_notifications_query

Private Attributes

 _password
 _avatar

Static Private Attributes

string __tablename__ = 'users'
tuple _password = Column('password', CHAR(60), nullable=False)
tuple _avatar = Column('avatar', Unicode(40))

Detailed Description

Definition at line 24 of file user.py.

Constructor & Destructor Documentation

def wowf.models.user.User.__init__ (   self,
  username,
  email,
  password,
  gender,
  dob,
  weight,
  height 
)

Definition at line 127 of file user.py.

Member Function Documentation

def wowf.models.user.User.__unicode__ (   self)

Reimplemented from wowf.models.meta.Base.

Definition at line 136 of file user.py.

def wowf.models.user.User._create_challenge (   self,
  challenge,
  competitor 
)
private

Add the competitor to the challenge and send them a notification.

Definition at line 557 of file user.py.

def wowf.models.user.User._create_workout (   self,
  workout 
)
private

Send the other competitor(s) a notification.

Definition at line 567 of file user.py.

def wowf.models.user.User._get_avatar (   self)
private

Return a stored image, to allow different versions of the avatar to be served.

e.g: user.avatar.large would return the large version, while user.avatar would return the original.

Definition at line 63 of file user.py.

def wowf.models.user.User._get_buddies_query (   self)
private

Query for all of this users buddies.

Definition at line 576 of file user.py.

def wowf.models.user.User._get_buddy (   self,
  user 
)
private

Return the buddy link between this user and the given user.

Definition at line 589 of file user.py.

def wowf.models.user.User._get_challenge_link (   self,
  challenge 
)
private

Return the link between this user and the given challenge.

Definition at line 602 of file user.py.

def wowf.models.user.User._get_notifications_query (   self,
  unconfirmed_only = True 
)
private
Parameters
unconfirmed_onlyWhether to only query for unconfirmed notifications

Definition at line 611 of file user.py.

def wowf.models.user.User._get_password (   self)
private

Definition at line 42 of file user.py.

def wowf.models.user.User._get_search_query (   cls,
  terms 
)
private

Definition at line 550 of file user.py.

def wowf.models.user.User._set_avatar (   self,
  avatar 
)
private

Upload the avatar and set the necessary reference to it.

Definition at line 74 of file user.py.

def wowf.models.user.User._set_password (   self,
  password 
)
private

Hash the given password.

Definition at line 49 of file user.py.

def wowf.models.user.User.accept_challenge (   self,
  challenge 
)

Change the status between this user and the given challenge to accepted, and send all other competitors a notification.

Definition at line 479 of file user.py.

def wowf.models.user.User.accepted_challenge (   self,
  challenge 
)

Check whether this user has accepted the given challenge.

Definition at line 462 of file user.py.

def wowf.models.user.User.add_buddy (   self,
  user 
)

Add the user to the list of workout buddies.

Definition at line 368 of file user.py.

def wowf.models.user.User.age (   self)

Calculate this users age.

Definition at line 88 of file user.py.

def wowf.models.user.User.bmi (   self)

Calculate this users Body Mass Index, which is a useful indicator of health.

Definition at line 97 of file user.py.

def wowf.models.user.User.bmi_category (   self)

Return the category this user belongs to based on BMI.

Definition at line 105 of file user.py.

def wowf.models.user.User.confirm_all_notifications (   self)

Mark all notifications as confirmed (read).

Definition at line 536 of file user.py.

def wowf.models.user.User.count_all_notifications (   self)

Count all notifications, regardless of status.

Definition at line 511 of file user.py.

def wowf.models.user.User.count_buddies (   self)

Count how many workout buddies this user has.

Definition at line 354 of file user.py.

def wowf.models.user.User.count_challenges (   self)

Count all challenges this user is a competitor in.

Definition at line 409 of file user.py.

def wowf.models.user.User.count_search_results (   cls,
  terms 
)

Definition at line 175 of file user.py.

def wowf.models.user.User.count_unconfirmed_notifications (   self)

Count all notifications which have not been confirmed.

Definition at line 529 of file user.py.

def wowf.models.user.User.create (   cls,
  username,
  email,
  password,
  gender,
  dob,
  weight,
  height 
)

Definition at line 156 of file user.py.

def wowf.models.user.User.create_bench_press_challenge (   self,
  competitor,
  percentage 
)

Definition at line 420 of file user.py.

def wowf.models.user.User.create_bench_press_workout (   self,
  challenge,
  repetitions 
)

Definition at line 436 of file user.py.

def wowf.models.user.User.create_endurance_challenge (   self,
  competitor,
  duration 
)

Definition at line 416 of file user.py.

def wowf.models.user.User.create_endurance_workout (   self,
  challenge,
  samples 
)

Definition at line 432 of file user.py.

def wowf.models.user.User.create_speed_challenge (   self,
  competitor,
  distance 
)

Definition at line 412 of file user.py.

def wowf.models.user.User.create_speed_workout (   self,
  challenge,
  samples 
)

Definition at line 428 of file user.py.

def wowf.models.user.User.create_squat_challenge (   self,
  competitor,
  percentage 
)

Definition at line 424 of file user.py.

def wowf.models.user.User.create_squat_workout (   self,
  challenge,
  repetitions 
)

Definition at line 440 of file user.py.

def wowf.models.user.User.denied_challenge (   self,
  challenge 
)

Check whether this user has denied the given challenge.

Definition at line 470 of file user.py.

def wowf.models.user.User.deny_challenge (   self,
  challenge 
)

Change the status between this user and the given challenge to denied, and send all other competitors a notification.

Definition at line 490 of file user.py.

def wowf.models.user.User.get_all_notifications (   self,
  limit = 50,
  page = 1 
)

Return all notifications, regardless of status (paginated).

Definition at line 500 of file user.py.

def wowf.models.user.User.get_average_bench_press_repetitions (   self,
  percentage 
)

Calculate the average bench press repetitions (bench press challenge) for a given percentage.

Definition at line 257 of file user.py.

def wowf.models.user.User.get_average_calories_burned (   self,
  duration 
)

Calculate the average calories burned (endurance challenge) for a given duration.

Definition at line 244 of file user.py.

def wowf.models.user.User.get_average_heart_rate (   self,
  duration 
)

Calculate the average heart rate (endurance challenge) for a given duration.

Definition at line 231 of file user.py.

def wowf.models.user.User.get_average_speed (   self,
  distance 
)

Calculate the average speed (speed challenge) for a given distance.

Definition at line 218 of file user.py.

def wowf.models.user.User.get_average_squat_repetitions (   self,
  percentage 
)

Calculate the average squat repetitions (squat challenge) for a given percentage.

Definition at line 270 of file user.py.

def wowf.models.user.User.get_buddies (   self,
  limit = 50,
  page = 1 
)

Return all of this users workout buddies.

Definition at line 342 of file user.py.

def wowf.models.user.User.get_by_email (   cls,
  email 
)

Search by email.

Definition at line 152 of file user.py.

def wowf.models.user.User.get_by_username (   cls,
  username 
)

Search by username.

Definition at line 144 of file user.py.

def wowf.models.user.User.get_challenges (   self,
  limit = 50,
  page = 1 
)

Return all challenges this user is apart of (paginated).

Definition at line 388 of file user.py.

def wowf.models.user.User.get_unconfirmed_notifications (   self,
  limit = 50,
  page = 1 
)

Return all notifications which have not been confirmed.

Definition at line 518 of file user.py.

def wowf.models.user.User.get_workout_for_challenge (   self,
  challenge 
)

Return this users workout for the given challenge.

Definition at line 400 of file user.py.

def wowf.models.user.User.group_average_bench_press_repetitions (   self,
  percentage 
)

Calculate the average bench press by day for a given percentage.

Definition at line 318 of file user.py.

def wowf.models.user.User.group_average_calories_burned (   self,
  duration 
)

Calculate the average calories burned by day for a given duration.

Definition at line 306 of file user.py.

def wowf.models.user.User.group_average_heart_rate (   self,
  duration 
)

Calculate the average heart rate by day for a given duration.

Definition at line 294 of file user.py.

def wowf.models.user.User.group_average_speed (   self,
  distance 
)

Calculate the average speed by day for a given distance.

Definition at line 282 of file user.py.

def wowf.models.user.User.group_average_squat_repetitions (   self,
  percentage 
)

Calculate the average squat repetitions by day for a given percentage.

Definition at line 330 of file user.py.

def wowf.models.user.User.has_unconfirmed_notifications (   self)

Check whether this user has any unconfirmed (unread) notifications.

Definition at line 546 of file user.py.

def wowf.models.user.User.in_challenge (   self,
  challenge 
)

Check whether this user is a competitor in the given challenge.

Definition at line 448 of file user.py.

def wowf.models.user.User.is_buddy (   self,
  user 
)

Check whether the given user is a workout buddy.

Definition at line 361 of file user.py.

def wowf.models.user.User.is_user (   self,
  user 
)

Quick and easy test to check if the given user is this user.

Some templating engines don't allow the use of is in conditionals.

Definition at line 184 of file user.py.

def wowf.models.user.User.owns_challenge (   self,
  challenge 
)

Check whether this user is the creator of the given challenge.

Definition at line 455 of file user.py.

def wowf.models.user.User.remove_buddy (   self,
  user 
)

Remove the user from the list of workout buddies.

Definition at line 379 of file user.py.

def wowf.models.user.User.search (   cls,
  terms,
  limit = 50,
  page = 1 
)

Perform a fulltext search, matching the given terms.

Definition at line 166 of file user.py.

def wowf.models.user.User.total_points (   self)

Calculate how many points this user has in total.

Definition at line 121 of file user.py.

def wowf.models.user.User.update_avatar (   self,
  avatar 
)

Update this users avatar (profile pic)

Definition at line 211 of file user.py.

def wowf.models.user.User.update_password (   self,
  password 
)

Update this users password.

Definition at line 204 of file user.py.

def wowf.models.user.User.update_profile (   self,
  username,
  email,
  gender,
  dob,
  weight,
  height,
  timezone 
)

Update this users profile, with both required and optional data.

Definition at line 191 of file user.py.

Member Data Documentation

string wowf.models.user.User.__tablename__ = 'users'
staticprivate

Definition at line 26 of file user.py.

tuple wowf.models.user.User._avatar = Column('avatar', Unicode(40))
staticprivate

Definition at line 37 of file user.py.

wowf.models.user.User._avatar
private

Definition at line 79 of file user.py.

tuple wowf.models.user.User._password = Column('password', CHAR(60), nullable=False)
staticprivate

Definition at line 31 of file user.py.

wowf.models.user.User._password
private

Definition at line 51 of file user.py.

tuple wowf.models.user.User.avatar = synonym('_avatar', descriptor=property(_get_avatar, _set_avatar))
static

Definition at line 81 of file user.py.

wowf.models.user.User.avatar

Definition at line 212 of file user.py.

tuple wowf.models.user.User.created_at = Column(DateTime, nullable=False, default=current_timestamp)
static

Definition at line 39 of file user.py.

tuple wowf.models.user.User.dob = Column(Date, nullable=False)
static

Definition at line 33 of file user.py.

wowf.models.user.User.dob

Definition at line 132 of file user.py.

tuple wowf.models.user.User.email = Column(Unicode(254), nullable=False, unique=True)
static

Definition at line 30 of file user.py.

wowf.models.user.User.email

Definition at line 129 of file user.py.

tuple wowf.models.user.User.gender = Column(Enum('F', 'M', name='user_genders'), nullable=False)
static

Definition at line 32 of file user.py.

wowf.models.user.User.gender

Definition at line 131 of file user.py.

tuple wowf.models.user.User.height = Column(Numeric(5, 4), nullable=False, doc='height in meters')
static

Definition at line 35 of file user.py.

wowf.models.user.User.height

Definition at line 134 of file user.py.

tuple wowf.models.user.User.id = Column(Integer(unsigned=True), primary_key=True)
static

Definition at line 28 of file user.py.

list wowf.models.user.User.index_fields = ['username']
static

Definition at line 27 of file user.py.

tuple wowf.models.user.User.is_active = Column(Boolean, nullable=False, default=True)
static

Definition at line 38 of file user.py.

tuple wowf.models.user.User.last_active_at = Column(DateTime, nullable=False, default=current_timestamp)
static

Definition at line 40 of file user.py.

tuple wowf.models.user.User.password = synonym('_password', descriptor=property(_get_password, _set_password))
static

Definition at line 53 of file user.py.

wowf.models.user.User.password

Definition at line 130 of file user.py.

tuple wowf.models.user.User.timezone = Column(Unicode(50))
static

Definition at line 36 of file user.py.

wowf.models.user.User.timezone

Definition at line 198 of file user.py.

tuple wowf.models.user.User.username = Column(Unicode(10), nullable=False, unique=True)
static

Definition at line 29 of file user.py.

wowf.models.user.User.username

Definition at line 128 of file user.py.

tuple wowf.models.user.User.weight = Column(Numeric(7, 4), nullable=False, doc='weight in kilograms')
static

Definition at line 34 of file user.py.

wowf.models.user.User.weight

Definition at line 133 of file user.py.


The documentation for this class was generated from the following file: