Skip to content

Commit

Permalink
Merge pull request #30 from argerim/master
Browse files Browse the repository at this point in the history
Continuando Milestones Encontros, e inciando Palestras
  • Loading branch information
Cairo Noleto committed Jun 14, 2011
2 parents d0628bb + 02dd43f commit 2434318
Show file tree
Hide file tree
Showing 57 changed files with 10,056 additions and 64 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ gem 'rake', '~> 0.8.7'
gem 'rails', '~> 3.0.7'

gem 'sqlite3'

gem 'omniauth', '>= 0.2.6'
gem 'declarative_authorization'
gem 'jquery-rails'
Expand Down
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ GEM
faraday (0.6.1)
addressable (~> 2.2.4)
multipart-post (~> 1.1.0)
rack (>= 1.1.0, < 2)
rack (< 2, >= 1.1.0)
ffi (1.0.9)
guard (0.4.2)
thor (~> 0.14.6)
Expand Down Expand Up @@ -184,7 +184,7 @@ GEM
thor (0.14.6)
treetop (1.4.9)
polyglot (>= 0.3.1)
tzinfo (0.3.27)
tzinfo (0.3.28)
xpath (0.1.4)
nokogiri (~> 1.3)

Expand Down
8 changes: 5 additions & 3 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ class ApplicationController < ActionController::Base
helper_method :current_user

private
def current_user
@current_user ||= User.find(session[:user_id]) if session[:user_id]
end
def current_user
@current_user ||= User.find(session[:user_id]) if session[:user_id]
end

end

7 changes: 4 additions & 3 deletions app/controllers/events_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# encoding: UTF-8
class EventsController < ApplicationController

respond_to :html
Expand All @@ -20,18 +21,18 @@ def edit

def create
@event = Event.new(params[:event])
flash[:notice] = 'Event was successfully created.' if @event.save
flash[:notice] = 'Evento criado com sucesso.' if @event.save
respond_with @event
end

def update
@event = Event.find_by_slug(params[:id])
flash[:notice] = 'Event was successfully updated.' if @event.update_attributes(params[:event])
flash[:notice] = 'Evento atualizado com sucesso.' if @event.update_attributes(params[:event])
respond_with @event
end

def destroy
flash[:notice] = 'Event was successfully deleted' if Event.find_by_slug(params[:id]).destroy
flash[:notice] = 'Evento deletado com sucesso' if Event.find_by_slug(params[:id]).destroy
respond_with @event, :location => events_url
end

Expand Down
43 changes: 43 additions & 0 deletions app/controllers/lectures_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# encoding: UTF-8
class LecturesController < ApplicationController

respond_to :html

def index
@lectures = Lecture.all
end

def show
@lecture = Lecture.find_by_slug(params[:id])
end

def new
@lecture = Lecture.new
end

def edit
@lecture = Lecture.find_by_slug(params[:id])
end

def create
@event = Event.find_by_slug(params[:event_id])
@lecture = @event.lectures.create(params[:lecture])
flash[:notice] = 'Palestra criada com sucesso.' if @lecture.save
respond_with @lecture, :location => event_path(@event)
end

def update
@lecture = Lecture.find_by_slug(params[:id])
flash[:notice] = 'Palestra atualizada com sucesso.' if @lecture.update_attributes(params[:lecture])
respond_with @lecture
end

def destroy
@event = Event.find_by_slug(params[:event_id])
@lecture = @event.lectures.find_by_slug(params[:id]).destroy
flash[:notice] = 'Palestra deletada com sucesso' if @lecture.destroy
respond_with @lecture, :location => event_path(@event)
end

end

2 changes: 2 additions & 0 deletions app/controllers/posts_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# encoding: UTF-8
class PostsController < ApplicationController
respond_to :html
def show
Expand All @@ -14,3 +15,4 @@ def create
respond_with @post
end
end

3 changes: 3 additions & 0 deletions app/controllers/sessions_controller.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
# encoding: UTF-8
class SessionsController < ApplicationController

def create
auth = request.env["omniauth.auth"]
user = User.find_by_provider_and_uid(auth["provider"], auth["uid"]) || User.create_with_omniauth(auth)
session[:user_id] = user.id
redirect_to root_url, :notice => "Seja Bem-vindo!"

end

def destroy
session[:user_id] = nil
redirect_to root_url, :notice => "Volte sempre… :)"
end
end

2 changes: 2 additions & 0 deletions app/helpers/lectures_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module LecturesHelper
end
2 changes: 2 additions & 0 deletions app/helpers/sessions_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module SessionsHelper
end
2 changes: 2 additions & 0 deletions app/helpers/welcome_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module WelcomeHelper
end
1 change: 1 addition & 0 deletions app/models/event.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
class Event < ActiveRecord::Base
before_save :slugify
has_many :lectures, :dependent => :destroy
validates :name, :presence => true, :uniqueness => true

def to_param
Expand Down
17 changes: 17 additions & 0 deletions app/models/lecture.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
class Lecture < ActiveRecord::Base
belongs_to :user
belongs_to :event
before_save :slugify
validates :name, :presence => true, :uniqueness => true

def to_param
slug
end

private
def slugify
self.slug = name.parameterize.to_s
end

end

1 change: 1 addition & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,4 @@ def self.create_with_omniauth(auth)
end
end
end

10 changes: 5 additions & 5 deletions app/views/events/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,23 @@
<% end %>

<div class="field">
<%= f.label :name %><br />
<%= f.label Event.human_attribute_name(:name) %><br />
<%= f.text_field :name %>
</div>
<div class="field">
<%= f.label :description %><br />
<%= f.label Event.human_attribute_name(:description) %><br />
<%= f.text_area :description %>
</div>
<div class="field">
<%= f.label :event_date %><br />
<%= f.label Event.human_attribute_name(:event_date) %><br />
<%= f.date_select :event_date %>
</div>
<div class="field">
<%= f.label :hour %><br />
<%= f.label Event.human_attribute_name(:hour) %><br />
<%= f.text_field :hour %>
</div>
<div class="field">
<%= f.label :place %><br />
<%= f.label Event.human_attribute_name(:place) %><br />
<%= f.text_field :place %>
</div>
<div class="actions">
Expand Down
5 changes: 3 additions & 2 deletions app/views/events/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@

<%= render 'form' %>

<%= link_to 'Show', @event %> |
<%= link_to 'Back', events_path %>
<%= link_to t(:show), @event %> |
<%= link_to t(:back), events_path %>

16 changes: 8 additions & 8 deletions app/views/events/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

<table>
<tr>
<th>Name</th>
<th>Event date</th>
<th>Hour</th>
<th>Place</th>
<th><%=Event.human_attribute_name(:name)%></th>
<th><%=Event.human_attribute_name(:event_date)%></th>
<th><%=Event.human_attribute_name(:hour)%></th>
<th><%=Event.human_attribute_name(:place)%></th>
<th></th>
<th></th>
<th></th>
Expand All @@ -17,14 +17,14 @@
<td><%= event.event_date %></td>
<td><%= event.hour %></td>
<td><%= event.place %></td>
<td><%= link_to 'Show', event %></td>
<td><%= link_to 'Edit', edit_event_path(event) %></td>
<td><%= link_to 'Destroy', event, :confirm => 'Are you sure?', :method => :delete %></td>
<td><%= link_to t(:show), event %></td>
<td><%= link_to t(:edit), edit_event_path(event) %></td>
<td><%= link_to t(:destroy), event, :confirm => t(:confirm), :method => :delete %></td>
</tr>
<% end %>
</table>

<br />

<%= link_to 'New Event', new_event_path %>
<%= link_to t(:new), new_event_path %>

3 changes: 2 additions & 1 deletion app/views/events/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@

<%= render 'form' %>

<%= link_to 'Back', events_path %>
<%= link_to t(:back), events_path %>

20 changes: 11 additions & 9 deletions app/views/events/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,32 +1,34 @@
<p id="notice"><%= notice %></p>

<p>
<b>Name:</b>
<b><%=Event.human_attribute_name(:name)%>:</b>
<%= @event.name %>
</p>

<p>
<b>Description:</b>
<b><%=Event.human_attribute_name(:description)%>:</b>
<p>
<%= @event.description.gsub(/\n/,"<br />").html_safe %>
</p>
</p>

<p>
<b>Event date:</b>
<b><%=Event.human_attribute_name(:event_date)%>:</b>
<%=l @event.event_date %>
</p>

<p>
<b>Hour:</b>
<b><%=Event.human_attribute_name(:hour)%>:</b>
<%= @event.hour %>
</p>

<p>
<b>Place:</b>
<b><%=Event.human_attribute_name(:place)%>:</b>
<%= @event.place %>
</p>
<br />
<h2>Palestras</h2>

<%= link_to 'Edit', edit_event_path(@event) %> |
<%= link_to 'Back', events_path %>
<%= render @event.lectures %>
<br />
<h2>Add uma Palestra:</h2>
<%= render "lectures/form" %>

10 changes: 8 additions & 2 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@
<!--[if IE 9 ]> <html lang="pt-br" class="no-js ie9"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--><html lang="pt-br" class="no-js"><!--<![endif]-->
<head>

<meta charset="utf-8">
<title>GuruPI - Grupo de Usuários de Ruby do Piauí</title>
<%= javascript_include_tag :defaults %>
<%= csrf_meta_tag %>
<link rel="stylesheet" href="/stylesheets/style.css?v=1">
<script src="/javascripts/modernizr-2.0.js"></script>
</head>
Expand Down Expand Up @@ -39,15 +42,18 @@
<% end %>
</div>
</div>

<p id="notice"><%= notice %></p>

<%= yield %>
<footer id="footer">
<div class="container">
<div class="links fb" align="center">
<ul>
<li><a href="#">Gurupi</a></li>
<li><a href="/">Gurupi</a></li>
<li><a href="#">Sobre</a></li>
<li><a href="#">Agenda</a></li>
<li><a href="#">Usuários</a></li>
<li><%= link_to %{Usuários}.html_safe, users_path %></li>
<li><a href="#">Blogs</a></li>
<li><a href="#">Imprensa</a></li>
<li><a href="#" style="border: 0px none">Contatos</a></li>
Expand Down
15 changes: 15 additions & 0 deletions app/views/lectures/_form.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<%= form_for([@event, @event.lectures.build]) do |f| %>
<div class="field">
<%= f.label Lecture.human_attribute_name(:name) %><br />
<%= f.text_field :name %>
</div>
<div class="field">
<%= f.label Lecture.human_attribute_name(:description) %><br />
<%= f.text_area :description %>
<%= f.hidden_field :user_id, :value => current_user.id %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>

25 changes: 25 additions & 0 deletions app/views/lectures/_lecture.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<p>
<b><%=Lecture.human_attribute_name(:name)%>:</b>
<%= lecture.name %>
</p>

<p>
<b><%=Lecture.human_attribute_name(:description)%>:</b>
<p>
<%= lecture.description.gsub(/\n/,"<br />").html_safe %>
</p>
</p>


<p>
<b><%=Lecture.human_attribute_name(:user)%>:</b>
<%= lecture.user.name %>
</p>

<p>
<%= link_to t(:destroy_lecture), [lecture.event, lecture],
:confirm => t(:confirm),
:method => :delete %>
</p>
<br />

7 changes: 7 additions & 0 deletions app/views/lectures/edit.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<h1>Editing lecture</h1>

<%= render 'form' %>

<%= link_to t(:show), @lecture %> |
<%= link_to t(:back), lectures_path %>

Loading

0 comments on commit 2434318

Please sign in to comment.