diff --git a/CHANGELOG.md b/CHANGELOG.md index 28d51353..632b3317 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). It uses [CalVer](https://calver.org/) as of May 2019. +## [22.09a](https://github.com/berkmancenter/lumendatabase/releases/tag/2022.09a) - 2022-09-05 +### Fixed +* Fixed duplicates of `special domains` when showing the full notice version. + ## [22.09](https://github.com/berkmancenter/lumendatabase/releases/tag/2022.09) - 2022-09-05 ### Added * Introduced special domains. diff --git a/app/helpers/notices_helper.rb b/app/helpers/notices_helper.rb index 45fc362c..76b26a32 100644 --- a/app/helpers/notices_helper.rb +++ b/app/helpers/notices_helper.rb @@ -2,9 +2,9 @@ module NoticesHelper # Determines whether 'click to request access' should be an option. # Yes, the messy function signature implies there is a lot going on with the # business logic. - def access_requestable?(notice, show_original, show_infringing) + def access_requestable?(notice, show_copyrighted, show_infringing) [ - show_original || show_infringing, + show_copyrighted || show_infringing, # Additional access cannot be requested for confidential court orders # as there is nothing further to display. !confidential_order?(notice), @@ -130,13 +130,6 @@ def placeholder_kind(user, role) { selected: user.entity.kind } end - def work_url(url) - return url if SpecialDomain.where('? ~~* domain_name', url).where("why_special ? 'full_urls_only_for_researchers'").none? || - (Current.user && (Current.user.role?(Role.researcher) || Current.user.role?(Role.super_admin))) - - Work.fqdn_from_url(url) - end - private def confidential_order?(notice) diff --git a/app/models/url.rb b/app/models/url.rb index 9e60f9bd..b4f9c906 100644 --- a/app/models/url.rb +++ b/app/models/url.rb @@ -6,6 +6,7 @@ class Url include ValidatesUrls attr_reader :url_original + attr_accessor :only_fqdn def [](index) self.instance_variable_get("@#{index}") diff --git a/app/models/work.rb b/app/models/work.rb index 6e12f6a8..f59087d3 100644 --- a/app/models/work.rb +++ b/app/models/work.rb @@ -87,6 +87,14 @@ def self.fqdn_from_url(url) fqdn end + def infringing_urls_public + filter_urls(infringing_urls) + end + + def copyrighted_urls_public + filter_urls(copyrighted_urls) + end + # == Private Methods ========================================================= private @@ -167,4 +175,28 @@ def valid_url(type, params) def not_valid_url_return(type) type.new(url: 'invalid') end + + def filter_urls(url_instances) + filtered_raw_urls = [] + fqdns = [] + user_allowed = (Current.user && (Current.user.role?(Role.researcher) || Current.user.role?(Role.super_admin))) + + url_instances.each do |url_instance| + just_url = url_instance.url + + filtered_raw_urls << url_instance and next if SpecialDomain.where('? ~~* domain_name', just_url).where("why_special ? 'full_urls_only_for_researchers'").none? || + user_allowed + + fqdn = Work.fqdn_from_url(just_url) + + next if fqdns.include?(fqdn) + + fqdns << fqdn + url_instance.url = fqdn + url_instance.only_fqdn = true + filtered_raw_urls << url_instance + end + + filtered_raw_urls.uniq + end end diff --git a/app/views/notices/_counterfeit_works.html.erb b/app/views/notices/_counterfeit_works.html.erb index 002417d4..d0dd2e04 100644 --- a/app/views/notices/_counterfeit_works.html.erb +++ b/app/views/notices/_counterfeit_works.html.erb @@ -11,9 +11,9 @@ <%= render 'works_urls', work: work, - original_title: 'Original URLs:', + copyrighted_title: 'Original URLs:', infringing_title: 'Allegedly Infringing Counterfeit URLs:', - show_original: false, + show_copyrighted: false, show_infringing: true %> <% end %> diff --git a/app/views/notices/_counternotice_works.html.erb b/app/views/notices/_counternotice_works.html.erb index bdfbea69..fc27cf86 100644 --- a/app/views/notices/_counternotice_works.html.erb +++ b/app/views/notices/_counternotice_works.html.erb @@ -16,9 +16,9 @@ <%= render 'works_urls', work: work, - original_title: 'Original URLs:', + copyrighted_title: 'Original URLs:', infringing_title: 'Allegedly Infringing URLs:', - show_original: true, + show_copyrighted: true, show_infringing: true %> <% end %> diff --git a/app/views/notices/_court_order_works.html.erb b/app/views/notices/_court_order_works.html.erb index 9ba205f0..ff8d70b7 100644 --- a/app/views/notices/_court_order_works.html.erb +++ b/app/views/notices/_court_order_works.html.erb @@ -12,7 +12,7 @@ <%= render 'works_urls', work: work, infringing_title: 'Targeted URLs:', - show_original: false, + show_copyrighted: false, show_infringing: true %> <% end %> diff --git a/app/views/notices/_data_protection_works.html.erb b/app/views/notices/_data_protection_works.html.erb index 6f67a771..0391dda2 100644 --- a/app/views/notices/_data_protection_works.html.erb +++ b/app/views/notices/_data_protection_works.html.erb @@ -7,7 +7,7 @@ <%= render 'works_urls', work: work, infringing_title: 'Location of Some of the Material Requested for Removal:', - show_original: false, + show_copyrighted: false, show_infringing: true %> <% end %> diff --git a/app/views/notices/_defamation_works.html.erb b/app/views/notices/_defamation_works.html.erb index adee9478..0b364ce8 100644 --- a/app/views/notices/_defamation_works.html.erb +++ b/app/views/notices/_defamation_works.html.erb @@ -7,7 +7,7 @@ <%= render 'works_urls', work: work, infringing_title: 'URLs of Allegedly Defamatory Material:', - show_original: false, + show_copyrighted: false, show_infringing: true %> <% end %> diff --git a/app/views/notices/_dmca_works.html.erb b/app/views/notices/_dmca_works.html.erb index bdfbea69..fc27cf86 100644 --- a/app/views/notices/_dmca_works.html.erb +++ b/app/views/notices/_dmca_works.html.erb @@ -16,9 +16,9 @@ <%= render 'works_urls', work: work, - original_title: 'Original URLs:', + copyrighted_title: 'Original URLs:', infringing_title: 'Allegedly Infringing URLs:', - show_original: true, + show_copyrighted: true, show_infringing: true %> <% end %> diff --git a/app/views/notices/_government_request_works.html.erb b/app/views/notices/_government_request_works.html.erb index 5b663bd3..1a8b9346 100644 --- a/app/views/notices/_government_request_works.html.erb +++ b/app/views/notices/_government_request_works.html.erb @@ -11,9 +11,9 @@ <%= render 'works_urls', work: work, - original_title: 'URLs of original work:', + copyrighted_title: 'URLs of original work:', infringing_title: 'URLs mentioned in request:', - show_original: true, + show_copyrighted: true, show_infringing: true %> <% end %> diff --git a/app/views/notices/_law_enforcement_request_works.html.erb b/app/views/notices/_law_enforcement_request_works.html.erb index 6ac705ca..8a35908b 100644 --- a/app/views/notices/_law_enforcement_request_works.html.erb +++ b/app/views/notices/_law_enforcement_request_works.html.erb @@ -11,9 +11,9 @@ <%= render 'works_urls', work: work, - original_title: 'URLs of original work:', + copyrighted_title: 'URLs of original work:', infringing_title: 'URLs mentioned in request:', - show_original: true, + show_copyrighted: true, show_infringing: true %> <% end %> diff --git a/app/views/notices/_other_works.html.erb b/app/views/notices/_other_works.html.erb index a3b86e5e..c5dbad78 100644 --- a/app/views/notices/_other_works.html.erb +++ b/app/views/notices/_other_works.html.erb @@ -16,9 +16,9 @@ <%= render 'works_urls', work: work, - original_title: 'URLs of original work:', + copyrighted_title: 'URLs of original work:', infringing_title: 'Problematic URLs:', - show_original: true, + show_copyrighted: true, show_infringing: true %> <% end %> diff --git a/app/views/notices/_private_information_works.html.erb b/app/views/notices/_private_information_works.html.erb index e2168ac6..4f9511e5 100644 --- a/app/views/notices/_private_information_works.html.erb +++ b/app/views/notices/_private_information_works.html.erb @@ -16,9 +16,9 @@ <%= render 'works_urls', work: work, - original_title: 'URLs of original work:', + copyrighted_title: 'URLs of original work:', infringing_title: 'URLs with private information:', - show_original: true, + show_copyrighted: true, show_infringing: true %> <% end %> diff --git a/app/views/notices/_trademark_works.html.erb b/app/views/notices/_trademark_works.html.erb index 8cd8d116..e53bcd71 100644 --- a/app/views/notices/_trademark_works.html.erb +++ b/app/views/notices/_trademark_works.html.erb @@ -13,7 +13,7 @@ <%= render 'works_urls', work: work, infringing_title: 'Allegedly Infringing URLs:', - show_original: false, + show_copyrighted: false, show_infringing: true %> <% end %> diff --git a/app/views/notices/_works_urls.html.erb b/app/views/notices/_works_urls.html.erb index ca8a7aa1..7cfaff32 100644 --- a/app/views/notices/_works_urls.html.erb +++ b/app/views/notices/_works_urls.html.erb @@ -1,33 +1,12 @@ -<% if can_see_full_notice_version?(@notice) %> - <% if show_original %> -
<%= link_to 'Click here', request_access_notice_path(@notice) %> to request access and see full URLs.