social_stream-events 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (145) hide show
  1. data/GPL Affero license +663 -0
  2. data/Gemfile +9 -0
  3. data/README.rdoc +6 -0
  4. data/Rakefile +29 -0
  5. data/app/assets/images/btn/btn_certificate.png +0 -0
  6. data/app/assets/images/btn/btn_certificates.png +0 -0
  7. data/app/assets/images/btn/btn_edit.png +0 -0
  8. data/app/assets/images/btn/btn_embebed.png +0 -0
  9. data/app/assets/images/btn/btn_event.png +0 -0
  10. data/app/assets/images/btn/btn_outline.png +0 -0
  11. data/app/assets/images/btn/event.png +0 -0
  12. data/app/assets/images/btn/flyer.png +0 -0
  13. data/app/assets/images/btn/keynote.png +0 -0
  14. data/app/assets/images/btn/live.png +0 -0
  15. data/app/assets/images/btn/time.png +0 -0
  16. data/app/assets/images/btn/trash.png +0 -0
  17. data/app/assets/images/icons/IconsByGlyphish.txt +1 -0
  18. data/app/assets/images/icons/down.png +0 -0
  19. data/app/assets/images/icons/search.png +0 -0
  20. data/app/assets/images/icons/up.png +0 -0
  21. data/app/assets/images/logos/actor/event.png +0 -0
  22. data/app/assets/images/logos/contact/event.png +0 -0
  23. data/app/assets/images/logos/original/event.png +0 -0
  24. data/app/assets/images/logos/profile/event.png +0 -0
  25. data/app/assets/images/logos/representation/event.png +0 -0
  26. data/app/assets/images/tab_bottom.png +0 -0
  27. data/app/assets/javascripts/schedule.js +123 -0
  28. data/app/assets/javascripts/settings.js +20 -0
  29. data/app/assets/javascripts/social_stream-events.js +5 -0
  30. data/app/assets/stylesheets/activities.css +4 -0
  31. data/app/assets/stylesheets/fullcalendar.css +621 -0
  32. data/app/assets/stylesheets/fullcalendar.print.css +61 -0
  33. data/app/assets/stylesheets/settings.css +4 -0
  34. data/app/assets/stylesheets/social_stream-events.css +262 -0
  35. data/app/assets/stylesheets/tie.css +4 -0
  36. data/app/assets/stylesheets/users.css +4 -0
  37. data/app/controllers/activities_controller.rb +42 -0
  38. data/app/controllers/agendas_controller.rb +54 -0
  39. data/app/controllers/calendar_events_controller.rb +157 -0
  40. data/app/controllers/events_controller.rb +85 -0
  41. data/app/controllers/sessions_controller.rb +133 -0
  42. data/app/controllers/settings_controller.rb +70 -0
  43. data/app/helpers/event_helper.rb +12 -0
  44. data/app/models/agenda.rb +55 -0
  45. data/app/models/calendar_event.rb +191 -0
  46. data/app/models/calendar_event_series.rb +126 -0
  47. data/app/models/event.rb +131 -0
  48. data/app/models/session.rb +22 -0
  49. data/app/views/activities/_activity.html.erb +5 -0
  50. data/app/views/activities/_child.html.erb +18 -0
  51. data/app/views/activities/_comments.html.erb +3 -0
  52. data/app/views/activities/_index.html.erb +95 -0
  53. data/app/views/activities/_new.html.erb +29 -0
  54. data/app/views/activities/_options.html.erb +15 -0
  55. data/app/views/activities/_root.html.erb +37 -0
  56. data/app/views/activities/_wall.html.erb +5 -0
  57. data/app/views/activities/_walls.html.erb +34 -0
  58. data/app/views/activities/documents.js.erb +1 -0
  59. data/app/views/activities/index.js.erb +1 -0
  60. data/app/views/agendas/_agenda.html.erb +1 -0
  61. data/app/views/agendas/_edit.html.erb +136 -0
  62. data/app/views/agendas/_schedule.html.erb +19 -0
  63. data/app/views/agendas/_show.html.erb +81 -0
  64. data/app/views/agendas/_show_day.html.erb +6 -0
  65. data/app/views/agendas/edit.html.erb +24 -0
  66. data/app/views/agendas/event.html.erb +1 -0
  67. data/app/views/agendas/index.html.erb +0 -0
  68. data/app/views/agendas/show.html.erb +25 -0
  69. data/app/views/calendar_events/_calendar.html.erb +0 -0
  70. data/app/views/calendar_events/_edit_form.html.erb +58 -0
  71. data/app/views/calendar_events/_form.html.erb +65 -0
  72. data/app/views/calendar_events/available.html.erb +81 -0
  73. data/app/views/calendar_events/create.js.erb +18 -0
  74. data/app/views/calendar_events/edit.js.erb +1 -0
  75. data/app/views/calendar_events/index.html.erb +162 -0
  76. data/app/views/calendar_events/move.js.erb +0 -0
  77. data/app/views/calendar_events/new.js.erb +9 -0
  78. data/app/views/calendar_events/resize.js.erb +0 -0
  79. data/app/views/calendar_events/schedule.html.erb +143 -0
  80. data/app/views/documents/_mediawall.html.erb +111 -0
  81. data/app/views/events/_event.html.erb +10 -0
  82. data/app/views/events/_fields.html.erb +5 -0
  83. data/app/views/events/_form.html.erb +12 -0
  84. data/app/views/events/_jquery.html.erb +125 -0
  85. data/app/views/events/_manage.html.erb +35 -0
  86. data/app/views/events/_new.html.erb +2 -0
  87. data/app/views/events/_sessions_edit.html.erb +46 -0
  88. data/app/views/events/_sidebar_cloud.html.erb +27 -0
  89. data/app/views/events/_sidebar_index.html.erb +1 -0
  90. data/app/views/events/_sidebar_show.html.erb +5 -0
  91. data/app/views/events/agendas.html +1 -0
  92. data/app/views/events/edit.html.erb +12 -0
  93. data/app/views/events/index.html.erb +30 -0
  94. data/app/views/events/manage.html.erb +69 -0
  95. data/app/views/events/manage.js.erb +1 -0
  96. data/app/views/events/show.html.erb +34 -0
  97. data/app/views/kaminari/_first_page.html.erb +11 -0
  98. data/app/views/kaminari/_gap.html.erb +8 -0
  99. data/app/views/kaminari/_last_page.html.erb +11 -0
  100. data/app/views/kaminari/_next_page.html.erb +11 -0
  101. data/app/views/kaminari/_page.html.erb +12 -0
  102. data/app/views/kaminari/_paginator.html.erb +23 -0
  103. data/app/views/kaminari/_prev_page.html.erb +11 -0
  104. data/app/views/profiles/_outline.html.erb +81 -0
  105. data/app/views/profiles/_profile.html.erb +40 -0
  106. data/app/views/sessions/_form.html.erb +41 -0
  107. data/app/views/sessions/_new.html.erb +63 -0
  108. data/app/views/sessions/_session.html.erb +1 -0
  109. data/app/views/sessions/_show.html.erb +27 -0
  110. data/app/views/sessions/create.html.erb +3 -0
  111. data/app/views/sessions/create.js.erb +1 -0
  112. data/app/views/sessions/destroy.js.erb +2 -0
  113. data/app/views/sessions/edit.html.erb +27 -0
  114. data/app/views/sessions/index.html.erb +1 -0
  115. data/app/views/sessions/index.js.erb +1 -0
  116. data/app/views/sessions/new.html.erb +27 -0
  117. data/app/views/settings/_contacto.html.erb +24 -0
  118. data/app/views/settings/_header.html.erb +8 -0
  119. data/app/views/settings/_index.html.erb +16 -0
  120. data/app/views/settings/_manage.html.erb +25 -0
  121. data/app/views/settings/_settings.html.erb +49 -0
  122. data/app/views/settings/delete_relation.js.erb +3 -0
  123. data/app/views/settings/index.html.erb +38 -0
  124. data/app/views/settings/manage.html.erb +31 -0
  125. data/app/views/settings/show.html.erb +15 -0
  126. data/app/views/settings/update_relation.js.erb +1 -0
  127. data/app/views/toolbar/_home.html.erb +11 -0
  128. data/app/views/toolbar/_logo.html.erb +23 -0
  129. data/app/views/toolbar/_organizer.html.erb +25 -0
  130. data/app/views/toolbar/_profile.html.erb +21 -0
  131. data/app/views/toolbar/_sponsor.html.erb +18 -0
  132. data/app/views/toolbar/_suscribed.html.erb +17 -0
  133. data/app/views/users/_index.html.erb +33 -0
  134. data/app/views/users/index.html.erb +46 -0
  135. data/config/locales/en.yml +97 -0
  136. data/config/routes.rb +46 -0
  137. data/db/20110615143707_create_social_stream_events.rb +54 -0
  138. data/lib/generators/social_stream/events/install_generator.rb +24 -0
  139. data/lib/social_stream-events.rb +15 -0
  140. data/lib/social_stream/events/engine.rb +8 -0
  141. data/lib/social_stream/migrations/events.rb +25 -0
  142. data/social_stream-events.gemspec +22 -0
  143. data/vendor/assets/javascripts/fullcalendar.js +5208 -0
  144. data/vendor/assets/javascripts/gcal.js +112 -0
  145. metadata +272 -0
@@ -0,0 +1,61 @@
1
+ /*
2
+ * FullCalendar v1.5.1 Print Stylesheet
3
+ *
4
+ * Include this stylesheet on your page to get a more printer-friendly calendar.
5
+ * When including this stylesheet, use the media='print' attribute of the <link> tag.
6
+ * Make sure to include this stylesheet IN ADDITION to the regular fullcalendar.css.
7
+ *
8
+ * Copyright (c) 2011 Adam Shaw
9
+ * Dual licensed under the MIT and GPL licenses, located in
10
+ * MIT-LICENSE.txt and GPL-LICENSE.txt respectively.
11
+ *
12
+ * Date: Sat Apr 9 14:09:51 2011 -0700
13
+ *
14
+ */
15
+
16
+
17
+ /* Events
18
+ -----------------------------------------------------*/
19
+
20
+ .fc-event-skin {
21
+ /*background: none !important;
22
+ color: #000 !important; */
23
+ }
24
+
25
+ /* horizontal events */
26
+
27
+ .fc-event-hori {
28
+ border-width: 0 0 1px 0 !important;
29
+ border-bottom-style: dotted !important;
30
+ border-bottom-color: #000 !important;
31
+ padding: 1px 0 0 0 !important;
32
+ }
33
+
34
+ .fc-event-hori .fc-event-inner {
35
+ border-width: 0 !important;
36
+ padding: 0 1px !important;
37
+ }
38
+
39
+ /* vertical events */
40
+
41
+ .fc-event-vert {
42
+ border-width: 0 0 0 1px !important;
43
+ border-left-style: dotted !important;
44
+ border-left-color: #000 !important;
45
+ padding: 0 1px 0 0 !important;
46
+ }
47
+
48
+ .fc-event-vert .fc-event-inner {
49
+ border-width: 0 !important;
50
+ padding: 1px 0 !important;
51
+ }
52
+
53
+ .fc-event-bg {
54
+ display: none !important;
55
+ }
56
+
57
+ .fc-event .ui-resizable-handle {
58
+ display: none !important;
59
+ }
60
+
61
+
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,262 @@
1
+ /*
2
+ *= require_tree .
3
+ */
4
+
5
+ #filter_div
6
+ {
7
+ position:absolute;
8
+ left:64%;
9
+ top:49%;
10
+ }
11
+ #calendar{margin-top:-9px;}
12
+ #fc-btn-agenda{ padding-left: 1px;}
13
+
14
+ #founder{ padding: 1px; padding-top: 5px; text-align: center; }
15
+ #founder #created{display: inline-block;}
16
+ #founder #thumb{display: inline-block;}
17
+
18
+ #event_name{
19
+ border: 1px solid #BDC7D8;
20
+ padding: 5px;
21
+ width: 95%;
22
+ }.sb_wrapper input[type="text"],
23
+ ul.sb_dropdown{
24
+ border:1px solid #fff;
25
+ background: #fafafa;
26
+ background: -webkit-gradient(linear, left top, left bottom, from(#f2f2f2), to(#fafafa));
27
+ background: -moz-linear-gradient(top, #f2f2f2, #fafafa);
28
+ font-size:24px;
29
+ font-family:"Myriad Pro", "Trebuchet MS", sans-serif;
30
+ -moz-box-shadow:1px 1px 3px #555;
31
+ -webkit-box-shadow:1px 1px 3px #555;
32
+ -box-shadow:1px 1px 3px #555;
33
+ outline:none;
34
+ padding:6px 5px 6px 20px;
35
+ text-shadow:1px 1px 1px #fff;
36
+ width:295px;
37
+ float:left;
38
+ margin:3px 0px;
39
+ }
40
+ ul.sb_dropdown{
41
+ float:left;
42
+ list-style:none;
43
+ width:295px;
44
+ padding:6px 5px;
45
+ -moz-border-radius:0px 0px 10px 10px;
46
+ -webkit-border-bottom-right-radius:10px;
47
+ -webkit-border-bottom-left-radius:10px;
48
+ border-bottom-right-radius:10px;
49
+ border-bottom-left-radius:10px;
50
+ }
51
+ ul.sb_dropdown li{
52
+ font-size:8px;
53
+ line-height:2px;
54
+ height:22px;
55
+ float:left;
56
+ width:30%;
57
+ }
58
+ ul.sb_dropdown li input[type="checkbox"]{
59
+ float:left;
60
+ margin:10px 4px 0 5px;
61
+ }
62
+ ul.sb_dropdown li.sb_filter{
63
+ width:148px;
64
+ border:1px solid #f9f9f9;
65
+ clear:both;
66
+ background: #ddd;
67
+ font-size:12px;
68
+ text-transform:uppercase;
69
+ letter-spacing:1px;
70
+ color:#444;
71
+ height:16px;
72
+ line-height:16px;
73
+ padding:5px;
74
+ -moz-box-shadow:0px 0px 2px #777;
75
+ -webkit-box-shadow:0px 0px 3px #555 inset;
76
+ -box-shadow:0px 0px 3px #555 inset;
77
+
78
+ }
79
+ span.sb_up,
80
+ span.sb_down{
81
+ margin-top:10px;
82
+ padding:5px 25px 5px 25px;
83
+ width:14px;
84
+ height:41px;
85
+ background-color:#f2f2f2;
86
+ background-position:center center;
87
+ background-repeat: no-repeat;
88
+ z-index:10;
89
+ border:1px solid #fff;
90
+ -moz-box-shadow:1px 0px 1px #ddd;
91
+ -webkit-box-shadow:1px 0px 1px #ddd;
92
+ -box-shadow:1px 0px 1px #ddd;
93
+
94
+ }
95
+ span.sb_up{
96
+ background-image:url(../icons/up.png);
97
+ }
98
+ span.sb_down{
99
+ background-image:url(../icons/down.png);
100
+ }
101
+ input.sb_search{
102
+ background:#f2f2f2 url(../icons/search.png) no-repeat center center;
103
+ height:43px;
104
+ width:50px;
105
+ float:left;
106
+ border:none;
107
+ margin:3px 0px;
108
+ border:1px solid #fff;
109
+ -moz-box-shadow:1px 1px 3px #555;
110
+ -webkit-box-shadow:1px 1px 3px #555;
111
+ -box-shadow:1px 1px 3px #555;
112
+ outline:none;
113
+ cursor:pointer;
114
+ }
115
+ input.sb_search:hover{
116
+ background-color:#fff;
117
+ }
118
+
119
+ .space_center_manage
120
+ {
121
+ padding-right: 0;
122
+ padding-top: 9px;
123
+ text-align: left;
124
+ }
125
+ .tie_form {
126
+ display: inline;
127
+ height: 1%;
128
+ margin: 0 0;
129
+ overflow: hidden;
130
+ }
131
+ #contact_data{width: 250px;}
132
+
133
+
134
+ .session_wrapper1,.session_wrapper2{float:left;display:block;}
135
+ .session_wrapper1{
136
+ width:14%;
137
+ text-align:center;
138
+ margin:15px 0 15px 0;
139
+ color:#000;
140
+ }
141
+ .session_wrapper2{width:86%;padding-top: 5px;}
142
+
143
+ .event_date_image{margin: 0px 10px 0px 0px;width:100%;color:black;text-align:center;font-weight: bold;vertical-align: middle;}
144
+ .event_day{font-size: 3.5em;line-height:90%;}
145
+ .event_month{font-size: 2.5em;line-height:80%;}
146
+ .event_year{font-size: 1.2em;line-height:110%;}
147
+ .event_hour{font-size: 1.5em;line-height:80%;min-width: 30px; min-height: 20px;}
148
+ .event_day_name{font-size: 1em;line-height:80%;}
149
+ .event_time{font-size: 1em; line-height:50%;}
150
+
151
+ .session_title{
152
+ border-bottom: 1px solid #ccc;
153
+ width: 100%;
154
+ }
155
+
156
+ .schedule{ height: 85px;}
157
+
158
+ .block .session{height: 110px;}
159
+ .block .session_title_black {color: black;}
160
+ .block .session_content{font-size: 13px;}
161
+
162
+
163
+
164
+
165
+
166
+ .sb_wrapper input[type="text"],
167
+ ul.sb_dropdown{
168
+ border:1px solid #fff;
169
+ background: #fafafa;
170
+ background: -webkit-gradient(linear, left top, left bottom, from(#f2f2f2), to(#fafafa));
171
+ background: -moz-linear-gradient(top, #f2f2f2, #fafafa);
172
+ font-size:24px;
173
+ font-family:"Myriad Pro", "Trebuchet MS", sans-serif;
174
+ -moz-box-shadow:1px 1px 3px #555;
175
+ -webkit-box-shadow:1px 1px 3px #555;
176
+ -box-shadow:1px 1px 3px #555;
177
+ outline:none;
178
+ padding:6px 5px 6px 20px;
179
+ text-shadow:1px 1px 1px #fff;
180
+ width:105px;
181
+ float:left;
182
+ margin:3px 0px;
183
+ }s
184
+ ul.sb_dropdown{
185
+ float:left;
186
+ list-style:none;
187
+ width:150px;
188
+ padding:6px 5px;
189
+ -moz-border-radius:0px 0px 10px 10px;
190
+ -webkit-border-bottom-right-radius:10px;
191
+ -webkit-border-bottom-left-radius:10px;
192
+ border-bottom-right-radius:10px;
193
+ border-bottom-left-radius:10px;
194
+ }
195
+ ul.sb_dropdown li{
196
+ float: left;
197
+ font-size: 12px;
198
+ height: 25px;
199
+ line-height: 10px;
200
+ width: 100%;
201
+ }
202
+ ul.sb_dropdown li input[type="checkbox"]{
203
+ float:right;
204
+ margin:0px 3px 0 5px;
205
+ }
206
+ ul.sb_dropdown li.sb_filter{
207
+ width:295px;
208
+ border:1px solid #f9f9f9;
209
+ clear:both;
210
+ background: #ddd;
211
+ font-size:12px;
212
+ text-transform:uppercase;
213
+ letter-spacing:1px;
214
+ color:#444;
215
+ height:16px;
216
+ line-height:16px;
217
+ padding:5px;
218
+ -moz-box-shadow:0px 0px 2px #777;
219
+ -webkit-box-shadow:0px 0px 3px #555 inset;
220
+ -box-shadow:0px 0px 3px #555 inset;
221
+
222
+ }
223
+ span.sb_up,
224
+ span.sb_down{
225
+
226
+ width:14px;
227
+ height:41px;
228
+ background-color:#f2f2f2;
229
+ /*background-position:center center;*/
230
+ background-position: left center;
231
+ background-repeat: no-repeat;
232
+ z-index:10;
233
+ border:1px solid #fff;
234
+ -moz-box-shadow:1px 0px 1px #ddd;
235
+ -webkit-box-shadow:1px 0px 1px #ddd;
236
+ -box-shadow:1px 0px 1px #ddd;
237
+
238
+ }
239
+ span.sb_up{
240
+ background-image:url("icons/up.png");
241
+ }
242
+ span.sb_down{
243
+ background-image:url("icons/down.png");
244
+ }
245
+ input.sb_search{
246
+ background:#f2f2f2 url("icons/search.png") no-repeat center center;
247
+ height:43px;
248
+ width:50px;
249
+ float:left;
250
+ border:none;
251
+ margin:3px 0px;
252
+ border:1px solid #fff;
253
+ -moz-box-shadow:1px 1px 3px #555;
254
+ -webkit-box-shadow:1px 1px 3px #555;
255
+ -box-shadow:1px 1px 3px #555;
256
+ outline:none;
257
+ cursor:pointer;
258
+ }
259
+ input.sb_search:hover{
260
+ background-color:#fff;
261
+ }
262
+
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,42 @@
1
+ class ActivitiesController < InheritedResources::Base
2
+ belongs_to_subjects
3
+ actions :index
4
+
5
+ respond_to :js
6
+
7
+ def documents
8
+ object_types = params[:types]
9
+ if object_types.nil? || object_types == "all"
10
+ # @activities=ActivityObject.where("object_type in :list",:list=> object_types).order("updated_at DESC").
11
+ logger.debug("es nil u all")
12
+ # @activities=ActivityObject.
13
+ # page(params[:page]).
14
+ # per(params[:per])
15
+ @activities=current_subject.wall(:home).page(params[:page])
16
+ else
17
+ logger.debug("tiene valores el arreglo")
18
+ # @activities=ActivityObject.where(:object_type => object_types).order("updated_at DESC").
19
+ # page(params[:page]).
20
+ # per(params[:per])
21
+ @activities=current_subject.wall(:home).joins(:activity_objects).where(:activity_objects=>{:object_type => object_types}).order("updated_at DESC").page(params[:page])
22
+ end
23
+ #@activities = profile_subject.wall(:profile,
24
+ # :for => current_subject,
25
+ # :object_type => object_types).#Array(self.class.index_object_type)).
26
+ # page(params[:page]).
27
+ # per(params[:per])
28
+ end
29
+
30
+ protected
31
+
32
+ def collection
33
+ rel = params[:section].to_i if params[:section].present?
34
+
35
+ # should be activities.page(params[:page], :count => { :select => 'activity.id', :distinct => true }) but it is not working in Rails 3.0.3
36
+ @activities ||= association_chain[-1].
37
+ wall(:profile,
38
+ :for => current_subject,
39
+ :relation => rel).
40
+ page(params[:page])
41
+ end
42
+ end
@@ -0,0 +1,54 @@
1
+ class AgendasController < InheritedResources::Base
2
+ #protect_from_forgery
3
+
4
+ def schedule
5
+
6
+ end
7
+
8
+ def index
9
+
10
+ end
11
+
12
+ def edit
13
+ @event = Event.find_by_slug(params[:id])
14
+
15
+
16
+ end
17
+
18
+ def get_sessions()
19
+ @event = Event.find_by_slug(params[:id])
20
+ @agenda = Agenda.find_by_id(@event.agenda.id)
21
+ @sessions = @agenda.getSessions(@event.id,Time.at(params['start'].to_i),Time.at(params['end'].to_i))
22
+
23
+ sessions = []
24
+ @sessions.each do |session|
25
+ sessions << {:id => session.id,
26
+ :title => session.title,
27
+ :description => session.description || "Some cool description here...",
28
+ :start => "#{session.start_at.iso8601}",
29
+ :end => "#{session.end_at.iso8601}",
30
+ :allDay => false,
31
+ :recurring => false,
32
+ :editable => true
33
+ }
34
+ end
35
+ render :text => sessions.to_json
36
+ end
37
+
38
+ def show
39
+ @event = Event.find_by_slug(params[:id])
40
+
41
+
42
+ end
43
+
44
+ def create
45
+
46
+ end
47
+
48
+
49
+
50
+
51
+
52
+ end
53
+
54
+
@@ -0,0 +1,157 @@
1
+ class CalendarEventsController < InheritedResources::Base
2
+
3
+ def new
4
+ starttime = params[:start]
5
+ endtime = params[:end]
6
+ allDay = params[:allDay]
7
+ @room = Room.find(params[:room_id])
8
+ logger.error "starttime => #{starttime}, endtime => #{endtime}, all_day => #{allDay}"
9
+ @event = CalendarEvent.new(:starttime => starttime ? starttime[0,20].strip : "", :endtime => endtime ? endtime[0,20].strip : "", :all_day => allDay, :period => "Does not repeat")
10
+ end
11
+
12
+ def create
13
+ if params[:calendar_event][:period] == "Does not repeat"
14
+ @event = CalendarEvent.new(params[:calendar_event])
15
+ else
16
+ #@event_series = EventSeries.new(:frequency => params[:event][:frequency], :period => params[:event][:repeats], :starttime => params[:event][:starttime], :endtime => params[:event][:endtime], :all_day => params[:event][:all_day])
17
+ @event_series = CalendarEventSeries.new(params[:calendar_event])
18
+ if (params[:repeat_until][:year] != "" && params[:repeat_until][:month] != "" && params[:repeat_until][:day] != "")
19
+ @event_series.repeat_until = Date.civil(params[:repeat_until][:year].to_i, params[:repeat_until][:month].to_i, params[:repeat_until][:day].to_i)
20
+ @event_series.save
21
+ end
22
+ end
23
+ end
24
+
25
+ def index
26
+
27
+ end
28
+
29
+ def get_calendar_events
30
+ events = []
31
+ # Current reservations
32
+ if params[:calendar_events] != nil
33
+ calendar_events_ids = params[:calendar_events].strip().split(' ')
34
+ @calendar_events = CalendarEvent.find(calendar_events_ids)
35
+ @calendar_events.each do |event|
36
+ events << {:id => event.id, :title => event.title,
37
+ :description => event.description || "Some cool description here...",
38
+ :start => event.starttime.in_time_zone(Time.zone).to_s[0,20].strip,
39
+ :end => event.endtime.in_time_zone(Time.zone).to_s[0,20].strip,
40
+ :allDay => event.all_day,
41
+ :editable => true,
42
+ :recurring => (event.calendar_event_series_id)? true: false}
43
+ end
44
+ end
45
+
46
+ render :text => events.to_json
47
+ end
48
+
49
+ def get_events
50
+ @events = CalendarEvent.find(:all, :conditions => ["starttime >= '#{Time.at(params['start'].to_i).to_formatted_s(:db)}' and endtime <= '#{Time.at(params['end'].to_i).to_formatted_s(:db)}'"] )
51
+ events = []
52
+ @events.each do |event|
53
+ events << {:id => event.id, :title => event.title, :description => event.description || "Some cool description here...", :start => "#{event.starttime.iso8601}", :end => "#{event.endtime.iso8601}", :allDay => event.all_day, :recurring => (event.calendar_event_series_id)? true: false}
54
+ end
55
+ render :text => events.to_json
56
+ end
57
+
58
+
59
+ def move
60
+ @event = CalendarEvent.find_by_id params[:id]
61
+ if @event
62
+ @event.starttime = (params[:minute_delta].to_i).minutes.from_now((params[:day_delta].to_i).days.from_now(@event.starttime))
63
+ @event.endtime = (params[:minute_delta].to_i).minutes.from_now((params[:day_delta].to_i).days.from_now(@event.endtime))
64
+ @event.all_day = params[:all_day]
65
+ @event.save
66
+ end
67
+ end
68
+
69
+ def resize
70
+ @event = CalendarEvent.find_by_id params[:id]
71
+ if @event
72
+ @event.endtime = (params[:minute_delta].to_i).minutes.from_now((params[:day_delta].to_i).days.from_now(@event.endtime))
73
+ @event.save
74
+ end
75
+ end
76
+
77
+ def edit
78
+ @event = CalendarEvent.find_by_id(params[:id])
79
+ end
80
+
81
+ def update
82
+ @event = CalendarEvent.find_by_id(params[:calendar_event][:id])
83
+ if params[:calendar_event][:commit_button] == "Actualizar todas las instancias"
84
+ @events = @event.calendar_event_series.calendar_events #.find(:all, :conditions => ["starttime > '#{@event.starttime.to_formatted_s(:db)}' "])
85
+ @event.update_calendar_events(@events, params[:calendar_event])
86
+ elsif params[:calendar_event][:commit_button] == "Actualizar todas las instancias siguientes"
87
+ @events = @event.calendar_event_series.calendar_events.find(:all, :conditions => ["starttime > '#{@event.starttime.to_formatted_s(:db)}' "])
88
+ @event.update_calendar_events(@events, params[:calendar_event])
89
+ else
90
+ @event.attributes = params[:calendar_event]
91
+ if params[:calendar_event][:period] != "Does not repeat"
92
+ @event_series = CalendarEventSeries.new(params[:calendar_event])
93
+ @event_series.repeat_until = Date.civil(params[:repeat_until][:year].to_i, params[:repeat_until][:month].to_i, params[:repeat_until][:day].to_i)
94
+ @event_series.object_type = @event.object_type
95
+ @event_series.object_id = @event.object_id
96
+ @event_series.save
97
+
98
+ @event.calendar_event_series = @event_series
99
+ end
100
+ @event.save
101
+ end
102
+
103
+ render :update do |page|
104
+ page<<"$('#calendar').fullCalendar( 'refetchEvents' )"
105
+ page<<"$('#desc_dialog').dialog('destroy')"
106
+ end
107
+
108
+ end
109
+
110
+ def destroy
111
+ @event = CalendarEvent.find_by_id(params[:id])
112
+ if params[:delete_all] == 'true'
113
+ @event.calendar_event_series.destroy
114
+ elsif params[:delete_all] == 'future'
115
+ @events = @event.calendar_event_series.calendar_events.find(:all, :conditions => ["starttime > '#{@event.starttime.to_formatted_s(:db)}' "])
116
+ @event.calendar_event_series.calendar_events.delete(@events)
117
+ else
118
+ @event.destroy
119
+ end
120
+
121
+ render :update do |page|
122
+ page<<"if (parent.$('#reservation_calendar_events').val()) { parent.$('#reservation_calendar_events').val(parent.$('#reservation_calendar_events').val().replace('#{@event.id}','')) };"
123
+ page<<"$('#calendar').fullCalendar( 'refetchEvents' )"
124
+ page<<"$('#desc_dialog').dialog('destroy')"
125
+ end
126
+
127
+ end
128
+
129
+ def show
130
+ calendar_events_ids = params[:calendar_events].strip().split(' ')
131
+ calendar_events = CalendarEvent.find(calendar_events_ids)
132
+ @schedules = ""
133
+
134
+ calendar_events.sort {|a,b| a.starttime <=> b.starttime}.each do |calendar_event|
135
+ @schedules += "<li id='calendar_schedule_#{calendar_event.id}' class='bit-box' rel='#{calendar_event.id}'>" +
136
+ "#{calendar_event}"+
137
+ "<a class='closebutton' href='#' "+
138
+ "onclick='$.ajax({url: \\\"/calendar_events/delete?id=#{calendar_event.id}\\\"});'>" +
139
+ "</a></li>"
140
+ end
141
+ render :update do |page|
142
+ page << "$('#holder_schedules').html(\""+@schedules+"\");"
143
+ end
144
+ end
145
+
146
+ def delete
147
+ calendar_event = CalendarEvent.find_by_id(params[:id])
148
+ calendar_event.destroy
149
+
150
+ render :update do |page|
151
+ page << "if ($('#reservation_calendar_events').val()) { $('#reservation_calendar_events').val($('#reservation_calendar_events').val().replace('#{calendar_event.id}','')); }"
152
+ page << "$.ajax({url: '/calendar_events/show?calendar_events='+$('#reservation_calendar_events').val()})"
153
+ end
154
+ end
155
+
156
+
157
+ end