Skip to content

Commit

Permalink
Merge branch 'release/0.5.3_patch.1'
Browse files Browse the repository at this point in the history
* release/0.5.3_patch.1:
  #274 some fixes
  update schema.rb
  • Loading branch information
kalashnikovisme committed Dec 21, 2015
2 parents 5b51dfd + a67f0c5 commit b7654c5
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 1 deletion.
19 changes: 19 additions & 0 deletions app/decorators/application_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,23 @@ class ApplicationDecorator < Draper::Decorator
include Rails.application.routes.url_helpers
include ActionView::Helpers
include RussianCases

def decorated_to_json(options = {})
hash = object.as_json options
if options[:only].is_a? Array
options[:only].each do |attribute|
hash = add_to_hash_attributes hash, attribute
end
else
hash = add_to_hash_attributes hash, options[:only]
end
hash.to_json
end

private

def add_to_hash_attributes(hash, attribute)
hash[attribute] = send attribute.to_s unless hash.keys.include? attribute
hash
end
end
4 changes: 4 additions & 0 deletions app/decorators/event_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ def lead
"#{object.description.first(150)}..."
end

def strip_tags_description
strip_tags(object.description).html_safe
end

def name
object.title
end
Expand Down
2 changes: 1 addition & 1 deletion app/views/web/events/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
.join
-#%a.join-button.mic-press-button{ href: "#" }
- if current_user_have_attended?(@all_registrations)
%button.join-button.mic-press-button{ value: 'out', data: { event: @event.to_json(only: [:id, :title, :description, :begin_date, :end_date]), user_id: current_user.id, google_id: google_id, registration: current_registration(@all_registrations).to_json(only: [:id, :google_calendar_event_id])} }
%button.join-button.mic-press-button{ value: 'out', data: { event: @event.decorated_to_json(only: [:id, :title, :strip_tags_description, :begin_date, :end_date]), user_id: current_user.id, google_id: google_id, registration: current_registration(@all_registrations).to_json(only: [:id, :google_calendar_event_id])} }
= t('.i_attend')
- else
- if signed_in? && current_user.is_active?
Expand Down
23 changes: 23 additions & 0 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,23 @@
t.text "logo"
end

create_table "activity_lines_corporative_arguments", force: :cascade do |t|
t.integer "member_id"
t.text "text"
t.text "argument_type"
t.integer "confession_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end

create_table "activity_lines_corporative_confessions", force: :cascade do |t|
t.integer "year"
t.integer "member_id"
t.text "nomination"
t.text "state"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "creator_id"
end

create_table "articles", force: :cascade do |t|
Expand Down Expand Up @@ -121,6 +131,16 @@
t.datetime "updated_at", null: false
end

create_table "content_videos", force: :cascade do |t|
t.text "title"
t.text "description"
t.integer "author_id"
t.text "link"
t.text "state"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end

create_table "documents", force: :cascade do |t|
t.text "file"
t.text "title"
Expand Down Expand Up @@ -272,6 +292,9 @@
t.integer "user_id"
end

add_index "teams_users", ["team_id"], name: "index_teams_users_on_team_id", using: :btree
add_index "teams_users", ["user_id"], name: "index_teams_users_on_user_id", using: :btree

create_table "users", force: :cascade do |t|
t.text "email"
t.text "password_digest"
Expand Down

0 comments on commit b7654c5

Please sign in to comment.