Skip to content

Commit

Permalink
Removed the server module
Browse files Browse the repository at this point in the history
  • Loading branch information
Francismb committed May 19, 2016
1 parent 0e07b21 commit 7eee3ba
Show file tree
Hide file tree
Showing 26 changed files with 33 additions and 172 deletions.
4 changes: 0 additions & 4 deletions app/assets/stylesheets/server.css

This file was deleted.

2 changes: 1 addition & 1 deletion app/controllers/admin_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def logout
# else it renders the login again.
# POST http://francismb.com/admin/authenticate
def authenticate
user = User.find_by_username(params[:username]);
user = User.find_by_username(params[:username])
if user && user.authenticate(params[:password])
flash[:error] = nil
session[:user_id] = user.id
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class ApplicationController < ActionController::Base
protect_from_forgery with: :exception

# Standard application layout
layout "application"
layout 'application'

# A few helper methods to assist controllers and templates.
include ApplicationHelper
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/messages_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class MessagesController < ApplicationController

# Require authentication for the following functions
before_action :require_admin_authentication, :only => [
before_action :logged_in, :only => [
:index,
:delete, :destroy
]
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/milestones_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class MilestonesController < ApplicationController

# Require authentication for the following functions
before_action :require_admin_authentication, :only => [
before_action :logged_in, :only => [
:new, :create,
:edit, :update,
:delete, :destroy
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/projects_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class ProjectsController < ApplicationController

# Require authentication for the following functions
before_action :require_admin_authentication, :only => [
before_action :logged_in, :only => [
:new, :create,
:edit, :update,
:delete, :destroy
Expand Down
69 changes: 0 additions & 69 deletions app/controllers/server_controller.rb

This file was deleted.

2 changes: 1 addition & 1 deletion app/controllers/skills_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class SkillsController < ApplicationController

# Require authentication for the following functions
before_action :require_admin_authentication, :only => [
before_action :logged_in, :only => [
:new, :create,
:edit, :update,
:delete, :destroy
Expand Down
16 changes: 0 additions & 16 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,6 @@ module ApplicationHelper
def logged_in
session[:user_id] != nil
end

# Returns true if the logged in user is an admin else false
def admin_logged_in
if session[:user_id] == nil
return false
end
return User.find_by_id(session[:user_id]).admin
end

# Returns the currently logged in user model.
def get_user
Expand All @@ -25,13 +17,5 @@ def require_authentication
redirect_to :controller => :admin, :action => :login
end
end

# A usefull before action to redirect the user to the login
# if the user has not logged in yet and is required to.
def require_admin_authentication
unless logged_in && get_user.admin
redirect_to :controller => :admin, :action => :login
end
end

end
2 changes: 0 additions & 2 deletions app/helpers/server_helper.rb

This file was deleted.

3 changes: 0 additions & 3 deletions app/views/admin/login.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
<% content_for :headers do %>
<%= stylesheet_link_tag "access" %>
<% end %>
<div class="login-form">
<%= form_for :user, :url => {:action => :authenticate} do |f| %>

Expand Down
7 changes: 2 additions & 5 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,9 @@
<a href="<%= url_for :controller => :milestones %>">Milestones</a>
</li>
<li>
<% if admin_logged_in %>
<a href="<%= url_for :controller => :messages %>">Messages</a>
<% end %>
<% if logged_in %>
<a href="<%= url_for :controller => :server, :action => :index %>">Server</a>
<a href="<%= url_for :controller => :admin, :action => :logout %>">Logout</a>
<a href="<%= url_for :controller => :messages %>">Messages</a>
<a href="<%= url_for :controller => :admin, :action => :logout %>">Logout</a>
<% else %>
<a href="<%= url_for :controller => :admin, :action => :login %>">Admin</a>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/milestones/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="container">
<h1 class="center">Milestones</h1>
<% if admin_logged_in %>
<% if logged_in %>
<a class="new-project button" href="<%= url_for :action => :new %>">
New Milestone
</a>
Expand Down
2 changes: 1 addition & 1 deletion app/views/milestones/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<article class="container">
<h1><%= @milestone.name %></h1>
<% if admin_logged_in %>
<% if logged_in %>
<a class="edit-project button" href="<%= url_for :action => :edit, :id => @milestone.id %>">
Edit Project
</a>
Expand Down
2 changes: 1 addition & 1 deletion app/views/projects/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<% end %>
<div class="container">
<h1 class="center">Projects</h1>
<% if admin_logged_in %>
<% if logged_in %>
<a class="new-project button" href="<%= url_for :action => :new %>">
New Project
</a>
Expand Down
4 changes: 2 additions & 2 deletions app/views/projects/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<article class="container">
<h1 class="title">
<span><%= @project.name %></span>
<% if @project.github_link.length() > 0 %>
<% if @project.github_link.length > 0 %>
<a class="github-link" target="_blank" href="<%= @project.github_link %>">Github Project Link</a>
<% end %>
</h1>
<% if admin_logged_in %>
<% if logged_in %>
<a class="edit-project button" href="<%= url_for :action => :edit, :id => @project.id %>">
Edit Project
</a>
Expand Down
16 changes: 0 additions & 16 deletions app/views/server/edit.html.erb

This file was deleted.

16 changes: 0 additions & 16 deletions app/views/server/new.html.erb

This file was deleted.

12 changes: 0 additions & 12 deletions app/views/server/show.html.erb

This file was deleted.

2 changes: 1 addition & 1 deletion app/views/skills/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<% end %>
<div class="container">
<h1 class="center">Skills</h1>
<% if admin_logged_in %>
<% if logged_in %>
<a class="new-skill button" href="<%= url_for :action => :new %>">
New Skill
</a>
Expand Down
2 changes: 1 addition & 1 deletion app/views/skills/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<article class="container">
<h1><%= @skill.name %></h1>
<% if admin_logged_in %>
<% if logged_in %>
<a class="edit-skill button" href="<%= url_for :action => :edit, :id => @skill.id %>">
Edit Skill
</a>
Expand Down
2 changes: 1 addition & 1 deletion db/migrate/20160422050913_add_admin_to_users.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class AddAdminToUsers < ActiveRecord::Migration
def change
add_column :users, :admin, :boolean
add_column :users, :admin, :boolean
end
end
9 changes: 9 additions & 0 deletions db/migrate/20160519070130_remove_servers.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class RemoveServers < ActiveRecord::Migration
def up
drop_table :servers
end

def down
fail ActiveRecord::IrreversibleMigration
end
end
5 changes: 5 additions & 0 deletions db/migrate/20160519070409_remove_admin_from_users.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class RemoveAdminFromUsers < ActiveRecord::Migration
def change
remove_column :users, :admin, :boolean
end
end
11 changes: 3 additions & 8 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20160422052639) do
ActiveRecord::Schema.define(version: 20160519070409) do

create_table "messages", force: :cascade do |t|
t.string "name"
Expand Down Expand Up @@ -44,10 +44,6 @@
t.integer "project_id"
end

create_table "servers", force: :cascade do |t|
t.string "content"
end

create_table "skills", force: :cascade do |t|
t.string "name"
t.text "summary"
Expand All @@ -58,9 +54,8 @@
end

create_table "users", force: :cascade do |t|
t.string "username"
t.string "password_digest"
t.boolean "admin"
t.string "username"
t.string "password_digest"
end

end
7 changes: 0 additions & 7 deletions test/controllers/server_controller_test.rb

This file was deleted.

0 comments on commit 7eee3ba

Please sign in to comment.