Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
6b57966
working table order (in response)
sonicseth2000 Oct 15, 2014
1e6fc0f
users added
sonicseth2000 Oct 20, 2014
5a5ee3b
bad
sonicseth2000 Nov 10, 2014
7eabaf0
working?
sonicseth2000 Nov 10, 2014
4c5fa40
validations1
Nov 10, 2014
3a54777
valid3
fabetron Nov 11, 2014
7e199ce
Revert "valid3"
Travis91 Nov 16, 2014
ec969cf
Revert "validations1"
Travis91 Nov 16, 2014
d2a115d
got rid of something that broke answer
Travis91 Nov 16, 2014
0b239ba
Added aboutPageStyle.css
odoming Nov 18, 2014
4c52fd9
valid4
fabetron Nov 18, 2014
f6e5043
Merge branch 'copy2' of https://github.com/sonicseth2000/BirdOverflow…
fabetron Nov 18, 2014
4149075
fixed broken validations
fabetron Nov 18, 2014
5163104
fixed answer model
fabetron Nov 18, 2014
a34a9a0
got rid of comment in questions view
fabetron Nov 18, 2014
ba7360f
question answer working
Travis91 Nov 19, 2014
39ed403
Added comment to index.html.erb
odoming Nov 25, 2014
d8c491a
Merge branch 'copy2' of https://github.com/sonicseth2000/BirdOverflow…
odoming Nov 25, 2014
802dabb
added to index.html.erb
odoming Nov 25, 2014
baf4d59
updated asnsers to update question
Travis91 Nov 25, 2014
55d50ce
answers updates question answered statud
Travis91 Nov 26, 2014
0afa6c7
minor questions bug fix
Travis91 Nov 26, 2014
045b963
correct stuff
Travis91 Nov 26, 2014
9beae54
working stuff
Travis91 Nov 26, 2014
189b51b
shows answers for specific question
Travis91 Nov 26, 2014
e8fe295
makes content and title unique and filled in
fabetron Nov 27, 2014
1aab663
fixed users model
fabetron Nov 27, 2014
23a0cd0
changed schema
fabetron Nov 27, 2014
75e3861
Deleted aboutPageStyle.css and added log in to index.html.erb
odoming Nov 27, 2014
bd1ef15
Added log in header
odoming Nov 27, 2014
0ec76ba
Added css to shift login input and buttons to the right
odoming Nov 27, 2014
2fca7da
using oscars boxes
Travis91 Nov 28, 2014
131429c
login/logout added, at top of questions for now
sonicseth2000 Nov 30, 2014
2471583
commit 2
sonicseth2000 Nov 30, 2014
5786834
points sort of working
Travis91 Nov 30, 2014
c3e7bce
points working better
Travis91 Dec 1, 2014
2bf2894
question index updates
Travis91 Dec 1, 2014
32846f9
questions index updated again
Travis91 Dec 1, 2014
3a96a75
validates passwords
fabetron Dec 1, 2014
ad1f720
login required
sonicseth2000 Dec 1, 2014
594decf
new user accessible when logged out
sonicseth2000 Dec 1, 2014
cc66af9
only can mark questions you made
Travis91 Dec 1, 2014
421a497
users page functions as ranking autorefreshes every 60 seconds
Travis91 Dec 1, 2014
7292c7f
trying again
sonicseth2000 Dec 1, 2014
efd5cb3
added more ui stuff
Travis91 Dec 1, 2014
a54954a
cleaned and responses added
sonicseth2000 Dec 1, 2014
95fdcc4
not much changed
Travis91 Dec 1, 2014
ad409ac
added answered button to question page
Travis91 Dec 1, 2014
45b731b
updated ui
Travis91 Dec 1, 2014
11d306a
updated views
Travis91 Dec 1, 2014
1e0ad2e
wuestion index roking
Travis91 Dec 1, 2014
7461d42
fixed format problem
Travis91 Dec 2, 2014
86067ea
i think it works
Travis91 Dec 2, 2014
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .project
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
</buildCommand>
</buildSpec>
<natures>
<nature>com.aptana.projects.webnature</nature>
<nature>org.radrails.rails.core.railsnature</nature>
<nature>com.aptana.ruby.core.rubynature</nature>
</natures>
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc

# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
gem 'bcrypt', '~> 3.1.7'

# Use unicorn as the app server
# gem 'unicorn'
Expand Down
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ GEM
thread_safe (~> 0.1)
tzinfo (~> 1.1)
arel (5.0.1.20140414130214)
bcrypt (3.1.9-x86-mingw32)
builder (3.2.2)
coffee-rails (4.0.1)
coffee-script (>= 2.2.0)
Expand Down Expand Up @@ -109,6 +110,7 @@ PLATFORMS
x86-mingw32

DEPENDENCIES
bcrypt (~> 3.1.7)
coffee-rails (~> 4.0.0)
jbuilder (~> 2.0)
jquery-rails
Expand Down
3 changes: 3 additions & 0 deletions app/assets/javascripts/answers.js.coffee
Original file line number Diff line number Diff line change
@@ -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://coffeescript.org/
3 changes: 3 additions & 0 deletions app/assets/javascripts/hackers.js.coffee
Original file line number Diff line number Diff line change
@@ -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://coffeescript.org/
3 changes: 3 additions & 0 deletions app/assets/javascripts/logout.js.coffee
Original file line number Diff line number Diff line change
@@ -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://coffeescript.org/
3 changes: 3 additions & 0 deletions app/assets/javascripts/sessions.js.coffee
Original file line number Diff line number Diff line change
@@ -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://coffeescript.org/
3 changes: 3 additions & 0 deletions app/assets/stylesheets/answers.css.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the Answers controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
3 changes: 3 additions & 0 deletions app/assets/stylesheets/hackers.css.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the Hackers controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
3 changes: 3 additions & 0 deletions app/assets/stylesheets/logout.css.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the logout controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
10 changes: 10 additions & 0 deletions app/assets/stylesheets/questions.css.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
// Place all the styles related to the Questions controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

// Shifting <pre></pre> login to the top right of the page

.usernameTB {
float: right;
text-align: right;
}



3 changes: 3 additions & 0 deletions app/assets/stylesheets/sessions.css.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the Sessions controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
103 changes: 103 additions & 0 deletions app/controllers/answers_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
class AnswersController < ApplicationController
before_action :set_answer, only: [:show, :edit, :update, :destroy]
before_action :list
# GET /answers
# GET /answers.json
def index
@answers = Answer.all
end

def list
@responses = Response.all
end

# GET /answers/1
# GET /answers/1.json
def show
end

# GET /answers/new
def new
@answer = Answer.new
end

# GET /answers/1/edit
def edit
end

# POST /answers
# POST /answers.json
def create
@answer = Answer.new(answer_params)
@answer.creator_id = session[:id]
respond_to do |format|
if @answer.save
format.html { redirect_to @answer, notice: 'Answer was successfully created.' }
format.json { render :show, status: :created, location: @answer }
else
format.html { render :new }
format.json { render json: @answer.errors, status: :unprocessable_entity }
end
end

end

# PATCH/PUT /answers/1
# PATCH/PUT /answers/1.json
def update
respond_to do |format|
if @answer.update(answer_params)
format.html { redirect_to @answer, notice: 'Answer was successfully updated.' }
format.json { render :show, status: :ok, location: @answer }
else
format.html { render :edit }
format.json { render json: @answer.errors, status: :unprocessable_entity }
end
end
end

# DELETE /answers/1
# DELETE /answers/1.json
def destroy
@answer.destroy
respond_to do |format|
format.html { redirect_to answers_url, notice: 'Answer was successfully destroyed.' }
format.json { head :no_content }
end
end
# POST /answers
# POST /answers.json

def correct
@answer = Answer.find(params[:id])
if @answer.response_score == 0
p "fuuuuuuuuuuuuuuuuuucccccccccccccckkkkkkkkkkkkkkkk"
@answer.response_score = 1
@question = Question.find(@answer.q_response_id)
@question.toggle!(:answered)
@user = User.find(@answer.creator_id)
@user.increment!(:score)

@user.save
@answer.save
@question.save
end
redirect_to(:back)
end
private
# Use callbacks to share common setup or constraints between actions.
def set_answer
@answer = Answer.find(params[:id])
end

# Never trust parameters from the scary internet, only allow the white list through.
def answer_params
params.require(:answer).permit(:answer_id, :q_response_id, :creator_id, :response_score, :content, :timestamp)
end

def answer
@answer.response_score=0
end


end
16 changes: 16 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,20 @@ class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception

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

helper_method :current_user

before_filter :require_login

private

def require_login
unless session[:id]
redirect_to new_session_path
end
end
end
74 changes: 74 additions & 0 deletions app/controllers/hackers_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
class HackersController < ApplicationController
before_action :set_hacker, only: [:show, :edit, :update, :destroy]

# GET /hackers
# GET /hackers.json
def index
@hackers = Hacker.all
end

# GET /hackers/1
# GET /hackers/1.json
def show
end

# GET /hackers/new
def new
@hacker = Hacker.new
end

# GET /hackers/1/edit
def edit
end

# POST /hackers
# POST /hackers.json
def create
@hacker = Hacker.new(hacker_params)

respond_to do |format|
if @hacker.save
format.html { redirect_to @hacker, notice: 'Hacker was successfully created.' }
format.json { render :show, status: :created, location: @hacker }
else
format.html { render :new }
format.json { render json: @hacker.errors, status: :unprocessable_entity }
end
end
end

# PATCH/PUT /hackers/1
# PATCH/PUT /hackers/1.json
def update
respond_to do |format|
if @hacker.update(hacker_params)
format.html { redirect_to @hacker, notice: 'Hacker was successfully updated.' }
format.json { render :show, status: :ok, location: @hacker }
else
format.html { render :edit }
format.json { render json: @hacker.errors, status: :unprocessable_entity }
end
end
end

# DELETE /hackers/1
# DELETE /hackers/1.json
def destroy
@hacker.destroy
respond_to do |format|
format.html { redirect_to hackers_url, notice: 'Hacker was successfully destroyed.' }
format.json { head :no_content }
end
end

private
# Use callbacks to share common setup or constraints between actions.
def set_hacker
@hacker = Hacker.find(params[:id])
end

# Never trust parameters from the scary internet, only allow the white list through.
def hacker_params
params.require(:hacker).permit(:username, :password, :first_name, :last_name, :score, :type)
end
end
25 changes: 25 additions & 0 deletions app/controllers/logout_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
class LogoutController < ApplicationController
def new
@session = Session.new
end


skip_before_filter :require_login

def create
user = User.find_by_username(params[:username])
if user && user.authenticate(params[:password])
session[:id] = user.id
reset_session
redirect_to root_url, :notice => "Logged in!"
else
flash.now.alert = "Invalid email or password"
render "new"
end
end

def destroy
session.delete(:id)
redirect_to root_url, :notice => "Logged out!"
end
end
15 changes: 13 additions & 2 deletions app/controllers/questions_controller.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
class QuestionsController < ApplicationController
before_action :set_question, only: [:show, :edit, :update, :destroy]

# GET /questions
# GET /questions.json
def index
@questions = Question.all

end

# GET /questions/1
# GET /questions/1.json
def show
@answers = Answer.where( q_response_id: @question.id)
end

# GET /questions/new
Expand All @@ -20,6 +22,15 @@ def new
# GET /questions/1/edit
def edit
end

# POST /questions
# POST /questions.json
def answer
@question = Question.find(params[:id])
@question.toggle!(:answered)
@question.save()
redirect_to(:back)
end

# POST /questions
# POST /questions.json
Expand Down Expand Up @@ -61,7 +72,6 @@ def destroy
end
end

private
# Use callbacks to share common setup or constraints between actions.
def set_question
@question = Question.find(params[:id])
Expand All @@ -71,4 +81,5 @@ def set_question
def question_params
params.require(:question).permit(:question_id, :creator_id, :title, :content, :category, :answered, :closing_comment, :timestamp)
end

end
25 changes: 25 additions & 0 deletions app/controllers/sessions_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
class SessionsController < ApplicationController
def new
end
def new
@session = Session.new
end

skip_before_filter :require_login

def create
user = User.find_by_username(params[:username])
if user && user.authenticate(params[:password])
session[:id] = user.id
redirect_to root_url, :notice => "Logged in!"
else
flash.now.alert = "Invalid email or password"
render "new"
end
end

def destroy
session.delete(:id)
redirect_to root_url, :notice => "Logged out!"
end
end
Loading