Skip to content

Commit

Permalink
Adding urls for image and document to events.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sven Windisch committed Oct 23, 2011
1 parent 023e940 commit 4465abd
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
11 changes: 11 additions & 0 deletions db/migrate/20111023132533_add_more_links_to_events.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class AddMoreLinksToEvents < ActiveRecord::Migration
def self.up
add_column :data_calendar_events, :image_url, :string
add_column :data_calendar_events, :document_url, :string
end

def self.down
remove_column :data_calendar_events, :image_url
remove_column :data_calendar_events, :document_url
end
end
4 changes: 3 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended to check this file into your version control system.

ActiveRecord::Schema.define(:version => 20110827145142) do
ActiveRecord::Schema.define(:version => 20111023132533) do

create_table "data_calendar_events", :force => true do |t|
t.integer "category_id"
Expand All @@ -27,6 +27,8 @@
t.datetime "updated_at"
t.boolean "public"
t.integer "user_id"
t.string "image_url"
t.string "document_url"
end

create_table "data_calendar_hosts", :force => true do |t|
Expand Down
2 changes: 2 additions & 0 deletions lib/models.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ class Event < ActiveRecord::Base
validate :format_of_time_to, :allow_nil => true
#TODO: strip html tags and such stuff from description
validates_format_of :url, :with => /^(http|https)\:\/\/[a-zA-Z0-9\-\.]+[a-zA-Z0-9\-]+\.[a-zA-Z]{2,3}(\/\S*)?$/, :allow_nil => true
validates_format_of :image_url, :with => /^(http|https)\:\/\/[a-zA-Z0-9\-\.]+[a-zA-Z0-9\-]+\.[a-zA-Z]{2,3}(\/\S*)?$/, :allow_nil => true
validates_format_of :document_url, :with => /^(http|https)\:\/\/[a-zA-Z0-9\-\.]+[a-zA-Z0-9\-]+\.[a-zA-Z]{2,3}(\/\S*)?$/, :allow_nil => true

def format_of_time_from
errors.add(:time_from, "is invalid.") unless time_from_before_type_cast =~ /^[0-2]{1}[0-9]{1}\:[0-5]{1}[0-9]{1}\:[0-5]{1}[0-9]{1}$/ unless time_from_before_type_cast.nil?
Expand Down

0 comments on commit 4465abd

Please sign in to comment.