Skip to content

Commit

Permalink
Random Data
Browse files Browse the repository at this point in the history
  • Loading branch information
RishiPithadiya-BTC committed Jul 7, 2014
1 parent 756903e commit 4251440
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 28 deletions.
6 changes: 4 additions & 2 deletions app/controllers/projects_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ class ProjectsController < ApplicationController
# GET /projects
# GET /projects.json
def index
@projects = Project.paginate(page: params[:page], :per_page => 10)
# @users = User.paginate(page: params[:page])
@projects = Project.paginate(page: params[:page], :per_page => 7)
@clients = Client.all

# @projects.order('dead_line_date asc').paginate(:page => params[:page], :per_page => 7).order('dead_line_date asc').where("name LIKE ? OR status LIKE ? ", "#{params[:search]}%", "#{params[:search]}%")
end

# GET /projects/1
Expand Down
1 change: 1 addition & 0 deletions app/views/layouts/_header.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<nav>
<ul class="nav pull-right">
<li><%= link_to "Home", home_path %></li>
<li><%= link_to "Clients", clients_path %></li>
</ul>
</nav>
</div>
Expand Down
8 changes: 6 additions & 2 deletions app/views/projects/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,13 @@
<%= f.select :status, [ 'POC', 'KICK OFF','COMPLETED'] %>
</div>
<div class="field">
<% if action_name == 'new' %>
<%= f.label :client_id %>
<%= f.collection_select :client, Client.all, :id, :name, placeholder: "Select Client name", :class => 'form-control', include_blank: false %>

<%= f.collection_select :client_id, Client.all, :id, :name, placeholder: "Select Client name", :class => 'form-control', include_blank: false %>
<% elsif action_name == 'edit' %>
<%= f.label :client_id %>
<%= f.collection_select :client, Client.all, :id, :name, {}, {:disabled => "disabled"} %>
<% end %>
</div>
<div class="actions">
<%= f.submit %>
Expand Down
46 changes: 38 additions & 8 deletions app/views/projects/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<h1><u>Listing projects</u></h1>
<h1><u>Projects</u></h1>

<table border="2" align="center">
<table border="2" align="center" cellpadding="9">
<thead>
<tr>
<th>Name</th>
Expand All @@ -20,7 +20,36 @@
</thead>

<% projects = @projects.sort_by(&:deadline_date) %>
<center><%= will_paginate %></center>

<center>
<div id="Search">
<!-- <input id="name" name="name" type="text" placeholder="Project Name" />
<select id="status">
<option>POC</option>
<option>KICK OFF</option>
<option>COMPLETED</option>
</select>
<select id="client">
<% @clients.each do |client| %>
<option><%= client.name%></option>
<% end %>
</select> -->

<%= form_tag(:projects, method: "get") do %>
<div align="center">
<%= text_field_tag "search", params[:search], :placeholder => "Project Name"%>
<%= select("status", "status_id", Project.select(:status).map(&:status).uniq) %>
<%= select("client_name", "client_id", Client.all.collect {|p| [ p.name, p.id ] }) %>
<%= submit_tag "Search", name: nil, class: "btn-custom-darken" %>
<br/>
</div>
<% end %>

<%#= @filtered=Project.where("name = ? AND status = ? AND client_id = ?",params[:search],status,client_id).all %>

</div>
</center>

<tbody>

<% projects.each do |project| %>
Expand All @@ -29,9 +58,9 @@
<td><%= project.code %></td>
<!--<td><%= project.description %></td>-->
<td><%= project.billing_type %></td>
<td><%= project.start_date.strftime("%m-%d-%Y") %></td>
<td><%= project.deadline_date.strftime("%m-%d-%Y") %></td>
<!--<td><%= project.end_date.strftime("%m-%d-%Y") %></td>
<td><%= project.start_date.strftime("%d-%m-%Y") %></td>
<td><%= project.deadline_date.strftime("%d-%m-%Y") %></td>
<!--<td><%= project.end_date.strftime("%d-%m-%Y") %></td>
<td><%= project.github_url %></td>-->
<td><%= project.status %></td>
<td><%= Client.find(project.client_id).name %></td>
Expand All @@ -41,9 +70,10 @@

<% end %>
</tbody>

</table>
<center><%= will_paginate %></center>
<center>
<%= will_paginate %>
</center>
<br>

<%= link_to 'New Project', new_project_path %>
11 changes: 8 additions & 3 deletions app/views/projects/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@

<p>
<strong>Start date:</strong>
<%= @project.start_date.strftime("%m-%d-%Y") %>
<%= @project.start_date.strftime("%d-%m-%Y") %>
</p>

<p>
<strong>Deadline date:</strong>
<%= @project.deadline_date.strftime("%m-%d-%Y") %>
<%= @project.deadline_date.strftime("%d-%m-%Y") %>
</p>

<p>
<strong>End date:</strong>
<%= @project.end_date.strftime("%m-%d-%Y") %>
<%= @project.end_date.strftime("%d-%m-%Y") %>
</p>

<p>
Expand All @@ -46,5 +46,10 @@
<%= @project.status %>
</p>

<p>
<strong>Client</strong>
<%= @project.client_id %>
</p>

<%= link_to 'Edit', edit_project_path(@project) %> |
<%= link_to 'Back', projects_path %>
13 changes: 0 additions & 13 deletions lib/tasks/sample_data.rake
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,6 @@ namespace :db do
make_clients
end
end
=begin
def sd
Date.new(Random.new.rand(2010..2011),Random.new.rand(1..12),Random.new.rand(1..30)).strftime("%m-%d-%Y")
end
def dd
Date.new(Random.new.rand(2011..2012),Random.new.rand(1..12),Random.new.rand(1..30)).strftime("%m-%d-%Y")
end
def ed
Date.new(Random.new.rand(2011..2012),Random.new.rand(1..12),Random.new.rand(1..30)).strftime("%m-%d-%Y")
end
=end
def make_projects
30.times do |n|
Project.create!(name: Faker::Name.name,
Expand Down

0 comments on commit 4251440

Please sign in to comment.