Initial work on recurrent events

recurrent
echarp 6 years ago
parent b6c5a735f1
commit 8bbece331e
  1. 2
      Gemfile
  2. 2
      Gemfile.lock
  3. 1
      app/models/event.rb
  4. 3
      app/models/schedule.rb
  5. 9
      app/views/events/_form.html.haml
  6. 18
      db/migrate/20160616190823_create_schedules.rb
  7. 15
      db/schema.rb

@ -2,6 +2,8 @@ source 'https://rubygems.org'
# The central piece of this application: the month calendar view
gem 'simple_calendar'
# The recurrence management library
gem 'ice_cube'
gem 'rails'
gem 'has_scope'

@ -210,6 +210,7 @@ GEM
http_accept_language (2.0.5)
http_parser.rb (0.6.0)
i18n (0.7.0)
ice_cube (0.14.0)
inherited_resources (1.6.0)
actionpack (>= 3.2, < 5)
has_scope (~> 0.6.0.rc)
@ -447,6 +448,7 @@ DEPENDENCIES
has_scope
http_accept_language
i18n-active_record!
ice_cube
jbuilder
jquery-rails (< 4.1)
jquery-sparkline-rails!

@ -1,6 +1,7 @@
# This is the central ADL class, where are managed all events
class Event < ActiveRecord::Base
extend SimpleCalendar
acts_as_schedulable :schedule
strip_attributes
has_paper_trail ignore: [:last_updated, :secret, :submitter, :decision_time,
:lock_version, :latitude, :longitude]

@ -0,0 +1,3 @@
# The data associated to recurrent events
class Schedule < Schedulable::Model::Schedule
end

@ -12,13 +12,17 @@
.field.title
= f.label :title
= f.text_field :title, required: true, placeholder: "#{t '.title_helper'}"
= f.text_field :title, required: true, placeholder: t('.title_helper')
.field.start_time
= f.label :start_time
= f.datetime_local_field :start_time, required: true
.field.end_time
= f.label :end_time
= f.datetime_local_field :end_time, required: true
.field
= f.label :schedule
= f.schedule_select :schedule, interval: true, until: true
.field.description
.helper
:markdown
@ -46,7 +50,8 @@
%option= city
.field.region
= f.label :region
= f.collection_select :region_id, Region.all, :id, :name, { include_blank: true }
= f.collection_select :region_id, Region.all, :id, :name,
include_blank: true
.field.locality
= f.label :locality
%span.radios

@ -0,0 +1,18 @@
# Manage a schedule for events, that will let adl create recurring events
class CreateSchedules < ActiveRecord::Migration
def change
create_table :schedules do |t|
t.string :rule
t.string :interval
t.text :day
t.text :day_of_week
t.datetime :until
t.integer :count
t.timestamps
end
add_reference :events, :schedule, index: true
end
end

@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20160409131029) do
ActiveRecord::Schema.define(version: 20160616190823) do
create_table "active_admin_comments", force: :cascade do |t|
t.string "namespace", limit: 255
@ -81,8 +81,10 @@ ActiveRecord::Schema.define(version: 20160409131029) do
t.float "longitude", limit: 24
t.integer "lock_version", limit: 4, default: 0, null: false
t.string "place_name", limit: 255
t.integer "schedule_id"
end
add_index "events", ["schedule_id"], name: "index_events_on_schedule_id"
add_index "events", ["start_time", "end_time"], name: "events_date"
create_table "kinds", force: :cascade do |t|
@ -134,6 +136,17 @@ ActiveRecord::Schema.define(version: 20160409131029) do
t.string "name", limit: 255, default: "", null: false
end
create_table "schedules", force: :cascade do |t|
t.string "rule"
t.string "interval"
t.text "day"
t.text "day_of_week"
t.datetime "until"
t.integer "count"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "taggings", force: :cascade do |t|
t.integer "tag_id"
t.integer "taggable_id"

Loading…
Cancel
Save