Adding and removing people

This commit is contained in:
Ancor Gonzalez Sosa 2013-07-10 16:13:53 +02:00
parent d95d8f234b
commit 3a2bf49f97
6 changed files with 64 additions and 28 deletions

View file

@ -1,5 +1,6 @@
class Admin::PeopleController < ApplicationController
before_filter :verify_organizer
respond_to :html
def index
@people = Person.all
@ -15,16 +16,28 @@ class Admin::PeopleController < ApplicationController
end
end
def create
def new
@person = Person.new
end
def create
@person = Person.new(params[:person])
flash[:notice] = 'Person was successfully created.' if @person.save
respond_with @person, :location => admin_people_path
end
def show
@person = Person.find(params[:id])
end
def update
def edit
@person = Person.find(params[:id])
end
def update
@person = Person.find(params[:id])
flash[:notice] = 'Person was successfully updated' if @person.update_attributes(params[:person])
respond_with @person, :location => admin_people_path
end
def delete

View file

@ -10,6 +10,7 @@ class Person < ActiveRecord::Base
validates :first_name, :presence => true
validates :last_name, :presence => true
validates :email, :presence => true
validate :biography_limit
before_create :generate_guid

View file

@ -0,0 +1,10 @@
= semantic_form_for [:admin, @person] do |f|
= f.inputs "Basic Information" do
= f.input :first_name, :as => :string
= f.input :last_name, :as => :string
= f.input :public_name, :as => :string
= f.input :email
= f.input :company, :as => :string
= f.input :biography, :input_html => {:rows => 10}
= f.actions do
= f.action :submit, :button_html => {:class => "btn primary"}

View file

@ -1,7 +1,15 @@
.row-fluid
.span6
%h2
People
- if @people
= "(#{@people.length})"
.span6
.pull-right{:style=>"margin-top:20px; margin-bottom:20px;"}
= link_to "New person", new_admin_person_path, :class => "btn btn-success"
.row-fluid
.span12
.well
%table.table.table-striped.table-bordered.table-hover#people
%thead
@ -16,6 +24,7 @@
%th
%b # of Conference Registrations
%th
%th
- @people.each do |person|
%tr
%td= person.email
@ -23,6 +32,7 @@
%td= person.first_name
%td= person.public_name
%td= person.registrations.count
%td= link_to "Edit", edit_admin_person_path(person)
%td= link_to "View", admin_person_path(person)
:javascript

View file

@ -0,0 +1 @@
= render :partial => "form"

View file

@ -0,0 +1 @@
= render :partial => "form"