Browse Source

Add icalendar, token

Maarten van den Berg 6 years ago
parent
commit
9ce1f07ab1

+ 3 - 0
Gemfile

67
 # Error reporting
67
 # Error reporting
68
 gem 'sentry-raven'
68
 gem 'sentry-raven'
69
 
69
 
70
+# Calendar support
71
+gem 'icalendar'
72
+
70
 group :development, :test do
73
 group :development, :test do
71
   # Call 'byebug' anywhere in the code to stop execution and get a debugger console
74
   # Call 'byebug' anywhere in the code to stop execution and get a debugger console
72
   gem 'byebug', platform: :mri
75
   gem 'byebug', platform: :mri

+ 2 - 0
Gemfile.lock

89
     i18n (0.8.1)
89
     i18n (0.8.1)
90
     i18n_generators (2.1.1)
90
     i18n_generators (2.1.1)
91
       rails (>= 3.0.0)
91
       rails (>= 3.0.0)
92
+    icalendar (2.4.1)
92
     jbuilder (2.6.3)
93
     jbuilder (2.6.3)
93
       activesupport (>= 3.0.0, < 5.2)
94
       activesupport (>= 3.0.0, < 5.2)
94
       multi_json (~> 1.2)
95
       multi_json (~> 1.2)
226
   font-awesome-sass
227
   font-awesome-sass
227
   haml
228
   haml
228
   i18n_generators
229
   i18n_generators
230
+  icalendar
229
   jbuilder (~> 2.5)
231
   jbuilder (~> 2.5)
230
   jquery-rails
232
   jquery-rails
231
   listen (~> 3.0.5)
233
   listen (~> 3.0.5)

+ 6 - 0
app/models/person.rb

24
   #   @return [String]
24
   #   @return [String]
25
   #     the person's email address.
25
   #     the person's email address.
26
   #
26
   #
27
+  # @!attribute calendar_token
28
+  #   @return [String]
29
+  #     the calendar token that can be used to open this Person's events as an
30
+  #     ICAL file.
31
+  #
27
   # @!attribute is_admin
32
   # @!attribute is_admin
28
   #   @return [Boolean]
33
   #   @return [Boolean]
29
   #     whether or not the person has administrative rights.
34
   #     whether or not the person has administrative rights.
35
     dependent: :destroy
40
     dependent: :destroy
36
   has_many :groups, through: :members
41
   has_many :groups, through: :members
37
   has_many :activities, through: :participants
42
   has_many :activities, through: :participants
43
+  has_secure_token :calendar_token
38
 
44
 
39
   validates :email, uniqueness: true
45
   validates :email, uniqueness: true
40
   validates :first_name, presence: true
46
   validates :first_name, presence: true

+ 6 - 0
db/migrate/20180904162042_add_calendar_token_to_people.rb

1
+class AddCalendarTokenToPeople < ActiveRecord::Migration[5.0]
2
+  def change
3
+    add_column :people, :calendar_token, :string
4
+    add_index :people, :calendar_token, unique: true
5
+  end
6
+end

+ 10 - 0
db/migrate/20180904163645_generate_calendar_tokens.rb

1
+class GenerateCalendarTokens < ActiveRecord::Migration[5.0]
2
+  def up
3
+    Person.all.each do |p|
4
+      p.regenerate_calendar_token
5
+    end
6
+  end
7
+
8
+  def down
9
+  end
10
+end

+ 3 - 1
db/schema.rb

10
 #
10
 #
11
 # It's strongly recommended that you check this file into your version control system.
11
 # It's strongly recommended that you check this file into your version control system.
12
 
12
 
13
-ActiveRecord::Schema.define(version: 20180206181016) do
13
+ActiveRecord::Schema.define(version: 20180904163645) do
14
 
14
 
15
   create_table "activities", force: :cascade do |t|
15
   create_table "activities", force: :cascade do |t|
16
     t.string   "name"
16
     t.string   "name"
96
     t.datetime "created_at",                              null: false
96
     t.datetime "created_at",                              null: false
97
     t.datetime "updated_at",                              null: false
97
     t.datetime "updated_at",                              null: false
98
     t.boolean  "send_attendance_reminder", default: true
98
     t.boolean  "send_attendance_reminder", default: true
99
+    t.string   "calendar_token"
100
+    t.index ["calendar_token"], name: "index_people_on_calendar_token", unique: true
99
     t.index ["email"], name: "index_people_on_email", unique: true
101
     t.index ["email"], name: "index_people_on_email", unique: true
100
   end
102
   end
101
 
103