Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'master' of github.com:michaeltreger/BOSS

  • Loading branch information...
commit 8f5f7ef450b225518ca8126405cdbcfb3ab0059c 2 parents 526a1d9 + f62dbdb
@petercheng00 petercheng00 authored
View
2  README
@@ -1,5 +1,5 @@
== Welcome to Rails
-a
+
Rails is a web-application framework that includes everything needed to create
database-backed web applications according to the Model-View-Control pattern.
View
6 app/assets/javascripts/calendar.js
@@ -192,6 +192,12 @@ $(document).ready(function() {
"backgroundColor" : "#999",
"border" : "1px solid #888"
});
+ } else if (calEvent.entry_type=== "time_off_request") {
+ $event.css("backgroundColor", "#da2");
+ $event.find(".wc-time").css({
+ "backgroundColor" : "#b80",
+ "border" : "1px solid #a70"
+ });
} else if (calEvent.entry_type=== "") {
color = randomColor(calEvent.description);
$event.css("backgroundColor", color);
View
3  app/assets/stylesheets/time_edits.css.scss
@@ -1,3 +1,6 @@
// Place all the styles related to the timeEdits controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
+
+tr.group1 td {background-color: #ffffff;}
+tr.group2 td {background-color: #c0c0c0;}
View
9 app/controllers/calendars_controller.rb
@@ -41,7 +41,8 @@ def index
# GET /calendars/1.json
def manage
- @sscalendars = Calendar.find_all_by_calendar_type(Calendar::SNAPSHOT) || []
+ @labcalendars = Calendar.find_all_by_calendar_type(Calendar::LAB) || []
+ @sscalendars = AvailabilitySnapshot.all || []
@wcalendars = Calendar.find_all_by_calendar_type(Calendar::SHIFTS) || []
respond_to do |format|
format.html
@@ -83,8 +84,10 @@ def show
if e.entry_type == "closed"
e[:readOnly] = true
end
- e.start_time = e.start_time + (@start_date-e.start_time.beginning_of_week)
- e.end_time = e.end_time + (@start_date-e.end_time.beginning_of_week)
+ if e.entry_type != "time_off_request"
+ e.start_time = e.start_time + (@start_date-e.start_time.beginning_of_week)
+ e.end_time = e.end_time + (@start_date-e.end_time.beginning_of_week)
+ end
end
results[:start_date] = @start_date
results[:end_date] = @start_date + 6.days
View
9 app/controllers/time_edits_controller.rb
@@ -2,7 +2,11 @@ class TimeEditsController < ApplicationController
# GET /time_edits
# GET /time_edits.json
def index
- @time_edits = TimeEdit.all
+ if @current_user.isAdminOrScheduler?
+ @time_edits = TimeEdit.order(:start_time).all
+ else
+ @time_edits = TimeEdit.order(:start_time).find_all_by_user_id(@current_user.id)
+ end
respond_to do |format|
format.html # index.html.erb
@@ -47,6 +51,9 @@ def edit
def create
params[:time_edit][:user_id] = @current_user.id
params[:time_edit][:calendar_id] = @current_user.shift_calendar.id
+ if params['positive-negative'] == 'negative'
+ params[:time_edit][:duration] = params[:time_edit][:duration].to_i.abs * -1
+ end
@time_edit = TimeEdit.new(params[:time_edit])
respond_to do |format|
View
2  app/controllers/users_controller.rb
@@ -31,7 +31,7 @@ def show
@acalendars = @user.calendars.find_all {|c| c.availability? and c.period.visible}
@wcalendars = @user.calendars.find_all {|c| c.shift?}
@preferences = @user.preference.find_all {|p| p.period.visible}
- @time_edits = TimeEdit.find_by_user_id(@user.id) || []
+ @time_edits = TimeEdit.find_all_by_user_id(@user.id) || []
@time_off_requests = TimeOffRequest.find_by_user_id(@user.id) || []
respond_to do |format|
format.html # show.html.erb
View
2  app/mailers/calendar_mailer.rb
@@ -6,7 +6,7 @@ def updated_calendar(calendar)
#mail(:to => cal.user.email, :subject => "Updated Calendar").deliver
#mail(:to => admins, :subject => "Updated Calendar").deliver
#mail(:to => scheds, :subject => "Updated Calendar").deliver
- mail(:to => "michael.treger+bostesting@gmail.com", :subject => "Updated Calendar").deliver
+ mail(:to => "michael.treger+bostesting@gmail.com", :subject => "[#{User.find(calendar.owner).initials}] Schedule Updated").deliver
end
end
View
4 app/mailers/substitution_mailer.rb
@@ -10,7 +10,7 @@ def posted_sub(sub)
else
#mail(:to => everyone, :subject => "Posted Sub").deliver
end
- mail(:to => "michael.treger+bostesting@gmail.com", :subject => "Posted Sub").deliver
+ mail(:to => "michael.treger+bostesting@gmail.com", :subject => "#{sub.entry.start_time.strftime('%m/%d: %I:%M%p')} - #{sub.entry.end_time.strftime('%I:%M%p')} at #{sub.entry.lab.initials} (#{sub.from_user.initials})").deliver
end
def taken_sub(sub, targetUser)
@@ -20,7 +20,7 @@ def taken_sub(sub, targetUser)
#mail(:to => sub.from_user.email, :subject => "Taken Sub").deliver
#mail(:to => admins, :subject => "Taken Sub").deliver
#mail(:to => scheds, :subject => "Taken Sub").deliver
- mail(:to => "michael.treger+bostesting@gmail.com", :subject => "Taken Sub").deliver
+ mail(:to => "michael.treger+bostesting@gmail.com", :subject => "#{sub.entry.start_time.strftime('%m/%d: %I:%M%p')} - #{sub.entry.end_time.strftime('%I:%M%p')} at #{sub.entry.lab.initials} for #{sub.from_user.initials} taken by #{targetUser.initials}").deliver
end
end
View
39 app/models/time_off_request.rb
@@ -3,25 +3,34 @@
class TimeOffRequest < ActiveRecord::Base
belongs_to :user
+ has_one :entry, :dependent => :destroy
-def is_expired?
- self.start_time < Time.current
-end
+ after_create :create_entry
-def isNotTimeValid?
- self.start_time > self.end_time
-end
+ def is_expired?
+ self.start_time < Time.current
+ end
-def distance_of_time
- deadline = self.start_time.prev_week.beginning_of_week.change(:hour => 17)
- self.submission = Time.current
- distance = distance_of_time_in_words(self.submission, deadline, include_seconds=false)
- if self.submission >= deadline
- "passed " + distance
- else
- distance + " left"
+ def isNotTimeValid?
+ self.start_time > self.end_time
+ end
+
+ def distance_of_time
+ deadline = self.start_time.prev_week.beginning_of_week.change(:hour => 17)
+ self.submission = Time.current
+ distance = distance_of_time_in_words(self.submission, deadline, include_seconds=false)
+ if self.submission >= deadline
+ "passed " + distance
+ else
+ distance + " left"
+ end
+ end
+
+ def create_entry
+ cal = User.find_by_id(user_id).availability_calendar(Period.current)
+ self.entry = Entry.create!(:entry_type=>"time_off_request", :start_time=>self.start_time, :end_time=>self.end_time, :description=>self.description)
+ cal.entries << self.entry
end
-end
end
View
2  app/views/availability_snapshots/index.html.haml
@@ -9,7 +9,7 @@
- @availability_snapshots.each do |availability_snapshot|
%tr
%td= link_to "#{availability_snapshot.start_date} - #{availability_snapshot.end_date}", availability_snapshot
- %td= availability_snapshot.created_at
+ %td= availability_snapshot.created_at.strftime('%a, %m/%d -- %I:%M%p')
%td= link_to 'Destroy', availability_snapshot, :confirm => 'Are you sure?', :method => :delete
%br
View
30 app/views/calendars/manage.html.haml
@@ -1,25 +1,27 @@
- @page_title = 'Calendar Administration'
-%h3 Submitted Availability Calendars
+%h3 Lab Calendars
%table
%tr
- %th Owner
%th Name
- %th Description
- %th Start
- %th End
%th Last Modified
- %th
- %th
- - @sscalendars.each do |c|
+ - @labcalendars.each do |c|
%tr
- %td= link_to c.user.initials, user_path(c.user)
%td= link_to c.name, calendar_path(c)
- %td= c.description
- %td= c.period.start_date
- %td= c.period.end_date
%td= c.updated_at.strftime('%a, %m/%d -- %I:%M%p')
- %td= link_to 'Edit', edit_calendar_path(c)
- %td= link_to 'Delete', c, :confirm => 'Are you sure?', :method => :delete
+
+%h3 Snapshot Calendars
+%table
+ %tr
+ %th Dates For
+ %th Created On
+ %th
+
+ - @sscalendars.each do |availability_snapshot|
+ %tr
+ %td= link_to "#{availability_snapshot.start_date} - #{availability_snapshot.end_date}", availability_snapshot
+ %td= availability_snapshot.created_at.strftime('%a, %m/%d -- %I:%M%p')
+ %td= link_to 'Destroy', availability_snapshot, :confirm => 'Are you sure?', :method => :delete
+
%h3 Work Calendars
%table
View
6 app/views/time_edits/_form.html.haml
@@ -10,7 +10,11 @@
= f.label :start_time
= f.datetime_select :start_time
.field
- = f.label :duration
+ = f.label 'duration (minutes)'
+ = radio_button_tag( 'positive-negative' , :positive, true)
+ +
+ = radio_button_tag( 'positive-negative' , :negative)
+ \-
= f.number_field :duration
.field
= f.label :lab_id
View
12 app/views/time_edits/index.html.haml
@@ -11,12 +11,18 @@
%th
%th
+ - pay_period = (@time_edits[0].start_time+16.days).month
+ - group = :group1
- @time_edits.each do |time_edit|
- %tr
- %td= time_edit.user_id
+ - if (time_edit.start_time+16.days).month != pay_period
+ - group = group == :group1 ? :group2 : :group1
+ - pay_period = (time_edit.start_time+16.days).month
+
+ %tr{:class=>group}
+ %td= User.find(time_edit.user_id).initials
%td= time_edit.start_time
%td= time_edit.duration
- %td= time_edit.lab_id
+ %td= Lab.find(time_edit.lab_id).initials
%td= time_edit.comment
%td= link_to 'Show', time_edit
%td= link_to 'Edit', edit_time_edit_path(time_edit)
View
8 db/migrate/20120514172803_add_time_off_request_entry.rb
@@ -0,0 +1,8 @@
+class AddTimeOffRequestEntry < ActiveRecord::Migration
+ def up
+ add_column :entries, :time_off_request_id, :integer
+ end
+
+ def down
+ end
+end
View
12 features/time_edits.feature
@@ -9,6 +9,10 @@ Background: A Calendar has been created
| Alice | 1 |
| Joe | 0 |
+ And the following labs exist:
+ | initials | max_employees | min_employees | name |
+ | MMF | 4 | 1 | Moffit |
+
And the following periods exist:
| name |
| Finals Week 1 |
@@ -18,17 +22,17 @@ Background: A Calendar has been created
| Alice's Calendar | 1 | 1 |
And the following time edits exist:
- | start_time | duration | comment | user_id | calendar_id |
- | 8:00, 1/1/2012 | -1 | "Alarm did not go off" | 1 | 1 |
+ | start_time | duration | comment | user_id | calendar_id | lab_id |
+ | 8:00, 1/1/2012 | -1 | "Alarm did not go off" | 1 | 1 | 1 |
Scenario: Alice can create a time edit
Given I am logged in as "Alice"
And I am on the "New Time Edit" page
When I select "14" from "time_edit_start_time_4i"
- And I fill in "Duration" with "2"
+ And I fill in "time_edit_duration" with "2"
+ And I select "MMF" from "time_edit_lab_id"
And I fill in "Comment" with "Lab training"
- #And I select "MMF" from "time_edit_lab_id"
And I press "Save"
Then I should be on the "Time Edit" page
And I should see "Alarm did not go off"
View
10 spec/controllers/calendars_controller_spec.rb
@@ -207,10 +207,10 @@ def nonadmin_session
before (:each) do
@student1 = User.create!(:name => "Micky", :cas_user => 123123)
@student2 = User.create!(:name => "Minnie", :cas_user => 456456)
- @calendar11 = Calendar.create!(:calendar_type => Calendar::SNAPSHOT, :name => "testing11", :description => "student1 clendar1", :user_id => @student1.id)
- @calendar12 = Calendar.create!(:calendar_type => Calendar::SNAPSHOT, :name => "testing12", :description => "student1 caldendar2", :user_id => @student1.id)
- @calendar21 = Calendar.create!(:calendar_type => Calendar::SNAPSHOT, :name => "testing21", :description => "student2 caldendar1", :user_id => @student2.id)
- @calendar22 = Calendar.create!(:calendar_type => Calendar::SNAPSHOT, :name => "testing22", :description => "student2 caldendar2", :user_id => @student2.id)
+ @calendar11 = Calendar.create!(:calendar_type => Calendar::AVAILABILITY, :name => "testing11", :description => "student1 clendar1", :user_id => @student1.id)
+ @calendar12 = Calendar.create!(:calendar_type => Calendar::AVAILABILITY, :name => "testing12", :description => "student1 caldendar2", :user_id => @student1.id)
+ @calendar21 = Calendar.create!(:calendar_type => Calendar::AVAILABILITY, :name => "testing21", :description => "student2 caldendar1", :user_id => @student2.id)
+ @calendar22 = Calendar.create!(:calendar_type => Calendar::AVAILABILITY, :name => "testing22", :description => "student2 caldendar2", :user_id => @student2.id)
@admin = User.create!(:name => "AF", :cas_user => 000000)
group = Group.find_by_name("Administrators")
group.users << @admin
@@ -224,7 +224,7 @@ def nonadmin_session
it "admin can view all students' calendars" do
get :manage
- assigns(:sscalendars).count.should == 4
+ assigns(:acalendars).count.should == 4
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.