-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:lilykuang/Fall14HKSA
- Loading branch information
Showing
37 changed files
with
303 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// Place all the styles related to the sponsors controller here. | ||
// They will automatically be included in application.css. | ||
// You can use Sass (SCSS) here: http://sass-lang.com/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,12 @@ | ||
// Place all the styles related to the Users controller here. | ||
// They will automatically be included in application.css. | ||
// You can use Sass (SCSS) here: http://sass-lang.com/ | ||
#error_explanation { | ||
color: #f00; | ||
ul { | ||
list-style: none; | ||
margin: 0 0 18px 0; | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,28 @@ | ||
class OfficersController < ApplicationController | ||
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i | ||
validates :email, presence: true, | ||
format: { with: VALID_EMAIL_REGEX }, | ||
uniqueness: { case_sensitive: false } | ||
|
||
def new | ||
@officer = Officer.new | ||
end | ||
|
||
def create | ||
@officer = Officer.new(officer_params) | ||
if @officer.save | ||
redirect_to officers_path | ||
else | ||
render 'new' | ||
end | ||
end | ||
|
||
def index | ||
@officer = Officer.all | ||
end | ||
|
||
private | ||
|
||
def officer_params | ||
params.require(:officer).permit(:firstName, | ||
:lastName, :year, :position, | ||
:major, :description) | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
class SponsorsController < ApplicationController | ||
def index | ||
@sponsors = Sponsor.all | ||
end | ||
|
||
def new | ||
@sponsor = Sponsor.new | ||
end | ||
|
||
def show | ||
@sponsor = Sponsor.find(params[:id]) | ||
end | ||
|
||
def create | ||
@sponsor = Sponsor.new(sponsor_params) | ||
if @sponsor.save | ||
redirect_to @sponsor | ||
else | ||
render 'new' | ||
end | ||
end | ||
|
||
def edit | ||
@sponsor = Sponsor.find(params[:id]) | ||
end | ||
|
||
private | ||
|
||
def sponsor_params | ||
params.require(:sponsor).permit(:name, :address, :advertisement) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module SponsorsHelper | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
class FrontPage < ActiveRecord::Base | ||
has_many: officers | ||
has_many: sponsors | ||
has_many :sponsors | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
class Sponsor < ActiveRecord::Base | ||
belongs_to :front_page | ||
validates :name, presence: true, length: { maximum: 50 } | ||
validates :address, presence: true, length: { maximum: 50 } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
<li><%= link_to 'Home', root_path %></li> | ||
<% if current_user.admin? && !current_user?(user) %> | ||
<h1>All Subscription</h1> | ||
<% @members.each do |member| %> | ||
<li><%= member.name %></br> | ||
<%= member.email %></li> | ||
<% if current_user %> | ||
<% if current_user.admin? %> | ||
<h1>All Subscription</h1> | ||
<% @members.each do |member| %> | ||
<li><%= member.name %> <%= member.email %> | ||
| <%= link_to "delete", member, method: :delete, | ||
data: { confirm: "You sure?" } %></li> | ||
<% end %> | ||
<% end %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
|
||
<% @officer.each do |officer| %> | ||
<h3><%= officer.firstName %> <%= officer.lastName %></h3> | ||
<li><%= officer.year %></li> | ||
<li><%= officer.position %></li> | ||
<li><%= officer.major %></li> | ||
<li><%= officer.description %> | ||
<% if current_user %> | ||
<% if current_user.admin? %> | ||
| <%= link_to "delete", officer, method: :delete, | ||
data: { confirm: "You sure?" } %> | ||
<% end %> | ||
<% end %></li> | ||
|
||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<h1>Add Officer</h1> | ||
<%= form_for @officer do |f| %> | ||
<p> | ||
<%= f.label :firstName %><br/> | ||
<%= f.text_field :firstName %> | ||
</p> | ||
<p> | ||
<%= f.label :lastName %><br/> | ||
<%= f.text_field :lastName %> | ||
</p> | ||
<p> | ||
<%= f.label :year %><br/> | ||
<%= f.text_field :year %> | ||
</p> | ||
<p> | ||
<%= f.label :position %><br/> | ||
<%= f.text_field :position %> | ||
</p> | ||
<p> | ||
<%= f.label :major %><br/> | ||
<%= f.text_field :major %> | ||
</p> | ||
<p> | ||
<%= f.label :description %><br/> | ||
<%= f.text_area :description, cols: 40, rows: 7 %> | ||
</p> | ||
<p> | ||
<%= f.submit %> | ||
</p> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<% if @user.errors.any? %> | ||
<div id="error_explanation"> | ||
<div class="alert alert-error"> | ||
The form contains <%= pluralize(@user.errors.count, "error") %>. | ||
</div> | ||
<ul> | ||
<% @user.errors.full_messages.each do |msg| %> | ||
<li>* <%= msg %></li> | ||
<% end %> | ||
</ul> | ||
</div> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<% if @sponsor.errors.any? %> | ||
<div id="error_explanation"> | ||
<div class="alert alert-error"> | ||
The form contains <%= pluralize(@sponsor.errors.count, "error") %>. | ||
</div> | ||
<ul> | ||
<% @sponsor.errors.full_messages.each do |msg| %> | ||
<li>* <%= msg %></li> | ||
<% end %> | ||
</ul> | ||
</div> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<% if @member.errors.any? %> | ||
<div id="error_explanation"> | ||
<div class="alert alert-error"> | ||
The form contains <%= pluralize(@member.errors.count, "error") %>. | ||
</div> | ||
<ul> | ||
<% @member.errors.full_messages.each do |msg| %> | ||
<li>* <%= msg %></li> | ||
<% end %> | ||
</ul> | ||
</div> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<div> | ||
<div> | ||
<%= form_for(@sponsor) do |f| %> | ||
<%= render 'shared/sponsor_error' %> | ||
<p> | ||
<%= f.label :name %> | ||
<%= f.text_field :name %> | ||
</p> | ||
<p> | ||
<%= f.label :address %> | ||
<%= f.text_field :address %> | ||
</p> | ||
<%= f.submit %> | ||
<% end %> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,7 @@ | ||
<%= @user.name %> | ||
<%= link_to "Sign out", signout_path, method: "delete" %> | ||
<%= link_to "Sign out", signout_path, method: "delete" %></br> | ||
<% if current_user.admin? %> | ||
<%= link_to "Add New Event", new_event_path %></br> | ||
<%= link_to "Add New Officer", new_officer_path %></br> | ||
<%= link_to "Add New Sponsor", new_sponsor_path %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,21 @@ | ||
Rails.application.routes.draw do | ||
#front_page | ||
root 'front_pages#index' | ||
|
||
resource :front_page, only: [:index] | ||
resource :front_page, only: [:index] | ||
resources :users | ||
resources :officers | ||
resources :events | ||
resources :sponsors | ||
resources :sessions, only: [:new, :create, :destroy] | ||
resources :members, only: [:show,:new, :create, :destroy] | ||
resources :members | ||
|
||
#officer login | ||
match '/signup', to: 'users#new', via: 'get' | ||
match '/signin', to: 'sessions#new', via: 'get' | ||
match '/signout', to: 'sessions#destroy', via: 'delete' | ||
match '/member_signup', to:'members#new', via: 'get' | ||
match '/about/', to: 'front_pages#index', via: 'get' | ||
match '/signup', to: 'users#new', via: 'get' | ||
match '/signin', to: 'sessions#new', via: 'get' | ||
match '/signout', to: 'sessions#destroy', via: 'delete' | ||
|
||
#Subscribe us | ||
match '/subscribe', to: 'members#new', via: 'get' | ||
match '/about/', to: 'front_pages#index', via: 'get' | ||
|
||
end |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class RemoveFirstNameFromMember < ActiveRecord::Migration | ||
def change | ||
remove_column :members, :firstName, :string | ||
remove_column :members, :lastName, :string | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddNameToMember < ActiveRecord::Migration | ||
def change | ||
add_column :members, :name, :string | ||
end | ||
end |
5 changes: 5 additions & 0 deletions
5
db/migrate/20140823220214_remove_officer_id_from_front_page.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class RemoveOfficerIdFromFrontPage < ActiveRecord::Migration | ||
def change | ||
remove_column :front_pages, :officer_id, :integer | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddIsCurrentToEvents < ActiveRecord::Migration | ||
def change | ||
add_column :events, :isCurrent, :boolean | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace :db do | ||
desc "Fill database with sample data" | ||
task populate: :environment do | ||
admin = User.create!(name: "Lily Kuang", | ||
email: "[email protected]", | ||
password: "19920725", | ||
password_confirmation: "19920725", | ||
admin: true) | ||
end | ||
end |
Oops, something went wrong.