diff --git a/app/assets/images/card-headers/.DS_Store b/app/assets/images/card-headers/.DS_Store deleted file mode 100644 index 5008ddfc..00000000 Binary files a/app/assets/images/card-headers/.DS_Store and /dev/null differ diff --git a/app/models/user.rb b/app/models/user.rb index 6bf02a11..91369c5f 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -44,6 +44,7 @@ class User < ActiveRecord::Base Universe.where(id: contributor_by_email + contributor_by_user) end + #TODO: rename this to #{content_type}_shared_with_me and only return contributable content that others own Rails.application.config.content_types[:all_non_universe].each do |content_type| pluralized_content_type = content_type.name.downcase.pluralize define_method "contributable_#{pluralized_content_type}" do @@ -52,6 +53,21 @@ class User < ActiveRecord::Base end end end + #TODO: rename this to the more descriptive name contributable_#{content_type} + # returns all content of that type that a user can edit/contribute to, even if it's not owned by the user + Rails.application.config.content_types[:all_non_universe].each do |content_type| + pluralized_content_type = content_type.name.downcase.pluralize + define_method "linkable_#{pluralized_content_type}" do + my_universe_ids = universes.pluck(:id) + contributable_universe_ids = contributable_universes.pluck(:id) + + content_type.where(""" + universe_id IN (#{(my_universe_ids + contributable_universe_ids).uniq.join(',')}) + OR + (universe_id IS NULL AND user_id = #{self.id.to_i}) + """) + end + end # TODO: Swap this out with a has_many when we transition from a scratchpad to users having multiple documents has_one :document diff --git a/app/views/content/form/_groupship_fields.html.erb b/app/views/content/form/_groupship_fields.html.erb index e23d2d82..96c31064 100644 --- a/app/views/content/form/_groupship_fields.html.erb +++ b/app/views/content/form/_groupship_fields.html.erb @@ -24,7 +24,7 @@