Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

mobile view of schools

  • Loading branch information...
commit 6c488e56a448fc3fef69a4fd7556f1c8e1789b85 1 parent f223f82
@croaky croaky authored
View
8 app/controllers/schools_controller.rb
@@ -1,5 +1,9 @@
-class SchoolsController < ApplicationController
+class SchoolsController < MobileController
def index
- send_data School.stats
+ @schools = School.most_students
+ end
+
+ def show
+ @school = School.find(params[:id])
end
end
View
8 app/models/registration.rb
@@ -23,6 +23,14 @@ def self.stats
all.to_csv(:only => [:name, :role, :twitter], :methods => [:school_name])
end
+ def designer?
+ role == "Designer"
+ end
+
+ def developer?
+ role == "Developer"
+ end
+
private
def find_or_create_school
View
8 app/models/school.rb
@@ -12,7 +12,15 @@ def self.alphabetical
order('name asc')
end
+ def self.most_students
+ order('registrations_count desc')
+ end
+
def self.stats
order('registrations_count desc').to_csv(:only => [:name, :registrations_count])
end
+
+ def students
+ registrations.order("name asc")
+ end
end
View
1  app/views/registrations/new.mobile.erb
@@ -6,6 +6,7 @@
<ul data-role="listview">
<li><%= link_to "Talks", talks_path %></li>
<li><%= link_to "Students", "#students" %></li>
+ <li><%= link_to "Schools", schools_path %></li>
<li><%= link_to "Startups", startups_path %></li>
<li><%= link_to "After-Party", party_path(:mobile => true) %></li>
<li><%= link_to "Opportunities", opportunities_path %></li>
View
11 app/views/schools/index.mobile.erb
@@ -0,0 +1,11 @@
+<div data-role="page" id="designers">
+ <div data-role="header">
+ <h1>Schools</h1>
+ </div>
+
+ <ul data-role="listview">
+ <% @schools.each do |school| %>
+ <li><%= link_to school.name, school_path(school) %> (<%= school.registrations_count %>)</li>
+ <% end %>
+ </ul>
+</div>
View
15 app/views/schools/show.mobile.erb
@@ -0,0 +1,15 @@
+<div data-role="page">
+ <div data-role="header">
+ <h1><%= @school.name %></h1>
+ </div>
+
+ <ul data-role="listview">
+ <% @school.students.each do |student| %>
+ <% if student.designer? %>
+ <li><%= link_to student.name, designer_path(student) %></li>
+ <% else %>
+ <li><%= link_to student.name, developer_path(student) %></li>
+ <% end %>
+ <% end %>
+ </ul>
+</div>
View
2  config/routes.rb
@@ -7,7 +7,7 @@
resources :developers, :only => [:index, :show]
resources :startups, :only => [:index, :show]
resources :opportunities, :only => [:index]
- resources :schools, :only => [:index]
+ resources :schools, :only => [:index, :show]
resource :party, :only => [:show]
resources :users, :only => [:update]
Please sign in to comment.
Something went wrong with that request. Please try again.