Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentable #1809

Merged
merged 53 commits into from
Sep 5, 2017
Merged

Conversation

Senen
Copy link
Member

@Senen Senen commented Sep 1, 2017

Where

What

Allow to attach documents easily to any application model. Configure documentable module for citizen proposals and budget investments.

How

  • Creating new Document polymorphic model to attach documents to any object.
  • Creating Documentable model concern with configurable arguments to easily customize feature restrictions on per model basis.
  • Configure new documentable module to proposals and budget investments.
  • Add upload document tips to show upload restrictions.(concerns configurable parameters).
  • Make uploads through AJAX call
  • Use progress bar to show uploads progress to final user.
  • Allow to upload multiple documents directly from proposal and budget investments forms as nested resources.
  • Allow to add single document to any proposal or budget investment through a single document upload form.

Te only reason to keep single document upload form is because users cannot edit budget investments projects and therefore they cannot add more documents after creation. With this single document form, authors and administrators can upload documents anytime.

Upload restrictions (Configurable concern arguments)
This configurable options allows developers to configure documentable module in different ways to on each documentable model. For example, we want to allow up to 5 documents on proposals but maybe we want to allow only 3 documents on budget investments. Upload restrictions are:

  • max_files_allowed: Allow to define the maximum number of documents on the recipient model.
  • max_file_size: Allow to define the maximum size on uploaded files.
  • accepted_content_types: Allow to define the accepted content type for file uploads

Restrictions
Only proposal or budget investment author or any administrator can upload or destroy documents.
Users can upload up to X MB document size on each documentable object.
Users can upload up to X documents on each documentable object.
Users can upload only allowed documents types (pdf, jpg, png, doc) to each documentable object.

We have configured following restrictions on Proposal and Budget::Investment models.

  • max_files_allowed: 3
  • max_file_size: 3 MB
  • accepted_content_types: [pdf]

Storage
Attachment uploader has a dynamic path to decide where to store files:

  • default paperclip path on document creation
  • "cached_attachments/user/#{attachment.instance.user_id}" for direct uploads.

When documents are created correctly cached_attachments are deleted and stored in default paperclip path ":rails_root/public/system/:class/:attachment/:id_partition/:style/:filename".

Storage configuration
Documents upload is working with local filestorage as well with aws s3 services.

To enable remote storage is needed to install remote service gem like aws-sdk and configure paperclip defaults to enable remote service access.

Filename
keeping original file name on file uploads.

Screenshots (Updated 27/07/2017)

New Proposal
Max 3 PDF files .
Max 3 megabyte.

crear-propuesta

Edit Proposal upload single file
Max 1 PDF files.
Max 3 megabyte.
show-propuesta-upload-single-file

Upload button on documentable page (proposal page ot budget investment page)
screen shot 2017-07-27 at 17 32 35-fullpage

User warning: Max number of documents reached
screen shot 2017-07-27 at 17 32 17-fullpage

Direct form upload
screen shot 2017-07-27 at 17 43 13-fullpage

Direct form upload validations errors
screen shot 2017-07-27 at 17 52 05-fullpage

Deploy

Run migrations.

Warnings

None.

Tests

Increased model, abilities and feature specs with reusable shared examples.

Senen and others added 30 commits August 25, 2017 17:27
…eate documents controller, documents helper, routes, translations and specs
…how alert on documents tab when maximum reached. Hide upload button when maximum reached.
…th the same width. Changed position buttons in responsive. Pass scss-lint.
…le js file to allow many input files at the same page.
@Senen
Copy link
Member Author

Senen commented Sep 1, 2017

Hi @bertocq, @decabeza, @MariaCheca and @voodoorai2000 we have first version of documentable. Hope you like the way we solved it!

Maybe we have to think what to do with orphan uploaded files. When a user start to create a new proposal or budget investment and uploads some files but then user not finishes creation process, uploaded files remain on server but they are not related with a document neither with documentable record. A manual rake task or scheduled task can achieve this by checking file date creation and removing it only if file was created more than 24 hours ago for example.

Waiting four your feedback and suggestions. 😃

@voodoorai2000
Copy link
Member

Excellent 😌

@voodoorai2000 voodoorai2000 merged commit ee3b3f2 into consuldemocracy:master Sep 5, 2017
@voodoorai2000 voodoorai2000 deleted the documentable-ajax branch September 5, 2017 09:22
@voodoorai2000 voodoorai2000 changed the title [WIP] Documentable Documentable Sep 5, 2017
This was referenced Sep 25, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants