Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Bug fixes, adding user.mailed and user.printed.

Now mails from whichever uploader finished last.
  • Loading branch information...
commit ab74c1485d500095b1bcfb206023e96891ef906e 1 parent f8ffbdd
Jeremy Herrman authored
12 scanbooth_web/app/jobs/ftp_upload.rb
@@ -12,12 +12,20 @@ def self.perform(user_id)
12 12 filename = user.scan_file_with_ext
13 13 path = [ScanBooth::Application.config.scans_path, filename].join('/')
14 14
15   - ftp = Net::FTP.new(server)
16   - ftp.login(username, password)
  15 + ftp = Net::FTP.new(FTP_SERVER)
  16 + ftp.login(FTP_USERNAME, FTP_PASSWORD)
17 17 ftp.putbinaryfile(path, File.basename( path ))
18 18 ftp.quit()
19 19
20 20 user.external_download_id = filename
21 21 user.save!
  22 +
  23 + if !user.mailed && ScanBooth::Application.config.scan_viewer_enabled && !user.external_view_id.blank?
  24 + puts 'mailing user from ftp'
  25 + UserMailer.scan_email(user).deliver
  26 + user.mailed = true
  27 + user.save!
  28 + end
  29 +
22 30 end
23 31 end
8 scanbooth_web/app/jobs/sketchfab_upload.rb
@@ -49,7 +49,13 @@ def self.perform(user_id)
49 49 if data['success']
50 50 user.external_view_id = data['id']
51 51 user.save!
52   - UserMailer.scan_email(user).deliver
  52 +
  53 + if !user.mailed && ScanBooth::Application.config.scan_download_enabled && !user.external_download_id.blank?
  54 + puts 'mailing user from sketchfab'
  55 + UserMailer.scan_email(user).deliver
  56 + user.mailed = true
  57 + user.save!
  58 + end
53 59 p "https://sketchfab.com/show/#{data['id']}"
54 60 else
55 61 p "Upload to sketchfab failed: #{response.body}"
2  scanbooth_web/app/mailers/user_mailer.rb
@@ -2,7 +2,7 @@ class UserMailer < ActionMailer::Base
2 2 default from: ScanBooth::Application.config.scan_mail[:from]
3 3 def scan_email(user)
4 4 @user = user
5   - @scan_view_url = [ScanBooth::Application.config, @user.external_view_id].join
  5 + @scan_view_url = [ScanBooth::Application.config.scan_view_url, @user.external_view_id].join
6 6 @scan_download_url = [ScanBooth::Application.config.scan_download_url, @user.external_download_id].join
7 7 mail(:to => @user.email, :subject => ScanBooth::Application.config.scan_mail[:subject])
8 8 end
4 scanbooth_web/app/models/user.rb
... ... @@ -1,11 +1,11 @@
1 1 class User < ActiveRecord::Base
2   - attr_accessible :name, :email, :scan_file, :external_view_id, :external_download_id
  2 + attr_accessible :name, :email, :scan_file, :mailed, :printed, :external_view_id, :external_download_id
3 3 before_create :generate_filename
4 4 after_create :async_upload_model
5 5
6 6 def generate_filename
7 7 self.scan_file = self.name.gsub(/[^a-z0-9\\-]/i,'')
8   - self.scan_file =
  8 + self.scan_file = self.id if self.scan_file.blank?;
9 9 end
10 10
11 11 def scan_file_with_ext
2  scanbooth_web/app/views/user_mailer/scan_email.html.erb
@@ -27,7 +27,7 @@
27 27
28 28 <p>
29 29 Sincerely,<br/>
30   - <a href="mailto:<%=ScanBooth::Application.config.contact[:email]%>?subject=<%=u ScanBooth::Application.config.scan_mail[:subject]%>"><%=ScanBooth::Application.config.contact[:name]%></a>
  30 + <a href="mailto:<%=ScanBooth::Application.config.contact_info[:email]%>?subject=<%=u ScanBooth::Application.config.scan_mail[:subject]%>"><%=ScanBooth::Application.config.contact_info[:name]%></a>
31 31 </p>
32 32 </body>
33 33 </html>
4 scanbooth_web/app/views/user_mailer/scan_email.text.erb
@@ -16,5 +16,5 @@ Please note: Your scan will only be viewable on sketchfab for 3 months.
16 16 <%= ScanBooth::Application.config.scan_mail[:thanks_message] %>
17 17
18 18 Sincerely,
19   -<%=ScanBooth::Application.config.contact[:name]%>
20   -<%=ScanBooth::Application.config.contact[:email]%>
  19 +<%=ScanBooth::Application.config.contact_info[:name]%>
  20 +<%=ScanBooth::Application.config.contact_info[:email]%>
8 scanbooth_web/app/views/users/_form.html.erb
@@ -19,6 +19,14 @@
19 19 <%= f.label :email %><br />
20 20 <%= f.text_field :email %>
21 21 </div>
  22 + <div class="field">
  23 + <%= f.label :printed %><br />
  24 + <%= f.check_box :printed %>
  25 + </div>
  26 + <div class="field">
  27 + <%= f.label :mailed %><br />
  28 + <%= f.check_box :mailed %>
  29 + </div>
22 30 <div class="actions">
23 31 <%= f.submit "Submit" %>
24 32 </div>
8 scanbooth_web/app/views/users/index.html.erb
@@ -5,7 +5,10 @@
5 5 <th>Name</th>
6 6 <th>Email</th>
7 7 <th>Scan file</th>
8   - <th>External</th>
  8 + <th>External View Id</th>
  9 + <th>External Download Id</th>
  10 + <th>Printed</th>
  11 + <th>Mailed</th>
9 12 <th></th>
10 13 <th></th>
11 14 <th></th>
@@ -17,6 +20,9 @@
17 20 <td><%= user.email %></td>
18 21 <td><%= user.scan_file %></td>
19 22 <td><%= user.external_view_id %></td>
  23 + <td><%= user.external_download_id %></td>
  24 + <td><%= user.printed %></td>
  25 + <td><%= user.mailed %></td>
20 26 <td><%= link_to 'Show', user %></td>
21 27 <td><%= link_to 'Edit', edit_user_path(user) %></td>
22 28 <td><%= link_to 'Destroy', user, method: :delete, data: { confirm: 'Are you sure?' } %></td>
5 scanbooth_web/db/migrate/20120923184415_add_external_download_id_to_user.rb
... ... @@ -0,0 +1,5 @@
  1 +class AddExternalDownloadIdToUser < ActiveRecord::Migration
  2 + def change
  3 + add_column :users, :external_download_id, :string
  4 + end
  5 +end
5 scanbooth_web/db/migrate/20120923184455_rename_user_external_id_to_external_view_id.rb
... ... @@ -0,0 +1,5 @@
  1 +class RenameUserExternalIdToExternalViewId < ActiveRecord::Migration
  2 + def change
  3 + rename_column :users, :external_id, :external_view_id
  4 + end
  5 +end
6 scanbooth_web/db/migrate/20120923205345_add_status_bools_to_user.rb
... ... @@ -0,0 +1,6 @@
  1 +class AddStatusBoolsToUser < ActiveRecord::Migration
  2 + def change
  3 + add_column :users, :printed, :boolean, :default => false
  4 + add_column :users, :mailed, :boolean, :default => false
  5 + end
  6 +end
11 scanbooth_web/db/schema.rb
@@ -11,15 +11,18 @@
11 11 #
12 12 # It's strongly recommended to check this file into your version control system.
13 13
14   -ActiveRecord::Schema.define(:version => 20120921172401) do
  14 +ActiveRecord::Schema.define(:version => 20120923205345) do
15 15
16 16 create_table "users", :force => true do |t|
17 17 t.string "name"
18 18 t.string "email"
19 19 t.string "scan_file"
20   - t.string "external_id"
21   - t.datetime "created_at", :null => false
22   - t.datetime "updated_at", :null => false
  20 + t.string "external_view_id"
  21 + t.datetime "created_at", :null => false
  22 + t.datetime "updated_at", :null => false
  23 + t.string "external_download_id"
  24 + t.boolean "printed", :default => false
  25 + t.boolean "mailed", :default => false
23 26 end
24 27
25 28 end

0 comments on commit ab74c14

Please sign in to comment.
Something went wrong with that request. Please try again.