enju_event 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +36 -0
- data/app/controllers/calendar_controller.rb +34 -0
- data/app/controllers/event_categories_controller.rb +18 -0
- data/app/controllers/event_import_files_controller.rb +95 -0
- data/app/controllers/event_import_results_controller.rb +15 -0
- data/app/controllers/events_controller.rb +152 -0
- data/app/controllers/participates_controller.rb +81 -0
- data/app/helpers/calendar_helper.rb +31 -0
- data/app/models/event.rb +87 -0
- data/app/models/event_category.rb +23 -0
- data/app/models/event_import_file.rb +166 -0
- data/app/models/event_import_result.rb +23 -0
- data/app/models/participate.rb +25 -0
- data/app/views/calendar/index.html.erb +45 -0
- data/app/views/event_categories/_form.html.erb +19 -0
- data/app/views/event_categories/edit.html.erb +13 -0
- data/app/views/event_categories/index.html.erb +46 -0
- data/app/views/event_categories/new.html.erb +12 -0
- data/app/views/event_categories/show.html.erb +29 -0
- data/app/views/event_import_files/edit.html.erb +25 -0
- data/app/views/event_import_files/index.html.erb +40 -0
- data/app/views/event_import_files/new.html.erb +37 -0
- data/app/views/event_import_files/show.html.erb +64 -0
- data/app/views/event_import_results/index.csv.erb +3 -0
- data/app/views/event_import_results/index.html.erb +50 -0
- data/app/views/event_import_results/show.html.erb +33 -0
- data/app/views/events/_all_day.html.erb +24 -0
- data/app/views/events/_form.html.erb +44 -0
- data/app/views/events/edit.html.erb +14 -0
- data/app/views/events/index.atom.builder +10 -0
- data/app/views/events/index.csv.erb +4 -0
- data/app/views/events/index.html.erb +105 -0
- data/app/views/events/index.ics.erb +13 -0
- data/app/views/events/index.mobile.erb +49 -0
- data/app/views/events/index.rss.builder +34 -0
- data/app/views/events/new.html.erb +17 -0
- data/app/views/events/show.html.erb +50 -0
- data/app/views/events/show.mobile.erb +42 -0
- data/app/views/participates/edit.html.erb +28 -0
- data/app/views/participates/index.html.erb +30 -0
- data/app/views/participates/new.html.erb +27 -0
- data/app/views/participates/show.html.erb +24 -0
- data/config/routes.rb +10 -0
- data/db/fixtures/event_categories.yml +13 -0
- data/db/migrate/113_create_events.rb +23 -0
- data/db/migrate/114_create_event_categories.rb +16 -0
- data/db/migrate/20081028093607_create_event_import_files.rb +29 -0
- data/db/migrate/20090519203307_create_participates.rb +17 -0
- data/db/migrate/20100925074639_create_event_import_results.rb +15 -0
- data/lib/enju_event.rb +5 -0
- data/lib/enju_event/engine.rb +18 -0
- data/lib/enju_event/version.rb +3 -0
- data/lib/tasks/enju_event_tasks.rake +5 -0
- data/spec/controllers/event_categories_controller_spec.rb +483 -0
- data/spec/controllers/event_import_files_controller_spec.rb +321 -0
- data/spec/controllers/events_controller_spec.rb +506 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/javascripts/application.js +9 -0
- data/spec/dummy/app/assets/stylesheets/application.css +7 -0
- data/spec/dummy/app/controllers/application_controller.rb +99 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/mailers/notifier.rb +28 -0
- data/spec/dummy/app/models/ability.rb +39 -0
- data/spec/dummy/app/models/language.rb +4 -0
- data/spec/dummy/app/models/library.rb +128 -0
- data/spec/dummy/app/models/library_group.rb +86 -0
- data/spec/dummy/app/models/patron.rb +163 -0
- data/spec/dummy/app/models/patron_type.rb +19 -0
- data/spec/dummy/app/models/role.rb +8 -0
- data/spec/dummy/app/models/shelf.rb +54 -0
- data/spec/dummy/app/models/user.rb +43 -0
- data/spec/dummy/app/models/user_group.rb +2 -0
- data/spec/dummy/app/models/user_has_role.rb +4 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/app/views/page/403.html.erb +9 -0
- data/spec/dummy/app/views/page/403.mobile.erb +5 -0
- data/spec/dummy/app/views/page/403.xml.erb +4 -0
- data/spec/dummy/app/views/page/404.html.erb +9 -0
- data/spec/dummy/app/views/page/404.mobile.erb +5 -0
- data/spec/dummy/app/views/page/404.xml.erb +4 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +45 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +30 -0
- data/spec/dummy/config/environments/production.rb +60 -0
- data/spec/dummy/config/environments/test.rb +39 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/devise.rb +209 -0
- data/spec/dummy/config/initializers/inflections.rb +10 -0
- data/spec/dummy/config/initializers/mime_types.rb +7 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +60 -0
- data/spec/dummy/db/migrate/001_create_patrons.rb +62 -0
- data/spec/dummy/db/migrate/059_create_libraries.rb +34 -0
- data/spec/dummy/db/migrate/069_create_shelves.rb +19 -0
- data/spec/dummy/db/migrate/080_create_library_groups.rb +25 -0
- data/spec/dummy/db/migrate/20080905191442_create_patron_types.rb +16 -0
- data/spec/dummy/db/migrate/20081025083905_create_languages.rb +27 -0
- data/spec/dummy/db/migrate/20100211105551_add_admin_networks_to_library_group.rb +9 -0
- data/spec/dummy/db/migrate/20100222124420_add_allow_bookmark_external_url_to_library_group.rb +9 -0
- data/spec/dummy/db/migrate/20100527113752_create_delayed_jobs.rb +21 -0
- data/spec/dummy/db/migrate/20110115022329_add_position_to_library_group.rb +9 -0
- data/spec/dummy/db/migrate/20110222073537_add_url_to_library_group.rb +9 -0
- data/spec/dummy/db/migrate/20111020063828_remove_dsbl_from_library_group.rb +11 -0
- data/spec/dummy/db/migrate/20111201121844_create_roles.rb +12 -0
- data/spec/dummy/db/migrate/20111201155456_create_users.rb +14 -0
- data/spec/dummy/db/migrate/20111201155513_add_devise_to_users.rb +31 -0
- data/spec/dummy/db/migrate/20111201163342_create_user_groups.rb +12 -0
- data/spec/dummy/db/migrate/20111201163718_create_user_has_roles.rb +10 -0
- data/spec/dummy/db/schema.rb +293 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/lib/enju_leaf.rb +4 -0
- data/spec/dummy/lib/enju_leaf/import_file.rb +13 -0
- data/spec/dummy/lib/enju_leaf/localized_name.rb +13 -0
- data/spec/dummy/lib/enju_leaf/master_model.rb +41 -0
- data/spec/dummy/lib/enju_leaf/url_validator.rb +10 -0
- data/spec/dummy/log/sunspot-solr-test.log +222 -0
- data/spec/dummy/log/test.log +145759 -0
- data/spec/dummy/private/system/event_imports/4/original/event_import_file_sample1.tsv +5 -0
- data/spec/dummy/private/system/event_imports/4/original/event_import_file_sample2.tsv +3 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +26 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/dummy/solr/conf/admin-extra.html +31 -0
- data/spec/dummy/solr/conf/elevate.xml +36 -0
- data/spec/dummy/solr/conf/mapping-ISOLatin1Accent.txt +246 -0
- data/spec/dummy/solr/conf/protwords.txt +21 -0
- data/spec/dummy/solr/conf/schema.xml +238 -0
- data/spec/dummy/solr/conf/scripts.conf +24 -0
- data/spec/dummy/solr/conf/solrconfig.xml +934 -0
- data/spec/dummy/solr/conf/spellings.txt +2 -0
- data/spec/dummy/solr/conf/stopwords.txt +58 -0
- data/spec/dummy/solr/conf/synonyms.txt +31 -0
- data/spec/dummy/solr/data/test/index/segments.gen +0 -0
- data/spec/dummy/solr/data/test/index/segments_1 +0 -0
- data/spec/dummy/solr/data/test/spellchecker/segments.gen +0 -0
- data/spec/dummy/solr/data/test/spellchecker/segments_1 +0 -0
- data/spec/factories/event.rb +7 -0
- data/spec/factories/event_category.rb +5 -0
- data/spec/factories/library.rb +13 -0
- data/spec/factories/user.rb +34 -0
- data/spec/fixtures/event_categories.yml +55 -0
- data/spec/fixtures/event_import_files.yml +49 -0
- data/spec/fixtures/event_import_results.yml +24 -0
- data/spec/fixtures/events.yml +142 -0
- data/spec/fixtures/languages.yml +1901 -0
- data/spec/fixtures/libraries.yml +108 -0
- data/spec/fixtures/library_groups.yml +34 -0
- data/spec/fixtures/patron_types.yml +35 -0
- data/spec/fixtures/patrons.yml +338 -0
- data/spec/fixtures/roles.yml +21 -0
- data/spec/fixtures/shelves.yml +46 -0
- data/spec/fixtures/user_groups.yml +25 -0
- data/spec/fixtures/user_has_roles.yml +41 -0
- data/spec/fixtures/users.yml +69 -0
- data/spec/models/event_category_spec.rb +21 -0
- data/spec/models/event_import_file_spec.rb +62 -0
- data/spec/models/event_import_result_spec.rb +20 -0
- data/spec/models/event_spec.rb +39 -0
- data/spec/spec_helper.rb +45 -0
- data/spec/support/controller_macros.rb +48 -0
- data/spec/support/devise.rb +4 -0
- metadata +541 -0
@@ -0,0 +1,31 @@
|
|
1
|
+
module CalendarHelper
|
2
|
+
include EventCalendar::CalendarHelper
|
3
|
+
def month_link(month_date)
|
4
|
+
link_to(I18n.localize(month_date, :format => "%B"), {:month => month_date.month, :year => month_date.year})
|
5
|
+
end
|
6
|
+
|
7
|
+
# custom options for this calendar
|
8
|
+
def event_calendar_opts
|
9
|
+
{
|
10
|
+
:year => @year,
|
11
|
+
:month => @month,
|
12
|
+
:event_strips => @event_strips,
|
13
|
+
:month_name_text => I18n.localize(@shown_month, :format => "%B %Y"),
|
14
|
+
:previous_month_text => "<< " + month_link(@shown_month.prev_month),
|
15
|
+
:next_month_text => month_link(@shown_month.next_month) + " >>",
|
16
|
+
:use_all_day => true,
|
17
|
+
:link_to_day_action => 'show'
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
def event_calendar
|
22
|
+
# args is an argument hash containing :event, :day, and :options
|
23
|
+
calendar event_calendar_opts do |args|
|
24
|
+
event, day = args[:event], args[:day]
|
25
|
+
html = %(<a href="#{event_path(event)}" title="#{h(event.display_name.localize)}">)
|
26
|
+
html << display_event_time(event, day)
|
27
|
+
html << %(#{h(event.display_name.localize)}</a>)
|
28
|
+
html
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/app/models/event.rb
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
class Event < ActiveRecord::Base
|
3
|
+
scope :closing_days, includes(:event_category).where('event_categories.name = ?', 'closed')
|
4
|
+
scope :on, lambda {|datetime| where('start_at >= ? AND start_at < ?', datetime.beginning_of_day, datetime.tomorrow.beginning_of_day + 1)}
|
5
|
+
scope :past, lambda {|datetime| where('end_at <= ?', Time.zone.parse(datetime).beginning_of_day)}
|
6
|
+
scope :upcoming, lambda {|datetime| where('start_at >= ?', Time.zone.parse(datetime).beginning_of_day)}
|
7
|
+
scope :at, lambda {|library| where(:library_id => library.id)}
|
8
|
+
|
9
|
+
belongs_to :event_category, :validate => true
|
10
|
+
belongs_to :library, :validate => true
|
11
|
+
has_many :attachment_files, :as => :attachable
|
12
|
+
has_many :picture_files, :as => :picture_attachable
|
13
|
+
has_many :participates, :dependent => :destroy
|
14
|
+
has_many :patrons, :through => :participates
|
15
|
+
has_one :event_import_result
|
16
|
+
|
17
|
+
has_event_calendar
|
18
|
+
|
19
|
+
searchable do
|
20
|
+
text :name, :note
|
21
|
+
integer :library_id
|
22
|
+
time :created_at
|
23
|
+
time :updated_at
|
24
|
+
time :start_at
|
25
|
+
time :end_at
|
26
|
+
end
|
27
|
+
|
28
|
+
validates_presence_of :name, :library, :event_category
|
29
|
+
validates_associated :library, :event_category
|
30
|
+
validate :check_date
|
31
|
+
before_validation :set_date
|
32
|
+
before_validation :set_display_name, :on => :create
|
33
|
+
|
34
|
+
def self.per_page
|
35
|
+
10
|
36
|
+
end
|
37
|
+
|
38
|
+
def set_date
|
39
|
+
if self.start_at.blank?
|
40
|
+
self.start_at = Time.zone.today.beginning_of_day
|
41
|
+
end
|
42
|
+
if self.end_at.blank?
|
43
|
+
self.end_at = Time.zone.today.end_of_day
|
44
|
+
end
|
45
|
+
|
46
|
+
set_all_day
|
47
|
+
end
|
48
|
+
|
49
|
+
def set_all_day
|
50
|
+
if self.all_day
|
51
|
+
self.start_at = self.start_at.beginning_of_day
|
52
|
+
self.end_at = self.end_at.end_of_day
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def check_date
|
57
|
+
if self.start_at and self.end_at
|
58
|
+
if self.start_at >= self.end_at
|
59
|
+
errors.add(:start_at)
|
60
|
+
errors.add(:end_at)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def set_display_name
|
66
|
+
self.display_name = self.name if self.display_name.blank?
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
# == Schema Information
|
71
|
+
#
|
72
|
+
# Table name: events
|
73
|
+
#
|
74
|
+
# id :integer not null, primary key
|
75
|
+
# library_id :integer default(1), not null
|
76
|
+
# event_category_id :integer default(1), not null
|
77
|
+
# name :string(255)
|
78
|
+
# note :text
|
79
|
+
# start_at :datetime
|
80
|
+
# end_at :datetime
|
81
|
+
# all_day :boolean default(FALSE), not null
|
82
|
+
# deleted_at :datetime
|
83
|
+
# created_at :datetime
|
84
|
+
# updated_at :datetime
|
85
|
+
# display_name :text
|
86
|
+
#
|
87
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class EventCategory < ActiveRecord::Base
|
2
|
+
include MasterModel
|
3
|
+
default_scope :order => "position"
|
4
|
+
has_many :events
|
5
|
+
|
6
|
+
def self.per_page
|
7
|
+
10
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
# == Schema Information
|
12
|
+
#
|
13
|
+
# Table name: event_categories
|
14
|
+
#
|
15
|
+
# id :integer not null, primary key
|
16
|
+
# name :string(255) not null
|
17
|
+
# display_name :text
|
18
|
+
# note :text
|
19
|
+
# position :integer
|
20
|
+
# created_at :datetime
|
21
|
+
# updated_at :datetime
|
22
|
+
#
|
23
|
+
|
@@ -0,0 +1,166 @@
|
|
1
|
+
class EventImportFile < ActiveRecord::Base
|
2
|
+
include ImportFile
|
3
|
+
default_scope :order => 'id DESC'
|
4
|
+
scope :not_imported, where(:state => 'pending', :imported_at => nil)
|
5
|
+
scope :stucked, where('created_at < ? AND state = ?', 1.hour.ago, 'pending')
|
6
|
+
|
7
|
+
if configatron.uploaded_file.storage == :s3
|
8
|
+
has_attached_file :event_import, :storage => :s3, :s3_credentials => "#{Rails.root.to_s}/config/s3.yml",
|
9
|
+
:path => "event_import_files/:id/:filename",
|
10
|
+
:s3_permissions => :private
|
11
|
+
else
|
12
|
+
has_attached_file :event_import, :path => ":rails_root/private:url"
|
13
|
+
end
|
14
|
+
validates_attachment_content_type :event_import, :content_type => ['text/csv', 'text/plain', 'text/tab-separated-values', 'application/octet-stream']
|
15
|
+
validates_attachment_presence :event_import
|
16
|
+
belongs_to :user, :validate => true
|
17
|
+
has_many :event_import_results
|
18
|
+
before_create :set_digest
|
19
|
+
|
20
|
+
state_machine :initial => :pending do
|
21
|
+
event :sm_start do
|
22
|
+
transition [:pending, :started] => :started
|
23
|
+
end
|
24
|
+
|
25
|
+
event :sm_complete do
|
26
|
+
transition :started => :completed
|
27
|
+
end
|
28
|
+
|
29
|
+
event :sm_fail do
|
30
|
+
transition :started => :failed
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def set_digest(options = {:type => 'sha1'})
|
35
|
+
if File.exists?(event_import.queued_for_write[:original])
|
36
|
+
self.file_hash = Digest::SHA1.hexdigest(File.open(event_import.queued_for_write[:original].path, 'rb').read)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def import_start
|
41
|
+
sm_start!
|
42
|
+
case edit_mode
|
43
|
+
when 'create'
|
44
|
+
import
|
45
|
+
when 'update'
|
46
|
+
when 'destroy'
|
47
|
+
else
|
48
|
+
import
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def import
|
53
|
+
self.reload
|
54
|
+
num = {:imported => 0, :failed => 0}
|
55
|
+
record = 2
|
56
|
+
|
57
|
+
rows = open_import_file
|
58
|
+
field = rows.first
|
59
|
+
if [field['name']].reject{|f| f.to_s.strip == ""}.empty?
|
60
|
+
raise "You should specify a name in the first line"
|
61
|
+
end
|
62
|
+
if [field['start_at'], field['end_at']].reject{|field| field.to_s.strip == ""}.empty?
|
63
|
+
raise "You should specify dates in the first line"
|
64
|
+
end
|
65
|
+
#rows.shift
|
66
|
+
rows.each do |row|
|
67
|
+
next if row['dummy'].to_s.strip.present?
|
68
|
+
import_result = EventImportResult.create!(:event_import_file => self, :body => row.fields.join("\t"))
|
69
|
+
|
70
|
+
event = Event.new
|
71
|
+
event.name = row['name']
|
72
|
+
event.note = row['note']
|
73
|
+
event.start_at = row['start_at']
|
74
|
+
event.end_at = row['end_at']
|
75
|
+
category = row['category'].to_s.strip
|
76
|
+
event.all_day = true
|
77
|
+
library = Library.where(:name => row['library_short_name']).first
|
78
|
+
library = Library.web if library.blank?
|
79
|
+
event.library = library
|
80
|
+
event_category = EventCategory.where(:name => category).first || EventCategory.where(:name => 'unknown').first
|
81
|
+
event.event_category = event_category
|
82
|
+
|
83
|
+
begin
|
84
|
+
if event.save!
|
85
|
+
import_result.event = event
|
86
|
+
num[:imported] += 1
|
87
|
+
if record % 50 == 0
|
88
|
+
Sunspot.commit
|
89
|
+
GC.start
|
90
|
+
end
|
91
|
+
end
|
92
|
+
rescue
|
93
|
+
Rails.logger.info("event import failed: column #{record}")
|
94
|
+
num[:failed] += 1
|
95
|
+
end
|
96
|
+
import_result.save!
|
97
|
+
record += 1
|
98
|
+
end
|
99
|
+
self.update_attribute(:imported_at, Time.zone.now)
|
100
|
+
Sunspot.commit
|
101
|
+
rows.close
|
102
|
+
sm_complete!
|
103
|
+
return num
|
104
|
+
end
|
105
|
+
|
106
|
+
def self.import
|
107
|
+
EventImportFile.not_imported.each do |file|
|
108
|
+
file.import_start
|
109
|
+
end
|
110
|
+
rescue
|
111
|
+
Rails.logger.info "#{Time.zone.now} importing events failed!"
|
112
|
+
end
|
113
|
+
|
114
|
+
private
|
115
|
+
def open_import_file
|
116
|
+
tempfile = Tempfile.new('event_import_file')
|
117
|
+
if configatron.uploaded_file.storage == :s3
|
118
|
+
uploaded_file_path = open(self.event_import.expiring_url(10)).path
|
119
|
+
else
|
120
|
+
uploaded_file_path = self.event_import.path
|
121
|
+
end
|
122
|
+
open(uploaded_file_path){|f|
|
123
|
+
f.each{|line|
|
124
|
+
tempfile.puts(NKF.nkf('-w -Lu', line))
|
125
|
+
}
|
126
|
+
}
|
127
|
+
tempfile.close
|
128
|
+
|
129
|
+
if RUBY_VERSION > '1.9'
|
130
|
+
file = CSV.open(tempfile, :col_sep => "\t")
|
131
|
+
header = file.first
|
132
|
+
rows = CSV.open(tempfile, :headers => header, :col_sep => "\t")
|
133
|
+
else
|
134
|
+
file = FasterCSV.open(tempfile.path, :col_sep => "\t")
|
135
|
+
header = file.first
|
136
|
+
rows = FasterCSV.open(tempfile.path, :headers => header, :col_sep => "\t")
|
137
|
+
end
|
138
|
+
EventImportResult.create!(:event_import_file => self, :body => header.join("\t"))
|
139
|
+
tempfile.close(true)
|
140
|
+
file.close
|
141
|
+
rows
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
# == Schema Information
|
146
|
+
#
|
147
|
+
# Table name: event_import_files
|
148
|
+
#
|
149
|
+
# id :integer not null, primary key
|
150
|
+
# parent_id :integer
|
151
|
+
# content_type :string(255)
|
152
|
+
# size :integer
|
153
|
+
# file_hash :string(255)
|
154
|
+
# user_id :integer
|
155
|
+
# note :text
|
156
|
+
# imported_at :datetime
|
157
|
+
# state :string(255)
|
158
|
+
# event_import_file_name :string(255)
|
159
|
+
# event_import_content_type :string(255)
|
160
|
+
# event_import_file_size :integer
|
161
|
+
# event_import_updated_at :datetime
|
162
|
+
# created_at :datetime
|
163
|
+
# updated_at :datetime
|
164
|
+
# edit_mode :string(255)
|
165
|
+
#
|
166
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class EventImportResult < ActiveRecord::Base
|
2
|
+
default_scope :order => 'event_import_results.id'
|
3
|
+
scope :file_id, proc{|file_id| {:conditions => {:event_import_file_id => file_id}}}
|
4
|
+
scope :failed, where(:event_id => nil)
|
5
|
+
|
6
|
+
belongs_to :event_import_file
|
7
|
+
belongs_to :event
|
8
|
+
|
9
|
+
validates_presence_of :event_import_file_id
|
10
|
+
end
|
11
|
+
|
12
|
+
# == Schema Information
|
13
|
+
#
|
14
|
+
# Table name: event_import_results
|
15
|
+
#
|
16
|
+
# id :integer not null, primary key
|
17
|
+
# event_import_file_id :integer
|
18
|
+
# event_id :integer
|
19
|
+
# body :text
|
20
|
+
# created_at :datetime
|
21
|
+
# updated_at :datetime
|
22
|
+
#
|
23
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
class Participate < ActiveRecord::Base
|
2
|
+
belongs_to :patron
|
3
|
+
belongs_to :event
|
4
|
+
|
5
|
+
validates_presence_of :patron_id, :event_id
|
6
|
+
validates_uniqueness_of :patron_id, :scope => :event_id
|
7
|
+
acts_as_list :scope => :event_id
|
8
|
+
|
9
|
+
def self.per_page
|
10
|
+
10
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
# == Schema Information
|
15
|
+
#
|
16
|
+
# Table name: participates
|
17
|
+
#
|
18
|
+
# id :integer not null, primary key
|
19
|
+
# patron_id :integer not null
|
20
|
+
# event_id :integer not null
|
21
|
+
# position :integer
|
22
|
+
# created_at :datetime
|
23
|
+
# updated_at :datetime
|
24
|
+
#
|
25
|
+
|
@@ -0,0 +1,45 @@
|
|
1
|
+
<div id="content_detail" class="ui-corner-all">
|
2
|
+
<%- if @library -%>
|
3
|
+
<h1 class="title">
|
4
|
+
<%= t('calendar.library_calendar', :library_name => @library.display_name.localize) -%>
|
5
|
+
</h1>
|
6
|
+
<%- else -%>
|
7
|
+
<h1 class="title">
|
8
|
+
<%= t('calendar.calendar') -%>
|
9
|
+
</h1>
|
10
|
+
<%- end -%>
|
11
|
+
|
12
|
+
<div id="content_list">
|
13
|
+
<p id="notice"><%= notice %></p>
|
14
|
+
|
15
|
+
<%- if @library -%>
|
16
|
+
<h2 class="resource_title">
|
17
|
+
<%= link_to @library.display_name.localize, @library -%>
|
18
|
+
</h2>
|
19
|
+
<%- else -%>
|
20
|
+
<h2 class="resource_title">
|
21
|
+
<%= t('event.all_libraries') -%>
|
22
|
+
</h2>
|
23
|
+
<%- end -%>
|
24
|
+
|
25
|
+
<p>
|
26
|
+
<%- if @library -%>
|
27
|
+
(<%= link_to 'iCalendar', library_events_path(@library, :format => :ics) -%>)
|
28
|
+
<%- else -%>
|
29
|
+
(<%= link_to 'iCalendar', events_path(:format => :ics) -%>)
|
30
|
+
<%- end -%>
|
31
|
+
</p>
|
32
|
+
|
33
|
+
<%= raw event_calendar %>
|
34
|
+
</div>
|
35
|
+
</div>
|
36
|
+
|
37
|
+
<div id="submenu" class="ui-corner-all">
|
38
|
+
<ul>
|
39
|
+
<li><%= link_to t('page.listing', :model => t('activerecord.models.event')), events_path -%></li>
|
40
|
+
<li><%= link_to t('page.show_all'), :controller => :calendar, :action => :index -%></li>
|
41
|
+
<%- @libraries.each do |library| -%>
|
42
|
+
<li><%= link_to library.display_name.localize, :controller => :calendar, :action => :index, :library_id => library.name -%></li>
|
43
|
+
<%- end -%>
|
44
|
+
</ul>
|
45
|
+
</div>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<%= form_for(@event_category) do |f| %>
|
2
|
+
<%= f.error_messages %>
|
3
|
+
|
4
|
+
<div class="field">
|
5
|
+
<%= f.label :name %><br />
|
6
|
+
<%= f.text_field :name %>
|
7
|
+
</div>
|
8
|
+
<div class="field">
|
9
|
+
<%= f.label :display_name %><br />
|
10
|
+
<%= f.text_area :display_name %>
|
11
|
+
</div>
|
12
|
+
<div class="field">
|
13
|
+
<%= f.label :note %><br />
|
14
|
+
<%= f.text_area :note %>
|
15
|
+
</div>
|
16
|
+
<div class="actions">
|
17
|
+
<%= f.submit %>
|
18
|
+
</div>
|
19
|
+
<% end %>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<div id="content_detail" class="ui-corner-all">
|
2
|
+
<h1 class="title"><%= t('page.editing', :model => t('activerecord.models.event_category')) -%></h1>
|
3
|
+
<div id="content_list">
|
4
|
+
<%= render 'form' %>
|
5
|
+
</div>
|
6
|
+
</div>
|
7
|
+
|
8
|
+
<div id="submenu" class="ui-corner-all">
|
9
|
+
<ul>
|
10
|
+
<li><%= link_to t('page.show'), @event_category -%></li>
|
11
|
+
<li><%= link_to t('page.back'), event_categories_path -%></li>
|
12
|
+
</ul>
|
13
|
+
</div>
|
@@ -0,0 +1,46 @@
|
|
1
|
+
<div id="content_detail" class="ui-corner-all">
|
2
|
+
<h1 class="title"><%= t('page.listing', :model => t('activerecord.models.event_category')) -%></h1>
|
3
|
+
<div id="content_list">
|
4
|
+
|
5
|
+
<table class="index">
|
6
|
+
<tr>
|
7
|
+
<th id="position"></th>
|
8
|
+
<th><%= t('activerecord.attributes.event_category.name') -%></th>
|
9
|
+
<th><%= t('activerecord.attributes.event_category.display_name') -%></th>
|
10
|
+
<th><%= t('activerecord.attributes.event_category.note') -%></th>
|
11
|
+
<th></th>
|
12
|
+
</tr>
|
13
|
+
|
14
|
+
<%- @event_categories.each do |event_category| -%>
|
15
|
+
<tr class="line<%= cycle("0", "1") -%>">
|
16
|
+
<td>
|
17
|
+
<%- if can? :update, event_category -%>
|
18
|
+
<%= move_position(event_category) -%>
|
19
|
+
<%- end -%>
|
20
|
+
</td>
|
21
|
+
<td><%= link_to event_category.name, event_category -%></td>
|
22
|
+
<td><%= link_to event_category.display_name.localize, event_category -%></td>
|
23
|
+
<td><%= event_category.note -%></td>
|
24
|
+
<td>
|
25
|
+
<%- if can? :update, event_category -%>
|
26
|
+
<%= link_to t('page.edit'), edit_event_category_path(event_category) -%>
|
27
|
+
<% end %>
|
28
|
+
<%- if can? :destroy, event_category -%>
|
29
|
+
<%= link_to t('page.destroy'), event_category, :confirm => t('page.are_you_sure'), :method => :delete -%>
|
30
|
+
<%- end -%>
|
31
|
+
</td>
|
32
|
+
</tr>
|
33
|
+
<%- end -%>
|
34
|
+
</table>
|
35
|
+
|
36
|
+
<%= will_paginate(@event_categories) -%>
|
37
|
+
</div>
|
38
|
+
</div>
|
39
|
+
|
40
|
+
<div id="submenu" class="ui-corner-all">
|
41
|
+
<ul>
|
42
|
+
<%- if can? :create, EventCategory -%>
|
43
|
+
<li><%= link_to t('page.new', :model => t('activerecord.models.event_category')), new_event_category_path -%></li>
|
44
|
+
<%- end -%>
|
45
|
+
</ul>
|
46
|
+
</div>
|