caboose-cms 0.8.63 → 0.8.64
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/controllers/caboose/invoice_transactions_controller.rb +1 -1
- data/app/controllers/caboose/products_controller.rb +27 -0
- data/app/models/caboose/invoice_transaction.rb +7 -2
- data/app/views/caboose/products/admin_alternate_ids.html.erb +58 -0
- data/app/views/caboose/products/admin_index.html.erb +1 -0
- data/lib/caboose/version.rb +1 -1
- metadata +3 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 2d35930182bb20d54aa4c0b5b5e8904f3ef90681
         | 
| 4 | 
            +
              data.tar.gz: ec38ef84ece6b6ea25ffc3aff9efda36f0d738df
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: b8525496f4bdcebb66cb5da6402250ea8750c94afebbec73bd9f85d75a2980c3a4511f308931b83cce7cde4c840596764c80fe847a681459bae16c90629bd172
         | 
| 7 | 
            +
              data.tar.gz: 5de7d8361b02fd800da40c2e24eb193cf4ba02a82d166394a6fe3c696f3faa0687783237d1b6c2886a11b91003e0b41328058858eec6946c564cfb985f74401a
         | 
| @@ -6,7 +6,7 @@ module Caboose | |
| 6 6 | 
             
                  return if !user_is_allowed('invoices', 'edit')
         | 
| 7 7 |  | 
| 8 8 | 
             
                  it = InvoiceTransaction.find(params[:id])
         | 
| 9 | 
            -
                  resp = params[:amount] ? it.capture(params[:amount]) : it.capture 
         | 
| 9 | 
            +
                  resp = params[:amount] ? it.capture(params[:amount].to_f) : it.capture 
         | 
| 10 10 |  | 
| 11 11 | 
             
                  render :json => resp            
         | 
| 12 12 | 
             
                end
         | 
| @@ -175,6 +175,33 @@ module Caboose | |
| 175 175 | 
             
                  render :json => vendor.save
         | 
| 176 176 | 
             
                end
         | 
| 177 177 |  | 
| 178 | 
            +
                # @route GET /admin/products/alternate-ids
         | 
| 179 | 
            +
                def admin_alternate_ids
         | 
| 180 | 
            +
                  return if !user_is_allowed('products', 'view')
         | 
| 181 | 
            +
                  
         | 
| 182 | 
            +
                  query = ["select P.id as product_id, V.id as variant_id, P.title, P.option1, V.option1 as option1_value, P.option2, V.option2 as option2_value, P.option3, V.option3 as option3_value, V.alternate_id
         | 
| 183 | 
            +
                    from store_variants V
         | 
| 184 | 
            +
                    left join store_products P on V.product_id = P.id
         | 
| 185 | 
            +
                    where P.site_id = ?
         | 
| 186 | 
            +
                    order by title, P.option1, V.option1", @site.id]      
         | 
| 187 | 
            +
                  rows = ActiveRecord::Base.connection.select_rows(ActiveRecord::Base.send(:sanitize_sql_array, query))
         | 
| 188 | 
            +
                  
         | 
| 189 | 
            +
                  @rows = rows.collect{ |row| Caboose::StdClass.new({
         | 
| 190 | 
            +
                    :product_id     => row[0],      
         | 
| 191 | 
            +
                    :variant_id     => row[1],
         | 
| 192 | 
            +
                    :title          => row[2],
         | 
| 193 | 
            +
                    :option1        => row[3],
         | 
| 194 | 
            +
                    :option1_value  => row[4],
         | 
| 195 | 
            +
                    :option2        => row[5],
         | 
| 196 | 
            +
                    :option2_value  => row[6],
         | 
| 197 | 
            +
                    :option3        => row[7],
         | 
| 198 | 
            +
                    :option3_value  => row[8],
         | 
| 199 | 
            +
                    :alternate_id   => row[9]        
         | 
| 200 | 
            +
                  })}
         | 
| 201 | 
            +
             | 
| 202 | 
            +
                  render :layout => 'caboose/admin'
         | 
| 203 | 
            +
                end
         | 
| 204 | 
            +
                
         | 
| 178 205 | 
             
                # @route GET /admin/products
         | 
| 179 206 | 
             
                def admin_index
         | 
| 180 207 | 
             
                  return if !user_is_allowed('products', 'view')
         | 
| @@ -69,8 +69,13 @@ module Caboose | |
| 69 69 | 
             
                      bt = nil
         | 
| 70 70 | 
             
                      begin            
         | 
| 71 71 | 
             
                        c = Stripe::Charge.retrieve(self.transaction_id)            
         | 
| 72 | 
            -
                        return { :error => "Amount given to capture is greater than the amount authorized." } if amount. | 
| 73 | 
            -
                         | 
| 72 | 
            +
                        return { :error => "Amount given to capture is greater than the amount authorized. amount = #{amount}, c.amount = #{c.amount}" } if (amount*100).to_i > c.amount            
         | 
| 73 | 
            +
                        amount = (amount.to_f * 100.0).to_i
         | 
| 74 | 
            +
                        if amount == c.amount              
         | 
| 75 | 
            +
                          c = c.capture
         | 
| 76 | 
            +
                        else
         | 
| 77 | 
            +
                          c = c.capture({ :amount => amount })
         | 
| 78 | 
            +
                        end
         | 
| 74 79 | 
             
                        bt = Stripe::BalanceTransaction.retrieve(c.balance_transaction)
         | 
| 75 80 | 
             
                      rescue Exception => ex
         | 
| 76 81 | 
             
                        resp.error = "Error during capture process\n#{ex.message}"                
         | 
| @@ -0,0 +1,58 @@ | |
| 1 | 
            +
             | 
| 2 | 
            +
            <div id='crumbtrail'></div>
         | 
| 3 | 
            +
            <h1>Product Alternate IDs</h1>
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            <p>Alternate IDs are used during import and export processes to associate products from other systems with the products in this system.</p>
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            <table class='data'>
         | 
| 8 | 
            +
              <tr>
         | 
| 9 | 
            +
                <th>Product ID     </th>      
         | 
| 10 | 
            +
                <th>Variant ID     </th>
         | 
| 11 | 
            +
                <th>Alternate ID   </th>
         | 
| 12 | 
            +
                <th>Title          </th>
         | 
| 13 | 
            +
                <th>Option 1       </th><th>Value 1 </th>
         | 
| 14 | 
            +
                <th>Option 2       </th><th>Value 2 </th>
         | 
| 15 | 
            +
                <th>Option 3       </th><th>Value 3 </th>    
         | 
| 16 | 
            +
              </tr>
         | 
| 17 | 
            +
              <% @rows.each do |row| %>
         | 
| 18 | 
            +
                <tr>
         | 
| 19 | 
            +
                  <td><%= row.product_id     %></td>      
         | 
| 20 | 
            +
                  <td><%= row.variant_id     %></td>
         | 
| 21 | 
            +
                  <td><div id='variant_<%= row.variant_id %>_alternate_id'></div></td>
         | 
| 22 | 
            +
                  <td><%= row.title          %></td>
         | 
| 23 | 
            +
                  <td><%= row.option1        %></td>
         | 
| 24 | 
            +
                  <td><%= row.option1_value  %></td>
         | 
| 25 | 
            +
                  <td><%= row.option2        %></td>
         | 
| 26 | 
            +
                  <td><%= row.option2_value  %></td>
         | 
| 27 | 
            +
                  <td><%= row.option3        %></td>
         | 
| 28 | 
            +
                  <td><%= row.option3_value  %></td>      
         | 
| 29 | 
            +
                </tr>
         | 
| 30 | 
            +
              <% end %>
         | 
| 31 | 
            +
            </table><br />
         | 
| 32 | 
            +
             | 
| 33 | 
            +
            <% content_for :caboose_js do %>
         | 
| 34 | 
            +
            <%= javascript_include_tag 'caboose/model/all' %>
         | 
| 35 | 
            +
            <script type='text/javascript'>
         | 
| 36 | 
            +
             | 
| 37 | 
            +
            $(document).ready(function() {
         | 
| 38 | 
            +
              var that = this;
         | 
| 39 | 
            +
              
         | 
| 40 | 
            +
              add_to_crumbtrail('/admin', 'Admin');
         | 
| 41 | 
            +
              add_to_crumbtrail('/admin/products', 'Products');
         | 
| 42 | 
            +
              add_to_crumbtrail('/admin/products/alternate-ids', 'Alternate IDs');
         | 
| 43 | 
            +
              
         | 
| 44 | 
            +
              <% @rows.each do |row| %>
         | 
| 45 | 
            +
              new ModelBinder({
         | 
| 46 | 
            +
                name: 'Variant',
         | 
| 47 | 
            +
                id: <%= row.variant_id %>,
         | 
| 48 | 
            +
                update_url: '/admin/products/<%= row.product_id %>/variants/<%= row.variant_id %>',
         | 
| 49 | 
            +
                authenticity_token: '<%= form_authenticity_token %>',
         | 
| 50 | 
            +
                attributes: [      
         | 
| 51 | 
            +
                  { name: 'alternate_id', nice_name: 'Alternate ID', type: 'text', value: <%= raw Caboose.json(row.alternate_id) %>, width: 100, fixed_placeholder: false }      
         | 
| 52 | 
            +
                ]
         | 
| 53 | 
            +
              });
         | 
| 54 | 
            +
              <% end %>
         | 
| 55 | 
            +
            });
         | 
| 56 | 
            +
                
         | 
| 57 | 
            +
            </script>
         | 
| 58 | 
            +
            <% end %>
         | 
| @@ -4,6 +4,7 @@ | |
| 4 4 | 
             
            <p style="margin: 12px 0">
         | 
| 5 5 | 
             
              <a href="/admin/vendors/new">New Vendor</a><span style="margin: 0 3px">|</span>  
         | 
| 6 6 | 
             
              <a href="/admin/products/sort">Sort Products</a><span style="margin: 0 3px">|</span>
         | 
| 7 | 
            +
              <a href="/admin/products/alternate-ids">Alternate IDs</a><span style="margin: 0 3px">|</span>
         | 
| 7 8 | 
             
              <a href='#'>Search Form</a>
         | 
| 8 9 | 
             
            </p>
         | 
| 9 10 |  | 
    
        data/lib/caboose/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: caboose-cms
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.8. | 
| 4 | 
            +
              version: 0.8.64
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - William Barry
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2016-09- | 
| 11 | 
            +
            date: 2016-09-02 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: pg
         | 
| @@ -1150,6 +1150,7 @@ files: | |
| 1150 1150 | 
             
            - app/views/caboose/products/_admin_header.html.erb
         | 
| 1151 1151 | 
             
            - app/views/caboose/products/_sort_options.html.erb
         | 
| 1152 1152 | 
             
            - app/views/caboose/products/admin_add_upcs.html.erb
         | 
| 1153 | 
            +
            - app/views/caboose/products/admin_alternate_ids.html.erb
         | 
| 1153 1154 | 
             
            - app/views/caboose/products/admin_delete_form.html.erb
         | 
| 1154 1155 | 
             
            - app/views/caboose/products/admin_edit_categories.html.erb
         | 
| 1155 1156 | 
             
            - app/views/caboose/products/admin_edit_category_images.html.erb
         |