Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/download one application #112

Closed
wants to merge 2 commits into from
Closed
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
44 changes: 27 additions & 17 deletions back/api/application/controllers/application.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'use strict';
'use strict'

/**
* Read the documentation (https://strapi.io/documentation/developer-docs/latest/development/backend-customization.html#core-controllers)
Expand All @@ -7,18 +7,29 @@

module.exports = {
async myApplications(ctx) {
const populateCommon = ['disponibility.espace', 'disponibility.espace.users_permissions_user', 'creation_file' ]
const { id, type } = ctx.state.user;
const {query: initialQuery}=ctx.request;
const query = type === "place" ? {...initialQuery, 'disponibility.espace.users_permissions_user.id':id} : {...initialQuery, company: id };
const populate = type==="place"? [...populateCommon,'company', ]:[...populateCommon,'place']
const populateCommon = [
'disponibility.espace',
'disponibility.espace.users_permissions_user',
'creation_file',
'campaign',
]
const { id, type } = ctx.state.user
const { query: initialQuery } = ctx.request
const query =
type === 'place'
? {
...initialQuery,
'disponibility.espace.users_permissions_user.id': id,
}
: { ...initialQuery, company: id }
const populate =
type === 'place'
? [...populateCommon, 'company']
: [...populateCommon, 'place']

return strapi
.query("application")
.find(
query,
populate
)
.query('application')
.find(query, populate)
.then((res) => {
return Promise.all(
res.map(async (application) => {
Expand All @@ -29,10 +40,9 @@ module.exports = {
type,
applicationId: application.id,
}),
};
})
);
});
}
}),
)
})
},

};
}
Loading
Loading