Skip to content

Commit

Permalink
Start and end date filter forms for assignments and pattern marks
Browse files Browse the repository at this point in the history
  • Loading branch information
francispotter committed Jul 25, 2011
1 parent 640b394 commit 04df63a
Show file tree
Hide file tree
Showing 6 changed files with 122 additions and 97 deletions.
9 changes: 7 additions & 2 deletions rails/app/controllers/assignments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class AssignmentsController < ApplicationController
# GET /assignments.xml
# GET /assignments.csv
def index
if params[:start_date] && params[:end_date]
if params[:start_date] and params[:end_date] and params[:start_date].length==10 and params[:end_date].length==10
@assignments = Assignment.where("created_at >= :start_date AND created_at <= :end_date",
{:start_date => params[:start_date], :end_date => params[:end_date]})
else
Expand All @@ -35,7 +35,12 @@ def index
end
format.xml { render :xml => @assignments }
format.csv do
render_csv @assignments, "assignments_all.csv"
if params[:start_date] and params[:end_date] and params[:start_date].length==10 and params[:end_date].length==10
filename = "assignments_#{params[:start_date]}_#{params[:end_date]}.csv"
else
filename = "assignemnts_all.csv"
end
render_csv @assignments, filename
end
end
end
Expand Down
9 changes: 7 additions & 2 deletions rails/app/controllers/pattern_marks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class PatternMarksController < ApplicationController
# GET /pattern_marks.xml
# GET /pattern_marks.csv
def index
if params[:start_date] && params[:end_date]
if params[:start_date] and params[:end_date] and params[:start_date].length==10 and params[:end_date].length==10
@pattern_marks = PatternMark.where("created_at >= :start_date AND created_at <= :end_date",
{:start_date => params[:start_date], :end_date => params[:end_date]})
else
Expand All @@ -33,7 +33,12 @@ def index
end
format.xml { render :xml => @pattern_marks }
format.csv do
render_csv @pattern_marks, "pattern_marks_all.csv"
if params[:start_date] and params[:end_date] and params[:start_date].length==10 and params[:end_date].length==10
filename = "pattern_marks_#{params[:start_date]}_#{params[:end_date]}.csv"
else
filename = "pattern_marks_all.csv"
end
render_csv @pattern_marks, filename
end
end
end
Expand Down
10 changes: 9 additions & 1 deletion rails/app/views/assignments/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
<h1><%=Assignment.count%> Assignments</h1>

<%= form_tag({:action=>:index}, {:method=>:get}) do%>
Start date (YYYY-MM-DD) <%= text_field_tag :start_date, params[:start_date] %> &nbsp;
End date (YYYY-MM-DD) <%= text_field_tag :end_date, params[:end_date] %> &nbsp;
<%= submit_tag "Filter by Date"%>
<%end%>

<br/><br/>

<%= paginate @assignments%>

<table>
Expand All @@ -12,7 +20,7 @@

<% @assignments.each do |assignment| %>
<tr>
<td><%= assignment.observation_range.friendly_name %></td>
<td><%= assignment.observation_range.friendly_name rescue '-'%></td>
<td><%= assignment.user.name %></td>
<td><%= assignment.status %></td>
<td><%= link_to 'Show', assignment %> <%= link_to 'Edit', edit_assignment_path(assignment) %> <%= link_to 'Destroy', assignment, :confirm => 'Are you sure?', :method => :delete %></td>
Expand Down
8 changes: 8 additions & 0 deletions rails/app/views/pattern_marks/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
<h1><%=PatternMark.count%> Pattern Marks</h1>

<%= form_tag({:action=>:index}, {:method=>:get}) do%>
Start date (YYYY-MM-DD) <%= text_field_tag :start_date, params[:start_date] %> &nbsp;
End date (YYYY-MM-DD) <%= text_field_tag :end_date, params[:end_date] %> &nbsp;
<%= submit_tag "Filter by Date"%>
<%end%>

<br/><br/>

<%= paginate @pattern_marks %>

<table>
Expand Down
1 change: 0 additions & 1 deletion rails/app/views/static/home.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
<div class="call_to_action">
<%= link_to "Android APK File", "/android/setiQuestExplorer.apk" %>
</div>

<%end%>
<%else%>
<p>Thanks for registering for the private beta program. We'll contact you when the program begins, with further information.</p>
Expand Down
182 changes: 91 additions & 91 deletions rails/db/schema.rb
Original file line number Diff line number Diff line change
@@ -1,91 +1,91 @@
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your
# database schema. If you need to create the application database on another
# system, you should be using db:schema:load, not running all the migrations
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
#
# It's strongly recommended to check this file into your version control system.

ActiveRecord::Schema.define(:version => 20110316032158) do

create_table "assignments", :force => true do |t|
t.integer "observation_range_id"
t.integer "user_id"
t.string "status"
t.datetime "created_at"
t.datetime "updated_at"
end

create_table "observation_ranges", :force => true do |t|
t.integer "observation_id"
t.decimal "lo_mhz"
t.decimal "hi_mhz"
t.string "status"
t.datetime "created_at"
t.datetime "updated_at"
t.text "url_part_list"
end

create_table "observations", :force => true do |t|
t.date "date"
t.integer "target_id"
t.datetime "created_at"
t.datetime "updated_at"
t.string "base_url"
end

create_table "pattern_marks", :force => true do |t|
t.decimal "mhz"
t.string "category"
t.date "date"
t.integer "pattern_id"
t.integer "assignment_id"
t.datetime "created_at"
t.datetime "updated_at"
end

create_table "patterns", :force => true do |t|
t.decimal "lo_mhz"
t.decimal "hi_mhz"
t.string "category"
t.text "description"
t.datetime "created_at"
t.datetime "updated_at"
t.integer "observation_id"
end

create_table "sessions", :force => true do |t|
t.string "session_id", :null => false
t.text "data"
t.datetime "created_at"
t.datetime "updated_at"
end

add_index "sessions", ["session_id"], :name => "index_sessions_on_session_id"
add_index "sessions", ["updated_at"], :name => "index_sessions_on_updated_at"

create_table "targets", :force => true do |t|
t.string "name"
t.text "description"
t.decimal "right_ascension", :precision => 15, :scale => 12
t.decimal "declination", :precision => 15, :scale => 12
t.datetime "created_at"
t.datetime "updated_at"
end

create_table "users", :force => true do |t|
t.datetime "created_at"
t.datetime "updated_at"
t.string "uid"
t.string "provider"
t.string "name"
t.string "role"
t.string "email"
t.string "user_agent_at_creation"
end

end
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your
# database schema. If you need to create the application database on another
# system, you should be using db:schema:load, not running all the migrations
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
#
# It's strongly recommended to check this file into your version control system.

ActiveRecord::Schema.define(:version => 20110316032158) do

create_table "assignments", :force => true do |t|
t.integer "observation_range_id"
t.integer "user_id"
t.string "status"
t.datetime "created_at"
t.datetime "updated_at"
end

create_table "observation_ranges", :force => true do |t|
t.integer "observation_id"
t.decimal "lo_mhz"
t.decimal "hi_mhz"
t.string "status"
t.datetime "created_at"
t.datetime "updated_at"
t.text "url_part_list"
end

create_table "observations", :force => true do |t|
t.date "date"
t.integer "target_id"
t.datetime "created_at"
t.datetime "updated_at"
t.string "base_url"
end

create_table "pattern_marks", :force => true do |t|
t.decimal "mhz"
t.string "category"
t.date "date"
t.integer "pattern_id"
t.integer "assignment_id"
t.datetime "created_at"
t.datetime "updated_at"
end

create_table "patterns", :force => true do |t|
t.decimal "lo_mhz"
t.decimal "hi_mhz"
t.string "category"
t.text "description"
t.datetime "created_at"
t.datetime "updated_at"
t.integer "observation_id"
end

create_table "sessions", :force => true do |t|
t.string "session_id", :null => false
t.text "data"
t.datetime "created_at"
t.datetime "updated_at"
end

add_index "sessions", ["session_id"], :name => "index_sessions_on_session_id"
add_index "sessions", ["updated_at"], :name => "index_sessions_on_updated_at"

create_table "targets", :force => true do |t|
t.string "name"
t.text "description"
t.decimal "right_ascension", :precision => 15, :scale => 12
t.decimal "declination", :precision => 15, :scale => 12
t.datetime "created_at"
t.datetime "updated_at"
end

create_table "users", :force => true do |t|
t.datetime "created_at"
t.datetime "updated_at"
t.string "uid"
t.string "provider"
t.string "name"
t.string "role"
t.string "email"
t.string "user_agent_at_creation"
end

end

0 comments on commit 04df63a

Please sign in to comment.