diff --git a/.gitignore b/.gitignore
index bab620d..7fd45e9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -19,3 +19,5 @@
# Ignore Byebug command history file.
.byebug_history
+
+/public/system/*
diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.scss
similarity index 78%
rename from app/assets/stylesheets/application.css
rename to app/assets/stylesheets/application.scss
index 0ebd7fe..1d43d32 100644
--- a/app/assets/stylesheets/application.css
+++ b/app/assets/stylesheets/application.scss
@@ -13,3 +13,22 @@
*= require_tree .
*= require_self
*/
+
+#columns {
+ display: flex;
+
+ #main {
+ padding: 1em;
+ flex: 1;
+ }
+
+ #side {
+ padding: 1em 2em;
+ }
+}
+
+@media all and (max-width: 800px) {
+ #columns {
+ flex-direction: column-reverse;
+ }
+}
diff --git a/app/controllers/documents_controller.rb b/app/controllers/documents_controller.rb
index 9314e16..931c0b2 100644
--- a/app/controllers/documents_controller.rb
+++ b/app/controllers/documents_controller.rb
@@ -26,6 +26,11 @@ class DocumentsController < ApplicationController
def create
@document = Document.new(document_params)
+ @document.name = @document.doc_file_name
+
+ if Document.exists?(doc_fingerprint: @document.doc_fingerprint)
+ end
+
respond_to do |format|
if @document.save
format.html { redirect_to @document, notice: 'Document was successfully created.' }
@@ -69,6 +74,6 @@ class DocumentsController < ApplicationController
# Never trust parameters from the scary internet, only allow the white list through.
def document_params
- params.require(:document).permit(:name, :doc)
+ params.require(:document).permit(:doc)
end
end
diff --git a/app/models/document.rb b/app/models/document.rb
index a39a400..ddda517 100644
--- a/app/models/document.rb
+++ b/app/models/document.rb
@@ -1,4 +1,4 @@
class Document < ApplicationRecord
- has_attached_file :doc
+ has_attached_file :doc, adapter_options: { hash_digest: Digest::SHA256 }
validates_attachment_content_type :doc, content_type: 'application/pdf'
end
diff --git a/app/views/documents/_form.html.erb b/app/views/documents/_form.html.erb
index cacf85b..38a11c7 100644
--- a/app/views/documents/_form.html.erb
+++ b/app/views/documents/_form.html.erb
@@ -12,11 +12,6 @@
<% end %>
- <%= f.label :name %>
- <%= f.text_field :name %>
-
-
-
<%= f.label :doc %>
<%= f.file_field :doc %>
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb
index 7c5b603..56e9d7f 100644
--- a/app/views/layouts/application.html.erb
+++ b/app/views/layouts/application.html.erb
@@ -8,8 +8,8 @@
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
-
-
+
+
<% if session[:user_id] %>
<%= button_to 'Logout', logout_path, method: :delete %>
diff --git a/db/migrate/20161124142626_add_fingerprint_to_document_doc.rb b/db/migrate/20161124142626_add_fingerprint_to_document_doc.rb
new file mode 100644
index 0000000..a3631d8
--- /dev/null
+++ b/db/migrate/20161124142626_add_fingerprint_to_document_doc.rb
@@ -0,0 +1,6 @@
+class AddFingerprintToDocumentDoc < ActiveRecord::Migration[5.0]
+ def change
+ add_column :documents, :doc_fingerprint, :string
+ add_index :documents, :doc_fingerprint
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 189f3f3..f35f97e 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20161124131141) do
+ActiveRecord::Schema.define(version: 20161124142626) do
create_table "documents", force: :cascade do |t|
t.string "name"
@@ -20,6 +20,8 @@ ActiveRecord::Schema.define(version: 20161124131141) do
t.string "doc_content_type"
t.integer "doc_file_size"
t.datetime "doc_updated_at"
+ t.string "doc_fingerprint"
+ t.index ["doc_fingerprint"], name: "index_documents_on_doc_fingerprint"
end
create_table "users", force: :cascade do |t|
diff --git a/public/system/documents/docs/000/000/003/original/mymedicaldevicename.xml b/public/system/documents/docs/000/000/003/original/mymedicaldevicename.xml
deleted file mode 100644
index e632d76..0000000
--- a/public/system/documents/docs/000/000/003/original/mymedicaldevicename.xml
+++ /dev/null
@@ -1,57 +0,0 @@
-
-
-
-
-
- CODE_ID
- My device description text.
-
-
- uuid-123
- MyManufacturer
- MyModelname
- MyModelnumber123
- MySN123
-
-
-
-
-
- CODE_ID_SETM
- My set method.
-
-
-
-
-
- CODE_ID_VMD
- My vmd descrtiption.
-
-
-
- CODE_ID_CHAN
- My channel description.
-
-
-
-
- Get
-
-
-
- CODE_ID_METRIC
- My metric description.
-
-
- MDC_DIM_DIMLESS
- No description for this unit code id.
-
- Unspec
- Intr
-
-
-
-
-
-
-
diff --git a/public/system/documents/docs/000/000/004/original/02cc55df9b654cefa6c647ecc7a502fa.png b/public/system/documents/docs/000/000/004/original/02cc55df9b654cefa6c647ecc7a502fa.png
deleted file mode 100644
index 9636b10..0000000
Binary files a/public/system/documents/docs/000/000/004/original/02cc55df9b654cefa6c647ecc7a502fa.png and /dev/null differ
diff --git a/public/system/documents/docs/000/000/005/original/MyMedicalDeviceName20161119012242.zip b/public/system/documents/docs/000/000/005/original/MyMedicalDeviceName20161119012242.zip
deleted file mode 100644
index 1e608cb..0000000
Binary files a/public/system/documents/docs/000/000/005/original/MyMedicalDeviceName20161119012242.zip and /dev/null differ
diff --git a/public/system/documents/docs/000/000/006/original/whenType.pdf b/public/system/documents/docs/000/000/006/original/whenType.pdf
deleted file mode 100644
index b0b011a..0000000
Binary files a/public/system/documents/docs/000/000/006/original/whenType.pdf and /dev/null differ