2009-02-25 09:22:11 +01:00
|
|
|
require File.join(FIXTURE_PATH, 'more', 'question')
|
|
|
|
require File.join(FIXTURE_PATH, 'more', 'person')
|
|
|
|
|
2010-06-20 22:01:11 +02:00
|
|
|
class Course < CouchRest::Model::Base
|
2009-02-25 09:22:11 +01:00
|
|
|
use_database TEST_SERVER.default_database
|
|
|
|
|
2010-06-20 22:01:11 +02:00
|
|
|
property :title, String
|
|
|
|
property :questions, [Question]
|
|
|
|
property :professor, Person
|
|
|
|
property :participants, [Object]
|
|
|
|
property :ends_at, Time
|
|
|
|
property :estimate, Float
|
|
|
|
property :hours, Integer
|
|
|
|
property :profit, BigDecimal
|
|
|
|
property :started_on, :type => Date
|
2011-03-13 19:34:25 +01:00
|
|
|
property :updated_at, DateTime
|
2010-06-20 22:01:11 +02:00
|
|
|
property :active, :type => TrueClass
|
2010-05-21 23:00:19 +02:00
|
|
|
property :very_active, :type => TrueClass
|
2010-06-20 22:01:11 +02:00
|
|
|
property :klass, :type => Class
|
2011-03-13 19:34:25 +01:00
|
|
|
|
2009-02-25 09:22:11 +01:00
|
|
|
view_by :title
|
2010-06-15 01:35:14 +02:00
|
|
|
view_by :title, :active
|
2009-02-25 09:22:11 +01:00
|
|
|
view_by :dept, :ducktype => true
|
2010-06-15 01:35:14 +02:00
|
|
|
|
2011-03-13 19:34:25 +01:00
|
|
|
view_by :active, :map => "function(d) { if (d['#{model_type_key}'] == 'Course' && d['active']) { emit(d['updated_at'], 1); }}", :reduce => "function(k,v,r) { return sum(v); }"
|
|
|
|
|
2010-03-03 03:18:32 +01:00
|
|
|
end
|