office_clerk 0.4 → 0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +11 -36
  3. data/LICENSE +22 -0
  4. data/app/assets/javascripts/office_clerk.js +0 -7
  5. data/app/assets/stylesheets/{office_clerk.scss → office_clerk.css.scss} +0 -0
  6. data/app/controllers/orders_controller.rb +10 -1
  7. data/app/controllers/products_controller.rb +2 -32
  8. data/app/controllers/shop_controller.rb +1 -0
  9. data/app/helpers/orders_helper.rb +6 -5
  10. data/app/helpers/shop_helper.rb +8 -7
  11. data/app/mailers/order_mailer.rb +19 -0
  12. data/app/views/addresses/_form_fields.html.haml +4 -4
  13. data/app/views/baskets/edit.html.haml +1 -1
  14. data/app/views/categories/edit.html.haml +22 -18
  15. data/app/views/clerks/edit.html.haml +6 -9
  16. data/app/views/layouts/office_clerk.haml +1 -0
  17. data/app/views/layouts/sales_clerk.haml +10 -0
  18. data/app/views/order_mailer/cancel.html.haml +6 -0
  19. data/app/views/order_mailer/confirm.html.haml +7 -0
  20. data/app/views/order_mailer/paid.html.haml +6 -0
  21. data/app/views/order_mailer/shipped.html.haml +6 -0
  22. data/app/views/orders/edit.html.haml +1 -1
  23. data/app/views/orders/show.html.haml +48 -44
  24. data/app/views/products/_head.haml +4 -2
  25. data/app/views/products/edit.html.haml +35 -24
  26. data/app/views/products/show.html.haml +32 -41
  27. data/app/views/purchases/edit.html.haml +4 -4
  28. data/app/views/sessions/sign_up.haml +1 -1
  29. data/app/views/shop/_product_box.haml +13 -0
  30. data/app/views/suppliers/edit.html.haml +2 -2
  31. data/bin/rails +3 -15
  32. data/config/environments/production.rb +2 -77
  33. data/config/locales/config.yml +1 -1
  34. data/config/locales/en.yml +75 -45
  35. data/config/locales/fi.yml +60 -67
  36. data/config/routes.rb +1 -1
  37. data/db/migrate/20131226143612_categories.rb +2 -1
  38. data/db/migrate/20131226151332_products.rb +2 -1
  39. data/lib/office_clerk.rb +2 -7
  40. data/lib/office_clerk/version.rb +1 -1
  41. data/lib/templates/haml/scaffold/_form.html.haml +1 -1
  42. data/office_clerk.gemspec +6 -12
  43. data/spec/features/products/edit_spec.rb +0 -4
  44. data/spec/mailers/order_mailer_spec.rb +24 -0
  45. data/spec/models/baskets/items_spec.rb +3 -3
  46. data/spec/models/locale_spec.rb +4 -0
  47. data/test_app/db/migrate/20141114205527_categories.office.rb +2 -2
  48. data/test_app/db/migrate/20141114205532_products.office.rb +2 -2
  49. data/test_app/db/schema.rb +4 -2
  50. data/todo +0 -4
  51. metadata +68 -111
  52. data/config/initializers/migrate.rb +0 -6
  53. data/config/initializers/simple_form.rb +0 -149
  54. data/config/initializers/simple_form_bootstrap.rb +0 -48
  55. data/db/seeds.rb +0 -4
  56. data/test/fixtures/baskets.yml +0 -41993
  57. data/test/fixtures/categories.yml +0 -638
  58. data/test/fixtures/clerks.yml +0 -694
  59. data/test/fixtures/items.yml +0 -83651
  60. data/test/fixtures/orders.yml +0 -58918
  61. data/test/fixtures/products.yml +0 -110904
  62. data/test/fixtures/purchases.yml +0 -1755
  63. data/test/fixtures/suppliers.yml +0 -341
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5a2b4bc40578de23126465f66caf7875b16d756a
4
- data.tar.gz: 0921190739bd31c9e5687fcdf9f2a3a82553d41b
3
+ metadata.gz: 56d6271f7a086331b09afec3ae09a147a9597258
4
+ data.tar.gz: 30ebd8fbf11b488f2a05d00d316ee64c8f693e3f
5
5
  SHA512:
6
- metadata.gz: d2dd8a0e3fd11659919f9bdf9ef5e72428d285448d01ab8628d11af4cfbaa4ba0d0167c6c5dde2030dccb2f3f2426ed7da3b9bdd98a6ad762a0340daa475fc6c
7
- data.tar.gz: c6c5bced0d3646e2b9e3810d84fef728c29340bd147c63fb6649b6e162b6208a25daaf2bbb06d29ea2db4b33f4fd7e94f378fbb1325792144b7c82335b0e7af1
6
+ metadata.gz: aa365643d22ae66f4c82b55d9d6715122dfca353c6cdb6684dcb7d0f57800caef83b910889d769108be317e4bc6c666a96a2d7e20e497aa34c7b4f93b591a3ee
7
+ data.tar.gz: 15932e74f50c0fca75818e3e2ef099c5d6b33370f72b0796ddfcad556dae7f02dd32cb43c41396fda97f10267277ccf2db224abbc61fe94635f1487e71c7e6aa
@@ -19,23 +19,20 @@ GIT
19
19
  PATH
20
20
  remote: ../
21
21
  specs:
22
- office_clerk (0.4)
23
- barby
22
+ office_clerk (0.5)
24
23
  bcrypt-ruby (~> 3.1)
25
24
  bootstrap-sass (~> 3.1)
26
25
  bootstrap_form (~> 2.2)
27
- chunky_png
26
+ coffee-rails
27
+ gon
28
28
  haml (~> 4.0)
29
+ jquery-rails (~> 3.1)
29
30
  jquery-ui-rails (~> 5.0)
30
31
  kramdown (~> 1.5)
31
- opal-jquery (~> 0.2)
32
- opal-rails (~> 0.6)
33
32
  paperclip (~> 4.1)
34
- prawn
35
33
  rails (~> 4.0, >= 4.0.1)
36
34
  rails-i18n (~> 4.0)
37
35
  sass-rails (~> 4.0)
38
- simple_form (~> 3.0)
39
36
  will_paginate-bootstrap (~> 1.0)
40
37
 
41
38
  GEM
@@ -67,7 +64,6 @@ GEM
67
64
  tzinfo (~> 0.3.37)
68
65
  addressable (2.3.6)
69
66
  arel (4.0.2)
70
- barby (0.6.2)
71
67
  bcrypt (3.1.9)
72
68
  bcrypt-ruby (3.1.5)
73
69
  bcrypt (>= 3.1.3)
@@ -77,7 +73,7 @@ GEM
77
73
  rack (>= 0.9.0)
78
74
  binding_of_caller (0.7.2)
79
75
  debug_inspector (>= 0.0.1)
80
- bootstrap-sass (3.1.1.1)
76
+ bootstrap-sass (3.3.1.0)
81
77
  sass (~> 3.2)
82
78
  bootstrap_form (2.2.0)
83
79
  builder (3.1.4)
@@ -93,7 +89,6 @@ GEM
93
89
  launchy
94
90
  celluloid (0.16.0)
95
91
  timers (~> 4.0.0)
96
- chunky_png (1.3.3)
97
92
  climate_control (0.0.3)
98
93
  activesupport (>= 3.0)
99
94
  cocaine (0.5.4)
@@ -129,6 +124,11 @@ GEM
129
124
  railties (>= 3.0.0)
130
125
  ffi (1.9.6)
131
126
  formatador (0.2.5)
127
+ gon (5.2.3)
128
+ actionpack (>= 2.3.0)
129
+ json
130
+ multi_json
131
+ request_store (>= 1.0.5)
132
132
  guard (2.8.2)
133
133
  formatador (>= 0.2.4)
134
134
  listen (~> 2.7)
@@ -186,33 +186,13 @@ GEM
186
186
  multi_json (1.10.1)
187
187
  nokogiri (1.6.4.1)
188
188
  mini_portile (~> 0.6.0)
189
- opal (0.6.2)
190
- source_map
191
- sprockets
192
- opal-activesupport (0.0.5)
193
- opal
194
- opal-jquery (0.2.0)
195
- opal (>= 0.5.0, < 1.0.0)
196
- opal-rails (0.6.3)
197
- jquery-rails
198
- opal (~> 0.6.0)
199
- opal-activesupport (>= 0.0.5)
200
- opal-jquery (>= 0.1.0)
201
- opal-rspec (~> 0.3.0.beta1)
202
- rails (>= 3.2.13, < 5.0)
203
- opal-rspec (0.3.0.beta3)
204
- opal (>= 0.6.0, < 1.0.0)
205
189
  paperclip (4.2.0)
206
190
  activemodel (>= 3.0.0)
207
191
  activesupport (>= 3.0.0)
208
192
  cocaine (~> 0.5.3)
209
193
  mime-types
210
- pdf-core (0.4.0)
211
194
  polyamorous (1.1.0)
212
195
  activerecord (>= 3.0)
213
- prawn (1.3.0)
214
- pdf-core (~> 0.4.0)
215
- ttfunk (~> 1.4.0)
216
196
  pry (0.10.1)
217
197
  coderay (~> 1.1.0)
218
198
  method_source (~> 0.8.1)
@@ -244,6 +224,7 @@ GEM
244
224
  ffi (>= 0.5.0)
245
225
  rb-readline (0.5.1)
246
226
  ref (1.0.5)
227
+ request_store (1.1.0)
247
228
  rspec (3.1.0)
248
229
  rspec-core (~> 3.1.0)
249
230
  rspec-expectations (~> 3.1.0)
@@ -270,17 +251,12 @@ GEM
270
251
  sass (~> 3.2.2)
271
252
  sprockets (~> 2.8, < 2.12)
272
253
  sprockets-rails (~> 2.0)
273
- simple_form (3.0.2)
274
- actionpack (~> 4.0)
275
- activemodel (~> 4.0)
276
254
  simplecov (0.9.1)
277
255
  docile (~> 1.1.0)
278
256
  multi_json (~> 1.0)
279
257
  simplecov-html (~> 0.8.0)
280
258
  simplecov-html (0.8.0)
281
259
  slop (3.6.0)
282
- source_map (3.0.1)
283
- json
284
260
  sprockets (2.11.3)
285
261
  hike (~> 1.2)
286
262
  multi_json (~> 1.0)
@@ -304,7 +280,6 @@ GEM
304
280
  timers (4.0.1)
305
281
  hitimes
306
282
  tins (1.3.3)
307
- ttfunk (1.4.0)
308
283
  tzinfo (0.3.42)
309
284
  uglifier (2.5.3)
310
285
  execjs (>= 0.3.0)
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 Rubyclerks
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
@@ -1,8 +1,6 @@
1
1
  //= require jquery
2
2
  //= require jquery-ui
3
3
  //= require jquery-ui/datepicker-fi
4
- //= require opal
5
- //= require opal_ujs
6
4
  //= require bootstrap
7
5
  //= require_self
8
6
 
@@ -13,11 +11,6 @@ $(function() {
13
11
  });
14
12
 
15
13
  function initPage(){
16
- // Barcode
17
- $('.barcode').each(function(){
18
- $(this).barcode($(this).attr('data-barcode'), $(this).attr('data-type-barcode'));
19
- });
20
-
21
14
  // Add Error Form style with bootstrap
22
15
  $("div.form-group>div.field_with_errors").parent().addClass("error");
23
16
  $("#error_explanation").addClass("text-error");
@@ -1,7 +1,7 @@
1
1
  # encoding : utf-8
2
2
  class OrdersController < AdminController
3
3
 
4
- before_filter :load_order, :only => [:show, :edit, :update , :pay , :ship]
4
+ before_filter :load_order, :only => [:show, :edit, :update , :pay , :ship , :mail]
5
5
 
6
6
  # Uncomment for check abilities with CanCan
7
7
  #authorize_resource
@@ -13,6 +13,7 @@ class OrdersController < AdminController
13
13
  end
14
14
 
15
15
  def show
16
+ gon.order_id = @order.id
16
17
  end
17
18
 
18
19
  def new
@@ -21,6 +22,14 @@ class OrdersController < AdminController
21
22
  render :edit
22
23
  end
23
24
 
25
+ def mail
26
+ action = params[:act]
27
+ puts "MAIL #{action}"
28
+ mail = eval("OrderMailer.#{action}(@order)")
29
+ mail.deliver
30
+ flash.notice = "Sent #{action}"
31
+ redirect_to :action => :show
32
+ end
24
33
  def pay
25
34
  @order.paid_on = Date.today
26
35
  @order.save!
@@ -1,14 +1,8 @@
1
1
  # encoding : utf-8
2
- require 'barby'
3
- require 'prawn'
4
- require 'prawn/measurement_extensions'
5
- require 'barby/barcode/code_128'
6
- require 'barby/barcode/ean_13'
7
- require 'barby/outputter/png_outputter'
8
2
 
9
3
  class ProductsController < AdminController
10
4
 
11
- before_filter :load_product, :only => [:show, :edit, :update, :delete , :barcode]
5
+ before_filter :load_product, :only => [:show, :edit, :update, :delete ]
12
6
 
13
7
  # Uncomment for check abilities with CanCan
14
8
  #authorize_resource
@@ -22,6 +16,7 @@ class ProductsController < AdminController
22
16
  end
23
17
 
24
18
  def show
19
+ gon.product_id = @product.id
25
20
  end
26
21
 
27
22
  def new
@@ -65,31 +60,6 @@ class ProductsController < AdminController
65
60
  redirect_to product_url , :notice => "#{t(:error)} : #{t(:inventory)}"
66
61
  end
67
62
  end
68
-
69
- # loads of ways to create barcodes nowadays, this is a bit older.
70
- # Used to be html but moved to pdf for better layout control
71
- def barcode
72
- code = @product.ean
73
- code = @product.name if code.blank?
74
- if code.length == 12
75
- aBarcode = ::Barby::EAN13.new( code )
76
- else
77
- aBarcode = ::Barby::Code128B.new( code )
78
- end
79
- pdf = create_pdf
80
- pdf.image( StringIO.new( aBarcode.to_png(:xdim => 5)) , :width => 50.mm ,
81
- :height => 10.mm , :at => [ 0 , 10.mm])
82
- send_data pdf.render , :type => "application/pdf" , :filename => "#{@product.full_name}.pdf"
83
- end
84
-
85
- private
86
-
87
- def create_pdf
88
- pdf = Prawn::Document.new( :page_size => [ 54.mm , 25.mm ] , :margin => 2.mm )
89
- pdf.text( @product.full_name , :align => :left )
90
- pdf.text( "#{@product.price} € " , :align => :right , :padding => 5.mm)
91
- pdf
92
- end
93
63
 
94
64
  def load_product
95
65
  @product = Product.find(params[:id])
@@ -31,6 +31,7 @@ class ShopController < OfficeController
31
31
  order_ps = params.require(:order).permit( :email,:name , :street , :city , :phone , :shipment_type )
32
32
  if @order.update_attributes(order_ps)
33
33
  new_basket
34
+ OrderMailer.confirm(@order).deliver
34
35
  redirect_to shop_order_path(@order), :notice => t(:thanks)
35
36
  return
36
37
  end
@@ -1,10 +1,11 @@
1
1
  # encoding : utf-8
2
- require "admin_helper"
3
2
  module OrdersHelper
4
- def print_styles
5
- OfficeClerk.config(:print_styles).split
3
+ def mail_actions
4
+ conf = OfficeClerk.config(:mail_buttons)
5
+ return "" if conf.blank?
6
+ conf.split(" ").collect{|s| s.strip }
6
7
  end
7
- def print_path style
8
- eval("office.#{style}_order_path(@order)")
8
+ def mail_path action
9
+
9
10
  end
10
11
  end
@@ -17,12 +17,13 @@ module ShopHelper
17
17
  end
18
18
 
19
19
  # a short version of a desciption text. now we use markdown and often have a bold "header"
20
- # so if we find a bold we use just that, regardless of length given
21
- # otherwise we try and find a space close to the given length, to avoid ugly half-words
22
- def short text , len = 110
23
- ind = text.index( "**" , 10) || text.index( "**" , 10)
24
- return text[0 .. ind + 1] if ind
25
- ind = text.index(" " , len - 10)
26
- ind ? text[0 .. ind + 1] : text[0 .. len +1]
20
+ # so one can give a char sequence
21
+ def short text , chop = "**"
22
+ ind = text.index( chop , 10)
23
+ if ind
24
+ return text[0 .. ind + 1]
25
+ else
26
+ return text[0 .. 100]
27
+ end
27
28
  end
28
29
  end
@@ -0,0 +1,19 @@
1
+ class OrderMailer < ActionMailer::Base
2
+
3
+ def confirm(order)
4
+ @order = order
5
+ mail(to: @order.email, from: "me@here.now" , subject: "Order #{@order.number}")
6
+ end
7
+ def cancel(order)
8
+ @order = order
9
+ mail(to: @order.email, from: "me@here.now" , subject: "Order #{@order.number}")
10
+ end
11
+ def paid(order)
12
+ @order = order
13
+ mail(to: @order.email, from: "me@here.now" , subject: "Order #{@order.number}")
14
+ end
15
+ def shipped(order)
16
+ @order = order
17
+ mail(to: @order.email, from: "me@here.now" , subject: "Order #{@order.number}")
18
+ end
19
+ end
@@ -1,4 +1,4 @@
1
- = f.input :name
2
- = f.input :street
3
- = f.input :city
4
- = f.input :phone
1
+ = f.text_field :name
2
+ = f.text_field :street
3
+ = f.text_field :city
4
+ = f.text_field :phone
@@ -29,7 +29,7 @@
29
29
  %tr{:class => "line-#{cycle("1","2")}"}
30
30
  %td.picture= image_tag item.product.main_picture.url(:thumb) if item.product
31
31
  %td.name= item.name
32
- = f.simple_fields_for :items , item do |iform|
32
+ = f.fields_for :items , item do |iform|
33
33
  %td= iform.text_field :quantity , :label => false
34
34
  %td= iform.text_field :price , :label => false
35
35
  %td
@@ -9,28 +9,32 @@
9
9
  - else
10
10
  = t(:new)
11
11
 
12
- = simple_form_for(@category, :html => { :multipart => true , :class => "form-horizontal" }) do |f|
12
+ = bootstrap_form_for(@category, :html => { :multipart => true }) do |f|
13
13
  .row.form-group
14
- .col-md-6
15
- = f.input :category , input_html: { class: 'form-control' } do
16
- = f.select :category_id, Category.all.order(:name).map { |c| [c.name, c.id ] }, :include_blank => true , :prompt => t(:select)
17
- = f.input :online
18
- = f.input :name
19
- = f.input :link
20
- = f.input :position
21
- .col-md-6
22
- = f.input :description , :as => :text , :input_html => {:rows => 12}
14
+ .col-md-5
15
+ = f.text_field :name
16
+ .row
17
+ .col-md-2
18
+ = f.check_box :online
19
+ .col-md-10
20
+ = f.text_field :link
21
+ = f.select :category_id , Category.all.order(:name).map { |c| [c.name, c.id ] }, :prompt => t(:select) , :include_blank => true
22
+ = f.text_field :position
23
+ .col-md-7
24
+ = f.text_area :description , :rows => 12
23
25
  .row
24
- .col-md-6
26
+ .col-md-4
25
27
  = image_tag @category.main_picture.url
28
+ .col-md-4
29
+ = image_tag @category.extra_picture.url
30
+ .col-md-4
31
+ = f.submit :class => "btn btn-success"
32
+ %br
33
+ %br
34
+ = link_to t(:back), categories_path, :class => "btn btn-warning"
26
35
  .row
27
- .col-md-6
36
+ .col-md-4
28
37
  = f.file_field :main_picture
29
- .col-md-6
38
+ .col-md-4
30
39
  = f.file_field :extra_picture
31
- .row
32
- .col-md-3
33
- = f.submit :class => "btn btn-success"
34
- .col-md-3
35
- = link_to t(:back), categories_path, :class => "btn btn-warning"
36
40
 
@@ -3,18 +3,15 @@
3
3
  = t(:clerk)
4
4
  -if @clerk.admin
5
5
  =t(:admin)
6
- = simple_form_for(@clerk, :html => { :class => "form-horizontal" }) do |f|
6
+ = bootstrap_form_for(@clerk) do |f|
7
7
  .row
8
- = f.input :admin
9
- = f.input :email
10
- = f.input :name
11
- = f.input :street
12
- = f.input :city
13
- = f.input :phone
8
+ = f.check_box :admin
9
+ = f.email_field :email
10
+ = render "addresses/form_fields" ,:f => f
14
11
  -unless @clerk.new_record?
15
12
  =f.label t(:may_be_blank)
16
- = f.input :password
17
- = f.input :password_confirmation
13
+ = f.password_field :password
14
+ = f.password_field :password_confirmation
18
15
  .form-actions
19
16
  = f.submit :class => "btn btn-success" , :id => "submit"
20
17
  = link_to t(:back), clerks_path, :class => "btn btn-warning"
@@ -5,6 +5,7 @@
5
5
  %title Office Clerk
6
6
  %meta{:content => "Office Clerk", :name => "description"}
7
7
  = stylesheet_link_tag "office_clerk"
8
+ = include_gon(:init => true)
8
9
  = javascript_include_tag "office_clerk"
9
10
  = render "layouts/header_extra"
10
11
  = csrf_meta_tags