Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Feedback leaving, LOTS of front-end work

  • Loading branch information...
commit bda95378e92abf6fcfd4d1c863a8f72d66460f76 1 parent 1a907c3
@nddrylliog authored
View
3  app/assets/javascripts/feedbacks.js.coffee
@@ -0,0 +1,3 @@
+# Place all the behaviors and hooks related to the matching controller here.
+# All this logic will automatically be available in application.js.
+# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
View
12 app/assets/stylesheets/application.css
@@ -23,7 +23,7 @@ body {
min-height: 100%;
}
-#content {
+.content {
background: #222;
max-width: 800px;
margin: 0 auto 0 auto;
@@ -31,7 +31,7 @@ body {
border-radius: 5px;
border: 1px solid #444;
- padding: 50px;
+ padding: 50px 40px 20px 40px;
}
h3 {
@@ -62,10 +62,14 @@ h3 {
color: #893;
}
-.logout a, .logout a:visited {
+.account {
+ margin-top: 30px;
+ font-size: 12pt;
+}
+
+.logout {
float: right;
margin-right: -20px;
- font-size: 12pt;
}
.small-logo {
View
36 app/assets/stylesheets/events.css.scss
@@ -14,12 +14,46 @@
float: right;
}
+.event-details {
+ color: #999;
+ vertical-align: middle;
+ font-size: 70%;
+ margin-left: 35pt;
+}
+
+.event .attending, .event .not-attending {
+ float: left;
+ margin-right: 15px;
+ display: inline-block;
+ font-size: 46pt;
+}
+
+.not-attending {
+ color: #444;
+}
+
+.attending {
+ color: #378;
+}
+
.event {
margin-top: 30px;
}
+.event h3.compact {
+ margin: 0;
+}
+
.event h3 a, .event h3 a:visited {
- color: #289;
+ display: block;
+ color: #eee;
+ text-decoration: none;
+ padding: 5px;
+ border-radius: 5px;
+}
+
+.event h3 a:hover {
+ background-color: #333;
}
.note {
View
31 app/assets/stylesheets/feedback.css.scss
@@ -0,0 +1,31 @@
+
+.feedback {
+ margin-left: 10px;
+ border-left: 5px solid #ddd;
+ padding-left: 10px;
+}
+
+form.feedback textarea, form.feedback input {
+ color: #eee;
+ font-family: WCRoughTrad;
+ border: 1px solid white;
+ margin: 0;
+ padding: 3px;
+ font-size: 20pt;
+ background: #222;
+ border-radius: 3px;
+}
+
+form.feedback input {
+ width: 300pt;
+}
+
+form.feedback textarea {
+ width: 100%;
+ min-height: 200px;
+}
+
+form.feedback a.button {
+ float: right;
+ margin-top: -50pt;
+}
View
3  app/assets/stylesheets/feedbacks.css.scss
@@ -0,0 +1,3 @@
+// Place all the styles related to the feedbacks controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
View
6 app/controllers/feedbacks_controller.rb
@@ -0,0 +1,6 @@
+class FeedbacksController < ApplicationController
+ def create
+ render :json => params
+ end
+
+end
View
2  app/helpers/feedbacks_helper.rb
@@ -0,0 +1,2 @@
+module FeedbacksHelper
+end
View
2  app/models/event.rb
@@ -2,6 +2,8 @@ class Event < ActiveRecord::Base
has_many :attendances
has_many :users, :through => :attendances
+ has_many :feedbacks
+
def self.top_visible_events
Event.order('created_at DESC').all(:limit => 10)
end
View
3  app/models/feedback.rb
@@ -1,3 +1,4 @@
class Feedback < ActiveRecord::Base
- belongs_to :attendance
+ belongs_to :user
+ belongs_to :event
end
View
10 app/models/user.rb
@@ -2,6 +2,8 @@ class User < ActiveRecord::Base
has_many :attendances
has_many :events, :through => :attendances
+ has_many :feedback, :through => :events
+
def update_credentials!(credentials)
self.token = credentials.token
self.secret = credentials.secret
@@ -11,4 +13,12 @@ def update_credentials!(credentials)
def attend!(event)
self.attendances.create!(:user => self, :event => event)
end
+
+ def attending?(event)
+ self.attendances.exists?(:event_id => event.id)
+ end
+
+ def attendance_for(event)
+ self.attendances.where(:event_id => event.id).first
+ end
end
View
7 app/views/application/_account.html.haml
@@ -0,0 +1,7 @@
+.account
+ logged in as
+ %a(href="https://twitter.com/#{@_current_user.nick}")= "@#{@_current_user.nick}"
+ .logout
+ = link_to '/logout' do
+ %span.symbol X
+ Sign out
View
32 app/views/events/_inline.html.haml
@@ -1,4 +1,21 @@
.event
+ %h3.compact
+ - if @_current_user.attending?(event)
+ %span.symbol.attending /
+ - else
+ %span.symbol.not-attending /
+ = event.name
+ &mdash;
+ = event.place
+
+ .participants
+ with
+ - if event.users.empty?
+ nobody so far. be the first!
+ - else
+ - event.users.each do |u|
+ %a(href='https://twitter.com/#{u.nick}/') @#{u.nick}
+
.attend
- if attendance.nil?
= link_to "/events/#{event.id}/attendances", :method => :post, :class => 'button' do
@@ -9,21 +26,6 @@
%span.symbol -
Woops, can't come
- %h3
- %a(href="/events/#{event.id}")
- %span.symbol /
- = event.name
- &mdash;
- = event.place
-
- .participants
- (with
- - if event.users.empty?
- nobody
- - else
- - event.users.each do |u|
- %a(href='https://twitter.com/#{u.nick}/') @#{u.nick}
- )
%h3 Description
- if event.description.nil?
View
11 app/views/events/_teaser.html.haml
@@ -1,7 +1,16 @@
.event
%h3
%a(href="/events/#{event.id}")
- %span.symbol /
+ - if @_current_user.attending?(event)
+ %span.symbol.attending /
+ - else
+ %span.symbol.not-attending /
= event.name
&mdash;
= event.place
+ .event-details
+ with
+ %span.symbol U
+ = event.attendances.count
+ - if @_current_user.attending?(event)
+ , including you!
View
7 app/views/events/index.html.haml
@@ -1,4 +1,4 @@
-#content
+.content
= render :partial => 'topbar', :locals => { :section => 'events' }
%p
@@ -32,9 +32,6 @@
- @events.each do |e|
= render :partial => 'events/teaser', :locals => { :event => e }
- .logout
- = link_to '/logout' do
- %span.symbol X
- Sign out
+ = render :partial => 'account'
= render :partial => 'footer'
View
8 app/views/events/show.html.haml
@@ -1,13 +1,15 @@
-#content
+.content
= render :partial => 'topbar', :locals => { :section => 'events' }
= link_to '/' do
&larr; Back to all events
- = render :partial => 'inline', :locals => { :event => @event, :attendance => @event.attendances.first }
+ = render :partial => 'inline', :locals => { :event => @event, :attendance => @_current_user.attendance_for(@event) }
%h3 Feedback
- = render :partial => 'feedback/index', :locals => { :feedbacks => @event.attendances.map { |a| a.feedback }.reject { |f| f.nil? } }
+ = render :partial => 'feedback/index', :locals => { :event => @event, :feedbacks => @event.attendances.map { |a| a.feedback }.reject { |f| f.nil? } }
.clear
+
+ = render :partial => 'account'
View
20 app/views/feedback/_index.html.haml
@@ -1,2 +1,20 @@
- feedbacks.each do |f|
- = f.url
+ - if not f.url.nil?
+ %a(href="#{f.url}")
+ %span.symbol j
+ Link
+
+= form_tag("/events/#{event.id}/feedbacks", :class => 'feedback') do
+ %p
+ %a(href="https://twitter.com/#{@_current_user.nick}")= "@#{@_current_user.nick}"
+ says:
+
+ %p
+ = text_area_tag 'content', '', :placeholder => 'something about this event'
+
+ %p
+ = text_field_tag 'url', '', :placeholder => 'http://...'
+
+ %a(href='#' class='button' onclick='$(this).closest("form").submit(); return false;')
+ %span.symbol c
+ Post feedback
View
3  config/routes.rb
@@ -1,4 +1,6 @@
Thebootstrap::Application.routes.draw do
+ get "feedbacks/create"
+
match 'auth/:provider/callback', :to => 'sessions#create'
match 'auth/failure', :to => 'sessions#failure'
@@ -7,6 +9,7 @@
resources :events do
resources :attendances
+ resources :feedbacks
end
root :to => 'events#index'
View
5 db/migrate/20120313160020_create_feedbacks.rb
@@ -3,11 +3,10 @@ def change
create_table :feedbacks do |t|
t.string :url
t.text :content
- t.references :attendance
+ t.references :user
+ t.references :event
t.timestamps
end
-
- add_index :feedbacks, :attendance_id
end
end
View
9 test/functional/feedbacks_controller_test.rb
@@ -0,0 +1,9 @@
+require 'test_helper'
+
+class FeedbacksControllerTest < ActionController::TestCase
+ test "should get create" do
+ get :create
+ assert_response :success
+ end
+
+end
View
4 test/unit/helpers/feedbacks_helper_test.rb
@@ -0,0 +1,4 @@
+require 'test_helper'
+
+class FeedbacksHelperTest < ActionView::TestCase
+end
Please sign in to comment.
Something went wrong with that request. Please try again.