Skip to content
This repository has been archived by the owner on Jun 3, 2019. It is now read-only.

Commit

Permalink
Makes topics linkable and adds a description attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
Maurizio De Magnis committed Jun 19, 2012
1 parent 8e0841a commit 1fac205
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 10 deletions.
5 changes: 4 additions & 1 deletion app/cells/event/section.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@
= link_to section.humanize, url_for([@event, section])
.tab-content
.tab-pane.active{id: @active_section}
= render_cell :event, @active_section, @event
- if @active_section == :topics && @topic
= render_cell :event, @active_section, @event, @topic
- else
= render_cell :event, @active_section, @event
9 changes: 7 additions & 2 deletions app/cells/event/topics.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@
- @event.ordered_topics.each do |topic|
%li
%article
%h1= topic.title
%p= topic.author
= link_to event_topic_path(@event, topic) do
%h1= topic.title
- if @topic == topic
- unless topic.author.blank?
%p Who / #{topic.author}
- unless topic.description.blank?
%p What / #{topic.description.try(:html_safe)}
- else
%p No topic has been proposed yet..
= image_tag "event-status/le_fu.jpeg", class: 'topics status'
6 changes: 4 additions & 2 deletions app/cells/event_cell.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ def controller(parent = parent_controller)
parent.kind_of?(ApplicationController) ? parent : controller(parent.parent_controller)
end

def section(event, active_section)
def section(event, active_section, topic = nil)
@event = event
@active_section = active_section
@sections = %w[topics users location]
@topic = topic
set_metas(@event, @active_section)
render
end
Expand All @@ -29,8 +30,9 @@ def set_metas(event, section)
controller.send :set_meta_tags, options
end

def topics(event)
def topics(event, topic = nil)
@event = event
@topic = topic
render
end

Expand Down
4 changes: 4 additions & 0 deletions app/controllers/topics_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@ class TopicsController < ApplicationController
def index
@event = Event.find(params[:event_id])
end

def show
@topic = Topic.find(params[:id])
end
end
2 changes: 1 addition & 1 deletion app/models/topic.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class Topic < ActiveRecord::Base
attr_accessible :author, :event_id, :title, :position
attr_accessible :author, :event_id, :title, :position, :description
belongs_to :event

scope :ordered, order('position')
Expand Down
1 change: 1 addition & 0 deletions app/views/topics/show.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
= render_cell :event, :section, @topic.event, :topics, @topic
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
member do
post 'toggle_subscription'
end
resources :topics, only: [:index]
resources :topics, only: [:index, :show]
resources :users, only: [:index]
resource :location, only: [:show]
end
Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20120619133949_add_description_to_topics.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddDescriptionToTopics < ActiveRecord::Migration
def change
add_column :topics, :description, :text
end
end
7 changes: 4 additions & 3 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.

ActiveRecord::Schema.define(:version => 20120612130806) do
ActiveRecord::Schema.define(:version => 20120619133949) do

create_table "events", :force => true do |t|
t.datetime "start"
Expand All @@ -37,9 +37,10 @@
t.string "title"
t.string "author"
t.integer "event_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "position"
t.text "description"
end

create_table "users", :force => true do |t|
Expand Down

0 comments on commit 1fac205

Please sign in to comment.