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

Feature/documents #8

Merged
merged 14 commits into from Jul 23, 2019
Merged

Feature/documents #8

merged 14 commits into from Jul 23, 2019

Conversation

tsubik
Copy link
Collaborator

@tsubik tsubik commented Jul 22, 2019

The first iteration of documents upload added to Litigations

Document could be

  • an uploaded one
  • external (we only store URL)

TODO

  • we need to add google storage service later
  • could the same document be attached to many different records? The third option "Select existing" would be needed if that is the case.
  • language column is missing, will be added in another story.

upload-documents-external-links

@tsubik tsubik requested a review from kowal July 22, 2019 13:57
@@ -16,4 +16,12 @@ def summary
def core_objective
model.core_objective.html_safe
end

def document_list
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

document_links?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea.

app/models/legislation.rb Outdated Show resolved Hide resolved
class DocumentDecorator < Draper::Decorator
delegate_all

def name_link
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you think about renaming those methods ..
name_link => document_page_link (or just document_link)
open_link => document_url_link
.. to indicate where those links actually go.

@@ -0,0 +1,16 @@
class UrlValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
return unless value.present?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we combine return unless value.present? and ..unless url_valid?(value) in single condition?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I will make two separate guard clauses. I think 2 will be more readable.

end

def url_valid?(url)
url = begin
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think url = URI.parse(url) rescue false would be enough here

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rubocop changed that automagically.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, let's not mess with RuboCop 🤖

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I already did. lol. I don't like that rule

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

haha ok )

this.wrapperClass = this.data.get('wrapperClass') || 'nested-fields';
}

addRecord(event) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code here looks like it shouldn't be directly related with "documents", rather, it is more like generic add/remove resource logic, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. I will change that

@tsubik tsubik merged commit 7dba26e into develop Jul 23, 2019
@tsubik tsubik deleted the feature/documents branch July 26, 2019 10:46
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

2 participants