Skip to content

Commit

Permalink
update transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
progressbarsk committed Sep 9, 2012
1 parent 8073c9c commit 44d25b8
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 16 deletions.
2 changes: 1 addition & 1 deletion app/controllers/api_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class ApiController < ::ApplicationController
protect_from_forgery

before_filter :check_rights, :only => [:create, :update, :new, :delete]
# before_filter :check_rights, :only => [:create, :update, :new, :delete]

private

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# This migration comes from refinery_transactions (originally 1)
class CreateTransactionsTransactions < ActiveRecord::Migration

def up
Expand All @@ -15,11 +14,13 @@ def up
t.text :message
t.text :raw

t.string :stamp
t.string :stamp, :null => false

t.timestamps
end

add_index :refinery_transactions, :stamp, :unique => true

end

def down
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,23 @@ def create
response = {'status' => false}
ptrans = params[:transaction]

trans = Transaction.new(ptrans)
if params[:help].present?
response['accessible_attributes'] = trans._accessible_attributes
else
if trans.valid?
response['status'] = trans.save!
begin
trans = Transaction.new(ptrans)
if params[:help].present?
response['accessible_attributes'] = trans._accessible_attributes
else
response['errors'] = trans.errors
if trans.valid?
response['status'] = trans.save!
else
response['errors'] = trans.errors
end
end
rescue
response = $!
end

render :text => response.to_json
# render :text => ptrans
end

end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ def custom_types
def title
case self.primary_type
when INCOME_TRANSACTION_TYPE
"Income from #{self.from_account.truncate(10)}"
"Income from #{self.from_account.truncate(10) if self.from_account.present?}"
when OUTCOME_TRANSACTION_TYPE
"Payment to #{self.to_account}"
"Payment to #{self.to_account if self.to_account.present?}"
end
end

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<tr class=" record <%= cycle('on', 'on-hover') %> <%= "transaction-#{transaction.primary_type}" %>" id="<%= dom_id(transaction) -%>">
<td class="title">
<span>
<%= transaction.stamp %>-t-
<%= transaction.title %>
<%= ", #{transaction.message.truncate(32)} " unless transaction.message.nil? %>
</span>
Expand All @@ -15,8 +16,7 @@
<% if current_refinery_user.has_role?(:superuser) %>
<td style="text-align: center">
<%#= link_to refinery_icon_tag("application_go.png"), refinery.transactions_transaction_path(transaction),
:title => t('.view_live_html'),
:target => "_blank" %>
:title => t('.view_live_html') %>
<%= link_to refinery_icon_tag("application_edit.png"), refinery.edit_transactions_admin_transaction_path(transaction),
:title => t('.edit') %>
Expand Down
1 change: 0 additions & 1 deletion vendor/extensions/transactions/config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# Frontend routes
get '/api/transaction/new' => 'transactions::transactions#create'


# Admin routes
namespace :transactions, :path => '' do
namespace :admin, :path => 'refinery' do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ def up
t.text :message
t.text :raw

t.string :stamp
t.string :stamp, :null => false

t.timestamps
end

add_index :refinery_transactions, :stamp, :unique => true

end

def down
Expand Down

0 comments on commit 44d25b8

Please sign in to comment.