camperapp package

Submodules

camperapp.forms module

class camperapp.forms.ChildEnrollmentForm(formdata=<object object>, **kwargs)

Bases: flask_wtf.form.FlaskForm

Child Enrollment Form

Form for use by Parents to enroll a child at camp

child_birth_date = <UnboundField(DateField, (), {'validators': [<wtforms.validators.DataRequired object>], 'label': 'Birthday'})>
child_first_name = <UnboundField(StringField, (), {'validators': [<wtforms.validators.DataRequired object>], 'label': 'First name'})>
child_gender = <UnboundField(SelectField, (), {'validators': [<wtforms.validators.DataRequired object>], 'choices': [('M', 'Male'), ('F', 'Female')], 'label': 'Gender'})>
child_grade = <UnboundField(IntegerField, (), {'validators': [<wtforms.validators.DataRequired object>], 'label': 'Grade'})>
child_last_name = <UnboundField(StringField, (), {'validators': [<wtforms.validators.DataRequired object>], 'label': 'Last name'})>
city = <UnboundField(StringField, (), {'validators': [<wtforms.validators.Optional object>], 'label': 'City'})>
consent = <UnboundField(SelectField, (), {'validators': [<wtforms.validators.DataRequired object>], 'choices': [('y', 'Yes, I consent')], 'label': ''})>
medical_notes = <UnboundField(TextAreaField, (), {'validators': [<wtforms.validators.Optional object>], 'label': 'Medical Notes'})>
other_parent_birth_date = <UnboundField(DateField, (), {'validators': [<wtforms.validators.Optional object>], 'label': "Parent/Guardian's Birth Date"})>
other_parent_cell = <UnboundField(StringField, (), {'validators': [<wtforms.validators.Optional object>], 'label': "Parent/Guardian's Cell"})>
other_parent_email = <UnboundField(StringField, (), {'validators': [<wtforms.validators.Optional object>], 'label': "Parent/Guardian's Email"})>
other_parent_name = <UnboundField(StringField, (), {'validators': [<wtforms.validators.Optional object>], 'label': "Parent/Guardian's Name"})>
state = <UnboundField(StringField, (), {'validators': [<wtforms.validators.Optional object>], 'label': 'State'})>
street_address = <UnboundField(StringField, (), {'validators': [<wtforms.validators.Optional object>], 'label': 'Street Address'})>
submit = <UnboundField(SubmitField, (), {'label': 'NEXT'})>
zipcode = <UnboundField(IntegerField, (), {'validators': [<wtforms.validators.Optional object>], 'label': 'Zip Code'})>
class camperapp.forms.CreateChildForm(formdata=<object object>, **kwargs)

Bases: flask_wtf.form.FlaskForm

Camper Creation Form

Form for use by Admins create a Camper/Child in the db

birth_date = <UnboundField(DateField, ('Birthday',), {'validators': [<wtforms.validators.DataRequired object>]})>
city = <UnboundField(StringField, ('City',), {})>
first_name = <UnboundField(StringField, ('First name',), {'validators': [<wtforms.validators.DataRequired object>]})>
gender = <UnboundField(SelectField, (), {'validators': [<wtforms.validators.DataRequired object>], 'choices': [('M', 'Male'), ('F', 'Female')], 'label': 'Gender'})>
grade = <UnboundField(IntegerField, ('Grade',), {'validators': [<wtforms.validators.DataRequired object>]})>
last_name = <UnboundField(StringField, ('Last name',), {'validators': [<wtforms.validators.DataRequired object>]})>
medical_notes = <UnboundField(TextAreaField, ('Medical Notes',), {})>
parent_first_name = <UnboundField(StringField, ("Parent's first name",), {'validators': [<wtforms.validators.DataRequired object>]})>
parent_last_name = <UnboundField(StringField, ("Parent's last name",), {'validators': [<wtforms.validators.DataRequired object>]})>
state = <UnboundField(StringField, ('State',), {})>
street_address = <UnboundField(StringField, ('Street Address',), {})>
submit = <UnboundField(SubmitField, ('SAVE',), {})>
zipcode = <UnboundField(IntegerField, ('Zip Code',), {})>
class camperapp.forms.CreateParentForm(formdata=<object object>, **kwargs)

Bases: flask_wtf.form.FlaskForm

Parent Creation Form

Form for use by Admins create a Parent in the db

birth_date = <UnboundField(DateField, ('Birthday',), {'validators': [<wtforms.validators.DataRequired object>]})>
city = <UnboundField(StringField, ('City',), {'validators': [<wtforms.validators.DataRequired object>]})>
email = <UnboundField(StringField, ('Email Address',), {'validators': [<wtforms.validators.DataRequired object>, <wtforms.validators.Email object>]})>
first_name = <UnboundField(StringField, ('First name',), {'validators': [<wtforms.validators.DataRequired object>]})>
gender = <UnboundField(SelectField, (), {'validators': [<wtforms.validators.DataRequired object>], 'choices': [('M', 'Male'), ('F', 'Female')], 'label': 'Gender'})>
last_name = <UnboundField(StringField, ('Last name',), {'validators': [<wtforms.validators.DataRequired object>]})>
phone = <UnboundField(StringField, ('Phone Number',), {'validators': [<wtforms.validators.DataRequired object>]})>
state = <UnboundField(StringField, ('State',), {'validators': [<wtforms.validators.DataRequired object>]})>
street_address = <UnboundField(StringField, ('Street Address',), {'validators': [<wtforms.validators.DataRequired object>]})>
submit = <UnboundField(SubmitField, ('SAVE',), {})>
zipcode = <UnboundField(IntegerField, ('Zip Code',), {'validators': [<wtforms.validators.DataRequired object>]})>
class camperapp.forms.LoginForm(formdata=<object object>, **kwargs)

Bases: flask_wtf.form.FlaskForm

Login Form for Admins and Parents

Login Flask Form for Admins and Parents

email = <UnboundField(StringField, ('Email',), {'validators': [<wtforms.validators.DataRequired object>, <wtforms.validators.Email object>]})>
password = <UnboundField(PasswordField, ('Password',), {'validators': [<wtforms.validators.DataRequired object>]})>
submit = <UnboundField(SubmitField, ('Sign in',), {})>
class camperapp.forms.SignupFormAdmin(formdata=<object object>, **kwargs)

Bases: flask_wtf.form.FlaskForm

Sign Up Form for Admins

Sign Up Flask Form for Admins

email = <UnboundField(StringField, ('Email',), {'validators': [<wtforms.validators.DataRequired object>, <wtforms.validators.Email object>]})>
first_name = <UnboundField(StringField, ('First name',), {'validators': [<wtforms.validators.DataRequired object>]})>
last_name = <UnboundField(StringField, ('Last name',), {'validators': [<wtforms.validators.DataRequired object>]})>
password = <UnboundField(PasswordField, ('Password',), {'validators': [<wtforms.validators.DataRequired object>, <wtforms.validators.Length object>]})>
submit = <UnboundField(SubmitField, ('Sign up',), {})>

camperapp.login module

camperapp.login.load_user(user_id)

Retrieve user with id user_id from database

Retrieves the user with the specified user_id from the Users table in the database

Args:
user_id (int) : id of user to be queried
Returns:
sql_alchemy user object with specified user_id
camperapp.login.requires_roles(*roles)

Wrapper Function to restrict access to endpoints

Functions with this as a wrapper will only execute if the flask_login current_user has a role from Role class specified in this function’s input

Args:
roles (any) : roles
Returns:
A wrapped version of the original function that will only run if current_user.role is in roles
Raises:
werkzeug.exceptions.Unauthorized: An error occurred if current_user.role is not in roles

camperapp.models module

class camperapp.models.CampEvent(title, start, end)

Bases: sqlalchemy.ext.declarative.api.Model

Model for Camp Events

SQL Alchemy model for Camp Events for the Camper+ Schedule

add_color_attr()

Add a color to the camp event

Adds the color of the events Camp Group to the event

classmethod convert_calevent_to_campevent(calevent)

Convert Full Calendar calevent dictionary to a Camp Event object

Converts a calendar event retrieved from the Full Calendar calender framework (calEvent) to a CampEvent to store in db

Args:
calevent (dict) : calendar event from full calendar
Returns:
A CampEvent instance ready to be committed to db
classmethod convert_iso_datetime_to_py_datetime(iso_datetime)

Convert ISO standard datetime to python datetime object

Converts an ISO standard datetime (e.g 2014-10-12T12:45) to a python datetime object. The Full Calendar Framework uses the ISO standard datetime

Args:
iso_datetime (str) : ISO datetime string
Returns:
A python datetime object
classmethod convert_py_datetime_to_iso_datetime(py_datetime)

Convert python datetime object to an ISO standard datetime string

Converts a python datetime object to an ISO standard datetime string (e.g 2014-10-12T12:45). The Full Calendar Framework uses the ISO standard datetime

Args:
py_datetime (datetime) : python datetime object
Returns:
An ISO standard datetime string
end
group_id
id
start
title
class camperapp.models.CampEventSchema(only=(), exclude=(), prefix='', strict=None, many=False, context=None, load_only=(), dump_only=(), partial=False)

Bases: marshmallow.schema.Schema

Schema for Camp Events

A Marshmallow Schema template to enable CampEvent objects to converted to JSON Objects. See sample code

Warning

Be sure to append a color to Camp Events using the add_color_attr method before trying to jsonify it.

opts = <marshmallow.schema.SchemaOpts object>
class camperapp.models.CampGroup(name, color)

Bases: sqlalchemy.ext.declarative.api.Model

Camp Group Model

SQL Alchemy Model of a Camp Group

campers
color
events
id
name
class camperapp.models.Camper(**kwargs)

Bases: sqlalchemy.ext.declarative.api.Model

Camper Model

SQL Alchemy Model of a Camper

age()

Get the age of Camper

Calculates the age of a Camper based on time since camper’s birth date

Returns:
age of Camper
alt_name()

Get an alternative display friendly name of Camper

Concatenates Camper’s first name and last name to a display friendly version. Format of name is Last name, First name

Returns:
‘First name Last name’ of Camper
birth_date
city
first_name
gender
get_color()

Get the color of camper’s Camp Group

Retrieves Camper’s assigned Camp Group’s color.

Returns:
color of camper’s Camp Group (camper.campgroup.color) or gray if camper has no group

Note

The default color of Camper’s without a group is gray but this is should never happen. Campers without groups should be put in the default None group created in camperapp.routes.py

grade
group_id
id
is_active
last_name
medical_notes
name()

Get a display friendly name of Camper

Concatenates Campers’s last name and first name to a display friendly version. Format of name is Last name, First name

Returns:
‘Last name, First name’ of Camper
other_parent_birth_date
other_parent_email
other_parent_name
other_parent_phone
parent_id
phone
state
street_address
zip_code
class camperapp.models.LowerCaseString(*args, **kwargs)

Bases: sqlalchemy.sql.type_api.TypeDecorator

Lowercase conversion template SQL Alchemy Models

Used to initialize the String Columns of Sql Alchemy Models for auto conversion of assigned string literals and variables to lowercase

Note

If no value is passed to the field, auto conversion doesn’t happen

impl

alias of String

process_bind_param(value, dialect)
class camperapp.models.Parent(**kwargs)

Bases: sqlalchemy.ext.declarative.api.Model

Parent Model

SQL Alchemy Model of a Parent

alt_name()

Get an alternative display friendly name of Parent

Concatenates Parent’s first name and last name to a display friendly version. Format of name is Last name, First name

Returns:
‘First name Last name’ of Parent
birth_date
campers
city
email
first_name
gender
id
last_name
name()

Get a display friendly name of Parent

Concatenates Parent’s last name and first name to a display friendly version. Format of name is Last name, First name

Returns:
‘Last name, First name’ of Parent
phone
state
street_address
user
zip_code
class camperapp.models.Role

Bases: enum.Enum

Role of Users

Roles that can be assumed by a user

admin = 'admin'
parent = 'parent'
class camperapp.models.User(email, password, role)

Bases: sqlalchemy.ext.declarative.api.Model

User Model

SQL Alchemy Model of a User (for login only) Current User types are admins and parents

check_password(password)

Check if password is user’s password

Encrypts password and checks if user’s saved password is equal to specified password using werkzeug.security.check_password_hash

Args:
password (str) : password to be checked
Returns:
True if password is user’s password else False
email
get_id()

Get User’s id

Getter for User’s id. Used by flask_login

Returns:
user’s id in the db
id
is_active()

Check if User is active

Check is current user is active. Required by Flask Login

Returns:
True
is_authenticated()

Check if User is authenticated

Check is current user is authenticated. Required by Flask Login

Returns:
True
parent_id
password
role
camperapp.models.get_user_name(user)

Retrieve the display name of users

Retrieves the print ready names of logged in users for rendering on web pages

Args:
user (User) : user object from User model
Returns:
the first part of the email of users without a name (admins) or the print ready name (last name, first name) of users with a name (parents)

camperapp.routes module

camperapp.routes.before_request()

Set Flask Global User

sets flask global user to current user

Note

this function is run before every request

camperapp.routes.campers()

Administrator people/groups View

Endpoint to view campers, camp groups and parents

Returns:
rendered admin_manage.html template

Note

Only authenticated admins can access this endpoint

camperapp.routes.create_default_group()

Create Default Group

Creates a default group called ‘none’ for campers ‘without a group’

Note

this function is run before every request to make sure a group exists for camper’s without groups

camperapp.routes.faq()

Camper+ FAQ Page Static Camper+ FAQ Page

camperapp.routes.get_camp_events()

Get Camp Events Endpoint

Endpoint to retrieve all camp events saved in db. Full Calendar calls this endpoint with a start and end argument representing the range of dates for which to get events for

Returns:
a list of all camp events in db as json

Note

Only authenticated admins can access this endpoint

camperapp.routes.index()

Index View

Endpoint for Camper+ homepage page with login form. Users are automatically redirected to default pages if they are logged in/authenticated

Returns:
parents are redirected to parent_enrollments endpoint. admins are redirected to campers endpoint. unauthenticated users are served the rendered home.html template with login form.
camperapp.routes.login()

Login Endpoint

Endpoint to login to Camper+ Application

Returns:
on GET request/invalid POST (failed authentication), returns rendered login.html page on successful POST, i.e successful authentication, returns redirect to url_for(‘campers’) or url_for(‘parent_enrollments’) if user is admin or parent respectively
camperapp.routes.logout()

Log out Endpoint

Logs out current user

Returns:
a redirect to url_for(‘index’), i.e Homepage
camperapp.routes.parent_enrollments()

Parent Enrollments View

Endpoint to show parent’s enrolled campers

Returns:
rendered parent_enrollments.html page

Note

Only authenticated parents can access this endpoint

camperapp.routes.parent_register()

Parent Child Registration View

Endpoint with forms for parents to register new camper. Valid Campers submitted are added to the Campers database table

Returns:
if a GET or invalid POST request is received, returns rendered parent_register.html template. if a valid POST request is received, returns rendered parent_register_complete.html template

Note

Only authenticated parents can access this endpoint

camperapp.routes.parent_schedule()

Parent Schedule View

Endpoint for parent camp schedule. Contains the Full Calendar js calendar for rendering camp events

Returns:
rendered parent_schedule.html template

Note

Only authenticated parents can access this endpoint

camperapp.routes.schedule()

Admin Schedule View

Endpoint for camp schedule. Contains the Full Calendar js calendar for rendering camp events

Returns:
rendered admin_schedule.html template

Note

Only authenticated admins can access this endpoint

camperapp.routes.submit_camp_group_management()

Camp Group Management Endpoint

Endpoint for administrator to edit, add and delete camp groups

Returns:
on valid POST request, returns a redirect to url_for(‘campers’) on valid DELETE, return json with success flag on invalid POST/DELETE request, return json with failure flag

Note

Only authenticated admins can access this endpoint

camperapp.routes.submit_camper_management()

Camper Management Endpoint

Endpoint for administrator to edit, add and delete campers

Returns:
on valid POST request, returns a redirect to url_for(‘campers’) on valid DELETE/PATCH, return json with success flag on invalid POST/DELETE request, return json with failure flag

Note

Only authenticated admins can access this endpoint

camperapp.routes.submit_handler()

Camp Event Management Endpoint

Endpoint for administrator to create, edit and delete camp events on the Full Calendar Schedule

Returns:
on valid POST request, returns a json with success flag and color to render event it. This color corresponds to the event’s camp group’s color on valid PUT/DELETE request, returns a json with success flag

Note

Only authenticated admins can access this endpoint

camperapp.routes.submit_parent_management()

Parent Management Endpoint

Endpoint for administrator to edit, add and delete parents

Returns:
on valid POST request, returns a redirect to url_for(‘campers’) on valid DELETE, return json with success flag on invalid POST/DELETE request, return json with failure flag

Note

Only authenticated admins can access this endpoint

camperapp.routes.update_forms()

Update Flask Forms

Updates CreateChildForm’s select Field with current groups and parents

Note

this function is run before every request to make sure recently created parents and groups are in the CreateChildForm

Module contents

Camper+ Web Application