aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorJoachim Filip Ignacy Bartosik <jbartosik@gmail.com>2010-07-05 17:00:26 +0200
committerJoachim Filip Ignacy Bartosik <jbartosik@gmail.com>2010-07-12 19:17:19 +0200
commit60c1b3ec74571066cff255e55f9bce3d50ae6282 (patch)
tree8f7abc208415aaea9c53d3f5410da2d7b505c299 /app
parentAdded a group of alternative questions to seed (diff)
downloadrecruiting-webapp-60c1b3ec74571066cff255e55f9bce3d50ae6282.tar.gz
recruiting-webapp-60c1b3ec74571066cff255e55f9bce3d50ae6282.tar.bz2
recruiting-webapp-60c1b3ec74571066cff255e55f9bce3d50ae6282.zip
Users can view descriptions of question groups
Added index of question groups (supports filtering by category).
Diffstat (limited to 'app')
-rw-r--r--app/controllers/question_groups_controller.rb10
-rw-r--r--app/models/question_category.rb4
-rw-r--r--app/models/question_group.rb5
-rw-r--r--app/views/question_groups/category.dryml11
-rw-r--r--app/views/taglibs/application.dryml1
5 files changed, 28 insertions, 3 deletions
diff --git a/app/controllers/question_groups_controller.rb b/app/controllers/question_groups_controller.rb
index 03ad9b3..e189f04 100644
--- a/app/controllers/question_groups_controller.rb
+++ b/app/controllers/question_groups_controller.rb
@@ -2,6 +2,14 @@ class QuestionGroupsController < ApplicationController
hobo_model_controller
- auto_actions :all
+ auto_actions :all, :except => :index
+ index_action :category
+ def category
+ if params["id"].nil? || params["id"].empty?
+ hobo_index
+ else
+ hobo_index QuestionGroup.in_category params["id"]
+ end
+ end
end
diff --git a/app/models/question_category.rb b/app/models/question_category.rb
index fdbdf28..d6b5723 100644
--- a/app/models/question_category.rb
+++ b/app/models/question_category.rb
@@ -13,4 +13,8 @@ class QuestionCategory < ActiveRecord::Base
has_many :user_categories
has_many :users, :through => :user_categories, :accessible => true
include Permissions::AnyoneCanViewAdminCanChange
+
+ def self.as_select_opts
+ [['All Categories', nil]] + QuestionCategory.all(:select => 'name, id').collect{ |q| [q.name, q.id]}
+ end
end
diff --git a/app/models/question_group.rb b/app/models/question_group.rb
index 2986eda..4dd9c96 100644
--- a/app/models/question_group.rb
+++ b/app/models/question_group.rb
@@ -3,12 +3,13 @@ class QuestionGroup < ActiveRecord::Base
hobo_model # Don't put anything above this
fields do
- name :string, :null => false
+ name :string, :null => false
+ description :text, :null => false
timestamps
end
has_many :questions
- validates_presence_of :name
+ validates_presence_of :name, :description
validates_uniqueness_of :name
include Permissions::AnyoneCanViewAdminCanChange
diff --git a/app/views/question_groups/category.dryml b/app/views/question_groups/category.dryml
new file mode 100644
index 0000000..aeccc98
--- /dev/null
+++ b/app/views/question_groups/category.dryml
@@ -0,0 +1,11 @@
+<index-page>
+ <content:>
+ <form action="/question_groups/category">
+ <%=
+ select("id", nil, QuestionCategory.as_select_opts, {:include_blank => false, :selected => params['id'].try[0].to_i})
+ %>
+ <submit label="view in this category"/>
+ </form>
+ <collection/>
+ </content:>
+</index-page>
diff --git a/app/views/taglibs/application.dryml b/app/views/taglibs/application.dryml
index cf03f64..f4dc13d 100644
--- a/app/views/taglibs/application.dryml
+++ b/app/views/taglibs/application.dryml
@@ -18,6 +18,7 @@
<nav-item with="&ProjectAcceptance"><ht key="project_acceptances.nav_item">Project Acceptances</ht></nav-item>
<nav-item with="&Question"><ht key="questions.nav_item">Questions</ht></nav-item>
<nav-item with="&QuestionCategory"><ht key="question_categories.nav_item">Question Categories</ht></nav-item>
+ <nav-item with="&QuestionGroup" action="category"><ht key="question_groups.nav_item">Question Groups</ht></nav-item>
<nav-item href="&suggest_questions_questions_path"><ht key="questions.nav_item">Suggestion Questions</ht></nav-item>
<nav-item href="&approve_questions_questions_path" if="&current_user.questions_to_approve.count > 0"><ht key="questions.nav_item">Approve Questions</ht></nav-item>
</navigation>