diff --git a/app/controllers/support_assignments_controller.rb b/app/controllers/support_assignments_controller.rb index cd1a9dc..f3c23f1 100644 --- a/app/controllers/support_assignments_controller.rb +++ b/app/controllers/support_assignments_controller.rb @@ -65,11 +65,15 @@ def destroy end end + # GET /support_assignments/today + # GET /support_assignments/today.json def today @support_assignment = SupportAssignment.where(date: Date.today).first render :show end + # GET /support_assignments/month/1 + # GET /support_assignments/month/1.json def month @support_assignments = SupportAssignment.where("strftime('%m', date) + 0 = ?", params[:month].to_i).order :date render :index diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb deleted file mode 100644 index de6be79..0000000 --- a/app/helpers/application_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module ApplicationHelper -end diff --git a/app/helpers/support_assignments_helper.rb b/app/helpers/support_assignments_helper.rb index 2030636..9d6e403 100644 --- a/app/helpers/support_assignments_helper.rb +++ b/app/helpers/support_assignments_helper.rb @@ -1,4 +1,5 @@ module SupportAssignmentsHelper + #Produces link for creating new assignments depending on whether the user_id param is available def new_assignment_link if params[:user_id].present? link_to('New Support assignment', new_user_support_assignment_path) @@ -7,6 +8,7 @@ def new_assignment_link end end + #Produces link for support assignments depending on wheher the user_id param is available def support_assignments_link if params[:user_id].present? link_to 'Back', user_support_assignments_path diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb deleted file mode 100644 index 2310a24..0000000 --- a/app/helpers/users_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module UsersHelper -end diff --git a/app/models/user.rb b/app/models/user.rb index 87c3dc7..9d897d9 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -2,25 +2,31 @@ class User < ActiveRecord::Base has_many :support_assignments, :dependent => :destroy validates :name, presence: true + # Returns true if the user is available on the specified date. def available? date date != unavailable_date end + # Assigns the user to support duty, if the user is available on the specified date. def assign_duty date support_assignments.create(date: date) if available? date end + # Marks the user as unavailable for duty on the specified date. + # If the user was assigned to duty on this date, another user swaps duty with this user. def unavailable_date= date reconcile_schedule_conflicts date write_attribute :unavailable_date, date end + # Returns a support assignment for the user with the date in the future def future_assignment support_assignments.select{ |assignment| assignment.date.future? }.first end + # Produces a array of users who are available on the specified date def self.available_users date - User.where(unavailable_date: nil) | User.where.not(unavailable_date: date) + (User.where(unavailable_date: nil) | User.where.not(unavailable_date: date)).to_a end private diff --git a/doc/apple-touch-icon.png b/doc/apple-touch-icon.png new file mode 100644 index 0000000..50f98b0 Binary files /dev/null and b/doc/apple-touch-icon.png differ diff --git a/doc/classes/ApplicationController.html b/doc/classes/ApplicationController.html new file mode 100644 index 0000000..49a73c5 --- /dev/null +++ b/doc/classes/ApplicationController.html @@ -0,0 +1,76 @@ + + + +
+POST /support_assignments POST /support_assignments.json
++ Source: + show + +
+# File controllers/support_assignments_controller.rb, line 30 +def create + @support_assignment = SupportAssignment.new(support_assignment_params) + + respond_to do |format| + if @support_assignment.save + format.html { redirect_to [@support_assignment.user, @support_assignment], notice: 'Support assignment was successfully created.' } + format.json { render :show, status: :created, location: @support_assignment } + else + format.html { render :new } + format.json { render json: @support_assignment.errors, status: :unprocessable_entity } + end + end +end+
DELETE /support_assignments/1 DELETE /support_assignments/1.json
++ Source: + show + +
+# File controllers/support_assignments_controller.rb, line 60 +def destroy + @support_assignment.destroy + respond_to do |format| + format.html { redirect_to support_assignments_url, notice: 'Support assignment was successfully destroyed.' } + format.json { head :no_content } + end +end+
GET /support_assignments/1/edit
++ Source: + show + +
+# File controllers/support_assignments_controller.rb, line 25 +def edit +end+
GET /support_assignments GET /support_assignments.json
++ Source: + show + +
+# File controllers/support_assignments_controller.rb, line 6 +def index + if params[:user_id].present? + @support_assignments = SupportAssignment.where(user_id: params[:user_id]).order :date + else + @support_assignments = SupportAssignment.all.order :date + end +end+
GET /support_assignments/month/1 GET /support_assignments/month/1.json
++ Source: + show + +
+# File controllers/support_assignments_controller.rb, line 77 +def month + @support_assignments = SupportAssignment.where("strftime('%m', date) + 0 = ?", params[:month].to_i).order :date + render :index +end+
GET /support_assignments/new
++ Source: + show + +
+# File controllers/support_assignments_controller.rb, line 20 +def new + @support_assignment = SupportAssignment.new +end+
GET /support_assignments/1 GET /support_assignments/1.json
++ Source: + show + +
+# File controllers/support_assignments_controller.rb, line 16 +def show +end+
GET /support_assignments/today GET /support_assignments/today.json
++ Source: + show + +
+# File controllers/support_assignments_controller.rb, line 70 +def today + @support_assignment = SupportAssignment.where(date: Date.today).first + render :show +end+
PATCH/PUT /support_assignments/1 PATCH/PUT /support_assignments/1.json
++ Source: + show + +
+# File controllers/support_assignments_controller.rb, line 46 +def update + respond_to do |format| + if @support_assignment.update(support_assignment_params) + format.html { redirect_to [@support_assignment.user, @support_assignment], notice: 'Support assignment was successfully updated.' } + format.json { render :show, status: :ok, location: [@support_assignment.user, @support_assignment] } + else + format.html { render :edit } + format.json { render json: @support_assignment.errors, status: :unprocessable_entity } + end + end +end+
Produces link for creating new assignments depending on whether the user_id +param is available
++ Source: + show + +
+# File helpers/support_assignments_helper.rb, line 3 +def new_assignment_link + if params[:user_id].present? + link_to('New Support assignment', new_user_support_assignment_path) + else + link_to('New Support assignment', new_support_assignment_path) + end +end+
Produces link for support assignments depending on wheher the user_id param +is available
++ Source: + show + +
+# File helpers/support_assignments_helper.rb, line 12 +def support_assignments_link + if params[:user_id].present? + link_to 'Back', user_support_assignments_path + else + link_to 'Back', support_assignments_path + end +end+
Produces a array of users who are available on the specified date
++ Source: + show + +
+# File models/user.rb, line 28 +def self.available_users date + (User.where(unavailable_date: nil) | User.where.not(unavailable_date: date)).to_a +end+
Assigns the user to support duty, if the user is available on the specified +date.
++ Source: + show + +
+# File models/user.rb, line 11 +def assign_duty date + support_assignments.create(date: date) if available? date +end+
Returns true if the user is available on the specified date.
++ Source: + show + +
+# File models/user.rb, line 6 +def available? date + date != unavailable_date +end+
Returns a support assignment for the user with the date in the future
++ Source: + show + +
+# File models/user.rb, line 23 +def future_assignment + support_assignments.select{ |assignment| assignment.date.future? }.first +end+
Marks the user as unavailable for duty on the specified date. If the user +was assigned to duty on this date, another user swaps duty with this user.
++ Source: + show + +
+ +POST /users POST /users.json
++ Source: + show + +
+# File controllers/users_controller.rb, line 26 +def create + @user = User.new(user_params) + + respond_to do |format| + if @user.save + format.html { redirect_to @user, notice: 'User was successfully created.' } + format.json { render :show, status: :created, location: @user } + else + format.html { render :new } + format.json { render json: @user.errors, status: :unprocessable_entity } + end + end +end+
DELETE /users/1 DELETE /users/1.json
++ Source: + show + +
+# File controllers/users_controller.rb, line 56 +def destroy + @user.destroy + respond_to do |format| + format.html { redirect_to users_url, notice: 'User was successfully destroyed.' } + format.json { head :no_content } + end +end+
GET /users/1/edit
++ Source: + show + +
+# File controllers/users_controller.rb, line 21 +def edit +end+
GET /users GET /users.json
++ Source: + show + +
+# File controllers/users_controller.rb, line 6 +def index + @users = User.all.to_a +end+
GET /users/new
++ Source: + show + +
+# File controllers/users_controller.rb, line 16 +def new + @user = User.new +end+
GET /users/1 GET /users/1.json
++ Source: + show + +
+# File controllers/users_controller.rb, line 12 +def show +end+
PATCH/PUT /users/1 PATCH/PUT /users/1.json
++ Source: + show + +
+# File controllers/users_controller.rb, line 42 +def update + respond_to do |format| + if @user.update(user_params) + format.html { redirect_to @user, notice: 'User was successfully updated.' } + format.json { render :show, status: :ok, location: @user } + else + format.html { render :edit } + format.json { render json: @user.errors, status: :unprocessable_entity } + end + end +end+
// This is a manifest file that'll be compiled into application.js, +which will include all the files // listed below. // // Any +JavaScript/Coffee file within this directory, lib/assets/javascripts, +vendor/assets/javascripts, // or any plugin's vendor/assets/javascripts +directory can be referenced here using a relative path. // // It's not +advisable to add code directly here, but if you do, it'll appear at the +bottom of the // compiled file. // // Read Sprockets README (github.com/rails/sprockets#sprockets-directives) +for details // about supported directives. // //= require jquery //= +require jquery_ujs //= require turbolinks //= require_tree .
+ +Place all the behaviors and hooks related to the matching controller here. +All this logic will automatically be available in application.js. You can +use CoffeeScript in this file: coffeescript.org/
+ +Place all the behaviors and hooks related to the matching controller here. +All this logic will automatically be available in application.js. You can +use CoffeeScript in this file: coffeescript.org/
+ +This is a manifest file that'll be compiled into application.css, which will include all the files
+listed below.
+
+Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
+or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
+
+You're free to add application-wide styles to this file and they'll appear at the bottom of the
+compiled file so the styles you add here take precedence over styles defined in any styles
+defined in the other CSS/SCSS files in this directory. It is generally better to create a new
+file per style scope.
+
+body {
+ +background-color: #fff;
+color: #333;
+font-family: verdana, arial, helvetica, sans-serif;
+font-size: 13px;
+line-height: 18px;
+
+}
+ +p, ol, ul, td {
+ +font-family: verdana, arial, helvetica, sans-serif;
+font-size: 13px;
+line-height: 18px;
+
+}
+ +pre {
+ +background-color: #eee;
+padding: 10px;
+font-size: 11px;
+
+}
+ +a {
+ +color: #000;
+&:visited {
+ color: #666;
+}
+&:hover {
+ color: #fff;
+ background-color: #000;
+}
+
+}
+ +div {
+ +&.field, &.actions {
+ margin-bottom: 10px;
+}
+
+}
+ +notice {
+ +color: green;
+
+}
+ +.field_with_errors {
+ +padding: 2px;
+background-color: red;
+display: table;
+
+}
+ +error_explanation {
+ +width: 450px;
+border: 2px solid red;
+padding: 7px;
+padding-bottom: 0;
+margin-bottom: 20px;
+background-color: #f0f0f0;
+h2 {
+ text-align: left;
+ font-weight: bold;
+ padding: 5px 5px 5px 15px;
+ font-size: 12px;
+ margin: -7px;
+ margin-bottom: 0px;
+ background-color: #c00;
+ color: #fff;
+}
+ul li {
+ font-size: 12px;
+ list-style: square;
+}
+
+}
+ +// Place all the styles related to the SupportAssignments controller here. +// They will automatically be included in application.css. // You can use +Sass (SCSS) here: sass-lang.com/
+ +// Place all the styles related to the Users controller here. // They will +automatically be included in application.css. // You can use Sass (SCSS) +here: sass-lang.com/
+ +json.array!(@support_assignments) do |support_assignment|
+ +json.extract! support_assignment, :id, :date, :user_id
+json.url support_assignments_url(support_assignment, format: :json)
+
+
+end
+ +json.extract! @support_assignment, :id, :date, :user_id, :created_at, +:updated_at
+ +json.array!(@users) do |user|
+ +json.extract! user, :id, :name, :unavailable_date
+json.url user_url(user, format: :json)
+
+
+end
+ +json.extract! @user, :id, :name, :unavailable_date, :created_at, +:updated_at
+ +"+w.value+"
";t=v.firstChild.firstChild;v.firstChild.cN=q.cN;q.parentNode.replaceChild(v.firstChild,q)}else{t.innerHTML=w.value}t.className=s;t.dataset={};t.dataset.result={language:w.language,kw:w.keyword_count,re:w.r};if(x&&x.language){t.dataset.second_best={language:x.language,kw:x.keyword_count,re:x.r}}}function j(){if(j.called){return}j.called=true;e();var q=document.getElementsByTagName("pre");for(var o=0;o+ + |