Skip to content

A generic application for scheduling services via the web, to be developed for specific services (ie delivery, laundry, mowing, etc)

Notifications You must be signed in to change notification settings

son1112/scheduler

Repository files navigation

A Generic Scheduler

Scheduler Application

http://gensched.herokuapp.com

Create a generic application for scheduling a service from a user’s phone or computer via the web (ie. delivery (laundry, beer, groceries)

Basic concept

A user, from the web (via mobile or desktop/laptop), visits the application site for a specific service (laundry pickup/delivery), selects a service and a date&time. A request for the service/time is emailed to admin. When approved, a confirmation email is returned and the service is planned for the appropriate time on the business side.

ModelViewControl

Users order and schedule services through a web-based application.

This application displays a calendar and scheduling information along with basic operation information. One or more datetimes are selected from a controlled array of available times for service to be rendered.

Model

Each page will serve as a node for site structure.

A user will have many shifts, associated by id when scheduling requests.

Admin users will have access to greenlighting of scheduling requests.

Page

  • [X] generate page scaffolding
    rails g scaffold Page index
        

Additional attributes/columns

  • [ ] index: string

User

Devise

  • [-] Install Devise
    • [X] add Devise gem to Gemfile and bundle
      gem 'devise'
      bundle 
              
    • [X] run the devise generator
rails generate devise:install

This generates a set of further instructions

Some setup you must do manually if you haven't yet:
  • [X] Ensure you have flash messages

    ./app/views/layouts/application.html.erb

    <p class="notice"><%= notice %></p>
    <p class="alert"><%= alert %></p>
        
  • [X] Copy Devise views (for customization):
    rails g devise:views
        
    • [X] Add Devise to a model
rails g devise MODEL
rails g devise User
  • [ ] Configure the model
  • [X] Migrate the database
rake db:migrate

Admin

  • [ ] create a migration to add admin boolean to User model

Shift

prebuilt options

While I am very interested in building this from scratch, I knew that there must be something already available as a gem. Enter fullcalendar-rails:

Let’s give it a shot.

Then I found fullcalendar-rails-engine

“Rails engine implementation of fullcalendar jQuery plugin. Create, edit, delete, reschedule, resize events like google calendar.”

https://github.com/vinsol/fullcalendar-rails-engine

This seems more full-featured and capable of meeting our needs.

fullcalendar-rails-engine
  • [X] install
gem 'fullcalendar_engine'
bundle install
bundle exec rails g fullcalendar_engine:install
  • [X] Declare routes

./config/routes.rb

mount FullcalendarEngine::Engine => "/fullcalendar_engine"
  • [ ] Create Single Event
FullcalendarEngine::Event.create({ 
    :title => 'title', 
    :description => 'description', 
    :starttime => Time.current, 
    :endtime => Time.current + 10.minute
})
fullcalendar-rails
Install

but as Ray Zane pointed out in issue #11, this will cause a problem if you try to change the colors of events.

An ideal solution, if you need a print stylesheet, is to create an application-print.css.scss file and include this (and other print-related css) in it. You’ll then need to add it to the precompile array in ./config/application.rb:

config.assets.precompile += ['application-print.css']

and then in your layouts where you need it, add:

<%= stylesheet_link_tag "application-print", :media => "print" %>

While it’s not needed for this library, the original javascript library’s author also includes an adapter for integrating Google calendars as an event source:

//= require gcal

Usage

http://arshaw.com/fullcalendar/

  • [X] The following script code should be placed in the head of your page

in application page or specific view? Trying in the head of ./app/views/layouts/application.html.erb

<script>
  $(document).ready(function(){
   $('#calendar').fullCalendar({
      // put your options and callbacks here
    })
  });
</script>
  • [X] Relies on there being an element with an id of “calendar” in the

body of your page. The calendar will be placed inside this div:

<div id='calendar'></div>

Attempting this at ./app/views/pages/test.html.erb

After restarting the server, it works!

  • [ ] To display events:
  • [ ] Using Google Calendar

    http://arshaw.com/fullcalendar/docs/google_calendar/

    FullCalendar can display events from a public Google Calendar. It can serve as a backend that manages and persistently stores event data (a feature that FullCalendar currently lacks).

    So, this may not be what we want. It would be nice if the scheduled events could just be placed on a Google calendar…

  • [ ] Using a standard JavaScript object that FullCalendar uses to store information about a calendar event.

    http://arshaw.com/fullcalendar/docs/event_data/

Generation

  • [X] Generate Shift scaffold
    rails g scaffold Shift index pickup:string dropoff:string
        

table

shift
id: integerpickup: string?dropoff: string?
example3Time.now.to_f.to_sTime.at(Time.now+60).to_f.to_s
7Time.at(60*30).to_f.to_sTime.at(90000000).to_f.to_s
  • [ ] other attributes?

    ./extra/sandbox/docs/gensched08077.png

    For user friendliness, needs to be able to be selected by day/date and then time

  • [ ] use .to_f method to retain fractions of a second
    Time.now => 2014-06-23 20:02:16 +0000 
    Time.now.to_i => 1403553736
    Time.now.to_f => 1403553736.279851
        
  • [ ] convert time to float before string?

    because the string can be converted back and Time.at(float) will return an actual time that can be used, whereas it seems that a string “2014-06-23 20:02:16 +0000” might not be convertable back to a time?

    • [ ] use the time module
require 'time'

then

Time.parse('2014-06-23 20:02:16 +0000') => 2014-06-23 20:02:16 +0000 

Commercial Exchange

Rails Generation

Scaffolding

  • [X] Disable scaffold stylesheet creation

    ./config/application.rb

    config.generators do |g|
      g.stylesheets false
    end
        
  • [X] Generate a scaffold

    EXAMPLE

    rails g scaffold Page index
        
  • [X] migrate the database
    rake db:migrate
        

Generating a Model

Service

For now, I think it would make sense to look at it simply, accounting for a single service that can be scheduled.

View

Skrollr

  • [ ] add skrollr script
  • [ ] application.js

Bootstrap-sass

  • [X] Create custom bootstrap stylesheet

    ./app/assets/stylesheets/bootstrap_and_customization.css.scss

    echo "@import 'bootsrap';" > app/assets/stylesheets/bootstrap_and_customization.css.scss
        

    NOTE Place new variables before “@import ‘bootstrap’”

    • [X] Fonts

      EXAMPLE:

    @import url(http://fonts.googleapis.com/css?family=Roboto:400,100,100italic,700italic,700|Clicker+Script);
        
    • [X] Variables
    $phill-grn: #3f8000;
        
  • [X] Require Bootstrap’s Javascript, after jquery_ujs

    ./app/assets/javascripts/application.js

    //= require jquery
    //= require jquery_ujs
    //= require bootstrap
    //= require turbolinks
    //= require_tree .
        

Assets

Stylesheets

Javascripts

//= require turbolinks
  • [X] add jquery.turbolinks under bootstrap
//= require bootstrap
//= require jquery.turbolinks

Images

  • [ ] css background images

Views

Application

./app/views/

Pages

./app/views/pages/

Home

./app/views/pages/home.html.erb

Layouts

Partials

Control

Routes

Views Directory

./config/routes.rb

  • [X] create root path
    root 'pages#index'
        

Controllers

./app/controllers/application_controller.rb

./app/controllers/pages_controller.rb

Other required services

Set up a mailer

commerce exchange

Application skeleton BASICS

Useful commands

Rake

rake routes

Rails

rails console

Essential Files

Gemfile

the following has now been defaulted into

DEV:edit ./rails-new.sh

./rails-new

Create the default skeletal application

  • [X] create scheduler application
    rails new scheduler
        
  • [X] update README
    rm README.rdoc
    touch README.org
        
  • [X] copy generic rails script

    For documentation and testing purpose of developing my default rails new bash script

    ln -s $HOME/bin/rails-new.sh rails-new.sh 
    cp $HOME/bin/rails-new.sh rails-new 
        
  • [X] rename application.css to application.css.scss
    cd app/assets/stylesheets
    mv application.css application.css.scss
        
  • [X] Test the skeletal application
    • [X] Start the Rails server
    rails s
        
    • [X] open your browser to localhost, port 3000
      localhost:3000
              
  • [X] update the Gemfile
    cat ~/RAILS-dev/DEFAULT-Gemfile > Gemfile
        
  • [X] update the bundle
    bundle update
    bundle install --without production
        

Set up Git and Heroku

Git

  • [X] initialize git repo
    git init
        
  • [X] update .gitignore
    echo ".env" >> .gitignore
    echo "Procfile" >> .gitignore
        
  • [X] initial stage and commit of all files
    git add .
    git commit -am "initial commit"
        
  • [X] add the origin
    git remote add origin https://github.com/son1112/scheduler.git
        
  • [X] initial push
    git push -u origin master
        

Heroku

  • [X] Create and push a new heroku app
    heroku create
    git push heroku master
        
  • [X] Rename the heroku app
    heroku rename gensched
        

About

A generic application for scheduling services via the web, to be developed for specific services (ie delivery, laundry, mowing, etc)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published