mirror of
https://github.com/indentlabs/notebook.git
synced 2025-10-26 11:19:22 +00:00
Include contributable content in linked lists
This commit is contained in:
parent
23a32f5bf5
commit
04f8a89b4a
BIN
app/assets/images/card-headers/.DS_Store
vendored
BIN
app/assets/images/card-headers/.DS_Store
vendored
Binary file not shown.
@ -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
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
<div class="col s10">
|
||||
<%=
|
||||
f.select "#{attribute}_id",
|
||||
current_user.send(klass.pluralize)
|
||||
current_user.send("linkable_#{klass.pluralize}")
|
||||
.in_universe(@universe_scope)
|
||||
.sort_by(&:name)
|
||||
.reject { |content| content.class.name == klass && content.id == @content.id }
|
||||
@ -49,4 +49,4 @@
|
||||
</script>
|
||||
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user