Reporting system for employees to record healthy activities daily, so management can track and reward employees monthly for a healthy lifestyle.
- Ruby 1.9.3
- Rails 3.2.16
All the gems used in this project are listed in the Gemfile, but notable ones include the following:
gem 'devise' # Sign-in and user functionality
gem 'devise_invitable', '~> 1.3.4' # Mailing functionality
gem "figaro" # Secret key handler
gem 'rspec-rails', '~> 3.0' # Unit testing
gem 'cucumber-rails' # Integration testing
gem 'poltergeist' # Allows tests to run PhantomJS
gem 'wkhtmltopdf-binary' # Creation of PDFs
gem 'pdfkit' # Creation of PDFs
gem 'simple_captcha', :git => 'git://github.com/galetahub/simple-captcha.git' # Generates captcha
gem 'twitter-bootstrap-rails' # CSS styling
gem 'fullcalendar-rails' # Calendar view
gem 'bootstrap-datepicker-rails', '~> 1.4.0' # Date selection pops up a nice calendar
gem 'bootstrap-glyphicons' # Provides icons through app
Credits to Glyphicons for the icons used throughout the application.
Fork this repository to your own GitHub account. Run the following command to clone to your local machine. It should look something like this:
git clone https://github.com/<your username here>/healthy-eff
Now run the setup script:
./bin/setup
Remember to configure the mailing system to invite new users.
Optionally, you can also modify the initial database or manually generate secret keys for authentication; however, by default, this is automatically done through the script.
We'll need to set up a mailing system to invite new users to the application. You'll need to provide the following:
- An email address
- Password for the email
- The host URL when you deploy on your own server
Open all three files in config/environments/
. They all have somewhere near the top something that looks like this:
config.action_mailer.default_url_options = { :host => 'localhost:3000' } # You'll change this for production.rb
config.action_mailer.delivery_method = :smtp # May change this, but smtp usually the basic protocol
config.action_mailer.perform_deliveries = true
config.action_mailer.smtp_settings = {
:enable_starttls_auto => true,
:address => "smtp.gmail.com", # Depends on email service
:port => 587,
:domain => "gmail.com", # Depends on email service
:authentication => :login,
:user_name => "EMAILER", # Change this: Specify email account (everything before the @)
:password => "PASSWORD" # Change this: Specify email account password
}
You can specify which email to use depending on the environment (development
, test
, production
). You can use the same email for all three, make each one different, or any other combination you see fit. Running the machine locally (covered in this section) will use the settings provided in development.rb
; running our tests will use test.rb
, and running the application on a deployed web server will use production.rb
.
Check out the current setup on these files for a concrete example. The current email is just a random email we've made for the sole purpose of sending emails, which you can use if you would like.
We've already added most of the employees, but feel free to change db/seeds.rb
to configure the starting database of the application.
If you want to add a new person (admin or user) before deploying, follow the
examples on the db/seeds.rb
file.
Devise and our application make use of a few secret keys to properly perform authentication. To do this manually, you can generate them and place them in a configuration file on your local machine.
We've already set up Figaro and
.gitignore
to exclude this file from future GitHub pushes and thus hide these
keys from the public.
By default, this is done through the setup script (./bin/setup
) in the call to
./bin/keys
, but if you'd like to manually generate your own secret keys, you
can comment out that line and use the following:
.../healthy-eff$ rake secret
e19fd9b63ab682ffa4f33677b8fb742423db788df4d256cbbb7c5...
Save the entire string somewhere; repeat this three more times to obtain 4 strings in total.
Format config/application.yml
(create it if it doesn't exist yet) as follows:
cookie_token: # First secret key
devise_token: # Second secret key
production:
cookie_token: # Third secret key
devise_token: # Fourth secret key
Save this file once you're done.
Start a server and enjoy!
.../healthy-eff$ rails s
Visit localhost:3000
on your favorite browser to see the application.
Check out Heroku for easy deployment (which is what we have been using).
Remember to change config.action_mailer.default_url_options
in config/environment/production.rb
so that the mailing system works for your web server.
- A user can sign in after receiving an email from an administrator.
Passwords must fulfill the following requirements:
- Eight character minimum
- Must contain at least one upper case letter
- Must contain at least one lower case letter
- Must contain at least one special character
- Must contain at least one number
- Upon logging in, the user will be brought to this page
-
In order to submit an activity:
- 'Duration' must be recorded in minutes (minimum 60 min.)
- 'Activity' may be left blank
- The user must fill in the captcha
-
Users can submit only once for each day.
-
User can add as many activities as they wish.
- If JavaScript is enabled: click 'Add Activity' in order to add another exercise
- If JavaScript is disabled, you will only be able to add a single activity per page
- To add previous days, click 'Input Past Days' at the bottom of the Log Healthy Activity home page. This will redirect you to the Add Previous Days page
- Adding any activity on the Past Day input page will send a request to the administrator for approval.
- For each day you want to add, click the date input box. If JavaScript is enabled, an datepicker will appear. Select which day you wish to add, otherwise type in the specific date in
mm/dd/yyyy
format. - Proceed to add activities in the same manner as inputting today's activities. If JavaScript is disabled, the user will not be able to add more than one day per form.
- A user may only input past days for the current month. However if the current date is on or before the 5th, a user may input past days for the previous month as well. All other dates, including the current day, which must be inputted on the today page, are considered out of range and will return an error.
- Again, users can submit only once per day.
- If a pending request has been denied, then the user may resubmit for that day.
- After inputting an activity, the user will be brought to the Calendar page.
- Every recorded activity will appear here with the activity name and duration, as well as the activity's status ('Approved', 'Rejected', or 'Pending'.
- The User Calendar Page displays the amount earned each month at the top right of the page.
- If JavaScript is disabled, the user can still view their calendar, but only through the past two months. Otherwise, the user can navigate through the calendar to see all months for which they have submitted healthy activities.
- Users can change their password and email address on the Settings page.
- Users can also change their Timezone Settings from this page.
- Default Timezone is Pacific Time
- General user restrictions: A user cannot access the admin page or the Manage page.
- To navigate to the Admin page, select the Admin tab at the top left.
- To select a specific month, use the arrow tabs. Tables will only appear for months with employee data.
- To generate a printable audit form or monthly accounting form, first select employees (either individually or through the select all checkbox), then select the appropriate option.
- Only employees who have submitted a healthy activity the month being viewed will be available for selection.
- To view a specific employee's calendar, click the calendar icon in the corresponding row.
- From this page, admin can edit employee information, and add or delete employees.
- While the admin can change the reimbursement rate, the rate is limited to four digit characters in length (i.e., $1111 and $11.11 are both valid; 11111 is not)
- Admins cannot delete themselves, but can still delete other admins; a confirmation window will pop up when this action is taken.
- Admins can make any employee an admin.
- On the pending page, the admin can approve or deny employees' past day inputs.
You'll need to install Phantom JS on your machine.
For Macs (with Homebrew):
.../healthy-eff$ brew install phantomjs
For Ubuntu users, follow instructions on this blog post for easy setup.
After you have PhantomJS installed, you can run our test suites. We used Cucumber and RSpec to test our application throughout the development process.
.../healthy-eff$ db:test:prepare; rake cucumber; rake spec
Developed through UC Berkeley's CS 169, in partnership with EFF.
Copyright (c) 2015 Sarah Hernandez, Alex Ho, Michelle Lin, Corinne Schafle, Allan Tang, Ashley Willard. See LICENSE for details.