X Tutup
Skip to content
This repository was archived by the owner on Mar 11, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,6 @@ public/javascripts/vendor/*/
.vagrant
.tm_properties
Vagrantfile
*.sublime-*
.byebug_history
doc
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
GIT
remote: git@github.com:documentcloud/bull_proof_china_shop
revision: 64abcde27387c080fa58e79289f4a2632660f54d
revision: 648729a16dd568d286ae0343429632fe20f68537
branch: master
specs:
bull_proof_china_shop (0.0.1)
Expand Down Expand Up @@ -433,4 +433,4 @@ DEPENDENCIES
webmock

BUNDLED WITH
1.12.5
1.14.4
3 changes: 2 additions & 1 deletion app/controllers/workspace_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ class WorkspaceController < ApplicationController
# searching, the home page otherwise.
def index
if logged_in? and current_account.real?
@projects = Project.load_for(current_account)
@projects = Project.load_for(current_account) # TODO: Filter out invitations
@project_invitations = [] # TODO: Fill this is in with invitations
@current_organization = current_account.organization
@organizations = Organization.all_slugs
@has_documents = Document.owned_by(current_account).exists?
Expand Down
7 changes: 7 additions & 0 deletions app/models/organization_project.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class OrganizationProject < ActiveRecord::Base

belongs_to :organization
belongs_to :project

validates :project_id, uniqueness: { scope: :organization_id }
end
1 change: 1 addition & 0 deletions app/models/project_membership.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ class ProjectMembership < ActiveRecord::Base

belongs_to :project
belongs_to :document
# belongs_to :membership

has_many :collaborations, :through => :project

Expand Down
45 changes: 45 additions & 0 deletions app/serializers/collaboration_serializer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
class CollaborationSerializer < ActiveModel::Serializer

attributes :id,
:account_id,
:creator_id,
:membership_id,
:hidden,
:project_id,
:title,
:account_full_name,
:annotation_count,
:document_count,
:public_url,
:collaborators
# TODO use a project serializer and pass the project object
def project
Project.find(object.project_id)
end

def title
return '[Untitled Project]' if object.project.title.blank?
object.project.title
end

def account_full_name
object.project.account_full_name
end

def annotation_count
project.annotation_count(object.account)
end

def document_count
object.project.project_memberships.count
end

def public_url
object.project.public_url
end

def collaborators
object.project.other_collaborators(object.account)
.map { |c| c.canonical(include_organization: true) }
end
end
2 changes: 1 addition & 1 deletion app/views/common/_bootstrap.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Organizations.reset(<%=raw @organizations.to_json(:include_document_count=>true, :include_note_count=>true) %>);
<% if @current_account && @current_account.memberships.any? %>
<%= render :partial => 'accounts/current_account.js', :type => :js %>
// ProjectInvitations.reset(<%=raw @projects.to_json() %>);
ProjectInvitations.reset(<%=raw @project_invitations.to_json() %>);
Projects.reset(<%=raw @projects.to_json({:account => @current_account, :include_collaborators => true}) %>);
dc.searchPrefixes = <%=raw DC::ALL_SEARCHES.to_json %>;
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Application < Rails::Application

# disable sprockets
config.assets.enabled = false

# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de
Expand Down
9 changes: 9 additions & 0 deletions db/migrate/20161019195011_add_attributes_to_account.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class AddAttributesToAccount < ActiveRecord::Migration
def change
remove_column :accounts, :identities, :string

add_column :accounts, :provider, :string
add_column :accounts, :access_token, :string
add_column :accounts, :uid, :integer
end
end
10 changes: 10 additions & 0 deletions db/migrate/20161215174011_create_organization_projects.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class CreateOrganizationProjects < ActiveRecord::Migration
def change
create_table :organization_projects do |t|
t.references :organization, index: true, foreign_key: true
t.references :project, index: true, foreign_key: true

t.timestamps # null: false
end
end
end
6 changes: 6 additions & 0 deletions db/migrate/20170124201757_add_membership_to_collaboration.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class AddMembershipToCollaboration < ActiveRecord::Migration
def change
add_reference :collaborations, :membership, index: true
add_column :collaborations, :hidden, :boolean, default: false
end
end
Loading
X Tutup