mirror of
https://github.com/fspc/BikeShed-1.git
synced 2025-03-03 09:53:23 -05:00
ActsAsLoggable User Actions fixtures, resources, controller, and views
This commit is contained in:
parent
7e0f43b271
commit
139f5ccf9b
36
app/controllers/acts_as_loggable/user_actions_controller.rb
Normal file
36
app/controllers/acts_as_loggable/user_actions_controller.rb
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
class ActsAsLoggable::UserActionsController < AuthenticatedController
|
||||||
|
#TODO Fix this so updating works
|
||||||
|
expose(:user_action)
|
||||||
|
expose(:user_actions) { ActsAsLoggable::UserAction.order('id').paginate(:page => params[:page]) }
|
||||||
|
|
||||||
|
def index
|
||||||
|
end
|
||||||
|
|
||||||
|
def show
|
||||||
|
end
|
||||||
|
|
||||||
|
def new
|
||||||
|
end
|
||||||
|
|
||||||
|
def create
|
||||||
|
if user_action.save
|
||||||
|
redirect_to acts_as_loggable_user_actions_url
|
||||||
|
else
|
||||||
|
render :new
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def update
|
||||||
|
puts user_action.inspect
|
||||||
|
if user_action.save
|
||||||
|
redirect_to acts_as_loggable_user_actions_url
|
||||||
|
else
|
||||||
|
render :edit
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def destroy
|
||||||
|
user_action.destroy
|
||||||
|
redirect_to acts_as_loggable_user_actions_url
|
||||||
|
end
|
||||||
|
end
|
8
app/views/acts_as_loggable/user_actions/_form.html.haml
Normal file
8
app/views/acts_as_loggable/user_actions/_form.html.haml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
= form_for user_action, :html => { :class => 'form-horizontal' } do |f|
|
||||||
|
.control-group
|
||||||
|
= f.label :action, :class => 'control-label'
|
||||||
|
.controls
|
||||||
|
= f.text_field :action, :class => 'text_field'
|
||||||
|
.form-actions
|
||||||
|
= f.submit nil, :class => 'btn btn-primary'
|
||||||
|
= link_to t('.cancel', :default => t("helpers.links.cancel")), acts_as_loggable_user_actions_path, :class => 'btn'
|
4
app/views/acts_as_loggable/user_actions/edit.html.haml
Normal file
4
app/views/acts_as_loggable/user_actions/edit.html.haml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
- model_class = user_action.class
|
||||||
|
.page-header
|
||||||
|
%h1=t '.title', :default => t('helpers.titles.edit', :model => model_class.model_name.human, :default => "Edit #{model_class.model_name.human}")
|
||||||
|
= render :partial => "form"
|
21
app/views/acts_as_loggable/user_actions/index.html.haml
Normal file
21
app/views/acts_as_loggable/user_actions/index.html.haml
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
- model_class = ActsAsLoggable::UserAction.new.class
|
||||||
|
.page-header
|
||||||
|
%h1=t '.title', :default => model_class.model_name.human.pluralize
|
||||||
|
%table.table.table-striped
|
||||||
|
%thead
|
||||||
|
%tr
|
||||||
|
%th= model_class.human_attribute_name(:id)
|
||||||
|
%th= model_class.human_attribute_name(:action)
|
||||||
|
%th= model_class.human_attribute_name(:created_at)
|
||||||
|
%th=t '.actions', :default => t("helpers.actions")
|
||||||
|
%tbody
|
||||||
|
- user_actions.each do |user_action|
|
||||||
|
%tr
|
||||||
|
%td= link_to user_action.id, acts_as_loggable_user_action_path(user_action)
|
||||||
|
%td= user_action.action
|
||||||
|
%td=l user_action.created_at
|
||||||
|
%td
|
||||||
|
= link_to t('.edit', :default => t("helpers.links.edit")), edit_acts_as_loggable_user_action_path(user_action), :class => 'btn btn-mini'
|
||||||
|
= link_to t('.destroy', :default => t("helpers.links.destroy")), acts_as_loggable_user_action_path(user_action), :method => :delete, :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')), :class => 'btn btn-mini btn-danger'
|
||||||
|
|
||||||
|
= link_to t('.new', :default => t("helpers.links.new")), new_acts_as_loggable_user_action_path, :class => 'btn btn-primary'
|
4
app/views/acts_as_loggable/user_actions/new.html.haml
Normal file
4
app/views/acts_as_loggable/user_actions/new.html.haml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
- model_class = user_action.class
|
||||||
|
.page-header
|
||||||
|
%h1=t '.title', :default => t('helpers.titles.new', :model => model_class.model_name.human, :default => "New #{model_class.model_name.human}")
|
||||||
|
= render :partial => "form"
|
13
app/views/acts_as_loggable/user_actions/show.html.haml
Normal file
13
app/views/acts_as_loggable/user_actions/show.html.haml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
- model_class = user_action.class
|
||||||
|
.page-header
|
||||||
|
%h1=t '.title', :default => model_class.model_name.human
|
||||||
|
|
||||||
|
%p
|
||||||
|
%strong= model_class.human_attribute_name(:action) + ':'
|
||||||
|
%br
|
||||||
|
= user_action.action
|
||||||
|
|
||||||
|
.form-actions
|
||||||
|
= link_to t('.back', :default => t("helpers.links.back")), acts_as_loggable_user_actions_path, :class => 'btn'
|
||||||
|
= link_to t('.edit', :default => t("helpers.links.edit")), edit_acts_as_loggable_user_action_path(user_action), :class => 'btn'
|
||||||
|
= link_to t('.destroy', :default => t("helpers.links.destroy")), acts_as_loggable_user_action_path(user_action), :method => "delete", :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')), :class => 'btn btn-danger'
|
@ -16,6 +16,7 @@ Velocipede::Application.routes.draw do
|
|||||||
|
|
||||||
namespace :acts_as_loggable do
|
namespace :acts_as_loggable do
|
||||||
resources :bike_actions
|
resources :bike_actions
|
||||||
|
resources :user_actions
|
||||||
end
|
end
|
||||||
#resources :clues
|
#resources :clues
|
||||||
#resources :maps
|
#resources :maps
|
||||||
|
15
db/seed/fixtures/acts_as_loggable/user_actions.yml
Normal file
15
db/seed/fixtures/acts_as_loggable/user_actions.yml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
volunteer:
|
||||||
|
id: 1
|
||||||
|
action: VOLUNTEER
|
||||||
|
created_at: <%= Time.now %>
|
||||||
|
updated_at: <%= Time.now %>
|
||||||
|
personal:
|
||||||
|
id: 2
|
||||||
|
action: PERSONAL
|
||||||
|
created_at: <%= Time.now %>
|
||||||
|
updated_at: <%= Time.now %>
|
||||||
|
staff:
|
||||||
|
id: 3
|
||||||
|
action: STAFF
|
||||||
|
created_at: <%= Time.now %>
|
||||||
|
updated_at: <%= Time.now %>
|
Loading…
x
Reference in New Issue
Block a user