Skip to content

Instantly share code, notes, and snippets.

@jakwuh
Last active May 6, 2016 12:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jakwuh/255a4cb9dbf8d9c770baf6146d9ac239 to your computer and use it in GitHub Desktop.
Save jakwuh/255a4cb9dbf8d9c770baf6146d9ac239 to your computer and use it in GitHub Desktop.
Open account for other users

A small guide for "Open account for other users" task

  • Create collections/policies & models/policies. Look for previously created collections and models for example.
  • Create appropriate relationship for models/company
initialize: function() {
	this.buildRelation('policies', require('collections/policies'));
}
  • Create views/collection.models/policy, views/app/collections/policies, views/app/layouts/ policies. Also create appropriate templates for these views. Look for previously created views and templates for example.
  • Create routes/app route
'policies': 'policies'
  • Create controllers/app method
policies: function() {
	this.layout.getRegion('main').show(new PoliciesView({model: new Company({id: this.appUser.get('company_id'})}));
  • Fetch all neccessary data in load method of views/app/layouts/policies
load: function() {
	return Promise.all([this.model.policies.fetch()]);
}
  • After loading data current layout view will be shown in its region. Don't forget to show fetched collection of policies in onBeforeAttachMethod
onBeforeAttach: function() {
	this.showChildView('policies', new PoliciesView({collection: this.model.policies}));
}

That's it!

POST /companies/:id/privacy

[{
  type: "profile",
  visibility: "groups" // or "guests", "members", "hidden"
  groups: [12, 13, 14, 15, 16] // this array contains ids only if visibility === "groups"
}, {
  type: "categories",
  visibility: "groups" // or "guests", "members", "hidden"
  groups: [12, 13, 14, 15, 16] // this array contains ids only if visibility === "groups"
}]
POST /user/privacy

[{
  type: "profile",
  visibility: "groups" // or "guests", "members", "hidden"
  groups: [12, 13, 14, 15, 16] // this array contains ids only if visibility === "groups"
}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment