-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
modified: Gemfile.lock -- Added the userstamp gem and the rails3_acts_as_paranoid gem new file: app/assets/javascripts/users.js.coffee new file: app/assets/stylesheets/users.css.scss new file: app/controllers/users_controller.rb new file: app/helpers/users_helper.rb new file: app/models/user.rb new file: app/views/users/_form.html.erb new file: app/views/users/edit.html.erb new file: app/views/users/index.html.erb new file: app/views/users/new.html.erb new file: app/views/users/show.html.erb modified: config/routes.rb new file: db/migrate/20121025001857_create_users.rb new file: test/fixtures/users.yml new file: test/functional/users_controller_test.rb new file: test/unit/helpers/users_helper_test.rb new file: test/unit/user_test.rb -- Generated scaffolding for user table (closes #19) modified: app/controllers/application_controller.rb modified: app/models/project.rb modified: app/models/site.rb new file: app/models/user.rb new file: db/migrate/20121025001857_create_users.rb new file: db/migrate/20121025045908_add_user_stamp_to_projects.rb new file: db/migrate/20121025050112_add_user_stamp_to_sites.rb -- Added support for created_by and updated_by in Users, Projects, and Sites (closes #11) modified: db/seeds.rb -- Added seed db user and sections for seed data in dev and prod
- Loading branch information
Showing
13 changed files
with
180 additions
and
0 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://jashkenas.github.com/coffee-script/ |
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 Users 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,14 @@ | ||
class ApplicationController < ActionController::Base | ||
protect_from_forgery | ||
|
||
# userstamp | ||
include Userstamp | ||
|
||
private | ||
|
||
def set_stamper | ||
# I expect this to fail | ||
# hack while we have no authentication | ||
User.stamper = User.first() #self.current_user | ||
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,83 @@ | ||
class UsersController < ApplicationController | ||
# GET /users | ||
# GET /users.json | ||
def index | ||
@users = User.all | ||
|
||
respond_to do |format| | ||
format.html # index.html.erb | ||
format.json { render json: @users } | ||
end | ||
end | ||
|
||
# GET /users/1 | ||
# GET /users/1.json | ||
def show | ||
@user = User.find(params[:id]) | ||
|
||
respond_to do |format| | ||
format.html # show.html.erb | ||
format.json { render json: @user } | ||
end | ||
end | ||
|
||
# GET /users/new | ||
# GET /users/new.json | ||
def new | ||
@user = User.new | ||
|
||
respond_to do |format| | ||
format.html # new.html.erb | ||
format.json { render json: @user } | ||
end | ||
end | ||
|
||
# GET /users/1/edit | ||
def edit | ||
@user = User.find(params[:id]) | ||
end | ||
|
||
# POST /users | ||
# POST /users.json | ||
def create | ||
@user = User.new(params[:user]) | ||
|
||
respond_to do |format| | ||
if @user.save | ||
format.html { redirect_to @user, notice: 'User was successfully created.' } | ||
format.json { render json: @user, status: :created, location: @user } | ||
else | ||
format.html { render action: "new" } | ||
format.json { render json: @user.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# PUT /users/1 | ||
# PUT /users/1.json | ||
def update | ||
@user = User.find(params[:id]) | ||
|
||
respond_to do |format| | ||
if @user.update_attributes(params[:user]) | ||
format.html { redirect_to @user, notice: 'User was successfully updated.' } | ||
format.json { head :no_content } | ||
else | ||
format.html { render action: "edit" } | ||
format.json { render json: @user.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# DELETE /users/1 | ||
# DELETE /users/1.json | ||
def destroy | ||
@user = User.find(params[:id]) | ||
@user.destroy | ||
|
||
respond_to do |format| | ||
format.html { redirect_to users_url } | ||
format.json { head :no_content } | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module UsersHelper | ||
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
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,7 @@ | ||
class User < ActiveRecord::Base | ||
attr_accessible :display_name | ||
|
||
# user stamp | ||
model_stamper | ||
stampable | ||
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,21 @@ | ||
<%= form_for(@user) do |f| %> | ||
<% if @user.errors.any? %> | ||
<div id="error_explanation"> | ||
<h2><%= pluralize(@user.errors.count, "error") %> prohibited this user from being saved:</h2> | ||
|
||
<ul> | ||
<% @user.errors.full_messages.each do |msg| %> | ||
<li><%= msg %></li> | ||
<% end %> | ||
</ul> | ||
</div> | ||
<% end %> | ||
|
||
<div class="field"> | ||
<%= f.label :display_name %><br /> | ||
<%= f.text_field :display_name %> | ||
</div> | ||
<div class="actions"> | ||
<%= f.submit %> | ||
</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,6 @@ | ||
<h1>Editing user</h1> | ||
|
||
<%= render 'form' %> | ||
|
||
<%= link_to 'Show', @user %> | | ||
<%= link_to 'Back', users_path %> |
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,23 @@ | ||
<h1>Listing users</h1> | ||
|
||
<table> | ||
<tr> | ||
<th>Display name</th> | ||
<th></th> | ||
<th></th> | ||
<th></th> | ||
</tr> | ||
|
||
<% @users.each do |user| %> | ||
<tr> | ||
<td><%= user.display_name %></td> | ||
<td><%= link_to 'Show', user %></td> | ||
<td><%= link_to 'Edit', edit_user_path(user) %></td> | ||
<td><%= link_to 'Destroy', user, method: :delete, data: { confirm: 'Are you sure?' } %></td> | ||
</tr> | ||
<% end %> | ||
</table> | ||
|
||
<br /> | ||
|
||
<%= link_to 'New User', new_user_path %> |
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 @@ | ||
<h1>New user</h1> | ||
|
||
<%= render 'form' %> | ||
|
||
<%= link_to 'Back', users_path %> |
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 @@ | ||
<p id="notice"><%= notice %></p> | ||
|
||
<p> | ||
<b>Display name:</b> | ||
<%= @user.display_name %> | ||
</p> | ||
|
||
|
||
<%= link_to 'Edit', edit_user_path(@user) %> | | ||
<%= link_to 'Back', users_path %> |